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},
278 {"ATE", Set_ATE_Proc},
279 {"ATEDA", Set_ATE_DA_Proc},
280 {"ATESA", Set_ATE_SA_Proc},
281 {"ATEBSSID", Set_ATE_BSSID_Proc},
282 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
283 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
284 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
285 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
286 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
287 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
288 {"ATETXBW", Set_ATE_TX_BW_Proc},
289 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
290 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
291 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
292 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
293 {"ATETXGI", Set_ATE_TX_GI_Proc},
294 {"ATERXFER", Set_ATE_RX_FER_Proc},
295 {"ATERRF", Set_ATE_Read_RF_Proc},
296 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
297 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
298 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
299 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
300 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
301 {"ATERE2P", Set_ATE_Read_E2P_Proc},
302 {"ATESHOW", Set_ATE_Show_Proc},
303 {"ATEHELP", Set_ATE_Help_Proc},
305 #ifdef RALINK_28xx_QA
306 {"TxStop", Set_TxStop_Proc},
307 {"RxStop", Set_RxStop_Proc},
308 #endif // RALINK_28xx_QA //
309 #endif // RALINK_ATE //
311 #ifdef WPA_SUPPLICANT_SUPPORT
312 {"WpaSupport", Set_Wpa_Support},
313 #endif // WPA_SUPPLICANT_SUPPORT //
317 {"FixedTxMode", Set_FixedTxMode_Proc},
318 #ifdef DOT11_N_SUPPORT
319 {"TGnWifiTest", Set_TGnWifiTest_Proc},
320 {"ForceGF", Set_ForceGF_Proc},
321 #endif // DOT11_N_SUPPORT //
322 #ifdef QOS_DLS_SUPPORT
323 {"DlsAddEntry", Set_DlsAddEntry_Proc},
324 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
325 #endif // QOS_DLS_SUPPORT //
326 {"LongRetry", Set_LongRetryLimit_Proc},
327 {"ShortRetry", Set_ShortRetryLimit_Proc},
328 #ifdef EXT_BUILD_CHANNEL_LIST
329 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
330 #endif // EXT_BUILD_CHANNEL_LIST //
331 #ifdef CARRIER_DETECTION_SUPPORT
332 {"CarrierDetect", Set_CarrierDetect_Proc},
333 #endif // CARRIER_DETECTION_SUPPORT //
340 IN PRTMP_ADAPTER pAd,
341 IN PNDIS_802_11_KEY pKey)
344 MAC_TABLE_ENTRY *pEntry;
346 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
348 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
349 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
351 if (pAd->StaCfg.bRadio == FALSE)
353 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
356 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
357 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
359 pAd->bPCIclkOff = FALSE;
362 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
364 if (pKey->KeyIndex & 0x80000000)
366 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
368 NdisZeroMemory(pAd->StaCfg.PMK, 32);
369 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
373 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
374 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
375 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
376 #ifdef WPA_SUPPLICANT_SUPPORT
377 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
379 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
380 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
383 #endif // WPA_SUPPLICANT_SUPPORT //
385 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
386 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
389 // Decide its ChiperAlg
390 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
391 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
392 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
393 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
395 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
397 // Update these related information to MAC_TABLE_ENTRY
398 pEntry = &pAd->MacTab.Content[BSSID_WCID];
399 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
400 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
401 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
402 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
404 // Update pairwise key information to ASIC Shared Key Table
405 AsicAddSharedKeyEntry(pAd,
408 pAd->SharedKey[BSS0][0].CipherAlg,
409 pAd->SharedKey[BSS0][0].Key,
410 pAd->SharedKey[BSS0][0].TxMic,
411 pAd->SharedKey[BSS0][0].RxMic);
413 // Update ASIC WCID attribute table and IVEIV table
414 RTMPAddWcidAttributeEntry(pAd,
417 pAd->SharedKey[BSS0][0].CipherAlg,
420 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
422 // set 802.1x port control
423 STA_PORT_SECURED(pAd);
425 // Indicate Connected for GUI
426 pAd->IndicateMediaState = NdisMediaStateConnected;
432 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
433 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
434 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
435 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
436 #ifdef WPA_SUPPLICANT_SUPPORT
437 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
439 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
440 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
443 #endif // WPA_SUPPLICANT_SUPPORT //
445 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
446 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
449 // Update Shared Key CipherAlg
450 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
451 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
452 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
453 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
454 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
456 // Update group key information to ASIC Shared Key Table
457 AsicAddSharedKeyEntry(pAd,
459 pAd->StaCfg.DefaultKeyId,
460 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
461 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
462 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
463 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
465 // Update ASIC WCID attribute table and IVEIV table
466 RTMPAddWcidAttributeEntry(pAd,
468 pAd->StaCfg.DefaultKeyId,
469 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
472 // set 802.1x port control
473 STA_PORT_SECURED(pAd);
475 // Indicate Connected for GUI
476 pAd->IndicateMediaState = NdisMediaStateConnected;
479 else // dynamic WEP from wpa_supplicant
484 if(pKey->KeyLength == 32)
487 KeyIdx = pKey->KeyIndex & 0x0fffffff;
491 // it is a default shared key, for Pairwise key setting
492 if (pKey->KeyIndex & 0x80000000)
494 pEntry = MacTableLookup(pAd, pKey->BSSID);
498 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
500 // set key material and key length
501 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
502 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
505 if (pKey->KeyLength == 5)
506 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
508 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
510 // Add Pair-wise key to Asic
511 AsicAddPairwiseKeyEntry(
515 &pEntry->PairwiseKey);
517 // update WCID attribute table and IVEIV table for this entry
518 RTMPAddWcidAttributeEntry(
521 KeyIdx, // The value may be not zero
522 pEntry->PairwiseKey.CipherAlg,
529 // Default key for tx (shared key)
530 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
532 // set key material and key length
533 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
534 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
537 if (pKey->KeyLength == 5)
538 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
540 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
542 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
543 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
545 // Set Group key material to Asic
546 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
548 // Update WCID attribute table and IVEIV table for this group key table
549 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
555 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
556 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
560 char * rtstrchr(const char * s, int c)
562 for(; *s != (char) c; ++s)
569 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
573 rt_ioctl_giwname(struct net_device *dev,
574 struct iw_request_info *info,
575 char *name, char *extra)
577 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
579 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
583 int rt_ioctl_siwfreq(struct net_device *dev,
584 struct iw_request_info *info,
585 struct iw_freq *freq, char *extra)
587 PRTMP_ADAPTER pAdapter = dev->ml_priv;
590 //check if the interface is down
591 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
593 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
601 if((freq->e == 0) && (freq->m <= 1000))
602 chan = freq->m; // Setting by channel number
604 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
606 if (ChannelSanity(pAdapter, chan) == TRUE)
608 pAdapter->CommonCfg.Channel = chan;
609 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
616 int rt_ioctl_giwfreq(struct net_device *dev,
617 struct iw_request_info *info,
618 struct iw_freq *freq, char *extra)
620 VIRTUAL_ADAPTER *pVirtualAd = NULL;
621 PRTMP_ADAPTER pAdapter = NULL;
625 if (dev->priv_flags == INT_MAIN)
627 pAdapter = dev->ml_priv;
631 pVirtualAd = dev->ml_priv;
632 if (pVirtualAd && pVirtualAd->RtmpDev)
633 pAdapter = pVirtualAd->RtmpDev->ml_priv;
636 if (pAdapter == NULL)
638 /* if 1st open fail, pAd will be free;
639 So the net_dev->ml_priv will be NULL in 2rd open */
643 ch = pAdapter->CommonCfg.Channel;
645 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
647 MAP_CHANNEL_ID_TO_KHZ(ch, m);
653 int rt_ioctl_siwmode(struct net_device *dev,
654 struct iw_request_info *info,
655 __u32 *mode, char *extra)
657 PRTMP_ADAPTER pAdapter = dev->ml_priv;
659 //check if the interface is down
660 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
662 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
669 Set_NetworkType_Proc(pAdapter, "Adhoc");
672 Set_NetworkType_Proc(pAdapter, "Infra");
674 case IW_MODE_MONITOR:
675 Set_NetworkType_Proc(pAdapter, "Monitor");
678 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
682 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
683 pAdapter->StaCfg.WpaState = SS_NOTUSE;
688 int rt_ioctl_giwmode(struct net_device *dev,
689 struct iw_request_info *info,
690 __u32 *mode, char *extra)
692 PRTMP_ADAPTER pAdapter = NULL;
693 VIRTUAL_ADAPTER *pVirtualAd = NULL;
695 if (dev->priv_flags == INT_MAIN)
697 pAdapter = dev->ml_priv;
701 pVirtualAd = dev->ml_priv;
702 if (pVirtualAd && pVirtualAd->RtmpDev)
703 pAdapter = pVirtualAd->RtmpDev->ml_priv;
706 if (pAdapter == NULL)
708 /* if 1st open fail, pAd will be free;
709 So the net_dev->ml_priv will be NULL in 2rd open */
713 if (ADHOC_ON(pAdapter))
714 *mode = IW_MODE_ADHOC;
715 else if (INFRA_ON(pAdapter))
716 *mode = IW_MODE_INFRA;
717 else if (MONITOR_ON(pAdapter))
719 *mode = IW_MODE_MONITOR;
722 *mode = IW_MODE_AUTO;
724 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
728 int rt_ioctl_siwsens(struct net_device *dev,
729 struct iw_request_info *info,
730 char *name, char *extra)
732 PRTMP_ADAPTER pAdapter = dev->ml_priv;
734 //check if the interface is down
735 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
737 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
744 int rt_ioctl_giwsens(struct net_device *dev,
745 struct iw_request_info *info,
746 char *name, char *extra)
751 int rt_ioctl_giwrange(struct net_device *dev,
752 struct iw_request_info *info,
753 struct iw_point *data, char *extra)
755 PRTMP_ADAPTER pAdapter = NULL;
756 VIRTUAL_ADAPTER *pVirtualAd = NULL;
757 struct iw_range *range = (struct iw_range *) extra;
761 if (dev->priv_flags == INT_MAIN)
763 pAdapter = dev->ml_priv;
767 pVirtualAd = dev->ml_priv;
768 if (pVirtualAd && pVirtualAd->RtmpDev)
769 pAdapter = pVirtualAd->RtmpDev->ml_priv;
772 if (pAdapter == NULL)
774 /* if 1st open fail, pAd will be free;
775 So the net_dev->ml_priv will be NULL in 2rd open */
779 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
780 data->length = sizeof(struct iw_range);
781 memset(range, 0, sizeof(struct iw_range));
783 range->txpower_capa = IW_TXPOW_DBM;
785 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
787 range->min_pmp = 1 * 1024;
788 range->max_pmp = 65535 * 1024;
789 range->min_pmt = 1 * 1024;
790 range->max_pmt = 1000 * 1024;
791 range->pmp_flags = IW_POWER_PERIOD;
792 range->pmt_flags = IW_POWER_TIMEOUT;
793 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
794 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
797 range->we_version_compiled = WIRELESS_EXT;
798 range->we_version_source = 14;
800 range->retry_capa = IW_RETRY_LIMIT;
801 range->retry_flags = IW_RETRY_LIMIT;
802 range->min_retry = 0;
803 range->max_retry = 255;
805 range->num_channels = pAdapter->ChannelListNum;
808 for (i = 1; i <= range->num_channels; i++)
811 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
812 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
813 range->freq[val].m = m * 100; /* HZ */
815 range->freq[val].e = 1;
817 if (val == IW_MAX_FREQUENCIES)
820 range->num_frequency = val;
822 range->max_qual.qual = 100; /* what is correct max? This was not
823 * documented exactly. At least
824 * 69 has been observed. */
825 range->max_qual.level = 0; /* dB */
826 range->max_qual.noise = 0; /* dB */
828 /* What would be suitable values for "average/typical" qual? */
829 range->avg_qual.qual = 20;
830 range->avg_qual.level = -60;
831 range->avg_qual.noise = -95;
832 range->sensitivity = 3;
834 range->max_encoding_tokens = NR_WEP_KEYS;
835 range->num_encoding_sizes = 2;
836 range->encoding_size[0] = 5;
837 range->encoding_size[1] = 13;
840 range->max_rts = 2347;
841 range->min_frag = 256;
842 range->max_frag = 2346;
844 #if WIRELESS_EXT > 17
845 /* IW_ENC_CAPA_* bit field */
846 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
847 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
853 int rt_ioctl_siwap(struct net_device *dev,
854 struct iw_request_info *info,
855 struct sockaddr *ap_addr, char *extra)
857 PRTMP_ADAPTER pAdapter = dev->ml_priv;
858 NDIS_802_11_MAC_ADDRESS Bssid;
860 //check if the interface is down
861 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
863 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
867 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
869 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
870 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
873 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
874 // this request, because this request is initiated by NDIS.
875 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
876 // Prevent to connect AP again in STAMlmePeriodicExec
877 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
879 memset(Bssid, 0, MAC_ADDR_LEN);
880 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
881 MlmeEnqueue(pAdapter,
882 MLME_CNTL_STATE_MACHINE,
884 sizeof(NDIS_802_11_MAC_ADDRESS),
887 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
888 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
893 int rt_ioctl_giwap(struct net_device *dev,
894 struct iw_request_info *info,
895 struct sockaddr *ap_addr, char *extra)
897 PRTMP_ADAPTER pAdapter = NULL;
898 VIRTUAL_ADAPTER *pVirtualAd = NULL;
900 if (dev->priv_flags == INT_MAIN)
902 pAdapter = dev->ml_priv;
906 pVirtualAd = dev->ml_priv;
907 if (pVirtualAd && pVirtualAd->RtmpDev)
908 pAdapter = pVirtualAd->RtmpDev->ml_priv;
911 if (pAdapter == NULL)
913 /* if 1st open fail, pAd will be free;
914 So the net_dev->ml_priv will be NULL in 2rd open */
918 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
920 ap_addr->sa_family = ARPHRD_ETHER;
921 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
923 #ifdef WPA_SUPPLICANT_SUPPORT
925 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
927 ap_addr->sa_family = ARPHRD_ETHER;
928 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
930 #endif // WPA_SUPPLICANT_SUPPORT //
933 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
941 * Units are in db above the noise floor. That means the
942 * rssi values reported in the tx/rx descriptors in the
943 * driver are the SNR expressed in db.
945 * If you assume that the noise floor is -95, which is an
946 * excellent assumption 99.5 % of the time, then you can
947 * derive the absolute signal level (i.e. -95 + rssi).
948 * There are some other slight factors to take into account
949 * depending on whether the rssi measurement is from 11b,
950 * 11g, or 11a. These differences are at most 2db and
953 * NB: various calculations are based on the orinoco/wavelan
954 * drivers for compatibility
956 static void set_quality(PRTMP_ADAPTER pAdapter,
957 struct iw_quality *iq,
964 ChannelQuality = 100;
965 else if (rssi >= -80) // between -50 ~ -80dbm
966 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
967 else if (rssi >= -90) // between -80 ~ -90dbm
968 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
972 iq->qual = (__u8)ChannelQuality;
974 iq->level = (__u8)(rssi);
975 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
976 iq->noise += 256 - 143;
977 iq->updated = pAdapter->iw_stats.qual.updated;
980 int rt_ioctl_iwaplist(struct net_device *dev,
981 struct iw_request_info *info,
982 struct iw_point *data, char *extra)
984 PRTMP_ADAPTER pAdapter = dev->ml_priv;
986 struct sockaddr addr[IW_MAX_AP];
987 struct iw_quality qual[IW_MAX_AP];
990 //check if the interface is down
991 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
993 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
999 for (i = 0; i <IW_MAX_AP ; i++)
1001 if (i >= pAdapter->ScanTab.BssNr)
1003 addr[i].sa_family = ARPHRD_ETHER;
1004 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1005 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1008 memcpy(extra, &addr, i*sizeof(addr[0]));
1009 data->flags = 1; /* signal quality present (sort of) */
1010 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1016 int rt_ioctl_siwscan(struct net_device *dev,
1017 struct iw_request_info *info,
1018 struct iw_point *data, char *extra)
1020 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1023 int Status = NDIS_STATUS_SUCCESS;
1025 //check if the interface is down
1026 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1028 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1032 if (MONITOR_ON(pAdapter))
1034 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1038 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
1039 && (pAdapter->StaCfg.bRadio == TRUE)
1040 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
1042 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
1044 // Check if still radio off.
1045 else if (pAdapter->bPCIclkOff == TRUE)
1048 #ifdef WPA_SUPPLICANT_SUPPORT
1049 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1051 pAdapter->StaCfg.WpaSupplicantScanCount++;
1053 #endif // WPA_SUPPLICANT_SUPPORT //
1055 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1056 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1061 #ifdef WPA_SUPPLICANT_SUPPORT
1062 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1063 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1065 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1066 Status = NDIS_STATUS_SUCCESS;
1069 #endif // WPA_SUPPLICANT_SUPPORT //
1071 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1072 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1073 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1074 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1076 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1077 Status = NDIS_STATUS_SUCCESS;
1081 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1083 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1084 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1087 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1088 // this request, because this request is initiated by NDIS.
1089 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1090 // Reset allowed scan retries
1091 pAdapter->StaCfg.ScanCnt = 0;
1092 pAdapter->StaCfg.LastScanTime = Now;
1094 MlmeEnqueue(pAdapter,
1095 MLME_CNTL_STATE_MACHINE,
1096 OID_802_11_BSSID_LIST_SCAN,
1100 Status = NDIS_STATUS_SUCCESS;
1101 RT28XX_MLME_HANDLER(pAdapter);
1106 int rt_ioctl_giwscan(struct net_device *dev,
1107 struct iw_request_info *info,
1108 struct iw_point *data, char *extra)
1111 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1113 char *current_ev = extra, *previous_ev = extra;
1115 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1118 #endif // IWEVGENIE //
1119 struct iw_event iwe;
1121 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1124 * Still scanning, indicate the caller should try again.
1130 #ifdef WPA_SUPPLICANT_SUPPORT
1131 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1133 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1135 #endif // WPA_SUPPLICANT_SUPPORT //
1137 if (pAdapter->ScanTab.BssNr == 0)
1143 #if WIRELESS_EXT >= 17
1144 if (data->length > 0)
1145 end_buf = extra + data->length;
1147 end_buf = extra + IW_SCAN_MAX_DATA;
1149 end_buf = extra + IW_SCAN_MAX_DATA;
1152 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1154 if (current_ev >= end_buf)
1156 #if WIRELESS_EXT >= 17
1164 //================================
1165 memset(&iwe, 0, sizeof(iwe));
1166 iwe.cmd = SIOCGIWAP;
1167 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1168 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1170 previous_ev = current_ev;
1171 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1172 if (current_ev == previous_ev)
1173 #if WIRELESS_EXT >= 17
1180 //================================
1181 memset(&iwe, 0, sizeof(iwe));
1182 iwe.cmd = SIOCGIWESSID;
1183 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1184 iwe.u.data.flags = 1;
1186 previous_ev = current_ev;
1187 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1188 if (current_ev == previous_ev)
1189 #if WIRELESS_EXT >= 17
1196 //================================
1197 memset(&iwe, 0, sizeof(iwe));
1198 iwe.cmd = SIOCGIWMODE;
1199 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1201 iwe.u.mode = IW_MODE_ADHOC;
1203 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1205 iwe.u.mode = IW_MODE_INFRA;
1209 iwe.u.mode = IW_MODE_AUTO;
1211 iwe.len = IW_EV_UINT_LEN;
1213 previous_ev = current_ev;
1214 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1215 if (current_ev == previous_ev)
1216 #if WIRELESS_EXT >= 17
1222 //Channel and Frequency
1223 //================================
1224 memset(&iwe, 0, sizeof(iwe));
1225 iwe.cmd = SIOCGIWFREQ;
1226 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1227 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1229 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1233 previous_ev = current_ev;
1234 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1235 if (current_ev == previous_ev)
1236 #if WIRELESS_EXT >= 17
1242 //Add quality statistics
1243 //================================
1244 memset(&iwe, 0, sizeof(iwe));
1246 iwe.u.qual.level = 0;
1247 iwe.u.qual.noise = 0;
1248 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1249 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1250 if (current_ev == previous_ev)
1251 #if WIRELESS_EXT >= 17
1258 //================================
1259 memset(&iwe, 0, sizeof(iwe));
1260 iwe.cmd = SIOCGIWENCODE;
1261 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1262 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1264 iwe.u.data.flags = IW_ENCODE_DISABLED;
1266 previous_ev = current_ev;
1267 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);
1268 if (current_ev == previous_ev)
1269 #if WIRELESS_EXT >= 17
1276 //================================
1277 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1279 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1280 memset(&iwe, 0, sizeof(iwe));
1281 iwe.cmd = SIOCGIWRATE;
1282 current_val = current_ev + IW_EV_LCP_LEN;
1283 if (tmpRate == 0x82)
1284 iwe.u.bitrate.value = 1 * 1000000;
1285 else if (tmpRate == 0x84)
1286 iwe.u.bitrate.value = 2 * 1000000;
1287 else if (tmpRate == 0x8B)
1288 iwe.u.bitrate.value = 5.5 * 1000000;
1289 else if (tmpRate == 0x96)
1290 iwe.u.bitrate.value = 11 * 1000000;
1292 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1294 iwe.u.bitrate.disabled = 0;
1295 current_val = iwe_stream_add_value(info, current_ev,
1296 current_val, end_buf, &iwe,
1299 if((current_val-current_ev)>IW_EV_LCP_LEN)
1300 current_ev = current_val;
1302 #if WIRELESS_EXT >= 17
1311 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1313 memset(&iwe, 0, sizeof(iwe));
1314 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1315 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1316 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1317 iwe.cmd = IWEVGENIE;
1318 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1319 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1320 if (current_ev == previous_ev)
1321 #if WIRELESS_EXT >= 17
1329 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1331 memset(&iwe, 0, sizeof(iwe));
1332 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1333 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1334 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1335 iwe.cmd = IWEVGENIE;
1336 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1337 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1338 if (current_ev == previous_ev)
1339 #if WIRELESS_EXT >= 17
1347 //================================
1348 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1350 NdisZeroMemory(&iwe, sizeof(iwe));
1351 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1352 iwe.cmd = IWEVCUSTOM;
1353 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1354 NdisMoveMemory(custom, "wpa_ie=", 7);
1355 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1356 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1357 previous_ev = current_ev;
1358 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1359 if (current_ev == previous_ev)
1360 #if WIRELESS_EXT >= 17
1368 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1370 NdisZeroMemory(&iwe, sizeof(iwe));
1371 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1372 iwe.cmd = IWEVCUSTOM;
1373 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1374 NdisMoveMemory(custom, "rsn_ie=", 7);
1375 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1376 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1377 previous_ev = current_ev;
1378 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1379 if (current_ev == previous_ev)
1380 #if WIRELESS_EXT >= 17
1386 #endif // IWEVGENIE //
1389 data->length = current_ev - extra;
1390 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1391 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1396 int rt_ioctl_siwessid(struct net_device *dev,
1397 struct iw_request_info *info,
1398 struct iw_point *data, char *essid)
1400 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1402 //check if the interface is down
1403 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1405 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1411 PCHAR pSsidString = NULL;
1413 // Includes null character.
1414 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1417 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1420 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1421 NdisMoveMemory(pSsidString, essid, data->length);
1422 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1431 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1437 int rt_ioctl_giwessid(struct net_device *dev,
1438 struct iw_request_info *info,
1439 struct iw_point *data, char *essid)
1441 PRTMP_ADAPTER pAdapter = NULL;
1442 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1444 if (dev->priv_flags == INT_MAIN)
1446 pAdapter = dev->ml_priv;
1450 pVirtualAd = dev->ml_priv;
1451 if (pVirtualAd && pVirtualAd->RtmpDev)
1452 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1455 if (pAdapter == NULL)
1457 /* if 1st open fail, pAd will be free;
1458 So the net_dev->ml_priv will be NULL in 2rd open */
1463 if (MONITOR_ON(pAdapter))
1469 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1471 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1472 data->length = pAdapter->CommonCfg.SsidLen;
1473 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1476 {//the ANY ssid was specified
1478 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1485 int rt_ioctl_siwnickn(struct net_device *dev,
1486 struct iw_request_info *info,
1487 struct iw_point *data, char *nickname)
1489 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1491 //check if the interface is down
1492 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1494 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1498 if (data->length > IW_ESSID_MAX_SIZE)
1501 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1502 memcpy(pAdapter->nickname, nickname, data->length);
1508 int rt_ioctl_giwnickn(struct net_device *dev,
1509 struct iw_request_info *info,
1510 struct iw_point *data, char *nickname)
1512 PRTMP_ADAPTER pAdapter = NULL;
1513 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1515 if (dev->priv_flags == INT_MAIN)
1517 pAdapter = dev->ml_priv;
1521 pVirtualAd = dev->ml_priv;
1522 if (pVirtualAd && pVirtualAd->RtmpDev)
1523 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1526 if (pAdapter == NULL)
1528 /* if 1st open fail, pAd will be free;
1529 So the net_dev->ml_priv will be NULL in 2rd open */
1533 if (data->length > strlen(pAdapter->nickname) + 1)
1534 data->length = strlen(pAdapter->nickname) + 1;
1535 if (data->length > 0) {
1536 memcpy(nickname, pAdapter->nickname, data->length-1);
1537 nickname[data->length-1] = '\0';
1542 int rt_ioctl_siwrts(struct net_device *dev,
1543 struct iw_request_info *info,
1544 struct iw_param *rts, char *extra)
1546 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1549 //check if the interface is down
1550 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1552 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1557 val = MAX_RTS_THRESHOLD;
1558 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1560 else if (rts->value == 0)
1561 val = MAX_RTS_THRESHOLD;
1565 if (val != pAdapter->CommonCfg.RtsThreshold)
1566 pAdapter->CommonCfg.RtsThreshold = val;
1571 int rt_ioctl_giwrts(struct net_device *dev,
1572 struct iw_request_info *info,
1573 struct iw_param *rts, char *extra)
1575 PRTMP_ADAPTER pAdapter = NULL;
1576 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1578 if (dev->priv_flags == INT_MAIN)
1580 pAdapter = dev->ml_priv;
1584 pVirtualAd = dev->ml_priv;
1585 if (pVirtualAd && pVirtualAd->RtmpDev)
1586 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1589 if (pAdapter == NULL)
1591 /* if 1st open fail, pAd will be free;
1592 So the net_dev->ml_priv will be NULL in 2rd open */
1596 //check if the interface is down
1597 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1599 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1603 rts->value = pAdapter->CommonCfg.RtsThreshold;
1604 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1610 int rt_ioctl_siwfrag(struct net_device *dev,
1611 struct iw_request_info *info,
1612 struct iw_param *frag, char *extra)
1614 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1617 //check if the interface is down
1618 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1620 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1625 val = MAX_FRAG_THRESHOLD;
1626 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1627 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1628 else if (frag->value == 0)
1629 val = MAX_FRAG_THRESHOLD;
1633 pAdapter->CommonCfg.FragmentThreshold = val;
1637 int rt_ioctl_giwfrag(struct net_device *dev,
1638 struct iw_request_info *info,
1639 struct iw_param *frag, char *extra)
1641 PRTMP_ADAPTER pAdapter = NULL;
1642 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1644 if (dev->priv_flags == INT_MAIN)
1646 pAdapter = dev->ml_priv;
1650 pVirtualAd = dev->ml_priv;
1651 if (pVirtualAd && pVirtualAd->RtmpDev)
1652 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1655 if (pAdapter == NULL)
1657 /* if 1st open fail, pAd will be free;
1658 So the net_dev->ml_priv will be NULL in 2rd open */
1662 //check if the interface is down
1663 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1665 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1669 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1670 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1676 #define MAX_WEP_KEY_SIZE 13
1677 #define MIN_WEP_KEY_SIZE 5
1678 int rt_ioctl_siwencode(struct net_device *dev,
1679 struct iw_request_info *info,
1680 struct iw_point *erq, char *extra)
1682 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1684 //check if the interface is down
1685 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1687 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1691 if ((erq->length == 0) &&
1692 (erq->flags & IW_ENCODE_DISABLED))
1694 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1695 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1696 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1697 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1698 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1701 else if ((erq->length == 0) &&
1702 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1704 STA_PORT_SECURED(pAdapter);
1705 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1706 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1707 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1708 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1709 if (erq->flags & IW_ENCODE_RESTRICTED)
1710 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1712 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1716 if (erq->length > 0)
1718 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1719 /* Check the size of the key */
1720 if (erq->length > MAX_WEP_KEY_SIZE) {
1723 /* Check key index */
1724 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1726 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1727 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1730 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1733 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1735 if (erq->length == MAX_WEP_KEY_SIZE)
1737 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1738 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1740 else if (erq->length == MIN_WEP_KEY_SIZE)
1742 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1743 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1746 /* Disable the key */
1747 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1749 /* Check if the key is not marked as invalid */
1750 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1751 /* Copy the key in the driver */
1752 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1757 /* Do we want to just set the transmit key index ? */
1758 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1759 if ((index >= 0) && (index < 4))
1761 pAdapter->StaCfg.DefaultKeyId = index;
1764 /* Don't complain if only change the mode */
1765 if (!(erq->flags & IW_ENCODE_MODE)) {
1771 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1772 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1773 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1774 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1779 rt_ioctl_giwencode(struct net_device *dev,
1780 struct iw_request_info *info,
1781 struct iw_point *erq, char *key)
1784 PRTMP_ADAPTER pAdapter = NULL;
1785 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1787 if (dev->priv_flags == INT_MAIN)
1789 pAdapter = dev->ml_priv;
1793 pVirtualAd = dev->ml_priv;
1794 if (pVirtualAd && pVirtualAd->RtmpDev)
1795 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1798 if (pAdapter == NULL)
1800 /* if 1st open fail, pAd will be free;
1801 So the net_dev->ml_priv will be NULL in 2rd open */
1805 //check if the interface is down
1806 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1808 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1812 kid = erq->flags & IW_ENCODE_INDEX;
1813 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1815 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1818 erq->flags = IW_ENCODE_DISABLED;
1820 else if ((kid > 0) && (kid <=4))
1823 erq->flags = kid ; /* NB: base 1 */
1824 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1825 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1826 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1827 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1828 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1829 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1830 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1832 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1837 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1838 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1840 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1841 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1842 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1843 // copy default key ID
1844 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1845 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1847 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1848 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1849 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1857 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1858 void *w, char *extra)
1860 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1861 PRTMP_ADAPTER pAdapter;
1863 char *this_char = extra;
1867 if (dev->priv_flags == INT_MAIN)
1869 pAdapter = dev->ml_priv;
1873 pVirtualAd = dev->ml_priv;
1874 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1876 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1878 if (pAdapter == NULL)
1880 /* if 1st open fail, pAd will be free;
1881 So the net_dev->ml_priv will be NULL in 2rd open */
1886 pObj->ioctl_if_type = INT_MAIN;
1887 pObj->ioctl_if = MAIN_MBSSID;
1890 //check if the interface is down
1891 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1893 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1900 if ((value = rtstrchr(this_char, '=')) != NULL)
1906 // reject setting nothing besides ANY ssid(ssidLen=0)
1907 if (!*value && (strcmp(this_char, "SSID") != 0))
1910 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1912 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1914 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1915 { //FALSE:Set private failed then return Invalid argument
1918 break; //Exit for loop.
1922 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1923 { //Not found argument
1925 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1933 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1934 struct iw_point *wrq, char *extra)
1937 PRTMP_ADAPTER pAd = dev->ml_priv;
1945 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1946 sprintf(extra, "\n\n");
1951 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1952 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1955 #endif // RALINK_ATE //
1957 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1958 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1960 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1961 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1962 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1963 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1965 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1966 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1967 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1968 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1970 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1974 if (pAd->ate.RxAntennaSel == 0)
1976 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1977 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1978 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1982 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1986 #endif // RALINK_ATE //
1988 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1989 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1990 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1992 #ifdef WPA_SUPPLICANT_SUPPORT
1993 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1994 #endif // WPA_SUPPLICANT_SUPPORT //
1997 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1998 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2003 #ifdef DOT11_N_SUPPORT
2005 IN PRTMP_ADAPTER pAd,
2009 BA_ORI_ENTRY *pOriBAEntry;
2010 BA_REC_ENTRY *pRecBAEntry;
2012 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2014 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2015 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2016 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2018 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2019 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2020 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2022 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2023 for (j=0; j < NUM_OF_TID; j++)
2025 if (pEntry->BARecWcidArray[j] != 0)
2027 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2028 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2031 sprintf(pOutBuf, "%s\n", pOutBuf);
2033 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2034 for (j=0; j < NUM_OF_TID; j++)
2036 if (pEntry->BAOriWcidArray[j] != 0)
2038 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2039 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2042 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2044 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2050 #endif // DOT11_N_SUPPORT //
2053 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2054 struct iw_point *wrq, char *extra)
2057 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2060 u32 subcmd = wrq->flags;
2062 if (dev->priv_flags == INT_MAIN)
2066 pVirtualAd = dev->ml_priv;
2067 pAd = pVirtualAd->RtmpDev->ml_priv;
2069 pObj = (POS_COOKIE) pAd->OS_Cookie;
2073 /* if 1st open fail, pAd will be free;
2074 So the net_dev->ml_priv will be NULL in 2rd open */
2083 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2086 pObj->ioctl_if_type = INT_MAIN;
2087 pObj->ioctl_if = MAIN_MBSSID;
2093 case SHOW_CONN_STATUS:
2094 if (MONITOR_ON(pAd))
2096 #ifdef DOT11_N_SUPPORT
2097 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2098 pAd->CommonCfg.RegTransmitSetting.field.BW)
2099 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2101 #endif // DOT11_N_SUPPORT //
2102 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2106 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2110 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2111 pAd->CommonCfg.Ssid,
2112 pAd->CommonCfg.Bssid[0],
2113 pAd->CommonCfg.Bssid[1],
2114 pAd->CommonCfg.Bssid[2],
2115 pAd->CommonCfg.Bssid[3],
2116 pAd->CommonCfg.Bssid[4],
2117 pAd->CommonCfg.Bssid[5]);
2118 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2120 else if (ADHOC_ON(pAd))
2121 sprintf(extra, "Connected\n");
2125 sprintf(extra, "Disconnected\n");
2126 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2129 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2131 case SHOW_DRVIER_VERION:
2132 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2133 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2135 #ifdef DOT11_N_SUPPORT
2137 getBaInfo(pAd, extra);
2138 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2140 #endif // DOT11_N_SUPPORT //
2141 case SHOW_DESC_INFO:
2143 Show_DescInfo_Proc(pAd, NULL);
2144 wrq->length = 0; // 1: size of '\0'
2148 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2150 sprintf(extra, "Scanning\n");
2151 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2154 pAd->StaCfg.bSwRadio = FALSE;
2155 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2157 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2158 if (pAd->StaCfg.bRadio == FALSE)
2161 // Update extra information
2162 pAd->ExtraInfo = SW_RADIO_OFF;
2165 sprintf(extra, "Radio Off\n");
2166 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2169 pAd->StaCfg.bSwRadio = TRUE;
2170 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2172 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2173 if (pAd->StaCfg.bRadio == TRUE)
2176 // Update extra information
2177 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2180 sprintf(extra, "Radio On\n");
2181 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2185 #ifdef QOS_DLS_SUPPORT
2186 case SHOW_DLS_ENTRY_INFO:
2188 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2189 wrq->length = 0; // 1: size of '\0'
2192 #endif // QOS_DLS_SUPPORT //
2194 case SHOW_CFG_VALUE:
2196 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2198 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2202 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2210 int rt_ioctl_siwmlme(struct net_device *dev,
2211 struct iw_request_info *info,
2212 union iwreq_data *wrqu,
2215 PRTMP_ADAPTER pAd = dev->ml_priv;
2216 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2217 MLME_QUEUE_ELEM MsgElem;
2218 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2219 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2221 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2228 #ifdef IW_MLME_DEAUTH
2229 case IW_MLME_DEAUTH:
2230 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2231 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2232 DeAuthReq.Reason = pMlme->reason_code;
2233 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2234 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2235 MlmeDeauthReqAction(pAd, &MsgElem);
2238 LinkDown(pAd, FALSE);
2239 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2242 #endif // IW_MLME_DEAUTH //
2243 #ifdef IW_MLME_DISASSOC
2244 case IW_MLME_DISASSOC:
2245 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2246 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2247 DisAssocReq.Reason = pMlme->reason_code;
2249 MsgElem.Machine = ASSOC_STATE_MACHINE;
2250 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2251 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2252 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2254 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2255 MlmeDisassocReqAction(pAd, &MsgElem);
2257 #endif // IW_MLME_DISASSOC //
2259 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2265 #endif // SIOCSIWMLME //
2267 #if WIRELESS_EXT > 17
2268 int rt_ioctl_siwauth(struct net_device *dev,
2269 struct iw_request_info *info,
2270 union iwreq_data *wrqu, char *extra)
2272 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2273 struct iw_param *param = &wrqu->param;
2275 //check if the interface is down
2276 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2278 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2281 switch (param->flags & IW_AUTH_INDEX) {
2282 case IW_AUTH_WPA_VERSION:
2283 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2285 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2286 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2287 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2289 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2290 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2292 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2294 case IW_AUTH_CIPHER_PAIRWISE:
2295 if (param->value == IW_AUTH_CIPHER_NONE)
2297 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2298 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2299 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2301 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2302 param->value == IW_AUTH_CIPHER_WEP104)
2304 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2305 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2306 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2307 #ifdef WPA_SUPPLICANT_SUPPORT
2308 pAdapter->StaCfg.IEEE8021X = FALSE;
2309 #endif // WPA_SUPPLICANT_SUPPORT //
2311 else if (param->value == IW_AUTH_CIPHER_TKIP)
2313 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2314 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2315 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2317 else if (param->value == IW_AUTH_CIPHER_CCMP)
2319 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2320 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2321 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2323 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2325 case IW_AUTH_CIPHER_GROUP:
2326 if (param->value == IW_AUTH_CIPHER_NONE)
2328 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2330 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2331 param->value == IW_AUTH_CIPHER_WEP104)
2333 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2335 else if (param->value == IW_AUTH_CIPHER_TKIP)
2337 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2339 else if (param->value == IW_AUTH_CIPHER_CCMP)
2341 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2343 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2345 case IW_AUTH_KEY_MGMT:
2346 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2348 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2350 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2351 #ifdef WPA_SUPPLICANT_SUPPORT
2352 pAdapter->StaCfg.IEEE8021X = FALSE;
2353 #endif // WPA_SUPPLICANT_SUPPORT //
2355 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2357 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2358 #ifdef WPA_SUPPLICANT_SUPPORT
2359 pAdapter->StaCfg.IEEE8021X = FALSE;
2360 #endif // WPA_SUPPLICANT_SUPPORT //
2362 #ifdef WPA_SUPPLICANT_SUPPORT
2365 pAdapter->StaCfg.IEEE8021X = TRUE;
2366 #endif // WPA_SUPPLICANT_SUPPORT //
2368 else if (param->value == 0)
2370 STA_PORT_SECURED(pAdapter);
2372 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2374 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2376 case IW_AUTH_PRIVACY_INVOKED:
2377 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2379 case IW_AUTH_DROP_UNENCRYPTED:
2380 if (param->value != 0)
2381 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2384 STA_PORT_SECURED(pAdapter);
2386 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2388 case IW_AUTH_80211_AUTH_ALG:
2389 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2391 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2393 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2395 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2399 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2401 case IW_AUTH_WPA_ENABLED:
2402 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2411 int rt_ioctl_giwauth(struct net_device *dev,
2412 struct iw_request_info *info,
2413 union iwreq_data *wrqu, char *extra)
2415 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2416 struct iw_param *param = &wrqu->param;
2418 //check if the interface is down
2419 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2421 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2425 switch (param->flags & IW_AUTH_INDEX) {
2426 case IW_AUTH_DROP_UNENCRYPTED:
2427 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2430 case IW_AUTH_80211_AUTH_ALG:
2431 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2434 case IW_AUTH_WPA_ENABLED:
2435 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2441 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2445 void fnSetCipherKey(
2446 IN PRTMP_ADAPTER pAdapter,
2450 IN struct iw_encode_ext *ext)
2452 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2453 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2455 if (pAdapter->StaCfg.bRadio == FALSE)
2457 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2460 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2461 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2462 RTMPusecDelay(6000);
2463 pAdapter->bPCIclkOff = FALSE;
2466 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2467 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2468 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2469 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2470 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2471 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2473 // Update group key information to ASIC Shared Key Table
2474 AsicAddSharedKeyEntry(pAdapter,
2477 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2478 pAdapter->SharedKey[BSS0][keyIdx].Key,
2479 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2480 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2483 // Update ASIC WCID attribute table and IVEIV table
2484 RTMPAddWcidAttributeEntry(pAdapter,
2487 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2490 // Update ASIC WCID attribute table and IVEIV table
2491 RTMPAddWcidAttributeEntry(pAdapter,
2494 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2495 &pAdapter->MacTab.Content[BSSID_WCID]);
2497 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2500 int rt_ioctl_siwencodeext(struct net_device *dev,
2501 struct iw_request_info *info,
2502 union iwreq_data *wrqu,
2505 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2506 struct iw_point *encoding = &wrqu->encoding;
2507 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2508 int keyIdx, alg = ext->alg;
2510 //check if the interface is down
2511 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2513 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2517 if (encoding->flags & IW_ENCODE_DISABLED)
2519 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2520 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2521 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2522 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2523 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2524 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2525 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2526 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2530 // Get Key Index and convet to our own defined key index
2531 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2532 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2535 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2537 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2538 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2542 case IW_ENCODE_ALG_NONE:
2543 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2545 case IW_ENCODE_ALG_WEP:
2546 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2547 if (ext->key_len == MAX_WEP_KEY_SIZE)
2549 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2550 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2552 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2554 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2555 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2560 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2561 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2563 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2564 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2566 // Set Group key material to Asic
2567 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2569 // Update WCID attribute table and IVEIV table for this group key table
2570 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2572 STA_PORT_SECURED(pAdapter);
2574 // Indicate Connected for GUI
2575 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2578 case IW_ENCODE_ALG_TKIP:
2579 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2580 if (ext->key_len == 32)
2582 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2584 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2585 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2587 STA_PORT_SECURED(pAdapter);
2590 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2592 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2594 // set 802.1x port control
2595 STA_PORT_SECURED(pAdapter);
2601 case IW_ENCODE_ALG_CCMP:
2602 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2604 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2605 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2606 STA_PORT_SECURED(pAdapter);
2608 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2610 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2612 // set 802.1x port control
2613 STA_PORT_SECURED(pAdapter);
2625 rt_ioctl_giwencodeext(struct net_device *dev,
2626 struct iw_request_info *info,
2627 union iwreq_data *wrqu, char *extra)
2629 PRTMP_ADAPTER pAd = dev->ml_priv;
2631 struct iw_point *encoding = &wrqu->encoding;
2632 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2633 int idx, max_key_len;
2635 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2637 max_key_len = encoding->length - sizeof(*ext);
2638 if (max_key_len < 0)
2641 idx = encoding->flags & IW_ENCODE_INDEX;
2644 if (idx < 1 || idx > 4)
2648 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2649 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2651 if (idx != pAd->StaCfg.DefaultKeyId)
2659 idx = pAd->StaCfg.DefaultKeyId;
2661 encoding->flags = idx + 1;
2662 memset(ext, 0, sizeof(*ext));
2665 switch(pAd->StaCfg.WepStatus) {
2666 case Ndis802_11WEPDisabled:
2667 ext->alg = IW_ENCODE_ALG_NONE;
2668 encoding->flags |= IW_ENCODE_DISABLED;
2670 case Ndis802_11WEPEnabled:
2671 ext->alg = IW_ENCODE_ALG_WEP;
2672 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2676 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2677 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2680 case Ndis802_11Encryption2Enabled:
2681 case Ndis802_11Encryption3Enabled:
2682 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2683 ext->alg = IW_ENCODE_ALG_TKIP;
2685 ext->alg = IW_ENCODE_ALG_CCMP;
2687 if (max_key_len < 32)
2692 pKey = &pAd->StaCfg.PMK[0];
2699 if (ext->key_len && pKey)
2701 encoding->flags |= IW_ENCODE_ENABLED;
2702 memcpy(ext->key, pKey, ext->key_len);
2709 int rt_ioctl_siwgenie(struct net_device *dev,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *extra)
2713 PRTMP_ADAPTER pAd = dev->ml_priv;
2715 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2716 (wrqu->data.length && extra == NULL))
2719 if (wrqu->data.length)
2721 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2722 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2726 pAd->StaCfg.RSNIE_Len = 0;
2727 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2732 #endif // SIOCSIWGENIE //
2734 int rt_ioctl_giwgenie(struct net_device *dev,
2735 struct iw_request_info *info,
2736 union iwreq_data *wrqu, char *extra)
2738 PRTMP_ADAPTER pAd = dev->ml_priv;
2740 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2741 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2743 wrqu->data.length = 0;
2747 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2749 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2751 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2754 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2755 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2758 #endif // SIOCSIWGENIE //
2759 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2761 UCHAR RSNIe = IE_WPA;
2763 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2765 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2767 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2768 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2771 extra[0] = (char)RSNIe;
2772 extra[1] = pAd->StaCfg.RSNIE_Len;
2773 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2779 int rt_ioctl_siwpmksa(struct net_device *dev,
2780 struct iw_request_info *info,
2781 union iwreq_data *wrqu,
2784 PRTMP_ADAPTER pAd = dev->ml_priv;
2785 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2786 INT CachedIdx = 0, idx = 0;
2791 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2794 case IW_PMKSA_FLUSH:
2795 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2796 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2798 case IW_PMKSA_REMOVE:
2799 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2801 // compare the BSSID
2802 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2804 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2805 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2806 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2808 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2809 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2811 pAd->StaCfg.SavedPMKNum--;
2816 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2819 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2821 // compare the BSSID
2822 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2826 // Found, replace it
2827 if (CachedIdx < PMKID_NO)
2829 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2830 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2831 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2832 pAd->StaCfg.SavedPMKNum++;
2834 // Not found, replace the last one
2837 // Randomly replace one
2838 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2839 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2840 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2841 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2844 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2847 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2853 #endif // #if WIRELESS_EXT > 17
2857 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2858 struct iw_point *wrq, char *extra)
2865 BOOLEAN bIsPrintAllBBP = FALSE;
2867 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2870 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2872 if (wrq->length > 1) //No parameters.
2874 sprintf(extra, "\n");
2876 //Parsing Read or Write
2877 this_char = wrq->pointer;
2878 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2882 if ((value = rtstrchr(this_char, '=')) != NULL)
2885 if (!value || !*value)
2887 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2888 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2893 if (ATE_ON(pAdapter))
2895 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2898 #endif // RALINK_ATE //
2900 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2902 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2903 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2904 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2907 {//Invalid parametes, so default printk all bbp
2908 bIsPrintAllBBP = TRUE;
2913 { //Invalid parametes, so default printk all bbp
2914 bIsPrintAllBBP = TRUE;
2920 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2925 if (ATE_ON(pAdapter))
2927 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2928 //Read it back for showing
2929 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2932 #endif // RALINK_ATE //
2934 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2935 //Read it back for showing
2936 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2938 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2939 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2940 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2943 {//Invalid parametes, so default printk all bbp
2944 bIsPrintAllBBP = TRUE;
2949 { //Invalid parametes, so default printk all bbp
2950 bIsPrintAllBBP = TRUE;
2956 bIsPrintAllBBP = TRUE;
2961 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2962 sprintf(extra, "\n");
2963 for (bbpId = 0; bbpId <= 136; bbpId++)
2965 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2968 if (ATE_ON(pAdapter))
2970 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2973 #endif // RALINK_ATE //
2974 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2975 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2977 sprintf(extra+strlen(extra), "\n");
2980 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2981 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2984 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2990 int rt_ioctl_siwrate(struct net_device *dev,
2991 struct iw_request_info *info,
2992 union iwreq_data *wrqu, char *extra)
2994 PRTMP_ADAPTER pAd = dev->ml_priv;
2995 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2997 //check if the interface is down
2998 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3000 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3004 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3005 /* rate = -1 => auto rate
3006 rate = X, fixed = 1 => (fixed rate X)
3011 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3012 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3013 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3014 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3015 RTMPSetDesiredRates(pAd, -1);
3017 #ifdef DOT11_N_SUPPORT
3019 #endif // DOT11_N_SUPPORT //
3025 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3026 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3027 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3028 RTMPSetDesiredRates(pAd, rate);
3031 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3032 #ifdef DOT11_N_SUPPORT
3034 #endif // DOT11_N_SUPPORT //
3036 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3040 // TODO: rate = X, fixed = 0 => (rates <= X)
3048 int rt_ioctl_giwrate(struct net_device *dev,
3049 struct iw_request_info *info,
3050 union iwreq_data *wrqu, char *extra)
3052 PRTMP_ADAPTER pAd = dev->ml_priv;
3053 int rate_index = 0, rate_count = 0;
3054 HTTRANSMIT_SETTING ht_setting;
3055 __s32 ralinkrate[] =
3056 {2, 4, 11, 22, // CCK
3057 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3058 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3059 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3060 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3061 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3062 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3063 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3064 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3065 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3067 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3068 //check if the interface is down
3069 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3071 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3075 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3077 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3078 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3080 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3082 #ifdef DOT11_N_SUPPORT
3083 if (ht_setting.field.MODE >= MODE_HTMIX)
3085 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3088 #endif // DOT11_N_SUPPORT //
3089 if (ht_setting.field.MODE == MODE_OFDM)
3090 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3091 else if (ht_setting.field.MODE == MODE_CCK)
3092 rate_index = (UCHAR)(ht_setting.field.MCS);
3097 if (rate_index > rate_count)
3098 rate_index = rate_count;
3100 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3101 wrqu->bitrate.disabled = 0;
3106 static const iw_handler rt_handler[] =
3108 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3109 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3110 (iw_handler) NULL, /* SIOCSIWNWID */
3111 (iw_handler) NULL, /* SIOCGIWNWID */
3112 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3113 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3114 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3115 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3116 (iw_handler) NULL, /* SIOCSIWSENS */
3117 (iw_handler) NULL, /* SIOCGIWSENS */
3118 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3119 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3120 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3121 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3122 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3123 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3124 (iw_handler) NULL, /* SIOCSIWSPY */
3125 (iw_handler) NULL, /* SIOCGIWSPY */
3126 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3127 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3128 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3129 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3131 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3133 (iw_handler) NULL, /* SIOCSIWMLME */
3134 #endif // SIOCSIWMLME //
3135 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3137 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3138 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3140 (iw_handler) NULL, /* SIOCSIWSCAN */
3141 (iw_handler) NULL, /* SIOCGIWSCAN */
3142 #endif /* SIOCGIWSCAN */
3143 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3144 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3145 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3146 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3147 (iw_handler) NULL, /* -- hole -- */
3148 (iw_handler) NULL, /* -- hole -- */
3149 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3150 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3151 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3152 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3153 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3154 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3155 (iw_handler) NULL, /* SIOCSIWTXPOW */
3156 (iw_handler) NULL, /* SIOCGIWTXPOW */
3157 (iw_handler) NULL, /* SIOCSIWRETRY */
3158 (iw_handler) NULL, /* SIOCGIWRETRY */
3159 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3160 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3161 (iw_handler) NULL, /* SIOCSIWPOWER */
3162 (iw_handler) NULL, /* SIOCGIWPOWER */
3163 (iw_handler) NULL, /* -- hole -- */
3164 (iw_handler) NULL, /* -- hole -- */
3165 #if WIRELESS_EXT > 17
3166 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3167 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3168 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3169 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3170 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3171 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3172 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3176 static const iw_handler rt_priv_handlers[] = {
3177 (iw_handler) NULL, /* + 0x00 */
3178 (iw_handler) NULL, /* + 0x01 */
3179 #ifndef CONFIG_AP_SUPPORT
3180 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3182 (iw_handler) NULL, /* + 0x02 */
3183 #endif // CONFIG_AP_SUPPORT //
3185 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3187 (iw_handler) NULL, /* + 0x03 */
3189 (iw_handler) NULL, /* + 0x04 */
3190 (iw_handler) NULL, /* + 0x05 */
3191 (iw_handler) NULL, /* + 0x06 */
3192 (iw_handler) NULL, /* + 0x07 */
3193 (iw_handler) NULL, /* + 0x08 */
3194 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3195 (iw_handler) NULL, /* + 0x0A */
3196 (iw_handler) NULL, /* + 0x0B */
3197 (iw_handler) NULL, /* + 0x0C */
3198 (iw_handler) NULL, /* + 0x0D */
3199 (iw_handler) NULL, /* + 0x0E */
3200 (iw_handler) NULL, /* + 0x0F */
3201 (iw_handler) NULL, /* + 0x10 */
3202 (iw_handler) rt_private_show, /* + 0x11 */
3203 (iw_handler) NULL, /* + 0x12 */
3204 (iw_handler) NULL, /* + 0x13 */
3205 (iw_handler) NULL, /* + 0x15 */
3206 (iw_handler) NULL, /* + 0x17 */
3207 (iw_handler) NULL, /* + 0x18 */
3210 const struct iw_handler_def rt28xx_iw_handler_def =
3212 #define N(a) (sizeof (a) / sizeof (a[0]))
3213 .standard = (iw_handler *) rt_handler,
3214 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3215 .private = (iw_handler *) rt_priv_handlers,
3216 .num_private = N(rt_priv_handlers),
3217 .private_args = (struct iw_priv_args *) privtab,
3218 .num_private_args = N(privtab),
3219 #if IW_HANDLER_VERSION >= 7
3220 .get_wireless_stats = rt28xx_get_wireless_stats,
3224 INT RTMPSetInformation(
3225 IN PRTMP_ADAPTER pAdapter,
3226 IN OUT struct ifreq *rq,
3229 struct iwreq *wrq = (struct iwreq *) rq;
3230 NDIS_802_11_SSID Ssid;
3231 NDIS_802_11_MAC_ADDRESS Bssid;
3232 RT_802_11_PHY_MODE PhyMode;
3233 RT_802_11_STA_CONFIG StaConfig;
3234 NDIS_802_11_RATES aryRates;
3235 RT_802_11_PREAMBLE Preamble;
3236 NDIS_802_11_WEP_STATUS WepStatus;
3237 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3238 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3239 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3240 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3241 NDIS_802_11_POWER_MODE PowerMode;
3242 PNDIS_802_11_KEY pKey = NULL;
3243 PNDIS_802_11_WEP pWepKey =NULL;
3244 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3245 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3246 NDIS_802_11_NETWORK_TYPE NetType;
3249 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3252 BOOLEAN StateMachineTouched = FALSE;
3253 #ifdef DOT11_N_SUPPORT
3254 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3255 #endif // DOT11_N_SUPPORT //
3256 #ifdef WPA_SUPPLICANT_SUPPORT
3257 PNDIS_802_11_PMKID pPmkId = NULL;
3258 BOOLEAN IEEE8021xState = FALSE;
3259 BOOLEAN IEEE8021x_required_keys = FALSE;
3260 UCHAR wpa_supplicant_enable = 0;
3261 #endif // WPA_SUPPLICANT_SUPPORT //
3264 TX_RTY_CFG_STRUC tx_rty_cfg;
3265 ULONG ShortRetryLimit, LongRetryLimit;
3267 #endif // SNMP_SUPPORT //
3270 #ifdef DOT11_N_SUPPORT
3271 MaxPhyMode = PHY_11N_5G;
3272 #endif // DOT11_N_SUPPORT //
3275 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3276 switch(cmd & 0x7FFF) {
3277 case RT_OID_802_11_COUNTRY_REGION:
3278 if (wrq->u.data.length < sizeof(UCHAR))
3280 // Only avaliable when EEPROM not programming
3281 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3286 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3287 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3288 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3289 TmpPhy = pAdapter->CommonCfg.PhyMode;
3290 pAdapter->CommonCfg.PhyMode = 0xff;
3291 // Build all corresponding channel information
3292 RTMPSetPhyMode(pAdapter, TmpPhy);
3293 #ifdef DOT11_N_SUPPORT
3294 SetCommonHT(pAdapter);
3295 #endif // DOT11_N_SUPPORT //
3296 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3297 pAdapter->CommonCfg.CountryRegion));
3300 case OID_802_11_BSSID_LIST_SCAN:
3302 if (ATE_ON(pAdapter))
3304 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3307 #endif // RALINK_ATE //
3309 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3311 if (MONITOR_ON(pAdapter))
3313 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3317 //Benson add 20080527, when radio off, sta don't need to scan
3318 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3321 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3323 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3324 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3325 Status = NDIS_STATUS_SUCCESS;
3329 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3331 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3332 Status = NDIS_STATUS_SUCCESS;
3333 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3337 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3338 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3339 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3340 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3341 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3342 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3344 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3345 Status = NDIS_STATUS_SUCCESS;
3346 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3351 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3353 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3354 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3357 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3358 // this request, because this request is initiated by NDIS.
3359 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3360 // Reset allowed scan retries
3361 pAdapter->StaCfg.ScanCnt = 0;
3362 pAdapter->StaCfg.LastScanTime = Now;
3364 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3365 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3366 MlmeEnqueue(pAdapter,
3367 MLME_CNTL_STATE_MACHINE,
3368 OID_802_11_BSSID_LIST_SCAN,
3372 Status = NDIS_STATUS_SUCCESS;
3373 StateMachineTouched = TRUE;
3375 case OID_802_11_SSID:
3376 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3380 PCHAR pSsidString = NULL;
3381 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3383 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3384 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3388 if (Ssid.SsidLength == 0)
3390 Set_SSID_Proc(pAdapter, "");
3394 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3397 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3398 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3399 Set_SSID_Proc(pAdapter, pSsidString);
3408 case OID_802_11_BSSID:
3410 if (ATE_ON(pAdapter))
3412 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3415 #endif // RALINK_ATE //
3416 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3420 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3422 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3423 // this request, because this request is initiated by NDIS.
3424 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3426 // Prevent to connect AP again in STAMlmePeriodicExec
3427 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3429 // Reset allowed scan retries
3430 pAdapter->StaCfg.ScanCnt = 0;
3432 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3434 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3435 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3437 MlmeEnqueue(pAdapter,
3438 MLME_CNTL_STATE_MACHINE,
3440 sizeof(NDIS_802_11_MAC_ADDRESS),
3442 Status = NDIS_STATUS_SUCCESS;
3443 StateMachineTouched = TRUE;
3445 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3446 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3449 case RT_OID_802_11_RADIO:
3450 if (wrq->u.data.length != sizeof(BOOLEAN))
3454 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3455 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3456 if (pAdapter->StaCfg.bSwRadio != RadioState)
3458 pAdapter->StaCfg.bSwRadio = RadioState;
3459 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3461 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3462 if (pAdapter->StaCfg.bRadio == TRUE)
3464 MlmeRadioOn(pAdapter);
3465 // Update extra information
3466 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3470 MlmeRadioOff(pAdapter);
3471 // Update extra information
3472 pAdapter->ExtraInfo = SW_RADIO_OFF;
3478 case RT_OID_802_11_PHY_MODE:
3479 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3483 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3484 if (PhyMode <= MaxPhyMode)
3486 RTMPSetPhyMode(pAdapter, PhyMode);
3487 #ifdef DOT11_N_SUPPORT
3488 SetCommonHT(pAdapter);
3489 #endif // DOT11_N_SUPPORT //
3491 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3494 case RT_OID_802_11_STA_CONFIG:
3495 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3499 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3500 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3501 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3502 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3503 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3504 (StaConfig.AdhocMode <= MaxPhyMode))
3506 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3507 // if setting changed, need to reset current TX rate as well as BEACON frame format
3508 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3510 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3511 RTMPSetPhyMode(pAdapter, PhyMode);
3512 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3513 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3514 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3517 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3518 pAdapter->CommonCfg.bEnableTxBurst,
3519 pAdapter->CommonCfg.UseBGProtection,
3520 pAdapter->CommonCfg.bUseShortSlotTime));
3523 case OID_802_11_DESIRED_RATES:
3524 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3528 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3529 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3530 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3531 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3532 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3533 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3534 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3535 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3536 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3537 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3540 case RT_OID_802_11_PREAMBLE:
3541 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3545 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3546 if (Preamble == Rt802_11PreambleShort)
3548 pAdapter->CommonCfg.TxPreamble = Preamble;
3549 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3551 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3553 // if user wants AUTO, initialize to LONG here, then change according to AP's
3554 // capability upon association.
3555 pAdapter->CommonCfg.TxPreamble = Preamble;
3556 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3563 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3566 case OID_802_11_WEP_STATUS:
3567 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3571 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3572 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3573 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3575 if (pAdapter->StaCfg.WepStatus != WepStatus)
3577 // Config has changed
3578 pAdapter->bConfigChanged = TRUE;
3580 pAdapter->StaCfg.WepStatus = WepStatus;
3581 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3582 pAdapter->StaCfg.PairCipher = WepStatus;
3583 pAdapter->StaCfg.GroupCipher = WepStatus;
3590 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3593 case OID_802_11_AUTHENTICATION_MODE:
3594 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3598 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3599 if (AuthMode > Ndis802_11AuthModeMax)
3606 if (pAdapter->StaCfg.AuthMode != AuthMode)
3608 // Config has changed
3609 pAdapter->bConfigChanged = TRUE;
3611 pAdapter->StaCfg.AuthMode = AuthMode;
3613 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3614 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3617 case OID_802_11_INFRASTRUCTURE_MODE:
3618 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3622 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3624 if (BssType == Ndis802_11IBSS)
3625 Set_NetworkType_Proc(pAdapter, "Adhoc");
3626 else if (BssType == Ndis802_11Infrastructure)
3627 Set_NetworkType_Proc(pAdapter, "Infra");
3628 else if (BssType == Ndis802_11Monitor)
3629 Set_NetworkType_Proc(pAdapter, "Monitor");
3633 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3637 case OID_802_11_REMOVE_WEP:
3638 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3639 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3645 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3647 if (KeyIdx & 0x80000000)
3649 // Should never set default bit when remove key
3654 KeyIdx = KeyIdx & 0x0fffffff;
3660 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3661 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3662 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3667 case RT_OID_802_11_RESET_COUNTERS:
3668 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3669 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3670 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3671 pAdapter->Counters8023.RxNoBuffer = 0;
3672 pAdapter->Counters8023.GoodReceives = 0;
3673 pAdapter->Counters8023.RxNoBuffer = 0;
3674 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3676 case OID_802_11_RTS_THRESHOLD:
3677 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3681 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3682 if (RtsThresh > MAX_RTS_THRESHOLD)
3685 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3687 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3689 case OID_802_11_FRAGMENTATION_THRESHOLD:
3690 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3694 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3695 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3696 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3698 if (FragThresh == 0)
3700 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3701 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3707 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3709 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3711 case OID_802_11_POWER_MODE:
3712 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3716 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3717 if (PowerMode == Ndis802_11PowerModeCAM)
3718 Set_PSMode_Proc(pAdapter, "CAM");
3719 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3720 Set_PSMode_Proc(pAdapter, "Max_PSP");
3721 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3722 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3723 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3724 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3728 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3730 case RT_OID_802_11_TX_POWER_LEVEL_1:
3731 if (wrq->u.data.length < sizeof(ULONG))
3735 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3736 if (PowerTemp > 100)
3737 PowerTemp = 0xffffffff; // AUTO
3738 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3739 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3740 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3743 case OID_802_11_NETWORK_TYPE_IN_USE:
3744 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3748 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3750 if (NetType == Ndis802_11DS)
3751 RTMPSetPhyMode(pAdapter, PHY_11B);
3752 else if (NetType == Ndis802_11OFDM24)
3753 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3754 else if (NetType == Ndis802_11OFDM5)
3755 RTMPSetPhyMode(pAdapter, PHY_11A);
3758 #ifdef DOT11_N_SUPPORT
3759 if (Status == NDIS_STATUS_SUCCESS)
3760 SetCommonHT(pAdapter);
3761 #endif // DOT11_N_SUPPORT //
3762 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3765 // For WPA PSK PMK key
3766 case RT_OID_802_11_ADD_WPA:
3767 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3774 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3775 if (pKey->Length != wrq->u.data.length)
3778 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3782 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3783 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3784 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3786 Status = -EOPNOTSUPP;
3787 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3789 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3790 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3791 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3793 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3794 // Use RaConfig as PSK agent.
3795 // Start STA supplicant state machine
3796 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3797 pAdapter->StaCfg.WpaState = SS_START;
3799 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3803 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3804 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3809 case OID_802_11_REMOVE_KEY:
3810 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3811 if(pRemoveKey == NULL)
3817 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3818 if (pRemoveKey->Length != wrq->u.data.length)
3821 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3825 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3827 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3828 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3832 KeyIdx = pRemoveKey->KeyIndex;
3834 if (KeyIdx & 0x80000000)
3836 // Should never set default bit when remove key
3838 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3842 KeyIdx = KeyIdx & 0x0fffffff;
3846 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3850 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3851 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3852 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3853 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3861 case OID_802_11_ADD_KEY:
3862 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3868 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3869 if (pKey->Length != wrq->u.data.length)
3872 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3876 RTMPAddKey(pAdapter, pKey);
3877 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3881 case OID_802_11_CONFIGURATION:
3882 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3886 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3889 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3890 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3892 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3893 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3895 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3897 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3899 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3900 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3901 // Config has changed
3902 pAdapter->bConfigChanged = TRUE;
3905 #ifdef DOT11_N_SUPPORT
3906 case RT_OID_802_11_SET_HT_PHYMODE:
3907 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3911 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3913 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3914 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3915 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3916 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3917 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3918 RTMPSetHT(pAdapter, pHTPhyMode);
3920 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3921 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3922 pAdapter->StaCfg.HTPhyMode.field.STBC));
3924 #endif // DOT11_N_SUPPORT //
3925 case RT_OID_802_11_SET_APSD_SETTING:
3926 if (wrq->u.data.length != sizeof(ULONG))
3931 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3933 /*-------------------------------------------------------------------
3934 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3935 ---------------------------------------------------------------------
3936 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3937 ---------------------------------------------------------------------*/
3938 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3939 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3940 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3941 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3942 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3943 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3945 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,
3946 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3950 case RT_OID_802_11_SET_APSD_PSM:
3951 if (wrq->u.data.length != sizeof(ULONG))
3955 // Driver needs to notify AP when PSM changes
3956 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3957 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3959 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3960 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3962 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3965 #ifdef QOS_DLS_SUPPORT
3966 case RT_OID_802_11_SET_DLS:
3967 if (wrq->u.data.length != sizeof(ULONG))
3971 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3972 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3973 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3976 // tear down local dls table entry
3977 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3979 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3981 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3982 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3983 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3987 // tear down peer dls table entry
3988 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3990 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3992 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3993 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3994 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3999 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
4003 case RT_OID_802_11_SET_DLS_PARAM:
4004 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4010 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4011 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4012 MlmeEnqueue(pAdapter,
4013 MLME_CNTL_STATE_MACHINE,
4014 RT_OID_802_11_SET_DLS_PARAM,
4015 sizeof(RT_802_11_DLS),
4017 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4020 #endif // QOS_DLS_SUPPORT //
4021 case RT_OID_802_11_SET_WMM:
4022 if (wrq->u.data.length != sizeof(BOOLEAN))
4026 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4027 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
4031 case OID_802_11_DISASSOCIATE:
4033 if (ATE_ON(pAdapter))
4035 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4038 #endif // RALINK_ATE //
4040 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4041 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4042 // when query OID_802_11_BSSID_LIST.
4044 // TRUE: NumberOfItems will set to 0.
4045 // FALSE: NumberOfItems no change.
4047 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4048 // Set to immediately send the media disconnect event
4049 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4050 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4052 if (INFRA_ON(pAdapter))
4054 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4056 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4057 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4060 MlmeEnqueue(pAdapter,
4061 MLME_CNTL_STATE_MACHINE,
4062 OID_802_11_DISASSOCIATE,
4066 StateMachineTouched = TRUE;
4070 #ifdef DOT11_N_SUPPORT
4071 case RT_OID_802_11_SET_IMME_BA_CAP:
4072 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4076 OID_BACAP_STRUC Orde ;
4077 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4078 if (Orde.Policy > BA_NOTUSE)
4080 Status = NDIS_STATUS_INVALID_DATA;
4082 else if (Orde.Policy == BA_NOTUSE)
4084 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4085 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4086 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4087 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4088 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4089 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4090 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4092 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4093 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4094 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4098 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4099 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4100 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4101 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4102 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4103 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4104 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4105 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4108 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4109 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4110 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4112 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4113 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4117 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4118 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4119 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4120 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4121 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4125 case RT_OID_802_11_ADD_IMME_BA:
4126 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4127 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4132 OID_ADD_BA_ENTRY BA;
4133 MAC_TABLE_ENTRY *pEntry;
4135 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4138 Status = NDIS_STATUS_INVALID_DATA;
4143 //BATableInsertEntry
4144 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4146 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4147 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4150 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4153 if (BA.IsRecipient == FALSE)
4155 if (pEntry->bIAmBadAtheros == TRUE)
4156 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4158 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4162 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4165 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4166 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4167 , BA.MACAddr[4], BA.MACAddr[5]));
4172 case RT_OID_802_11_TEAR_IMME_BA:
4173 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4174 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4178 POID_ADD_BA_ENTRY pBA;
4179 MAC_TABLE_ENTRY *pEntry;
4181 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4185 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4186 Status = NDIS_STATUS_FAILURE;
4190 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4191 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4193 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4195 Status = NDIS_STATUS_INVALID_DATA;
4199 if (pBA->IsRecipient == FALSE)
4201 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4202 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4205 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4206 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4209 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4213 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4216 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4219 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4225 #endif // DOT11_N_SUPPORT //
4227 // For WPA_SUPPLICANT to set static wep key
4228 case OID_802_11_ADD_WEP:
4229 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4234 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4237 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4241 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4245 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4246 // KeyIdx must be 0 ~ 3
4250 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4254 UCHAR CipherAlg = 0;
4257 // set key material and key length
4258 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4259 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4260 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4262 switch(pWepKey->KeyLength)
4265 CipherAlg = CIPHER_WEP64;
4268 CipherAlg = CIPHER_WEP128;
4271 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4275 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4277 // Default key for tx (shared key)
4278 if (pWepKey->KeyIndex & 0x80000000)
4280 #ifdef WPA_SUPPLICANT_SUPPORT
4281 // set key material and key length
4282 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4283 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4284 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4285 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4286 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4287 #endif // WPA_SUPPLICANT_SUPPORT //
4288 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4291 #ifdef WPA_SUPPLICANT_SUPPORT
4292 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4293 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4295 Key = pWepKey->KeyMaterial;
4297 // Set Group key material to Asic
4298 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4300 // Update WCID attribute table and IVEIV table for this group key table
4301 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4303 STA_PORT_SECURED(pAdapter);
4305 // Indicate Connected for GUI
4306 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4308 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4309 #endif // WPA_SUPPLICANT_SUPPORT
4311 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4313 // Set key material and cipherAlg to Asic
4314 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4316 if (pWepKey->KeyIndex & 0x80000000)
4318 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4319 // Assign group key info
4320 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4321 // Assign pairwise key info
4322 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4325 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"));
4330 #ifdef WPA_SUPPLICANT_SUPPORT
4331 case OID_SET_COUNTERMEASURES:
4332 if (wrq->u.data.length != sizeof(int))
4337 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4339 pAdapter->StaCfg.bBlockAssoc = TRUE;
4341 // WPA MIC error should block association attempt for 60 seconds
4342 pAdapter->StaCfg.bBlockAssoc = FALSE;
4343 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4346 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4347 if (wrq->u.data.length != sizeof(UCHAR))
4351 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4352 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4353 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4356 case OID_802_11_DEAUTHENTICATION:
4357 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4361 MLME_DEAUTH_REQ_STRUCT *pInfo;
4362 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4364 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4365 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4366 MlmeDeauthReqAction(pAdapter, MsgElem);
4369 if (INFRA_ON(pAdapter))
4371 LinkDown(pAdapter, FALSE);
4372 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4374 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4377 case OID_802_11_DROP_UNENCRYPTED:
4378 if (wrq->u.data.length != sizeof(int))
4383 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4385 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4387 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4388 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4389 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4390 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4391 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4394 case OID_802_11_SET_IEEE8021X:
4395 if (wrq->u.data.length != sizeof(BOOLEAN))
4399 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4400 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4401 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4404 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4405 if (wrq->u.data.length != sizeof(BOOLEAN))
4409 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4410 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4411 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4414 case OID_802_11_PMKID:
4415 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4417 if(pPmkId == NULL) {
4421 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4423 // check the PMKID information
4424 if (pPmkId->BSSIDInfoCount == 0)
4425 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4428 PBSSID_INFO pBssIdInfo;
4432 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4434 // point to the indexed BSSID_INFO structure
4435 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4436 // Find the entry in the saved data base.
4437 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4439 // compare the BSSID
4440 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4444 // Found, replace it
4445 if (CachedIdx < PMKID_NO)
4447 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4448 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4449 pAdapter->StaCfg.SavedPMKNum++;
4451 // Not found, replace the last one
4454 // Randomly replace one
4455 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4456 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4457 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4464 #endif // WPA_SUPPLICANT_SUPPORT //
4469 case OID_802_11_SHORTRETRYLIMIT:
4470 if (wrq->u.data.length != sizeof(ULONG))
4474 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4475 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4476 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4477 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4478 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4482 case OID_802_11_LONGRETRYLIMIT:
4483 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4484 if (wrq->u.data.length != sizeof(ULONG))
4488 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4489 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4490 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4491 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4492 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4496 case OID_802_11_WEPDEFAULTKEYVALUE:
4497 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4498 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4499 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4502 if ( pKey->Length != wrq->u.data.length)
4505 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4507 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4508 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4510 // it is a shared key
4515 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4516 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4517 if (pKey->KeyIndex & 0x80000000)
4519 // Default key for tx (shared key)
4520 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4522 //RestartAPIsRequired = TRUE;
4527 case OID_802_11_WEPDEFAULTKEYID:
4528 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4530 if (wrq->u.data.length != sizeof(UCHAR))
4533 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4538 case OID_802_11_CURRENTCHANNEL:
4539 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4540 if (wrq->u.data.length != sizeof(UCHAR))
4544 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4545 sprintf(&ctmp,"%d", ctmp);
4546 Set_Channel_Proc(pAdapter, &ctmp);
4554 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4555 Status = -EOPNOTSUPP;
4563 INT RTMPQueryInformation(
4564 IN PRTMP_ADAPTER pAdapter,
4565 IN OUT struct ifreq *rq,
4568 struct iwreq *wrq = (struct iwreq *) rq;
4569 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4570 PNDIS_WLAN_BSSID_EX pBss;
4571 NDIS_802_11_SSID Ssid;
4572 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4573 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4574 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4575 NDIS_802_11_STATISTICS *pStatistics = NULL;
4576 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4577 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4578 NDIS_802_11_POWER_MODE PowerMode;
4579 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4580 RT_802_11_PREAMBLE PreamType;
4581 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4582 NDIS_802_11_WEP_STATUS WepStatus;
4583 NDIS_MEDIA_STATE MediaState;
4584 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4586 PUCHAR pBuf = NULL, pPtr;
4587 INT Status = NDIS_STATUS_SUCCESS;
4588 UINT we_version_compiled;
4589 UCHAR i, Padding = 0;
4591 UCHAR driverVersion[8];
4592 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4597 DefaultKeyIdxValue *pKeyIdxValue;
4599 TX_RTY_CFG_STRUC tx_rty_cfg;
4600 ULONG ShortRetryLimit, LongRetryLimit;
4606 case RT_OID_DEVICE_NAME:
4607 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4608 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4610 case RT_OID_VERSION_INFO:
4611 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4612 wrq->u.data.length = 8*sizeof(UCHAR);
4613 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4614 driverVersion[7] = '\0';
4615 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4621 case RT_QUERY_ATE_TXDONE_COUNT:
4622 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4623 wrq->u.data.length = sizeof(UINT32);
4624 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4629 #endif // RALINK_ATE //
4630 case OID_802_11_BSSID_LIST:
4631 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4634 * Still scanning, indicate the caller should try again.
4636 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4639 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4640 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4641 // Claculate total buffer size required
4642 BssBufSize = sizeof(ULONG);
4644 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4646 // Align pointer to 4 bytes boundary.
4647 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4650 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4653 // For safety issue, we add 256 bytes just in case
4655 // Allocate the same size as passed from higher layer
4656 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4662 // Init 802_11_BSSID_LIST_EX structure
4663 NdisZeroMemory(pBuf, BssBufSize);
4664 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4665 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4667 // Calculate total buffer length
4668 BssLen = 4; // Consist of NumberOfItems
4669 // Point to start of NDIS_WLAN_BSSID_EX
4670 // pPtr = pBuf + sizeof(ULONG);
4671 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4672 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4674 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4675 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4676 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4679 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4680 // and then failed to send EAPOl farame.
4682 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4684 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4685 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4688 pBss->Ssid.SsidLength = 0;
4692 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4693 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4695 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4696 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4697 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4698 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4699 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4700 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4702 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4704 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4705 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4707 pBss->InfrastructureMode = Ndis802_11IBSS;
4709 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4710 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4711 pAdapter->ScanTab.BssEntry[i].ExtRate,
4712 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4714 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4716 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4717 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4718 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4722 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4723 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4724 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4725 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4726 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4728 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4730 #if WIRELESS_EXT < 17
4731 if ((BssLen + pBss->Length) < wrq->u.data.length)
4732 BssLen += pBss->Length;
4735 pBssidList->NumberOfItems = i;
4739 BssLen += pBss->Length;
4743 #if WIRELESS_EXT < 17
4744 wrq->u.data.length = BssLen;
4746 if (BssLen > wrq->u.data.length)
4752 wrq->u.data.length = BssLen;
4754 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4757 case OID_802_3_CURRENT_ADDRESS:
4758 wrq->u.data.length = MAC_ADDR_LEN;
4759 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4761 case OID_GEN_MEDIA_CONNECT_STATUS:
4762 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4763 MediaState = NdisMediaStateConnected;
4765 MediaState = NdisMediaStateDisconnected;
4767 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4768 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4770 case OID_802_11_BSSID:
4772 if (ATE_ON(pAdapter))
4774 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4775 Status = NDIS_STATUS_RESOURCES;
4778 #endif // RALINK_ATE //
4779 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4781 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4786 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4790 case OID_802_11_SSID:
4791 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4792 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4793 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4794 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4795 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4796 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4797 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4799 case RT_OID_802_11_QUERY_LINK_STATUS:
4800 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4803 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4804 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4805 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4806 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4807 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4808 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4809 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4811 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4815 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4819 case OID_802_11_CONFIGURATION:
4820 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4823 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4824 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4825 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4826 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4827 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4828 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4829 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4830 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4831 kfree(pConfiguration);
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4839 case RT_OID_802_11_SNR_0:
4840 if ((pAdapter->StaCfg.LastSNR0 > 0))
4842 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4843 wrq->u.data.length = sizeof(ulInfo);
4844 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4845 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4850 case RT_OID_802_11_SNR_1:
4851 if ((pAdapter->Antenna.field.RxPath > 1) &&
4852 (pAdapter->StaCfg.LastSNR1 > 0))
4854 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4855 wrq->u.data.length = sizeof(ulInfo);
4856 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4857 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4861 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4863 case OID_802_11_RSSI_TRIGGER:
4864 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4865 wrq->u.data.length = sizeof(ulInfo);
4866 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4867 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4869 case OID_802_11_RSSI:
4870 case RT_OID_802_11_RSSI:
4871 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4872 wrq->u.data.length = sizeof(ulInfo);
4873 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4875 case RT_OID_802_11_RSSI_1:
4876 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4877 wrq->u.data.length = sizeof(ulInfo);
4878 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4880 case RT_OID_802_11_RSSI_2:
4881 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4882 wrq->u.data.length = sizeof(ulInfo);
4883 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4885 case OID_802_11_STATISTICS:
4886 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4889 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4890 // add the most up-to-date h/w raw counters into software counters
4891 NICUpdateRawCounters(pAdapter);
4893 // Sanity check for calculation of sucessful count
4894 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4895 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4897 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4898 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4899 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4900 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4901 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4902 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4903 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4904 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4905 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4906 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4907 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4909 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4911 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4912 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4914 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4915 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4920 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4924 case OID_GEN_RCV_OK:
4925 ulInfo = pAdapter->Counters8023.GoodReceives;
4926 wrq->u.data.length = sizeof(ulInfo);
4927 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4929 case OID_GEN_RCV_NO_BUFFER:
4930 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4931 wrq->u.data.length = sizeof(ulInfo);
4932 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4934 case RT_OID_802_11_PHY_MODE:
4935 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4936 wrq->u.data.length = sizeof(ulInfo);
4937 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4938 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4940 case RT_OID_802_11_STA_CONFIG:
4941 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4944 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4945 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4946 pStaConfig->EnableTurboRate = 0;
4947 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4948 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4949 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4950 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4951 pStaConfig->Rsv1 = 0;
4952 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4953 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4954 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4959 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4963 case OID_802_11_RTS_THRESHOLD:
4964 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4965 wrq->u.data.length = sizeof(RtsThresh);
4966 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4967 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4969 case OID_802_11_FRAGMENTATION_THRESHOLD:
4970 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4971 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4973 wrq->u.data.length = sizeof(FragThresh);
4974 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4975 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4977 case OID_802_11_POWER_MODE:
4978 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4979 wrq->u.data.length = sizeof(PowerMode);
4980 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4981 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4983 case RT_OID_802_11_RADIO:
4984 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4985 wrq->u.data.length = sizeof(RadioState);
4986 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4987 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4989 case OID_802_11_INFRASTRUCTURE_MODE:
4990 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4991 BssType = Ndis802_11IBSS;
4992 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4993 BssType = Ndis802_11Infrastructure;
4994 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4995 BssType = Ndis802_11Monitor;
4997 BssType = Ndis802_11AutoUnknown;
4999 wrq->u.data.length = sizeof(BssType);
5000 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5001 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5003 case RT_OID_802_11_PREAMBLE:
5004 PreamType = pAdapter->CommonCfg.TxPreamble;
5005 wrq->u.data.length = sizeof(PreamType);
5006 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5007 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5009 case OID_802_11_AUTHENTICATION_MODE:
5010 AuthMode = pAdapter->StaCfg.AuthMode;
5011 wrq->u.data.length = sizeof(AuthMode);
5012 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5013 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5015 case OID_802_11_WEP_STATUS:
5016 WepStatus = pAdapter->StaCfg.WepStatus;
5017 wrq->u.data.length = sizeof(WepStatus);
5018 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5019 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5021 case OID_802_11_TX_POWER_LEVEL:
5022 wrq->u.data.length = sizeof(ULONG);
5023 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
5024 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
5026 case RT_OID_802_11_TX_POWER_LEVEL_1:
5027 wrq->u.data.length = sizeof(ULONG);
5028 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5029 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
5031 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5032 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
5034 NetworkTypeList[0] = 3; // NumberOfItems = 3
5035 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5036 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5037 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5038 wrq->u.data.length = 16;
5039 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5043 NetworkTypeList[0] = 2; // NumberOfItems = 2
5044 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5045 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5046 wrq->u.data.length = 12;
5047 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5049 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5051 case OID_802_11_NETWORK_TYPE_IN_USE:
5052 wrq->u.data.length = sizeof(ULONG);
5053 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5054 ulInfo = Ndis802_11OFDM5;
5055 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5056 ulInfo = Ndis802_11OFDM24;
5058 ulInfo = Ndis802_11DS;
5059 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5061 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5062 ulInfo = (ULONG)pAdapter->LastRxRate;
5063 wrq->u.data.length = sizeof(ulInfo);
5064 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5065 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5067 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5068 //ulInfo = (ULONG)pAdapter->LastTxRate;
5069 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5070 wrq->u.data.length = sizeof(ulInfo);
5071 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5072 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5074 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5075 wrq->u.data.length = sizeof(ULONG);
5076 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5078 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5079 wrq->u.data.length = sizeof(ULONG);
5080 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5082 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5083 wrq->u.data.length = sizeof(UCHAR);
5084 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5085 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5087 case RT_OID_802_11_EXTRA_INFO:
5088 wrq->u.data.length = sizeof(ULONG);
5089 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5090 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5092 case RT_OID_WE_VERSION_COMPILED:
5093 wrq->u.data.length = sizeof(UINT);
5094 we_version_compiled = WIRELESS_EXT;
5095 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5097 case RT_OID_802_11_QUERY_APSD_SETTING:
5098 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5099 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5101 wrq->u.data.length = sizeof(ULONG);
5102 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5103 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",
5104 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5106 case RT_OID_802_11_QUERY_APSD_PSM:
5107 wrq->u.data.length = sizeof(ULONG);
5108 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5109 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5111 case RT_OID_802_11_QUERY_WMM:
5112 wrq->u.data.length = sizeof(BOOLEAN);
5113 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5114 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5116 #ifdef WPA_SUPPLICANT_SUPPORT
5117 case RT_OID_NEW_DRIVER:
5120 wrq->u.data.length = sizeof(UCHAR);
5121 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5122 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5125 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5126 wrq->u.data.length = sizeof(UCHAR);
5127 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5128 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5130 #endif // WPA_SUPPLICANT_SUPPORT //
5132 case RT_OID_DRIVER_DEVICE_NAME:
5133 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5134 wrq->u.data.length = 16;
5135 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5140 case RT_OID_802_11_QUERY_HT_PHYMODE:
5141 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5144 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5145 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5146 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5147 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5148 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5149 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5151 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5152 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5153 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5157 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5158 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5159 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5163 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5167 case RT_OID_802_11_COUNTRY_REGION:
5168 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5169 wrq->u.data.length = sizeof(ulInfo);
5170 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5171 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5172 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5177 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5178 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5181 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5182 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5183 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5184 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5185 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5186 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5188 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5189 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5193 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5194 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5195 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5199 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5203 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5204 wrq->u.data.length = sizeof(UCHAR);
5206 #ifdef MULTIPLE_CARD_SUPPORT
5208 #endif // MULTIPLE_CARD_SUPPORT //
5209 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5213 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5216 case RT_OID_802_11_MAC_ADDRESS:
5217 wrq->u.data.length = MAC_ADDR_LEN;
5218 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5221 case RT_OID_802_11_MANUFACTUREROUI:
5222 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5223 wrq->u.data.length = ManufacturerOUI_LEN;
5224 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5227 case RT_OID_802_11_MANUFACTURERNAME:
5228 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5229 wrq->u.data.length = strlen(ManufacturerNAME);
5230 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5233 case RT_OID_802_11_RESOURCETYPEIDNAME:
5234 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5235 wrq->u.data.length = strlen(ResourceTypeIdName);
5236 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5239 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5240 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5241 ulInfo = 1; // 1 is support wep else 2 is not support.
5242 wrq->u.data.length = sizeof(ulInfo);
5243 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5246 case RT_OID_802_11_POWERMANAGEMENTMODE:
5247 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5248 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5249 ulInfo = 1; // 1 is power active else 2 is power save.
5253 wrq->u.data.length = sizeof(ulInfo);
5254 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5257 case OID_802_11_WEPDEFAULTKEYVALUE:
5258 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5259 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5260 pKeyIdxValue = wrq->u.data.pointer;
5261 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5262 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5263 NdisMoveMemory(pKeyIdxValue->Value,
5264 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5266 pKeyIdxValue->Value[valueLen]='\0';
5268 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5270 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5271 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,
5272 pAdapter->SharedKey[BSS0][0].Key[0],
5273 pAdapter->SharedKey[BSS0][1].Key[0],
5274 pAdapter->SharedKey[BSS0][2].Key[0],
5275 pAdapter->SharedKey[BSS0][3].Key[0]));
5278 case OID_802_11_WEPDEFAULTKEYID:
5279 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5280 wrq->u.data.length = sizeof(UCHAR);
5281 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5282 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5285 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5286 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5287 wrq->u.data.length = sizeof(UCHAR);
5288 Status = copy_to_user(wrq->u.data.pointer,
5289 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5290 wrq->u.data.length);
5293 case OID_802_11_SHORTRETRYLIMIT:
5294 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5295 wrq->u.data.length = sizeof(ULONG);
5296 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5297 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5298 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5299 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5302 case OID_802_11_LONGRETRYLIMIT:
5303 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5304 wrq->u.data.length = sizeof(ULONG);
5305 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5306 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5307 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5308 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5311 case RT_OID_802_11_PRODUCTID:
5312 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5317 if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
5318 pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5320 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5321 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5323 wrq->u.data.length = strlen(tmp);
5324 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5327 case RT_OID_802_11_MANUFACTUREID:
5328 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5329 wrq->u.data.length = strlen(ManufacturerNAME);
5330 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5333 case OID_802_11_CURRENTCHANNEL:
5334 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5335 wrq->u.data.length = sizeof(UCHAR);
5336 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5337 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5338 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5340 #endif //SNMP_SUPPORT
5342 case OID_802_11_BUILD_CHANNEL_EX:
5345 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5346 wrq->u.data.length = sizeof(UCHAR);
5347 #ifdef EXT_BUILD_CHANNEL_LIST
5348 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5351 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5353 #endif // EXT_BUILD_CHANNEL_LIST //
5354 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5355 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5359 case OID_802_11_GET_CH_LIST:
5361 PRT_CHANNEL_LIST_INFO pChListBuf;
5363 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5364 if (pAdapter->ChannelListNum == 0)
5366 wrq->u.data.length = 0;
5370 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5371 if (pChListBuf == NULL)
5373 wrq->u.data.length = 0;
5377 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5378 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5379 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5381 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5382 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5383 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5390 case OID_802_11_GET_COUNTRY_CODE:
5391 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5392 wrq->u.data.length = 2;
5393 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5394 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5397 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5398 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5399 wrq->u.data.length = 1;
5400 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5401 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5405 #ifdef QOS_DLS_SUPPORT
5406 case RT_OID_802_11_QUERY_DLS:
5407 wrq->u.data.length = sizeof(BOOLEAN);
5408 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5409 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5412 case RT_OID_802_11_QUERY_DLS_PARAM:
5414 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5415 if (pDlsInfo == NULL)
5418 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5420 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5423 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5424 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5425 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5426 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5432 #endif // QOS_DLS_SUPPORT //
5434 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5435 Status = -EOPNOTSUPP;
5441 INT rt28xx_sta_ioctl(
5442 IN struct net_device *net_dev,
5443 IN OUT struct ifreq *rq,
5447 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5448 RTMP_ADAPTER *pAd = NULL;
5449 struct iwreq *wrq = (struct iwreq *) rq;
5450 BOOLEAN StateMachineTouched = FALSE;
5451 INT Status = NDIS_STATUS_SUCCESS;
5454 if (net_dev->priv_flags == INT_MAIN)
5456 pAd = net_dev->ml_priv;
5460 pVirtualAd = net_dev->ml_priv;
5461 pAd = pVirtualAd->RtmpDev->ml_priv;
5463 pObj = (POS_COOKIE) pAd->OS_Cookie;
5467 /* if 1st open fail, pAd will be free;
5468 So the net_dev->ml_priv will be NULL in 2rd open */
5472 //check if the interface is down
5473 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5476 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5481 { // determine this ioctl command is comming from which interface.
5482 pObj->ioctl_if_type = INT_MAIN;
5483 pObj->ioctl_if = MAIN_MBSSID;
5489 #ifdef RALINK_28xx_QA
5490 case RTPRIV_IOCTL_ATE:
5492 RtmpDoAte(pAd, wrq);
5495 #endif // RALINK_28xx_QA //
5496 #endif // RALINK_ATE //
5498 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5499 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5503 char *name=&wrq->u.name[0];
5504 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5507 case SIOCGIWESSID: //Get ESSID
5509 struct iw_point *essid=&wrq->u.essid;
5510 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5513 case SIOCSIWESSID: //Set ESSID
5515 struct iw_point *essid=&wrq->u.essid;
5516 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5519 case SIOCSIWNWID: // set network id (the cell)
5520 case SIOCGIWNWID: // get network id
5521 Status = -EOPNOTSUPP;
5523 case SIOCSIWFREQ: //set channel/frequency (Hz)
5525 struct iw_freq *freq=&wrq->u.freq;
5526 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5529 case SIOCGIWFREQ: // get channel/frequency (Hz)
5531 struct iw_freq *freq=&wrq->u.freq;
5532 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5535 case SIOCSIWNICKN: //set node name/nickname
5537 struct iw_point *data=&wrq->u.data;
5538 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5541 case SIOCGIWNICKN: //get node name/nickname
5543 struct iw_point *data=&wrq->u.data;
5544 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5547 case SIOCGIWRATE: //get default bit rate (bps)
5548 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5550 case SIOCSIWRATE: //set default bit rate (bps)
5551 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5553 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5555 struct iw_param *rts=&wrq->u.rts;
5556 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5559 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5561 struct iw_param *rts=&wrq->u.rts;
5562 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5565 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5567 struct iw_param *frag=&wrq->u.frag;
5568 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5571 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5573 struct iw_param *frag=&wrq->u.frag;
5574 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5577 case SIOCGIWENCODE: //get encoding token & mode
5579 struct iw_point *erq=&wrq->u.encoding;
5581 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5584 case SIOCSIWENCODE: //set encoding token & mode
5586 struct iw_point *erq=&wrq->u.encoding;
5588 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5591 case SIOCGIWAP: //get access point MAC addresses
5593 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5594 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5597 case SIOCSIWAP: //set access point MAC addresses
5599 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5600 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5603 case SIOCGIWMODE: //get operation mode
5605 __u32 *mode=&wrq->u.mode;
5606 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5609 case SIOCSIWMODE: //set operation mode
5611 __u32 *mode=&wrq->u.mode;
5612 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5615 case SIOCGIWSENS: //get sensitivity (dBm)
5616 case SIOCSIWSENS: //set sensitivity (dBm)
5617 case SIOCGIWPOWER: //get Power Management settings
5618 case SIOCSIWPOWER: //set Power Management settings
5619 case SIOCGIWTXPOW: //get transmit power (dBm)
5620 case SIOCSIWTXPOW: //set transmit power (dBm)
5621 case SIOCGIWRANGE: //Get range of parameters
5622 case SIOCGIWRETRY: //get retry limits and lifetime
5623 case SIOCSIWRETRY: //set retry limits and lifetime
5624 Status = -EOPNOTSUPP;
5627 subcmd = wrq->u.data.flags;
5628 if( subcmd & OID_GET_SET_TOGGLE)
5629 Status = RTMPSetInformation(pAd, rq, subcmd);
5631 Status = RTMPQueryInformation(pAd, rq, subcmd);
5634 if (wrq->u.data.pointer)
5636 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5638 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5639 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5643 case RTPRIV_IOCTL_SET:
5644 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5646 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5648 case RTPRIV_IOCTL_GSITESURVEY:
5649 RTMPIoctlGetSiteSurvey(pAd, wrq);
5652 case RTPRIV_IOCTL_MAC:
5653 RTMPIoctlMAC(pAd, wrq);
5655 case RTPRIV_IOCTL_E2P:
5656 RTMPIoctlE2PROM(pAd, wrq);
5662 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5663 Status = -EOPNOTSUPP;
5667 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5668 RT28XX_MLME_HANDLER(pAd);
5674 ==========================================================================
5678 TRUE if all parameters are OK, FALSE otherwise
5679 ==========================================================================
5682 IN PRTMP_ADAPTER pAdapter,
5685 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5686 BOOLEAN StateMachineTouched = FALSE;
5689 if( strlen(arg) <= MAX_LEN_OF_SSID)
5691 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5692 if (strlen(arg) != 0)
5694 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5695 Ssid.SsidLength = strlen(arg);
5699 Ssid.SsidLength = 0;
5700 memcpy(Ssid.Ssid, "", 0);
5701 pAdapter->StaCfg.BssType = BSS_INFRA;
5702 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5703 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5707 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5709 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5710 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5713 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5714 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5715 pAdapter->bConfigChanged = TRUE;
5717 MlmeEnqueue(pAdapter,
5718 MLME_CNTL_STATE_MACHINE,
5720 sizeof(NDIS_802_11_SSID),
5723 StateMachineTouched = TRUE;
5724 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5729 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5730 RT28XX_MLME_HANDLER(pAdapter);
5737 ==========================================================================
5739 Set WmmCapable Enable or Disable
5741 TRUE if all parameters are OK, FALSE otherwise
5742 ==========================================================================
5744 INT Set_WmmCapable_Proc(
5745 IN PRTMP_ADAPTER pAd,
5748 BOOLEAN bWmmCapable;
5750 bWmmCapable = simple_strtol(arg, 0, 10);
5752 if ((bWmmCapable == 1)
5754 pAd->CommonCfg.bWmmCapable = TRUE;
5755 else if (bWmmCapable == 0)
5756 pAd->CommonCfg.bWmmCapable = FALSE;
5758 return FALSE; //Invalid argument
5760 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5761 pAd->CommonCfg.bWmmCapable));
5765 #endif // WMM_SUPPORT //
5768 ==========================================================================
5770 Set Network Type(Infrastructure/Adhoc mode)
5772 TRUE if all parameters are OK, FALSE otherwise
5773 ==========================================================================
5775 INT Set_NetworkType_Proc(
5776 IN PRTMP_ADAPTER pAdapter,
5781 if (strcmp(arg, "Adhoc") == 0)
5783 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5785 // Config has changed
5786 pAdapter->bConfigChanged = TRUE;
5787 if (MONITOR_ON(pAdapter))
5789 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5790 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5792 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5793 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5794 pAdapter->StaCfg.bAutoReconnect = TRUE;
5795 LinkDown(pAdapter, FALSE);
5797 if (INFRA_ON(pAdapter))
5799 //BOOLEAN Cancelled;
5800 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5801 // Since calling this indicate user don't want to connect to that SSID anymore.
5802 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5803 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5805 LinkDown(pAdapter, FALSE);
5807 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5810 pAdapter->StaCfg.BssType = BSS_ADHOC;
5811 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5812 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5814 else if (strcmp(arg, "Infra") == 0)
5816 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5818 // Config has changed
5819 pAdapter->bConfigChanged = TRUE;
5820 if (MONITOR_ON(pAdapter))
5822 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5823 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5825 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5826 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5827 pAdapter->StaCfg.bAutoReconnect = TRUE;
5828 LinkDown(pAdapter, FALSE);
5830 if (ADHOC_ON(pAdapter))
5832 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5833 // Since calling this indicate user don't want to connect to that SSID anymore.
5834 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5835 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5837 LinkDown(pAdapter, FALSE);
5840 pAdapter->StaCfg.BssType = BSS_INFRA;
5841 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5842 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5844 pAdapter->StaCfg.BssType = BSS_INFRA;
5846 else if (strcmp(arg, "Monitor") == 0)
5849 BCN_TIME_CFG_STRUC csr;
5850 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5851 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5852 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5853 // disable all periodic state machine
5854 pAdapter->StaCfg.bAutoReconnect = FALSE;
5855 // reset all mlme state machine
5856 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5857 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5858 if (pAdapter->CommonCfg.CentralChannel == 0)
5860 #ifdef DOT11_N_SUPPORT
5861 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5862 pAdapter->CommonCfg.CentralChannel = 36;
5864 #endif // DOT11_N_SUPPORT //
5865 pAdapter->CommonCfg.CentralChannel = 6;
5867 #ifdef DOT11_N_SUPPORT
5869 N_ChannelCheck(pAdapter);
5870 #endif // DOT11_N_SUPPORT //
5872 #ifdef DOT11_N_SUPPORT
5873 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5874 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5875 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5877 // 40MHz ,control channel at lower
5878 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5879 bbpValue &= (~0x18);
5881 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5882 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5883 // RX : control channel at lower
5884 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5885 bbpValue &= (~0x20);
5886 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5888 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5889 Value &= 0xfffffffe;
5890 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5891 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5892 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5893 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5894 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5895 pAdapter->CommonCfg.Channel,
5896 pAdapter->CommonCfg.CentralChannel));
5898 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5899 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5900 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5902 // 40MHz ,control channel at upper
5903 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5904 bbpValue &= (~0x18);
5906 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5907 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5908 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5910 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5912 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5914 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5915 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5916 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5917 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5918 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5919 pAdapter->CommonCfg.Channel,
5920 pAdapter->CommonCfg.CentralChannel));
5923 #endif // DOT11_N_SUPPORT //
5926 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5927 bbpValue &= (~0x18);
5928 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5929 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5930 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5931 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5932 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5934 // Enable Rx with promiscuous reception
5935 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5936 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5937 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5939 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5941 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5942 csr.field.bBeaconGen = 0;
5943 csr.field.bTBTTEnable = 0;
5944 csr.field.TsfSyncMode = 0;
5945 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5947 pAdapter->StaCfg.BssType = BSS_MONITOR;
5948 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5949 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5952 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5953 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5955 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5961 ==========================================================================
5963 Set Authentication mode
5965 TRUE if all parameters are OK, FALSE otherwise
5966 ==========================================================================
5968 INT Set_AuthMode_Proc(
5969 IN PRTMP_ADAPTER pAdapter,
5972 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5973 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5974 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5975 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5976 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5977 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5978 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5979 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5980 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5981 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5982 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5983 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5984 #ifdef WPA_SUPPLICANT_SUPPORT
5985 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5986 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5987 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5988 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5989 #endif // WPA_SUPPLICANT_SUPPORT //
5993 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5995 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6001 ==========================================================================
6005 TRUE if all parameters are OK, FALSE otherwise
6006 ==========================================================================
6008 INT Set_EncrypType_Proc(
6009 IN PRTMP_ADAPTER pAdapter,
6012 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6014 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6015 return TRUE; // do nothing
6017 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6018 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6019 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6021 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6023 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6024 return TRUE; // do nothing
6026 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6027 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6028 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6030 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6032 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6033 return TRUE; // do nothing
6035 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6036 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6037 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6039 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6041 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6042 return TRUE; // do nothing
6044 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6045 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6046 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6051 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6053 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6059 ==========================================================================
6063 TRUE if all parameters are OK, FALSE otherwise
6064 ==========================================================================
6066 INT Set_DefaultKeyID_Proc(
6067 IN PRTMP_ADAPTER pAdapter,
6072 KeyIdx = simple_strtol(arg, 0, 10);
6073 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6074 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6076 return FALSE; //Invalid argument
6078 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6084 ==========================================================================
6088 TRUE if all parameters are OK, FALSE otherwise
6089 ==========================================================================
6092 IN PRTMP_ADAPTER pAdapter,
6097 UCHAR CipherAlg=CIPHER_WEP64;
6099 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6100 return TRUE; // do nothing
6102 KeyLen = strlen(arg);
6106 case 5: //wep 40 Ascii type
6107 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6108 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6109 CipherAlg = CIPHER_WEP64;
6110 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6112 case 10: //wep 40 Hex type
6113 for(i=0; i < KeyLen; i++)
6115 if( !isxdigit(*(arg+i)) )
6116 return FALSE; //Not Hex value;
6118 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6119 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6120 CipherAlg = CIPHER_WEP64;
6121 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6123 case 13: //wep 104 Ascii type
6124 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6125 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6126 CipherAlg = CIPHER_WEP128;
6127 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6129 case 26: //wep 104 Hex type
6130 for(i=0; i < KeyLen; i++)
6132 if( !isxdigit(*(arg+i)) )
6133 return FALSE; //Not Hex value;
6135 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6136 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6137 CipherAlg = CIPHER_WEP128;
6138 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6140 default: //Invalid argument
6141 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6145 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6147 // Set keys (into ASIC)
6148 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6150 else // Old WEP stuff
6152 AsicAddSharedKeyEntry(pAdapter,
6155 pAdapter->SharedKey[BSS0][0].CipherAlg,
6156 pAdapter->SharedKey[BSS0][0].Key,
6164 ==========================================================================
6169 TRUE if all parameters are OK, FALSE otherwise
6170 ==========================================================================
6173 IN PRTMP_ADAPTER pAdapter,
6178 UCHAR CipherAlg=CIPHER_WEP64;
6180 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6181 return TRUE; // do nothing
6183 KeyLen = strlen(arg);
6187 case 5: //wep 40 Ascii type
6188 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6189 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6190 CipherAlg = CIPHER_WEP64;
6191 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6193 case 10: //wep 40 Hex type
6194 for(i=0; i < KeyLen; i++)
6196 if( !isxdigit(*(arg+i)) )
6197 return FALSE; //Not Hex value;
6199 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6200 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6201 CipherAlg = CIPHER_WEP64;
6202 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6204 case 13: //wep 104 Ascii type
6205 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6206 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6207 CipherAlg = CIPHER_WEP128;
6208 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6210 case 26: //wep 104 Hex type
6211 for(i=0; i < KeyLen; i++)
6213 if( !isxdigit(*(arg+i)) )
6214 return FALSE; //Not Hex value;
6216 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6217 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6218 CipherAlg = CIPHER_WEP128;
6219 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6221 default: //Invalid argument
6222 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6225 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6227 // Set keys (into ASIC)
6228 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6230 else // Old WEP stuff
6232 AsicAddSharedKeyEntry(pAdapter,
6235 pAdapter->SharedKey[BSS0][1].CipherAlg,
6236 pAdapter->SharedKey[BSS0][1].Key,
6244 ==========================================================================
6248 TRUE if all parameters are OK, FALSE otherwise
6249 ==========================================================================
6252 IN PRTMP_ADAPTER pAdapter,
6257 UCHAR CipherAlg=CIPHER_WEP64;
6259 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6260 return TRUE; // do nothing
6262 KeyLen = strlen(arg);
6266 case 5: //wep 40 Ascii type
6267 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6268 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6269 CipherAlg = CIPHER_WEP64;
6270 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6272 case 10: //wep 40 Hex type
6273 for(i=0; i < KeyLen; i++)
6275 if( !isxdigit(*(arg+i)) )
6276 return FALSE; //Not Hex value;
6278 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6279 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6280 CipherAlg = CIPHER_WEP64;
6281 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6283 case 13: //wep 104 Ascii type
6284 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6285 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6286 CipherAlg = CIPHER_WEP128;
6287 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6289 case 26: //wep 104 Hex type
6290 for(i=0; i < KeyLen; i++)
6292 if( !isxdigit(*(arg+i)) )
6293 return FALSE; //Not Hex value;
6295 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6296 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6297 CipherAlg = CIPHER_WEP128;
6298 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6300 default: //Invalid argument
6301 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6304 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6306 // Set keys (into ASIC)
6307 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6309 else // Old WEP stuff
6311 AsicAddSharedKeyEntry(pAdapter,
6314 pAdapter->SharedKey[BSS0][2].CipherAlg,
6315 pAdapter->SharedKey[BSS0][2].Key,
6323 ==========================================================================
6327 TRUE if all parameters are OK, FALSE otherwise
6328 ==========================================================================
6331 IN PRTMP_ADAPTER pAdapter,
6336 UCHAR CipherAlg=CIPHER_WEP64;
6338 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6339 return TRUE; // do nothing
6341 KeyLen = strlen(arg);
6345 case 5: //wep 40 Ascii type
6346 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6347 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6348 CipherAlg = CIPHER_WEP64;
6349 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6351 case 10: //wep 40 Hex type
6352 for(i=0; i < KeyLen; i++)
6354 if( !isxdigit(*(arg+i)) )
6355 return FALSE; //Not Hex value;
6357 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6358 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6359 CipherAlg = CIPHER_WEP64;
6360 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6362 case 13: //wep 104 Ascii type
6363 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6364 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6365 CipherAlg = CIPHER_WEP128;
6366 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6368 case 26: //wep 104 Hex type
6369 for(i=0; i < KeyLen; i++)
6371 if( !isxdigit(*(arg+i)) )
6372 return FALSE; //Not Hex value;
6374 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6375 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6376 CipherAlg = CIPHER_WEP128;
6377 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6379 default: //Invalid argument
6380 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6383 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6385 // Set keys (into ASIC)
6386 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6388 else // Old WEP stuff
6390 AsicAddSharedKeyEntry(pAdapter,
6393 pAdapter->SharedKey[BSS0][3].CipherAlg,
6394 pAdapter->SharedKey[BSS0][3].Key,
6403 ==========================================================================
6407 TRUE if all parameters are OK, FALSE otherwise
6408 ==========================================================================
6410 INT Set_WPAPSK_Proc(
6411 IN PRTMP_ADAPTER pAdapter,
6414 UCHAR keyMaterial[40];
6416 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6417 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6418 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6420 return TRUE; // do nothing
6422 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6424 NdisZeroMemory(keyMaterial, 40);
6426 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6428 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6432 if (strlen(arg) == 64)
6434 AtoH(arg, keyMaterial, 32);
6435 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6440 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6441 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6446 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6447 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6449 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6453 // Start STA supplicant state machine
6454 pAdapter->StaCfg.WpaState = SS_START;
6461 ==========================================================================
6463 Set Power Saving mode
6465 TRUE if all parameters are OK, FALSE otherwise
6466 ==========================================================================
6468 INT Set_PSMode_Proc(
6469 IN PRTMP_ADAPTER pAdapter,
6472 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6474 if ((strcmp(arg, "Max_PSP") == 0) ||
6475 (strcmp(arg, "max_psp") == 0) ||
6476 (strcmp(arg, "MAX_PSP") == 0))
6478 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6479 // to exclude certain situations.
6480 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6481 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6482 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6483 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6484 pAdapter->StaCfg.DefaultListenCount = 5;
6487 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6488 (strcmp(arg, "fast_psp") == 0) ||
6489 (strcmp(arg, "FAST_PSP") == 0))
6491 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6492 // to exclude certain situations.
6493 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6494 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6495 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6496 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6497 pAdapter->StaCfg.DefaultListenCount = 3;
6499 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6500 (strcmp(arg, "legacy_psp") == 0) ||
6501 (strcmp(arg, "LEGACY_PSP") == 0))
6503 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6504 // to exclude certain situations.
6505 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6506 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6507 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6508 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6509 pAdapter->StaCfg.DefaultListenCount = 3;
6513 //Default Ndis802_11PowerModeCAM
6514 // clear PSM bit immediately
6515 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6516 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6517 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6518 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6519 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6522 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6531 #ifdef WPA_SUPPLICANT_SUPPORT
6533 ==========================================================================
6535 Set WpaSupport flag.
6537 0: Driver ignore wpa_supplicant.
6538 1: wpa_supplicant initiates scanning and AP selection.
6539 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6541 TRUE if all parameters are OK, FALSE otherwise
6542 ==========================================================================
6544 INT Set_Wpa_Support(
6545 IN PRTMP_ADAPTER pAd,
6549 if ( simple_strtol(arg, 0, 10) == 0)
6550 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6551 else if ( simple_strtol(arg, 0, 10) == 1)
6552 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6553 else if ( simple_strtol(arg, 0, 10) == 2)
6554 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6556 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6558 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6562 #endif // WPA_SUPPLICANT_SUPPORT //
6566 ==========================================================================
6570 pAdapter Pointer to our adapter
6571 wrq Pointer to the ioctl argument
6578 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6579 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6580 ==========================================================================
6583 IN PRTMP_ADAPTER pAdapter,
6584 IN struct iwreq *wrq)
6592 UCHAR temp[16], temp2[16];
6593 UINT32 macValue = 0;
6597 memset(msg, 0x00, 1024);
6598 if (wrq->u.data.length > 1) //No parameters.
6600 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6603 //Parsing Read or Write
6608 if ((value = rtstrchr(this_char, '=')) != NULL)
6611 if (!value || !*value)
6614 if(strlen(this_char) > 4)
6617 j = strlen(this_char);
6620 if(this_char[j] > 'f' || this_char[j] < '0')
6625 k = j = strlen(this_char);
6628 this_char[4-k+j] = this_char[j];
6632 this_char[3-k++]='0';
6635 if(strlen(this_char) == 4)
6637 AtoH(this_char, temp, 2);
6638 macAddr = *temp*256 + temp[1];
6639 if (macAddr < 0xFFFF)
6641 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6642 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6643 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6646 {//Invalid parametes, so default printk all bbp
6653 memcpy(&temp2, value, strlen(value));
6654 temp2[strlen(value)] = '\0';
6657 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6660 j = strlen(this_char);
6663 if(this_char[j] > 'f' || this_char[j] < '0')
6670 if(temp2[j] > 'f' || temp2[j] < '0')
6675 k = j = strlen(this_char);
6678 this_char[4-k+j] = this_char[j];
6682 this_char[3-k++]='0';
6686 k = j = strlen(temp2);
6689 temp2[8-k+j] = temp2[j];
6697 AtoH(this_char, temp, 2);
6698 macAddr = *temp*256 + temp[1];
6700 AtoH(temp2, temp, 4);
6701 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6704 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6706 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6707 if (macValue & 0x000000ff)
6709 pAdapter->BbpTuning.bEnable = TRUE;
6710 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6715 pAdapter->BbpTuning.bEnable = FALSE;
6716 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6718 if (ATE_ON(pAdapter))
6720 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6723 #endif // RALINK_ATE //
6724 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6725 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6730 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6732 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6733 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6738 if(strlen(msg) == 1)
6739 sprintf(msg+strlen(msg), "===>Error command format!");
6741 // Copy the information into the user buffer
6742 wrq->u.data.length = strlen(msg);
6743 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6745 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6749 ==========================================================================
6753 pAdapter Pointer to our adapter
6754 wrq Pointer to the ioctl argument
6761 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6762 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6763 ==========================================================================
6765 VOID RTMPIoctlE2PROM(
6766 IN PRTMP_ADAPTER pAdapter,
6767 IN struct iwreq *wrq)
6775 UCHAR temp[16], temp2[16];
6780 memset(msg, 0x00, 1024);
6781 if (wrq->u.data.length > 1) //No parameters.
6783 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6786 //Parsing Read or Write
6793 if ((value = rtstrchr(this_char, '=')) != NULL)
6796 if (!value || !*value)
6800 if(strlen(this_char) > 4)
6803 j = strlen(this_char);
6806 if(this_char[j] > 'f' || this_char[j] < '0')
6811 k = j = strlen(this_char);
6814 this_char[4-k+j] = this_char[j];
6818 this_char[3-k++]='0';
6821 if(strlen(this_char) == 4)
6823 AtoH(this_char, temp, 2);
6824 eepAddr = *temp*256 + temp[1];
6825 if (eepAddr < 0xFFFF)
6827 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6828 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6831 {//Invalid parametes, so default printk all bbp
6838 memcpy(&temp2, value, strlen(value));
6839 temp2[strlen(value)] = '\0';
6842 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6845 j = strlen(this_char);
6848 if(this_char[j] > 'f' || this_char[j] < '0')
6854 if(temp2[j] > 'f' || temp2[j] < '0')
6859 k = j = strlen(this_char);
6862 this_char[4-k+j] = this_char[j];
6866 this_char[3-k++]='0';
6870 k = j = strlen(temp2);
6873 temp2[4-k+j] = temp2[j];
6880 AtoH(this_char, temp, 2);
6881 eepAddr = *temp*256 + temp[1];
6883 AtoH(temp2, temp, 2);
6884 eepValue = *temp*256 + temp[1];
6886 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6887 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6891 if(strlen(msg) == 1)
6892 sprintf(msg+strlen(msg), "===>Error command format!");
6895 // Copy the information into the user buffer
6896 wrq->u.data.length = strlen(msg);
6897 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6899 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6906 INT Set_TGnWifiTest_Proc(
6907 IN PRTMP_ADAPTER pAd,
6910 if (simple_strtol(arg, 0, 10) == 0)
6911 pAd->StaCfg.bTGnWifiTest = FALSE;
6913 pAd->StaCfg.bTGnWifiTest = TRUE;
6915 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6919 INT Set_LongRetryLimit_Proc(
6920 IN PRTMP_ADAPTER pAdapter,
6923 TX_RTY_CFG_STRUC tx_rty_cfg;
6924 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6926 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6927 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6928 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6929 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6933 INT Set_ShortRetryLimit_Proc(
6934 IN PRTMP_ADAPTER pAdapter,
6937 TX_RTY_CFG_STRUC tx_rty_cfg;
6938 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6940 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6941 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6942 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6943 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6947 #ifdef EXT_BUILD_CHANNEL_LIST
6948 INT Set_Ieee80211dClientMode_Proc(
6949 IN PRTMP_ADAPTER pAdapter,
6952 if (simple_strtol(arg, 0, 10) == 0)
6953 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6954 else if (simple_strtol(arg, 0, 10) == 1)
6955 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6956 else if (simple_strtol(arg, 0, 10) == 2)
6957 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6961 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6964 #endif // EXT_BUILD_CHANNEL_LIST //
6966 #ifdef CARRIER_DETECTION_SUPPORT
6967 INT Set_CarrierDetect_Proc(
6968 IN PRTMP_ADAPTER pAd,
6971 if (simple_strtol(arg, 0, 10) == 0)
6972 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6974 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6976 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6979 #endif // CARRIER_DETECTION_SUPPORT //