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 #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
53 #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
54 #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
56 extern UCHAR CipherWpa2Template[];
57 extern UCHAR CipherWpaPskTkip[];
58 extern UCHAR CipherWpaPskTkipLen;
60 typedef struct PACKED _RT_VERSION_INFO{
66 UINT DriverBuildMonth;
68 } RT_VERSION_INFO, *PRT_VERSION_INFO;
70 struct iw_priv_args privtab[] = {
72 IW_PRIV_TYPE_CHAR | 1024, 0,
75 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
77 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
79 /* --- sub-ioctls definitions --- */
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
89 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
91 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
92 #ifdef QOS_DLS_SUPPORT
93 { SHOW_DLS_ENTRY_INFO,
94 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
95 #endif // QOS_DLS_SUPPORT //
97 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
98 /* --- sub-ioctls relations --- */
102 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
105 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
108 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
112 { RTPRIV_IOCTL_STATISTICS,
113 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
115 { RTPRIV_IOCTL_GSITESURVEY,
116 0, IW_PRIV_TYPE_CHAR | 1024,
121 IN PRTMP_ADAPTER pAdapter,
125 INT Set_WmmCapable_Proc(
126 IN PRTMP_ADAPTER pAd,
130 INT Set_NetworkType_Proc(
131 IN PRTMP_ADAPTER pAdapter,
134 INT Set_AuthMode_Proc(
135 IN PRTMP_ADAPTER pAdapter,
138 INT Set_EncrypType_Proc(
139 IN PRTMP_ADAPTER pAdapter,
142 INT Set_DefaultKeyID_Proc(
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,
163 IN PRTMP_ADAPTER pAdapter,
168 IN PRTMP_ADAPTER pAdapter,
171 #ifdef WPA_SUPPLICANT_SUPPORT
173 IN PRTMP_ADAPTER pAd,
175 #endif // WPA_SUPPLICANT_SUPPORT //
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
186 VOID RTMPIoctlE2PROM(
187 IN PRTMP_ADAPTER pAdapter,
188 IN struct iwreq *wrq);
192 NDIS_STATUS RTMPWPANoneAddKeyProc(
193 IN PRTMP_ADAPTER pAd,
196 INT Set_FragTest_Proc(
197 IN PRTMP_ADAPTER pAdapter,
200 #ifdef DOT11_N_SUPPORT
201 INT Set_TGnWifiTest_Proc(
202 IN PRTMP_ADAPTER pAd,
204 #endif // DOT11_N_SUPPORT //
206 INT Set_LongRetryLimit_Proc(
207 IN PRTMP_ADAPTER pAdapter,
210 INT Set_ShortRetryLimit_Proc(
211 IN PRTMP_ADAPTER pAdapter,
214 #ifdef EXT_BUILD_CHANNEL_LIST
215 INT Set_Ieee80211dClientMode_Proc(
216 IN PRTMP_ADAPTER pAdapter,
218 #endif // EXT_BUILD_CHANNEL_LIST //
220 #ifdef CARRIER_DETECTION_SUPPORT
221 INT Set_CarrierDetect_Proc(
222 IN PRTMP_ADAPTER pAd,
224 #endif // CARRIER_DETECTION_SUPPORT //
228 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
229 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
230 {"DriverVersion", Set_DriverVersion_Proc},
231 {"CountryRegion", Set_CountryRegion_Proc},
232 {"CountryRegionABand", Set_CountryRegionABand_Proc},
233 {"SSID", Set_SSID_Proc},
234 {"WirelessMode", Set_WirelessMode_Proc},
235 {"TxBurst", Set_TxBurst_Proc},
236 {"TxPreamble", Set_TxPreamble_Proc},
237 {"TxPower", Set_TxPower_Proc},
238 {"Channel", Set_Channel_Proc},
239 {"BGProtection", Set_BGProtection_Proc},
240 {"RTSThreshold", Set_RTSThreshold_Proc},
241 {"FragThreshold", Set_FragThreshold_Proc},
242 #ifdef DOT11_N_SUPPORT
243 {"HtBw", Set_HtBw_Proc},
244 {"HtMcs", Set_HtMcs_Proc},
245 {"HtGi", Set_HtGi_Proc},
246 {"HtOpMode", Set_HtOpMode_Proc},
247 {"HtExtcha", Set_HtExtcha_Proc},
248 {"HtMpduDensity", Set_HtMpduDensity_Proc},
249 {"HtBaWinSize", Set_HtBaWinSize_Proc},
250 {"HtRdg", Set_HtRdg_Proc},
251 {"HtAmsdu", Set_HtAmsdu_Proc},
252 {"HtAutoBa", Set_HtAutoBa_Proc},
253 {"HtBaDecline", Set_BADecline_Proc},
254 {"HtProtect", Set_HtProtect_Proc},
255 {"HtMimoPs", Set_HtMimoPs_Proc},
256 #endif // DOT11_N_SUPPORT //
258 #ifdef AGGREGATION_SUPPORT
259 {"PktAggregate", Set_PktAggregate_Proc},
263 {"WmmCapable", Set_WmmCapable_Proc},
265 {"IEEE80211H", Set_IEEE80211H_Proc},
266 {"NetworkType", Set_NetworkType_Proc},
267 {"AuthMode", Set_AuthMode_Proc},
268 {"EncrypType", Set_EncrypType_Proc},
269 {"DefaultKeyID", Set_DefaultKeyID_Proc},
270 {"Key1", Set_Key1_Proc},
271 {"Key2", Set_Key2_Proc},
272 {"Key3", Set_Key3_Proc},
273 {"Key4", Set_Key4_Proc},
274 {"WPAPSK", Set_WPAPSK_Proc},
275 {"ResetCounter", Set_ResetStatCounter_Proc},
276 {"PSMode", Set_PSMode_Proc},
278 {"Debug", Set_Debug_Proc},
282 {"ATE", Set_ATE_Proc},
283 {"ATEDA", Set_ATE_DA_Proc},
284 {"ATESA", Set_ATE_SA_Proc},
285 {"ATEBSSID", Set_ATE_BSSID_Proc},
286 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
287 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
288 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
289 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
290 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
291 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
292 {"ATETXBW", Set_ATE_TX_BW_Proc},
293 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
294 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
295 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
296 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
297 {"ATETXGI", Set_ATE_TX_GI_Proc},
298 {"ATERXFER", Set_ATE_RX_FER_Proc},
299 {"ATERRF", Set_ATE_Read_RF_Proc},
300 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
301 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
302 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
303 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
304 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
305 {"ATERE2P", Set_ATE_Read_E2P_Proc},
306 {"ATESHOW", Set_ATE_Show_Proc},
307 {"ATEHELP", Set_ATE_Help_Proc},
309 #ifdef RALINK_28xx_QA
310 {"TxStop", Set_TxStop_Proc},
311 {"RxStop", Set_RxStop_Proc},
312 #endif // RALINK_28xx_QA //
313 #endif // RALINK_ATE //
315 #ifdef WPA_SUPPLICANT_SUPPORT
316 {"WpaSupport", Set_Wpa_Support},
317 #endif // WPA_SUPPLICANT_SUPPORT //
321 {"FixedTxMode", Set_FixedTxMode_Proc},
322 #ifdef CONFIG_APSTA_MIXED_SUPPORT
323 {"OpMode", Set_OpMode_Proc},
324 #endif // CONFIG_APSTA_MIXED_SUPPORT //
325 #ifdef DOT11_N_SUPPORT
326 {"TGnWifiTest", Set_TGnWifiTest_Proc},
327 {"ForceGF", Set_ForceGF_Proc},
328 #endif // DOT11_N_SUPPORT //
329 #ifdef QOS_DLS_SUPPORT
330 {"DlsAddEntry", Set_DlsAddEntry_Proc},
331 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
332 #endif // QOS_DLS_SUPPORT //
333 {"LongRetry", Set_LongRetryLimit_Proc},
334 {"ShortRetry", Set_ShortRetryLimit_Proc},
335 #ifdef EXT_BUILD_CHANNEL_LIST
336 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
337 #endif // EXT_BUILD_CHANNEL_LIST //
338 #ifdef CARRIER_DETECTION_SUPPORT
339 {"CarrierDetect", Set_CarrierDetect_Proc},
340 #endif // CARRIER_DETECTION_SUPPORT //
347 IN PRTMP_ADAPTER pAd,
348 IN PNDIS_802_11_KEY pKey)
351 MAC_TABLE_ENTRY *pEntry;
353 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
355 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
357 if (pKey->KeyIndex & 0x80000000)
359 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
361 NdisZeroMemory(pAd->StaCfg.PMK, 32);
362 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
366 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
367 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
368 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
369 #ifdef WPA_SUPPLICANT_SUPPORT
370 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
372 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
373 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
376 #endif // WPA_SUPPLICANT_SUPPORT //
378 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
379 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
382 // Decide its ChiperAlg
383 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
384 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
385 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
386 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
388 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
390 // Update these related information to MAC_TABLE_ENTRY
391 pEntry = &pAd->MacTab.Content[BSSID_WCID];
392 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
393 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
394 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
395 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
397 // Update pairwise key information to ASIC Shared Key Table
398 AsicAddSharedKeyEntry(pAd,
401 pAd->SharedKey[BSS0][0].CipherAlg,
402 pAd->SharedKey[BSS0][0].Key,
403 pAd->SharedKey[BSS0][0].TxMic,
404 pAd->SharedKey[BSS0][0].RxMic);
406 // Update ASIC WCID attribute table and IVEIV table
407 RTMPAddWcidAttributeEntry(pAd,
410 pAd->SharedKey[BSS0][0].CipherAlg,
413 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
415 // set 802.1x port control
416 STA_PORT_SECURED(pAd);
418 // Indicate Connected for GUI
419 pAd->IndicateMediaState = NdisMediaStateConnected;
425 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
426 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
427 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
428 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
429 #ifdef WPA_SUPPLICANT_SUPPORT
430 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
432 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
433 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
436 #endif // WPA_SUPPLICANT_SUPPORT //
438 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
439 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
442 // Update Shared Key CipherAlg
443 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
444 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
445 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
446 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
447 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
449 // Update group key information to ASIC Shared Key Table
450 AsicAddSharedKeyEntry(pAd,
452 pAd->StaCfg.DefaultKeyId,
453 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
454 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
455 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
456 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
458 // Update ASIC WCID attribute table and IVEIV table
459 RTMPAddWcidAttributeEntry(pAd,
461 pAd->StaCfg.DefaultKeyId,
462 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
465 // set 802.1x port control
466 STA_PORT_SECURED(pAd);
468 // Indicate Connected for GUI
469 pAd->IndicateMediaState = NdisMediaStateConnected;
472 else // dynamic WEP from wpa_supplicant
477 if(pKey->KeyLength == 32)
480 KeyIdx = pKey->KeyIndex & 0x0fffffff;
484 // it is a default shared key, for Pairwise key setting
485 if (pKey->KeyIndex & 0x80000000)
487 pEntry = MacTableLookup(pAd, pKey->BSSID);
491 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
493 // set key material and key length
494 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
495 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
498 if (pKey->KeyLength == 5)
499 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
501 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
503 // Add Pair-wise key to Asic
504 AsicAddPairwiseKeyEntry(
508 &pEntry->PairwiseKey);
510 // update WCID attribute table and IVEIV table for this entry
511 RTMPAddWcidAttributeEntry(
514 KeyIdx, // The value may be not zero
515 pEntry->PairwiseKey.CipherAlg,
522 // Default key for tx (shared key)
523 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
525 // set key material and key length
526 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
527 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
530 if (pKey->KeyLength == 5)
531 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
533 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
535 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
536 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
538 // Set Group key material to Asic
539 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
541 // Update WCID attribute table and IVEIV table for this group key table
542 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
551 char * rtstrchr(const char * s, int c)
553 for(; *s != (char) c; ++s)
560 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
564 rt_ioctl_giwname(struct net_device *dev,
565 struct iw_request_info *info,
566 char *name, char *extra)
568 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
571 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
576 int rt_ioctl_siwfreq(struct net_device *dev,
577 struct iw_request_info *info,
578 struct iw_freq *freq, char *extra)
580 PRTMP_ADAPTER pAdapter = dev->ml_priv;
583 //check if the interface is down
584 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
586 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
594 if((freq->e == 0) && (freq->m <= 1000))
595 chan = freq->m; // Setting by channel number
597 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
599 if (ChannelSanity(pAdapter, chan) == TRUE)
601 pAdapter->CommonCfg.Channel = chan;
602 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
609 int rt_ioctl_giwfreq(struct net_device *dev,
610 struct iw_request_info *info,
611 struct iw_freq *freq, char *extra)
613 VIRTUAL_ADAPTER *pVirtualAd = NULL;
614 PRTMP_ADAPTER pAdapter = NULL;
618 if (dev->priv_flags == INT_MAIN)
620 pAdapter = dev->ml_priv;
624 pVirtualAd = dev->ml_priv;
625 if (pVirtualAd && pVirtualAd->RtmpDev)
626 pAdapter = pVirtualAd->RtmpDev->ml_priv;
629 if (pAdapter == NULL)
631 /* if 1st open fail, pAd will be free;
632 So the net_dev->ml_priv will be NULL in 2rd open */
636 ch = pAdapter->CommonCfg.Channel;
638 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
640 MAP_CHANNEL_ID_TO_KHZ(ch, m);
646 int rt_ioctl_siwmode(struct net_device *dev,
647 struct iw_request_info *info,
648 __u32 *mode, char *extra)
650 PRTMP_ADAPTER pAdapter = dev->ml_priv;
652 //check if the interface is down
653 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
655 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
662 Set_NetworkType_Proc(pAdapter, "Adhoc");
665 Set_NetworkType_Proc(pAdapter, "Infra");
667 case IW_MODE_MONITOR:
668 Set_NetworkType_Proc(pAdapter, "Monitor");
671 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
675 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
676 pAdapter->StaCfg.WpaState = SS_NOTUSE;
681 int rt_ioctl_giwmode(struct net_device *dev,
682 struct iw_request_info *info,
683 __u32 *mode, char *extra)
685 PRTMP_ADAPTER pAdapter = NULL;
686 VIRTUAL_ADAPTER *pVirtualAd = NULL;
688 if (dev->priv_flags == INT_MAIN)
690 pAdapter = dev->ml_priv;
694 pVirtualAd = dev->ml_priv;
695 if (pVirtualAd && pVirtualAd->RtmpDev)
696 pAdapter = pVirtualAd->RtmpDev->ml_priv;
699 if (pAdapter == NULL)
701 /* if 1st open fail, pAd will be free;
702 So the net_dev->ml_priv will be NULL in 2rd open */
706 if (ADHOC_ON(pAdapter))
707 *mode = IW_MODE_ADHOC;
708 else if (INFRA_ON(pAdapter))
709 *mode = IW_MODE_INFRA;
710 else if (MONITOR_ON(pAdapter))
712 *mode = IW_MODE_MONITOR;
715 *mode = IW_MODE_AUTO;
717 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
721 int rt_ioctl_siwsens(struct net_device *dev,
722 struct iw_request_info *info,
723 char *name, char *extra)
725 PRTMP_ADAPTER pAdapter = dev->ml_priv;
727 //check if the interface is down
728 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
730 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
737 int rt_ioctl_giwsens(struct net_device *dev,
738 struct iw_request_info *info,
739 char *name, char *extra)
744 int rt_ioctl_giwrange(struct net_device *dev,
745 struct iw_request_info *info,
746 struct iw_point *data, char *extra)
748 PRTMP_ADAPTER pAdapter = NULL;
749 VIRTUAL_ADAPTER *pVirtualAd = NULL;
750 struct iw_range *range = (struct iw_range *) extra;
754 if (dev->priv_flags == INT_MAIN)
756 pAdapter = dev->ml_priv;
760 pVirtualAd = dev->ml_priv;
761 if (pVirtualAd && pVirtualAd->RtmpDev)
762 pAdapter = pVirtualAd->RtmpDev->ml_priv;
765 if (pAdapter == NULL)
767 /* if 1st open fail, pAd will be free;
768 So the net_dev->ml_priv will be NULL in 2rd open */
772 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
773 data->length = sizeof(struct iw_range);
774 memset(range, 0, sizeof(struct iw_range));
776 range->txpower_capa = IW_TXPOW_DBM;
778 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
780 range->min_pmp = 1 * 1024;
781 range->max_pmp = 65535 * 1024;
782 range->min_pmt = 1 * 1024;
783 range->max_pmt = 1000 * 1024;
784 range->pmp_flags = IW_POWER_PERIOD;
785 range->pmt_flags = IW_POWER_TIMEOUT;
786 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
787 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
790 range->we_version_compiled = WIRELESS_EXT;
791 range->we_version_source = 14;
793 range->retry_capa = IW_RETRY_LIMIT;
794 range->retry_flags = IW_RETRY_LIMIT;
795 range->min_retry = 0;
796 range->max_retry = 255;
798 range->num_channels = pAdapter->ChannelListNum;
801 for (i = 1; i <= range->num_channels; i++)
804 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
805 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
806 range->freq[val].m = m * 100; /* HZ */
808 range->freq[val].e = 1;
810 if (val == IW_MAX_FREQUENCIES)
813 range->num_frequency = val;
815 range->max_qual.qual = 100; /* what is correct max? This was not
816 * documented exactly. At least
817 * 69 has been observed. */
818 range->max_qual.level = 0; /* dB */
819 range->max_qual.noise = 0; /* dB */
821 /* What would be suitable values for "average/typical" qual? */
822 range->avg_qual.qual = 20;
823 range->avg_qual.level = -60;
824 range->avg_qual.noise = -95;
825 range->sensitivity = 3;
827 range->max_encoding_tokens = NR_WEP_KEYS;
828 range->num_encoding_sizes = 2;
829 range->encoding_size[0] = 5;
830 range->encoding_size[1] = 13;
833 range->max_rts = 2347;
834 range->min_frag = 256;
835 range->max_frag = 2346;
837 #if WIRELESS_EXT > 17
838 /* IW_ENC_CAPA_* bit field */
839 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
840 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
846 int rt_ioctl_siwap(struct net_device *dev,
847 struct iw_request_info *info,
848 struct sockaddr *ap_addr, char *extra)
850 PRTMP_ADAPTER pAdapter = dev->ml_priv;
851 NDIS_802_11_MAC_ADDRESS Bssid;
853 //check if the interface is down
854 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
856 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
860 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
862 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
863 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
866 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
867 // this request, because this request is initiated by NDIS.
868 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
869 // Prevent to connect AP again in STAMlmePeriodicExec
870 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
872 memset(Bssid, 0, MAC_ADDR_LEN);
873 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
874 MlmeEnqueue(pAdapter,
875 MLME_CNTL_STATE_MACHINE,
877 sizeof(NDIS_802_11_MAC_ADDRESS),
880 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
881 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
886 int rt_ioctl_giwap(struct net_device *dev,
887 struct iw_request_info *info,
888 struct sockaddr *ap_addr, char *extra)
890 PRTMP_ADAPTER pAdapter = NULL;
891 VIRTUAL_ADAPTER *pVirtualAd = NULL;
893 if (dev->priv_flags == INT_MAIN)
895 pAdapter = dev->ml_priv;
899 pVirtualAd = dev->ml_priv;
900 if (pVirtualAd && pVirtualAd->RtmpDev)
901 pAdapter = pVirtualAd->RtmpDev->ml_priv;
904 if (pAdapter == NULL)
906 /* if 1st open fail, pAd will be free;
907 So the net_dev->ml_priv will be NULL in 2rd open */
911 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
913 ap_addr->sa_family = ARPHRD_ETHER;
914 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
916 #ifdef WPA_SUPPLICANT_SUPPORT
918 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
920 ap_addr->sa_family = ARPHRD_ETHER;
921 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
923 #endif // WPA_SUPPLICANT_SUPPORT //
926 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
934 * Units are in db above the noise floor. That means the
935 * rssi values reported in the tx/rx descriptors in the
936 * driver are the SNR expressed in db.
938 * If you assume that the noise floor is -95, which is an
939 * excellent assumption 99.5 % of the time, then you can
940 * derive the absolute signal level (i.e. -95 + rssi).
941 * There are some other slight factors to take into account
942 * depending on whether the rssi measurement is from 11b,
943 * 11g, or 11a. These differences are at most 2db and
946 * NB: various calculations are based on the orinoco/wavelan
947 * drivers for compatibility
949 static void set_quality(PRTMP_ADAPTER pAdapter,
950 struct iw_quality *iq,
957 ChannelQuality = 100;
958 else if (rssi >= -80) // between -50 ~ -80dbm
959 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
960 else if (rssi >= -90) // between -80 ~ -90dbm
961 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
965 iq->qual = (__u8)ChannelQuality;
967 iq->level = (__u8)(rssi);
968 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
969 iq->noise += 256 - 143;
970 iq->updated = pAdapter->iw_stats.qual.updated;
973 int rt_ioctl_iwaplist(struct net_device *dev,
974 struct iw_request_info *info,
975 struct iw_point *data, char *extra)
977 PRTMP_ADAPTER pAdapter = dev->ml_priv;
979 struct sockaddr addr[IW_MAX_AP];
980 struct iw_quality qual[IW_MAX_AP];
983 //check if the interface is down
984 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
986 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
992 for (i = 0; i <IW_MAX_AP ; i++)
994 if (i >= pAdapter->ScanTab.BssNr)
996 addr[i].sa_family = ARPHRD_ETHER;
997 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
998 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1001 memcpy(extra, &addr, i*sizeof(addr[0]));
1002 data->flags = 1; /* signal quality present (sort of) */
1003 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1009 int rt_ioctl_siwscan(struct net_device *dev,
1010 struct iw_request_info *info,
1011 struct iw_point *data, char *extra)
1013 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1016 int Status = NDIS_STATUS_SUCCESS;
1018 //check if the interface is down
1019 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1021 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1025 if (MONITOR_ON(pAdapter))
1027 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1032 #ifdef WPA_SUPPLICANT_SUPPORT
1033 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1035 pAdapter->StaCfg.WpaSupplicantScanCount++;
1037 #endif // WPA_SUPPLICANT_SUPPORT //
1039 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1040 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1045 #ifdef WPA_SUPPLICANT_SUPPORT
1046 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1047 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1049 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1050 Status = NDIS_STATUS_SUCCESS;
1053 #endif // WPA_SUPPLICANT_SUPPORT //
1055 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1056 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1057 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1058 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1060 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1061 Status = NDIS_STATUS_SUCCESS;
1065 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1067 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1068 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1071 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1072 // this request, because this request is initiated by NDIS.
1073 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1074 // Reset allowed scan retries
1075 pAdapter->StaCfg.ScanCnt = 0;
1076 pAdapter->StaCfg.LastScanTime = Now;
1078 MlmeEnqueue(pAdapter,
1079 MLME_CNTL_STATE_MACHINE,
1080 OID_802_11_BSSID_LIST_SCAN,
1084 Status = NDIS_STATUS_SUCCESS;
1085 RT28XX_MLME_HANDLER(pAdapter);
1090 int rt_ioctl_giwscan(struct net_device *dev,
1091 struct iw_request_info *info,
1092 struct iw_point *data, char *extra)
1095 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1097 char *current_ev = extra, *previous_ev = extra;
1099 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1102 #endif // IWEVGENIE //
1103 struct iw_event iwe;
1105 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1108 * Still scanning, indicate the caller should try again.
1114 #ifdef WPA_SUPPLICANT_SUPPORT
1115 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1117 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1119 #endif // WPA_SUPPLICANT_SUPPORT //
1121 if (pAdapter->ScanTab.BssNr == 0)
1127 #if WIRELESS_EXT >= 17
1128 if (data->length > 0)
1129 end_buf = extra + data->length;
1131 end_buf = extra + IW_SCAN_MAX_DATA;
1133 end_buf = extra + IW_SCAN_MAX_DATA;
1136 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1138 if (current_ev >= end_buf)
1140 #if WIRELESS_EXT >= 17
1148 //================================
1149 memset(&iwe, 0, sizeof(iwe));
1150 iwe.cmd = SIOCGIWAP;
1151 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1152 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1154 previous_ev = current_ev;
1155 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1156 if (current_ev == previous_ev)
1157 #if WIRELESS_EXT >= 17
1164 //================================
1165 memset(&iwe, 0, sizeof(iwe));
1166 iwe.cmd = SIOCGIWESSID;
1167 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1168 iwe.u.data.flags = 1;
1170 previous_ev = current_ev;
1171 current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1172 if (current_ev == previous_ev)
1173 #if WIRELESS_EXT >= 17
1180 //================================
1181 memset(&iwe, 0, sizeof(iwe));
1182 iwe.cmd = SIOCGIWMODE;
1183 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1185 iwe.u.mode = IW_MODE_ADHOC;
1187 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1189 iwe.u.mode = IW_MODE_INFRA;
1193 iwe.u.mode = IW_MODE_AUTO;
1195 iwe.len = IW_EV_UINT_LEN;
1197 previous_ev = current_ev;
1198 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1199 if (current_ev == previous_ev)
1200 #if WIRELESS_EXT >= 17
1206 //Channel and Frequency
1207 //================================
1208 memset(&iwe, 0, sizeof(iwe));
1209 iwe.cmd = SIOCGIWFREQ;
1210 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1211 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1213 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1217 previous_ev = current_ev;
1218 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
1219 if (current_ev == previous_ev)
1220 #if WIRELESS_EXT >= 17
1226 //Add quality statistics
1227 //================================
1228 memset(&iwe, 0, sizeof(iwe));
1230 iwe.u.qual.level = 0;
1231 iwe.u.qual.noise = 0;
1232 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1233 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1234 if (current_ev == previous_ev)
1235 #if WIRELESS_EXT >= 17
1242 //================================
1243 memset(&iwe, 0, sizeof(iwe));
1244 iwe.cmd = SIOCGIWENCODE;
1245 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1246 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1248 iwe.u.data.flags = IW_ENCODE_DISABLED;
1250 previous_ev = current_ev;
1251 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);
1252 if (current_ev == previous_ev)
1253 #if WIRELESS_EXT >= 17
1260 //================================
1261 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1263 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1264 memset(&iwe, 0, sizeof(iwe));
1265 iwe.cmd = SIOCGIWRATE;
1266 current_val = current_ev + IW_EV_LCP_LEN;
1267 if (tmpRate == 0x82)
1268 iwe.u.bitrate.value = 1 * 1000000;
1269 else if (tmpRate == 0x84)
1270 iwe.u.bitrate.value = 2 * 1000000;
1271 else if (tmpRate == 0x8B)
1272 iwe.u.bitrate.value = 5.5 * 1000000;
1273 else if (tmpRate == 0x96)
1274 iwe.u.bitrate.value = 11 * 1000000;
1276 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1278 iwe.u.bitrate.disabled = 0;
1279 current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
1280 current_val, end_buf, &iwe,
1283 if((current_val-current_ev)>IW_EV_LCP_LEN)
1284 current_ev = current_val;
1286 #if WIRELESS_EXT >= 17
1295 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1297 memset(&iwe, 0, sizeof(iwe));
1298 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1299 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1300 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1301 iwe.cmd = IWEVGENIE;
1302 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1303 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1304 if (current_ev == previous_ev)
1305 #if WIRELESS_EXT >= 17
1313 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1315 memset(&iwe, 0, sizeof(iwe));
1316 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1317 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1318 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1319 iwe.cmd = IWEVGENIE;
1320 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1321 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1322 if (current_ev == previous_ev)
1323 #if WIRELESS_EXT >= 17
1331 //================================
1332 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1334 NdisZeroMemory(&iwe, sizeof(iwe));
1335 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1336 iwe.cmd = IWEVCUSTOM;
1337 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1338 NdisMoveMemory(custom, "wpa_ie=", 7);
1339 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1340 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1341 previous_ev = current_ev;
1342 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1343 if (current_ev == previous_ev)
1344 #if WIRELESS_EXT >= 17
1352 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1354 NdisZeroMemory(&iwe, sizeof(iwe));
1355 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1356 iwe.cmd = IWEVCUSTOM;
1357 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1358 NdisMoveMemory(custom, "rsn_ie=", 7);
1359 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1360 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1361 previous_ev = current_ev;
1362 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1363 if (current_ev == previous_ev)
1364 #if WIRELESS_EXT >= 17
1370 #endif // IWEVGENIE //
1373 data->length = current_ev - extra;
1374 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1375 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1380 int rt_ioctl_siwessid(struct net_device *dev,
1381 struct iw_request_info *info,
1382 struct iw_point *data, char *essid)
1384 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1386 //check if the interface is down
1387 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1389 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1395 PCHAR pSsidString = NULL;
1397 // Includes null character.
1398 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1401 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1404 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1405 NdisMoveMemory(pSsidString, essid, data->length);
1406 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1415 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1421 int rt_ioctl_giwessid(struct net_device *dev,
1422 struct iw_request_info *info,
1423 struct iw_point *data, char *essid)
1425 PRTMP_ADAPTER pAdapter = NULL;
1426 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1428 if (dev->priv_flags == INT_MAIN)
1430 pAdapter = dev->ml_priv;
1434 pVirtualAd = dev->ml_priv;
1435 if (pVirtualAd && pVirtualAd->RtmpDev)
1436 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1439 if (pAdapter == NULL)
1441 /* if 1st open fail, pAd will be free;
1442 So the net_dev->ml_priv will be NULL in 2rd open */
1447 if (MONITOR_ON(pAdapter))
1453 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1455 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1456 data->length = pAdapter->CommonCfg.SsidLen;
1457 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1460 {//the ANY ssid was specified
1462 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1469 int rt_ioctl_siwnickn(struct net_device *dev,
1470 struct iw_request_info *info,
1471 struct iw_point *data, char *nickname)
1473 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1475 //check if the interface is down
1476 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1478 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1482 if (data->length > IW_ESSID_MAX_SIZE)
1485 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1486 memcpy(pAdapter->nickname, nickname, data->length);
1492 int rt_ioctl_giwnickn(struct net_device *dev,
1493 struct iw_request_info *info,
1494 struct iw_point *data, char *nickname)
1496 PRTMP_ADAPTER pAdapter = NULL;
1497 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1499 if (dev->priv_flags == INT_MAIN)
1501 pAdapter = dev->ml_priv;
1505 pVirtualAd = dev->ml_priv;
1506 if (pVirtualAd && pVirtualAd->RtmpDev)
1507 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1510 if (pAdapter == NULL)
1512 /* if 1st open fail, pAd will be free;
1513 So the net_dev->ml_priv will be NULL in 2rd open */
1517 if (data->length > strlen(pAdapter->nickname) + 1)
1518 data->length = strlen(pAdapter->nickname) + 1;
1519 if (data->length > 0) {
1520 memcpy(nickname, pAdapter->nickname, data->length-1);
1521 nickname[data->length-1] = '\0';
1526 int rt_ioctl_siwrts(struct net_device *dev,
1527 struct iw_request_info *info,
1528 struct iw_param *rts, char *extra)
1530 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1533 //check if the interface is down
1534 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1536 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1541 val = MAX_RTS_THRESHOLD;
1542 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1544 else if (rts->value == 0)
1545 val = MAX_RTS_THRESHOLD;
1549 if (val != pAdapter->CommonCfg.RtsThreshold)
1550 pAdapter->CommonCfg.RtsThreshold = val;
1555 int rt_ioctl_giwrts(struct net_device *dev,
1556 struct iw_request_info *info,
1557 struct iw_param *rts, char *extra)
1559 PRTMP_ADAPTER pAdapter = NULL;
1560 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1562 if (dev->priv_flags == INT_MAIN)
1564 pAdapter = dev->ml_priv;
1568 pVirtualAd = dev->ml_priv;
1569 if (pVirtualAd && pVirtualAd->RtmpDev)
1570 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1573 if (pAdapter == NULL)
1575 /* if 1st open fail, pAd will be free;
1576 So the net_dev->ml_priv will be NULL in 2rd open */
1580 //check if the interface is down
1581 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1583 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1587 rts->value = pAdapter->CommonCfg.RtsThreshold;
1588 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1594 int rt_ioctl_siwfrag(struct net_device *dev,
1595 struct iw_request_info *info,
1596 struct iw_param *frag, char *extra)
1598 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1601 //check if the interface is down
1602 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1604 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1609 val = MAX_FRAG_THRESHOLD;
1610 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1611 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1612 else if (frag->value == 0)
1613 val = MAX_FRAG_THRESHOLD;
1617 pAdapter->CommonCfg.FragmentThreshold = val;
1621 int rt_ioctl_giwfrag(struct net_device *dev,
1622 struct iw_request_info *info,
1623 struct iw_param *frag, char *extra)
1625 PRTMP_ADAPTER pAdapter = NULL;
1626 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1628 if (dev->priv_flags == INT_MAIN)
1630 pAdapter = dev->ml_priv;
1634 pVirtualAd = dev->ml_priv;
1635 if (pVirtualAd && pVirtualAd->RtmpDev)
1636 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1639 if (pAdapter == NULL)
1641 /* if 1st open fail, pAd will be free;
1642 So the net_dev->ml_priv will be NULL in 2rd open */
1646 //check if the interface is down
1647 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1649 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1653 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1654 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1660 #define MAX_WEP_KEY_SIZE 13
1661 #define MIN_WEP_KEY_SIZE 5
1662 int rt_ioctl_siwencode(struct net_device *dev,
1663 struct iw_request_info *info,
1664 struct iw_point *erq, char *extra)
1666 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1668 //check if the interface is down
1669 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1671 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1675 if ((erq->length == 0) &&
1676 (erq->flags & IW_ENCODE_DISABLED))
1678 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1679 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1680 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1681 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1682 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1685 else if ((erq->length == 0) &&
1686 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1688 STA_PORT_SECURED(pAdapter);
1689 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1690 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1691 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1692 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1693 if (erq->flags & IW_ENCODE_RESTRICTED)
1694 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1696 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1700 if (erq->length > 0)
1702 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1703 /* Check the size of the key */
1704 if (erq->length > MAX_WEP_KEY_SIZE) {
1707 /* Check key index */
1708 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1710 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1711 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1714 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1717 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1719 if (erq->length == MAX_WEP_KEY_SIZE)
1721 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1722 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1724 else if (erq->length == MIN_WEP_KEY_SIZE)
1726 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1727 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1730 /* Disable the key */
1731 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1733 /* Check if the key is not marked as invalid */
1734 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1735 /* Copy the key in the driver */
1736 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1741 /* Do we want to just set the transmit key index ? */
1742 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1743 if ((index >= 0) && (index < 4))
1745 pAdapter->StaCfg.DefaultKeyId = index;
1748 /* Don't complain if only change the mode */
1749 if (!(erq->flags & IW_ENCODE_MODE)) {
1755 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1756 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1757 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1758 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1763 rt_ioctl_giwencode(struct net_device *dev,
1764 struct iw_request_info *info,
1765 struct iw_point *erq, char *key)
1768 PRTMP_ADAPTER pAdapter = NULL;
1769 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1771 if (dev->priv_flags == INT_MAIN)
1773 pAdapter = dev->ml_priv;
1777 pVirtualAd = dev->ml_priv;
1778 if (pVirtualAd && pVirtualAd->RtmpDev)
1779 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1782 if (pAdapter == NULL)
1784 /* if 1st open fail, pAd will be free;
1785 So the net_dev->ml_priv will be NULL in 2rd open */
1789 //check if the interface is down
1790 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1792 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1796 kid = erq->flags & IW_ENCODE_INDEX;
1797 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1799 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1802 erq->flags = IW_ENCODE_DISABLED;
1804 else if ((kid > 0) && (kid <=4))
1807 erq->flags = kid ; /* NB: base 1 */
1808 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1809 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1810 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1811 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1812 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1813 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1814 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1816 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1821 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1822 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1824 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1825 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1826 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1827 // copy default key ID
1828 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1829 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1831 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1832 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1833 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1841 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1842 void *w, char *extra)
1844 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1845 PRTMP_ADAPTER pAdapter;
1847 char *this_char = extra;
1851 if (dev->priv_flags == INT_MAIN)
1853 pAdapter = dev->ml_priv;
1857 pVirtualAd = dev->ml_priv;
1858 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1860 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1862 if (pAdapter == NULL)
1864 /* if 1st open fail, pAd will be free;
1865 So the net_dev->ml_priv will be NULL in 2rd open */
1870 pObj->ioctl_if_type = INT_MAIN;
1871 pObj->ioctl_if = MAIN_MBSSID;
1874 //check if the interface is down
1875 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1877 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1884 if ((value = rtstrchr(this_char, '=')) != NULL)
1890 // reject setting nothing besides ANY ssid(ssidLen=0)
1891 if (!*value && (strcmp(this_char, "SSID") != 0))
1894 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1896 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1898 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1899 { //FALSE:Set private failed then return Invalid argument
1902 break; //Exit for loop.
1906 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1907 { //Not found argument
1909 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1917 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1918 struct iw_point *wrq, char *extra)
1921 PRTMP_ADAPTER pAd = dev->ml_priv;
1929 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1930 sprintf(extra, "\n\n");
1935 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1936 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1939 #endif // RALINK_ATE //
1941 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1942 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1944 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1945 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1946 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1947 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1949 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1950 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1951 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1952 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1954 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1958 if (pAd->ate.RxAntennaSel == 0)
1960 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1961 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1962 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1966 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1970 #endif // RALINK_ATE //
1972 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1973 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1974 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1976 #ifdef WPA_SUPPLICANT_SUPPORT
1977 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1978 #endif // WPA_SUPPLICANT_SUPPORT //
1981 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1982 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1987 #ifdef DOT11_N_SUPPORT
1989 IN PRTMP_ADAPTER pAd,
1993 BA_ORI_ENTRY *pOriBAEntry;
1994 BA_REC_ENTRY *pRecBAEntry;
1996 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1998 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1999 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2000 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2002 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2004 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2005 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2007 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2008 for (j=0; j < NUM_OF_TID; j++)
2010 if (pEntry->BARecWcidArray[j] != 0)
2012 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2013 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2016 sprintf(pOutBuf, "%s\n", pOutBuf);
2018 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2019 for (j=0; j < NUM_OF_TID; j++)
2021 if (pEntry->BAOriWcidArray[j] != 0)
2023 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2024 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2027 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2029 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2035 #endif // DOT11_N_SUPPORT //
2038 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2039 struct iw_point *wrq, char *extra)
2042 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2045 u32 subcmd = wrq->flags;
2047 if (dev->priv_flags == INT_MAIN)
2051 pVirtualAd = dev->ml_priv;
2052 pAd = pVirtualAd->RtmpDev->ml_priv;
2054 pObj = (POS_COOKIE) pAd->OS_Cookie;
2058 /* if 1st open fail, pAd will be free;
2059 So the net_dev->ml_priv will be NULL in 2rd open */
2068 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2071 pObj->ioctl_if_type = INT_MAIN;
2072 pObj->ioctl_if = MAIN_MBSSID;
2078 case SHOW_CONN_STATUS:
2079 if (MONITOR_ON(pAd))
2081 #ifdef DOT11_N_SUPPORT
2082 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2083 pAd->CommonCfg.RegTransmitSetting.field.BW)
2084 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2086 #endif // DOT11_N_SUPPORT //
2087 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2091 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2095 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2096 pAd->CommonCfg.Ssid,
2097 pAd->CommonCfg.Bssid[0],
2098 pAd->CommonCfg.Bssid[1],
2099 pAd->CommonCfg.Bssid[2],
2100 pAd->CommonCfg.Bssid[3],
2101 pAd->CommonCfg.Bssid[4],
2102 pAd->CommonCfg.Bssid[5]);
2103 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2105 else if (ADHOC_ON(pAd))
2106 sprintf(extra, "Connected\n");
2110 sprintf(extra, "Disconnected\n");
2111 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2114 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2116 case SHOW_DRVIER_VERION:
2117 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2118 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2120 #ifdef DOT11_N_SUPPORT
2122 getBaInfo(pAd, extra);
2123 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2125 #endif // DOT11_N_SUPPORT //
2126 case SHOW_DESC_INFO:
2128 Show_DescInfo_Proc(pAd, NULL);
2129 wrq->length = 0; // 1: size of '\0'
2133 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2135 sprintf(extra, "Scanning\n");
2136 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2139 pAd->StaCfg.bSwRadio = FALSE;
2140 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2142 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2143 if (pAd->StaCfg.bRadio == FALSE)
2146 // Update extra information
2147 pAd->ExtraInfo = SW_RADIO_OFF;
2150 sprintf(extra, "Radio Off\n");
2151 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2154 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2156 sprintf(extra, "Scanning\n");
2157 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2160 pAd->StaCfg.bSwRadio = TRUE;
2161 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2163 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2164 if (pAd->StaCfg.bRadio == TRUE)
2167 // Update extra information
2168 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2171 sprintf(extra, "Radio On\n");
2172 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2176 #ifdef QOS_DLS_SUPPORT
2177 case SHOW_DLS_ENTRY_INFO:
2179 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2180 wrq->length = 0; // 1: size of '\0'
2183 #endif // QOS_DLS_SUPPORT //
2185 case SHOW_CFG_VALUE:
2187 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2189 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2193 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2201 int rt_ioctl_siwmlme(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu,
2206 PRTMP_ADAPTER pAd = dev->ml_priv;
2207 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2208 MLME_QUEUE_ELEM MsgElem;
2209 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2210 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2212 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2219 #ifdef IW_MLME_DEAUTH
2220 case IW_MLME_DEAUTH:
2221 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2222 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2223 DeAuthReq.Reason = pMlme->reason_code;
2224 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2225 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2226 MlmeDeauthReqAction(pAd, &MsgElem);
2229 LinkDown(pAd, FALSE);
2230 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2233 #endif // IW_MLME_DEAUTH //
2234 #ifdef IW_MLME_DISASSOC
2235 case IW_MLME_DISASSOC:
2236 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2237 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2238 DisAssocReq.Reason = pMlme->reason_code;
2240 MsgElem.Machine = ASSOC_STATE_MACHINE;
2241 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2242 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2243 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2245 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2246 MlmeDisassocReqAction(pAd, &MsgElem);
2248 #endif // IW_MLME_DISASSOC //
2250 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2256 #endif // SIOCSIWMLME //
2258 #if WIRELESS_EXT > 17
2259 int rt_ioctl_siwauth(struct net_device *dev,
2260 struct iw_request_info *info,
2261 union iwreq_data *wrqu, char *extra)
2263 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2264 struct iw_param *param = &wrqu->param;
2266 //check if the interface is down
2267 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2269 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2272 switch (param->flags & IW_AUTH_INDEX) {
2273 case IW_AUTH_WPA_VERSION:
2274 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2276 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2277 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2278 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2280 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2281 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2283 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2285 case IW_AUTH_CIPHER_PAIRWISE:
2286 if (param->value == IW_AUTH_CIPHER_NONE)
2288 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2289 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2290 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2292 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2293 param->value == IW_AUTH_CIPHER_WEP104)
2295 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2296 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2297 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2298 #ifdef WPA_SUPPLICANT_SUPPORT
2299 pAdapter->StaCfg.IEEE8021X = FALSE;
2300 #endif // WPA_SUPPLICANT_SUPPORT //
2302 else if (param->value == IW_AUTH_CIPHER_TKIP)
2304 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2305 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2306 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2308 else if (param->value == IW_AUTH_CIPHER_CCMP)
2310 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2311 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2312 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2314 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2316 case IW_AUTH_CIPHER_GROUP:
2317 if (param->value == IW_AUTH_CIPHER_NONE)
2319 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2321 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2322 param->value == IW_AUTH_CIPHER_WEP104)
2324 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2326 else if (param->value == IW_AUTH_CIPHER_TKIP)
2328 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2330 else if (param->value == IW_AUTH_CIPHER_CCMP)
2332 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2334 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2336 case IW_AUTH_KEY_MGMT:
2337 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2339 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2341 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2342 #ifdef WPA_SUPPLICANT_SUPPORT
2343 pAdapter->StaCfg.IEEE8021X = FALSE;
2344 #endif // WPA_SUPPLICANT_SUPPORT //
2346 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2348 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2349 #ifdef WPA_SUPPLICANT_SUPPORT
2350 pAdapter->StaCfg.IEEE8021X = FALSE;
2351 #endif // WPA_SUPPLICANT_SUPPORT //
2353 #ifdef WPA_SUPPLICANT_SUPPORT
2356 pAdapter->StaCfg.IEEE8021X = TRUE;
2357 #endif // WPA_SUPPLICANT_SUPPORT //
2359 else if (param->value == 0)
2361 STA_PORT_SECURED(pAdapter);
2363 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2365 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2367 case IW_AUTH_PRIVACY_INVOKED:
2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2370 case IW_AUTH_DROP_UNENCRYPTED:
2371 if (param->value != 0)
2372 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2375 STA_PORT_SECURED(pAdapter);
2377 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2379 case IW_AUTH_80211_AUTH_ALG:
2380 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2382 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2384 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2386 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2390 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2392 case IW_AUTH_WPA_ENABLED:
2393 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2402 int rt_ioctl_giwauth(struct net_device *dev,
2403 struct iw_request_info *info,
2404 union iwreq_data *wrqu, char *extra)
2406 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2407 struct iw_param *param = &wrqu->param;
2409 //check if the interface is down
2410 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2412 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2416 switch (param->flags & IW_AUTH_INDEX) {
2417 case IW_AUTH_DROP_UNENCRYPTED:
2418 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2421 case IW_AUTH_80211_AUTH_ALG:
2422 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2425 case IW_AUTH_WPA_ENABLED:
2426 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2432 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2436 void fnSetCipherKey(
2437 IN PRTMP_ADAPTER pAdapter,
2441 IN struct iw_encode_ext *ext)
2443 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2444 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2445 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2446 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2447 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2448 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2450 // Update group key information to ASIC Shared Key Table
2451 AsicAddSharedKeyEntry(pAdapter,
2454 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2455 pAdapter->SharedKey[BSS0][keyIdx].Key,
2456 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2457 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2460 // Update ASIC WCID attribute table and IVEIV table
2461 RTMPAddWcidAttributeEntry(pAdapter,
2464 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2467 // Update ASIC WCID attribute table and IVEIV table
2468 RTMPAddWcidAttributeEntry(pAdapter,
2471 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2472 &pAdapter->MacTab.Content[BSSID_WCID]);
2475 int rt_ioctl_siwencodeext(struct net_device *dev,
2476 struct iw_request_info *info,
2477 union iwreq_data *wrqu,
2480 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2481 struct iw_point *encoding = &wrqu->encoding;
2482 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2483 int keyIdx, alg = ext->alg;
2485 //check if the interface is down
2486 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2488 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2492 if (encoding->flags & IW_ENCODE_DISABLED)
2494 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2495 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2496 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2497 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2498 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2499 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2500 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2501 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2505 // Get Key Index and convet to our own defined key index
2506 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2507 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2510 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2512 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2513 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2517 case IW_ENCODE_ALG_NONE:
2518 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2520 case IW_ENCODE_ALG_WEP:
2521 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2522 if (ext->key_len == MAX_WEP_KEY_SIZE)
2524 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2525 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2527 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2529 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2530 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2535 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2536 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2538 case IW_ENCODE_ALG_TKIP:
2539 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2540 if (ext->key_len == 32)
2542 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2544 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2545 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2547 STA_PORT_SECURED(pAdapter);
2550 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2552 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2554 // set 802.1x port control
2555 STA_PORT_SECURED(pAdapter);
2561 case IW_ENCODE_ALG_CCMP:
2562 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2564 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2565 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2566 STA_PORT_SECURED(pAdapter);
2568 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2570 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2572 // set 802.1x port control
2573 STA_PORT_SECURED(pAdapter);
2585 rt_ioctl_giwencodeext(struct net_device *dev,
2586 struct iw_request_info *info,
2587 union iwreq_data *wrqu, char *extra)
2589 PRTMP_ADAPTER pAd = dev->ml_priv;
2591 struct iw_point *encoding = &wrqu->encoding;
2592 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2593 int idx, max_key_len;
2595 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2597 max_key_len = encoding->length - sizeof(*ext);
2598 if (max_key_len < 0)
2601 idx = encoding->flags & IW_ENCODE_INDEX;
2604 if (idx < 1 || idx > 4)
2608 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2609 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2611 if (idx != pAd->StaCfg.DefaultKeyId)
2619 idx = pAd->StaCfg.DefaultKeyId;
2621 encoding->flags = idx + 1;
2622 memset(ext, 0, sizeof(*ext));
2625 switch(pAd->StaCfg.WepStatus) {
2626 case Ndis802_11WEPDisabled:
2627 ext->alg = IW_ENCODE_ALG_NONE;
2628 encoding->flags |= IW_ENCODE_DISABLED;
2630 case Ndis802_11WEPEnabled:
2631 ext->alg = IW_ENCODE_ALG_WEP;
2632 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2636 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2637 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2640 case Ndis802_11Encryption2Enabled:
2641 case Ndis802_11Encryption3Enabled:
2642 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2643 ext->alg = IW_ENCODE_ALG_TKIP;
2645 ext->alg = IW_ENCODE_ALG_CCMP;
2647 if (max_key_len < 32)
2652 pKey = &pAd->StaCfg.PMK[0];
2659 if (ext->key_len && pKey)
2661 encoding->flags |= IW_ENCODE_ENABLED;
2662 memcpy(ext->key, pKey, ext->key_len);
2669 int rt_ioctl_siwgenie(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
2673 PRTMP_ADAPTER pAd = dev->ml_priv;
2675 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2676 (wrqu->data.length && extra == NULL))
2679 if (wrqu->data.length)
2681 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2682 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2686 pAd->StaCfg.RSNIE_Len = 0;
2687 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2692 #endif // SIOCSIWGENIE //
2694 int rt_ioctl_giwgenie(struct net_device *dev,
2695 struct iw_request_info *info,
2696 union iwreq_data *wrqu, char *extra)
2698 PRTMP_ADAPTER pAd = dev->ml_priv;
2700 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2701 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2703 wrqu->data.length = 0;
2707 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2709 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2711 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2714 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2715 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2718 #endif // SIOCSIWGENIE //
2719 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2721 UCHAR RSNIe = IE_WPA;
2723 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2725 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2727 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2728 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2731 extra[0] = (char)RSNIe;
2732 extra[1] = pAd->StaCfg.RSNIE_Len;
2733 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2739 int rt_ioctl_siwpmksa(struct net_device *dev,
2740 struct iw_request_info *info,
2741 union iwreq_data *wrqu,
2744 PRTMP_ADAPTER pAd = dev->ml_priv;
2745 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2746 INT CachedIdx = 0, idx = 0;
2751 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2754 case IW_PMKSA_FLUSH:
2755 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2756 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2758 case IW_PMKSA_REMOVE:
2759 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2761 // compare the BSSID
2762 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2764 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2765 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2766 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2768 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2769 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2771 pAd->StaCfg.SavedPMKNum--;
2776 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2779 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2781 // compare the BSSID
2782 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2786 // Found, replace it
2787 if (CachedIdx < PMKID_NO)
2789 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2790 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2791 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2792 pAd->StaCfg.SavedPMKNum++;
2794 // Not found, replace the last one
2797 // Randomly replace one
2798 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2799 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2800 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2801 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2804 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2807 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2813 #endif // #if WIRELESS_EXT > 17
2817 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2818 struct iw_point *wrq, char *extra)
2825 BOOLEAN bIsPrintAllBBP = FALSE;
2827 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2830 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2832 if (wrq->length > 1) //No parameters.
2834 sprintf(extra, "\n");
2836 //Parsing Read or Write
2837 this_char = wrq->pointer;
2838 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2842 if ((value = rtstrchr(this_char, '=')) != NULL)
2845 if (!value || !*value)
2847 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2848 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2853 if (ATE_ON(pAdapter))
2855 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2858 #endif // RALINK_ATE //
2860 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2862 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2863 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2864 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2867 {//Invalid parametes, so default printk all bbp
2868 bIsPrintAllBBP = TRUE;
2873 { //Invalid parametes, so default printk all bbp
2874 bIsPrintAllBBP = TRUE;
2880 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2885 if (ATE_ON(pAdapter))
2887 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2888 //Read it back for showing
2889 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2892 #endif // RALINK_ATE //
2894 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2895 //Read it back for showing
2896 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2898 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2899 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2900 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2903 {//Invalid parametes, so default printk all bbp
2904 bIsPrintAllBBP = TRUE;
2909 { //Invalid parametes, so default printk all bbp
2910 bIsPrintAllBBP = TRUE;
2916 bIsPrintAllBBP = TRUE;
2921 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2922 sprintf(extra, "\n");
2923 for (bbpId = 0; bbpId <= 136; bbpId++)
2925 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2928 if (ATE_ON(pAdapter))
2930 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2933 #endif // RALINK_ATE //
2934 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2935 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2937 sprintf(extra+strlen(extra), "\n");
2940 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2941 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2944 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2950 int rt_ioctl_siwrate(struct net_device *dev,
2951 struct iw_request_info *info,
2952 union iwreq_data *wrqu, char *extra)
2954 PRTMP_ADAPTER pAd = dev->ml_priv;
2955 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2957 //check if the interface is down
2958 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2960 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2964 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2965 /* rate = -1 => auto rate
2966 rate = X, fixed = 1 => (fixed rate X)
2971 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2972 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2973 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2974 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2975 RTMPSetDesiredRates(pAd, -1);
2977 #ifdef DOT11_N_SUPPORT
2979 #endif // DOT11_N_SUPPORT //
2985 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2986 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2987 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2988 RTMPSetDesiredRates(pAd, rate);
2991 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2992 #ifdef DOT11_N_SUPPORT
2994 #endif // DOT11_N_SUPPORT //
2996 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3000 // TODO: rate = X, fixed = 0 => (rates <= X)
3008 int rt_ioctl_giwrate(struct net_device *dev,
3009 struct iw_request_info *info,
3010 union iwreq_data *wrqu, char *extra)
3012 PRTMP_ADAPTER pAd = dev->ml_priv;
3013 int rate_index = 0, rate_count = 0;
3014 HTTRANSMIT_SETTING ht_setting;
3015 __s32 ralinkrate[] =
3016 {2, 4, 11, 22, // CCK
3017 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3018 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3019 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3020 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3021 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3022 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3023 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3024 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3025 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3027 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3028 //check if the interface is down
3029 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3031 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3035 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3037 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3038 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3040 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3042 #ifdef DOT11_N_SUPPORT
3043 if (ht_setting.field.MODE >= MODE_HTMIX)
3045 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3048 #endif // DOT11_N_SUPPORT //
3049 if (ht_setting.field.MODE == MODE_OFDM)
3050 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3051 else if (ht_setting.field.MODE == MODE_CCK)
3052 rate_index = (UCHAR)(ht_setting.field.MCS);
3057 if (rate_index > rate_count)
3058 rate_index = rate_count;
3060 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3061 wrqu->bitrate.disabled = 0;
3066 static const iw_handler rt_handler[] =
3068 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3069 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3070 (iw_handler) NULL, /* SIOCSIWNWID */
3071 (iw_handler) NULL, /* SIOCGIWNWID */
3072 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3073 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3074 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3075 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3076 (iw_handler) NULL, /* SIOCSIWSENS */
3077 (iw_handler) NULL, /* SIOCGIWSENS */
3078 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3079 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3080 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3081 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3082 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3083 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3084 (iw_handler) NULL, /* SIOCSIWSPY */
3085 (iw_handler) NULL, /* SIOCGIWSPY */
3086 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3087 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3088 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3089 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3091 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3093 (iw_handler) NULL, /* SIOCSIWMLME */
3094 #endif // SIOCSIWMLME //
3095 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3097 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3098 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3100 (iw_handler) NULL, /* SIOCSIWSCAN */
3101 (iw_handler) NULL, /* SIOCGIWSCAN */
3102 #endif /* SIOCGIWSCAN */
3103 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3104 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3105 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3106 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3107 (iw_handler) NULL, /* -- hole -- */
3108 (iw_handler) NULL, /* -- hole -- */
3109 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3110 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3111 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3112 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3113 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3114 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3115 (iw_handler) NULL, /* SIOCSIWTXPOW */
3116 (iw_handler) NULL, /* SIOCGIWTXPOW */
3117 (iw_handler) NULL, /* SIOCSIWRETRY */
3118 (iw_handler) NULL, /* SIOCGIWRETRY */
3119 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3120 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3121 (iw_handler) NULL, /* SIOCSIWPOWER */
3122 (iw_handler) NULL, /* SIOCGIWPOWER */
3123 (iw_handler) NULL, /* -- hole -- */
3124 (iw_handler) NULL, /* -- hole -- */
3125 #if WIRELESS_EXT > 17
3126 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3127 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3128 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3129 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3130 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3131 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3132 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3136 static const iw_handler rt_priv_handlers[] = {
3137 (iw_handler) NULL, /* + 0x00 */
3138 (iw_handler) NULL, /* + 0x01 */
3139 #ifndef CONFIG_AP_SUPPORT
3140 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3142 (iw_handler) NULL, /* + 0x02 */
3143 #endif // CONFIG_AP_SUPPORT //
3145 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3147 (iw_handler) NULL, /* + 0x03 */
3149 (iw_handler) NULL, /* + 0x04 */
3150 (iw_handler) NULL, /* + 0x05 */
3151 (iw_handler) NULL, /* + 0x06 */
3152 (iw_handler) NULL, /* + 0x07 */
3153 (iw_handler) NULL, /* + 0x08 */
3154 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3155 (iw_handler) NULL, /* + 0x0A */
3156 (iw_handler) NULL, /* + 0x0B */
3157 (iw_handler) NULL, /* + 0x0C */
3158 (iw_handler) NULL, /* + 0x0D */
3159 (iw_handler) NULL, /* + 0x0E */
3160 (iw_handler) NULL, /* + 0x0F */
3161 (iw_handler) NULL, /* + 0x10 */
3162 (iw_handler) rt_private_show, /* + 0x11 */
3163 (iw_handler) NULL, /* + 0x12 */
3164 (iw_handler) NULL, /* + 0x13 */
3165 (iw_handler) NULL, /* + 0x15 */
3166 (iw_handler) NULL, /* + 0x17 */
3167 (iw_handler) NULL, /* + 0x18 */
3170 const struct iw_handler_def rt28xx_iw_handler_def =
3172 #define N(a) (sizeof (a) / sizeof (a[0]))
3173 .standard = (iw_handler *) rt_handler,
3174 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3175 .private = (iw_handler *) rt_priv_handlers,
3176 .num_private = N(rt_priv_handlers),
3177 .private_args = (struct iw_priv_args *) privtab,
3178 .num_private_args = N(privtab),
3179 #if IW_HANDLER_VERSION >= 7
3180 .get_wireless_stats = rt28xx_get_wireless_stats,
3184 INT RTMPSetInformation(
3185 IN PRTMP_ADAPTER pAdapter,
3186 IN OUT struct ifreq *rq,
3189 struct iwreq *wrq = (struct iwreq *) rq;
3190 NDIS_802_11_SSID Ssid;
3191 NDIS_802_11_MAC_ADDRESS Bssid;
3192 RT_802_11_PHY_MODE PhyMode;
3193 RT_802_11_STA_CONFIG StaConfig;
3194 NDIS_802_11_RATES aryRates;
3195 RT_802_11_PREAMBLE Preamble;
3196 NDIS_802_11_WEP_STATUS WepStatus;
3197 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3198 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3199 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3200 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3201 NDIS_802_11_POWER_MODE PowerMode;
3202 PNDIS_802_11_KEY pKey = NULL;
3203 PNDIS_802_11_WEP pWepKey =NULL;
3204 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3205 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3206 NDIS_802_11_NETWORK_TYPE NetType;
3209 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3212 BOOLEAN StateMachineTouched = FALSE;
3213 #ifdef DOT11_N_SUPPORT
3214 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3215 #endif // DOT11_N_SUPPORT //
3216 #ifdef WPA_SUPPLICANT_SUPPORT
3217 PNDIS_802_11_PMKID pPmkId = NULL;
3218 BOOLEAN IEEE8021xState = FALSE;
3219 BOOLEAN IEEE8021x_required_keys = FALSE;
3220 UCHAR wpa_supplicant_enable = 0;
3221 #endif // WPA_SUPPLICANT_SUPPORT //
3224 TX_RTY_CFG_STRUC tx_rty_cfg;
3225 ULONG ShortRetryLimit, LongRetryLimit;
3227 #endif // SNMP_SUPPORT //
3230 #ifdef DOT11_N_SUPPORT
3231 MaxPhyMode = PHY_11N_5G;
3232 #endif // DOT11_N_SUPPORT //
3235 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3236 switch(cmd & 0x7FFF) {
3237 case RT_OID_802_11_COUNTRY_REGION:
3238 if (wrq->u.data.length < sizeof(UCHAR))
3240 // Only avaliable when EEPROM not programming
3241 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3246 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3247 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3248 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3249 TmpPhy = pAdapter->CommonCfg.PhyMode;
3250 pAdapter->CommonCfg.PhyMode = 0xff;
3251 // Build all corresponding channel information
3252 RTMPSetPhyMode(pAdapter, TmpPhy);
3253 #ifdef DOT11_N_SUPPORT
3254 SetCommonHT(pAdapter);
3255 #endif // DOT11_N_SUPPORT //
3256 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3257 pAdapter->CommonCfg.CountryRegion));
3260 case OID_802_11_BSSID_LIST_SCAN:
3262 if (ATE_ON(pAdapter))
3264 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3267 #endif // RALINK_ATE //
3269 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3271 if (MONITOR_ON(pAdapter))
3273 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3277 //Benson add 20080527, when radio off, sta don't need to scan
3278 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3281 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3283 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3284 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3285 Status = NDIS_STATUS_SUCCESS;
3289 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3291 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3292 Status = NDIS_STATUS_SUCCESS;
3293 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3297 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3298 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3299 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3300 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3301 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3302 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3304 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3305 Status = NDIS_STATUS_SUCCESS;
3306 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3311 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3313 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3314 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3317 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3318 // this request, because this request is initiated by NDIS.
3319 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3320 // Reset allowed scan retries
3321 pAdapter->StaCfg.ScanCnt = 0;
3322 pAdapter->StaCfg.LastScanTime = Now;
3324 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3325 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3326 MlmeEnqueue(pAdapter,
3327 MLME_CNTL_STATE_MACHINE,
3328 OID_802_11_BSSID_LIST_SCAN,
3332 Status = NDIS_STATUS_SUCCESS;
3333 StateMachineTouched = TRUE;
3335 case OID_802_11_SSID:
3336 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3340 PCHAR pSsidString = NULL;
3341 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3343 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3344 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3348 if (Ssid.SsidLength == 0)
3350 Set_SSID_Proc(pAdapter, "");
3354 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3357 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3358 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3359 Set_SSID_Proc(pAdapter, pSsidString);
3368 case OID_802_11_BSSID:
3370 if (ATE_ON(pAdapter))
3372 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3375 #endif // RALINK_ATE //
3376 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3380 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3382 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3383 // this request, because this request is initiated by NDIS.
3384 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3386 // Prevent to connect AP again in STAMlmePeriodicExec
3387 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3389 // Reset allowed scan retries
3390 pAdapter->StaCfg.ScanCnt = 0;
3392 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3394 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3395 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3397 MlmeEnqueue(pAdapter,
3398 MLME_CNTL_STATE_MACHINE,
3400 sizeof(NDIS_802_11_MAC_ADDRESS),
3402 Status = NDIS_STATUS_SUCCESS;
3403 StateMachineTouched = TRUE;
3405 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3406 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3409 case RT_OID_802_11_RADIO:
3410 if (wrq->u.data.length != sizeof(BOOLEAN))
3414 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3415 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3416 if (pAdapter->StaCfg.bSwRadio != RadioState)
3418 pAdapter->StaCfg.bSwRadio = RadioState;
3419 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3421 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3422 if (pAdapter->StaCfg.bRadio == TRUE)
3424 MlmeRadioOn(pAdapter);
3425 // Update extra information
3426 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3430 MlmeRadioOff(pAdapter);
3431 // Update extra information
3432 pAdapter->ExtraInfo = SW_RADIO_OFF;
3438 case RT_OID_802_11_PHY_MODE:
3439 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3443 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3444 if (PhyMode <= MaxPhyMode)
3446 RTMPSetPhyMode(pAdapter, PhyMode);
3447 #ifdef DOT11_N_SUPPORT
3448 SetCommonHT(pAdapter);
3449 #endif // DOT11_N_SUPPORT //
3451 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3454 case RT_OID_802_11_STA_CONFIG:
3455 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3459 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3460 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3461 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3462 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3463 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3464 (StaConfig.AdhocMode <= MaxPhyMode))
3466 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3467 // if setting changed, need to reset current TX rate as well as BEACON frame format
3468 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3470 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3471 RTMPSetPhyMode(pAdapter, PhyMode);
3472 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3473 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3474 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3477 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3478 pAdapter->CommonCfg.bEnableTxBurst,
3479 pAdapter->CommonCfg.UseBGProtection,
3480 pAdapter->CommonCfg.bUseShortSlotTime));
3483 case OID_802_11_DESIRED_RATES:
3484 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3488 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3489 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3490 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3491 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3492 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3493 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3494 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3495 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3496 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3497 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3500 case RT_OID_802_11_PREAMBLE:
3501 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3505 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3506 if (Preamble == Rt802_11PreambleShort)
3508 pAdapter->CommonCfg.TxPreamble = Preamble;
3509 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3511 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3513 // if user wants AUTO, initialize to LONG here, then change according to AP's
3514 // capability upon association.
3515 pAdapter->CommonCfg.TxPreamble = Preamble;
3516 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3523 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3526 case OID_802_11_WEP_STATUS:
3527 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3531 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3532 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3533 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3535 if (pAdapter->StaCfg.WepStatus != WepStatus)
3537 // Config has changed
3538 pAdapter->bConfigChanged = TRUE;
3540 pAdapter->StaCfg.WepStatus = WepStatus;
3541 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3542 pAdapter->StaCfg.PairCipher = WepStatus;
3543 pAdapter->StaCfg.GroupCipher = WepStatus;
3550 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3553 case OID_802_11_AUTHENTICATION_MODE:
3554 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3558 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3559 if (AuthMode > Ndis802_11AuthModeMax)
3566 if (pAdapter->StaCfg.AuthMode != AuthMode)
3568 // Config has changed
3569 pAdapter->bConfigChanged = TRUE;
3571 pAdapter->StaCfg.AuthMode = AuthMode;
3573 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3574 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3577 case OID_802_11_INFRASTRUCTURE_MODE:
3578 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3582 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3584 if (BssType == Ndis802_11IBSS)
3585 Set_NetworkType_Proc(pAdapter, "Adhoc");
3586 else if (BssType == Ndis802_11Infrastructure)
3587 Set_NetworkType_Proc(pAdapter, "Infra");
3588 else if (BssType == Ndis802_11Monitor)
3589 Set_NetworkType_Proc(pAdapter, "Monitor");
3593 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3597 case OID_802_11_REMOVE_WEP:
3598 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3599 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3605 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3607 if (KeyIdx & 0x80000000)
3609 // Should never set default bit when remove key
3614 KeyIdx = KeyIdx & 0x0fffffff;
3620 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3621 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3622 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3627 case RT_OID_802_11_RESET_COUNTERS:
3628 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3629 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3630 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3631 pAdapter->Counters8023.RxNoBuffer = 0;
3632 pAdapter->Counters8023.GoodReceives = 0;
3633 pAdapter->Counters8023.RxNoBuffer = 0;
3634 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3636 case OID_802_11_RTS_THRESHOLD:
3637 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3641 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3642 if (RtsThresh > MAX_RTS_THRESHOLD)
3645 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3647 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3649 case OID_802_11_FRAGMENTATION_THRESHOLD:
3650 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3654 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3655 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3656 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3658 if (FragThresh == 0)
3660 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3661 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3667 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3669 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3671 case OID_802_11_POWER_MODE:
3672 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3676 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3677 if (PowerMode == Ndis802_11PowerModeCAM)
3678 Set_PSMode_Proc(pAdapter, "CAM");
3679 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3680 Set_PSMode_Proc(pAdapter, "Max_PSP");
3681 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3682 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3683 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3684 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3688 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3690 case RT_OID_802_11_TX_POWER_LEVEL_1:
3691 if (wrq->u.data.length < sizeof(ULONG))
3695 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3696 if (PowerTemp > 100)
3697 PowerTemp = 0xffffffff; // AUTO
3698 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3699 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3700 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3703 case OID_802_11_NETWORK_TYPE_IN_USE:
3704 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3708 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3710 if (NetType == Ndis802_11DS)
3711 RTMPSetPhyMode(pAdapter, PHY_11B);
3712 else if (NetType == Ndis802_11OFDM24)
3713 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3714 else if (NetType == Ndis802_11OFDM5)
3715 RTMPSetPhyMode(pAdapter, PHY_11A);
3718 #ifdef DOT11_N_SUPPORT
3719 if (Status == NDIS_STATUS_SUCCESS)
3720 SetCommonHT(pAdapter);
3721 #endif // DOT11_N_SUPPORT //
3722 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3725 // For WPA PSK PMK key
3726 case RT_OID_802_11_ADD_WPA:
3727 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3734 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3735 if (pKey->Length != wrq->u.data.length)
3738 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3742 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3743 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3744 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3746 Status = -EOPNOTSUPP;
3747 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3749 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3750 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3751 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3753 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3754 // Use RaConfig as PSK agent.
3755 // Start STA supplicant state machine
3756 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3757 pAdapter->StaCfg.WpaState = SS_START;
3759 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3763 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3764 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3769 case OID_802_11_REMOVE_KEY:
3770 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3771 if(pRemoveKey == NULL)
3777 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3778 if (pRemoveKey->Length != wrq->u.data.length)
3781 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3785 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3787 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3788 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3792 KeyIdx = pRemoveKey->KeyIndex;
3794 if (KeyIdx & 0x80000000)
3796 // Should never set default bit when remove key
3798 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3802 KeyIdx = KeyIdx & 0x0fffffff;
3806 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3810 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3811 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3812 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3813 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3821 case OID_802_11_ADD_KEY:
3822 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3828 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3829 if (pKey->Length != wrq->u.data.length)
3832 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3836 RTMPAddKey(pAdapter, pKey);
3837 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3841 case OID_802_11_CONFIGURATION:
3842 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3846 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3849 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3850 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3852 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3853 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3855 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3857 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3859 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3860 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3861 // Config has changed
3862 pAdapter->bConfigChanged = TRUE;
3865 #ifdef DOT11_N_SUPPORT
3866 case RT_OID_802_11_SET_HT_PHYMODE:
3867 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3871 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3873 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3874 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3875 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3876 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3877 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3878 RTMPSetHT(pAdapter, pHTPhyMode);
3880 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3881 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3882 pAdapter->StaCfg.HTPhyMode.field.STBC));
3884 #endif // DOT11_N_SUPPORT //
3885 case RT_OID_802_11_SET_APSD_SETTING:
3886 if (wrq->u.data.length != sizeof(ULONG))
3891 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3893 /*-------------------------------------------------------------------
3894 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3895 ---------------------------------------------------------------------
3896 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3897 ---------------------------------------------------------------------*/
3898 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3899 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3900 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3901 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3902 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3903 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3905 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,
3906 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3910 case RT_OID_802_11_SET_APSD_PSM:
3911 if (wrq->u.data.length != sizeof(ULONG))
3915 // Driver needs to notify AP when PSM changes
3916 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3917 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3919 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3920 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3922 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3925 #ifdef QOS_DLS_SUPPORT
3926 case RT_OID_802_11_SET_DLS:
3927 if (wrq->u.data.length != sizeof(ULONG))
3931 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3932 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3933 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3936 // tear down local dls table entry
3937 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3939 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3941 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3942 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3943 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3947 // tear down peer dls table entry
3948 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3950 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3952 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3953 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3954 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3959 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3963 case RT_OID_802_11_SET_DLS_PARAM:
3964 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3970 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3971 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3972 MlmeEnqueue(pAdapter,
3973 MLME_CNTL_STATE_MACHINE,
3974 RT_OID_802_11_SET_DLS_PARAM,
3975 sizeof(RT_802_11_DLS),
3977 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3980 #endif // QOS_DLS_SUPPORT //
3981 case RT_OID_802_11_SET_WMM:
3982 if (wrq->u.data.length != sizeof(BOOLEAN))
3986 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3987 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3991 case OID_802_11_DISASSOCIATE:
3993 if (ATE_ON(pAdapter))
3995 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3998 #endif // RALINK_ATE //
4000 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4001 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4002 // when query OID_802_11_BSSID_LIST.
4004 // TRUE: NumberOfItems will set to 0.
4005 // FALSE: NumberOfItems no change.
4007 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4008 // Set to immediately send the media disconnect event
4009 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4010 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4012 if (INFRA_ON(pAdapter))
4014 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4016 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4017 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4020 MlmeEnqueue(pAdapter,
4021 MLME_CNTL_STATE_MACHINE,
4022 OID_802_11_DISASSOCIATE,
4026 StateMachineTouched = TRUE;
4030 #ifdef DOT11_N_SUPPORT
4031 case RT_OID_802_11_SET_IMME_BA_CAP:
4032 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4036 OID_BACAP_STRUC Orde ;
4037 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4038 if (Orde.Policy > BA_NOTUSE)
4040 Status = NDIS_STATUS_INVALID_DATA;
4042 else if (Orde.Policy == BA_NOTUSE)
4044 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4045 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4046 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4047 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4048 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4049 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4050 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4052 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4053 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4054 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4058 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4059 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4060 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4061 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4062 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4063 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4064 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4065 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4068 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4069 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4070 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4072 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4073 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4077 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4078 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4079 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4080 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4081 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4085 case RT_OID_802_11_ADD_IMME_BA:
4086 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4087 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4092 OID_ADD_BA_ENTRY BA;
4093 MAC_TABLE_ENTRY *pEntry;
4095 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4098 Status = NDIS_STATUS_INVALID_DATA;
4103 //BATableInsertEntry
4104 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4106 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4107 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4110 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4113 if (BA.IsRecipient == FALSE)
4115 if (pEntry->bIAmBadAtheros == TRUE)
4116 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4118 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4122 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4125 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4126 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4127 , BA.MACAddr[4], BA.MACAddr[5]));
4132 case RT_OID_802_11_TEAR_IMME_BA:
4133 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4134 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4138 POID_ADD_BA_ENTRY pBA;
4139 MAC_TABLE_ENTRY *pEntry;
4141 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4145 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4146 Status = NDIS_STATUS_FAILURE;
4150 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4151 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4153 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4155 Status = NDIS_STATUS_INVALID_DATA;
4159 if (pBA->IsRecipient == FALSE)
4161 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4162 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4165 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4166 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4169 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4173 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4176 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4179 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4185 #endif // DOT11_N_SUPPORT //
4187 // For WPA_SUPPLICANT to set static wep key
4188 case OID_802_11_ADD_WEP:
4189 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4194 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4197 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4201 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4205 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4206 // KeyIdx must be 0 ~ 3
4210 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4214 UCHAR CipherAlg = 0;
4217 // set key material and key length
4218 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4219 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4220 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4222 switch(pWepKey->KeyLength)
4225 CipherAlg = CIPHER_WEP64;
4228 CipherAlg = CIPHER_WEP128;
4231 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4235 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4237 // Default key for tx (shared key)
4238 if (pWepKey->KeyIndex & 0x80000000)
4240 #ifdef WPA_SUPPLICANT_SUPPORT
4241 // set key material and key length
4242 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4243 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4244 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4245 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4246 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4247 #endif // WPA_SUPPLICANT_SUPPORT //
4248 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4251 #ifdef WPA_SUPPLICANT_SUPPORT
4252 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4253 #endif // WPA_SUPPLICANT_SUPPORT
4255 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4257 // Set key material and cipherAlg to Asic
4258 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4260 if (pWepKey->KeyIndex & 0x80000000)
4262 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4263 // Assign group key info
4264 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4265 // Assign pairwise key info
4266 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4269 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"));
4274 #ifdef WPA_SUPPLICANT_SUPPORT
4275 case OID_SET_COUNTERMEASURES:
4276 if (wrq->u.data.length != sizeof(int))
4281 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4283 pAdapter->StaCfg.bBlockAssoc = TRUE;
4285 // WPA MIC error should block association attempt for 60 seconds
4286 pAdapter->StaCfg.bBlockAssoc = FALSE;
4287 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4290 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4291 if (wrq->u.data.length != sizeof(UCHAR))
4295 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4296 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4297 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4300 case OID_802_11_DEAUTHENTICATION:
4301 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4305 MLME_DEAUTH_REQ_STRUCT *pInfo;
4306 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4308 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4309 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4310 MlmeDeauthReqAction(pAdapter, MsgElem);
4313 if (INFRA_ON(pAdapter))
4315 LinkDown(pAdapter, FALSE);
4316 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4318 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4321 case OID_802_11_DROP_UNENCRYPTED:
4322 if (wrq->u.data.length != sizeof(int))
4327 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4329 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4331 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4332 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4333 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4334 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4335 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4338 case OID_802_11_SET_IEEE8021X:
4339 if (wrq->u.data.length != sizeof(BOOLEAN))
4343 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4344 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4345 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4348 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4349 if (wrq->u.data.length != sizeof(BOOLEAN))
4353 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4354 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4355 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4358 case OID_802_11_PMKID:
4359 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4361 if(pPmkId == NULL) {
4365 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4367 // check the PMKID information
4368 if (pPmkId->BSSIDInfoCount == 0)
4369 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4372 PBSSID_INFO pBssIdInfo;
4376 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4378 // point to the indexed BSSID_INFO structure
4379 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4380 // Find the entry in the saved data base.
4381 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4383 // compare the BSSID
4384 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4388 // Found, replace it
4389 if (CachedIdx < PMKID_NO)
4391 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4392 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4393 pAdapter->StaCfg.SavedPMKNum++;
4395 // Not found, replace the last one
4398 // Randomly replace one
4399 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4400 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4401 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4408 #endif // WPA_SUPPLICANT_SUPPORT //
4413 case OID_802_11_SHORTRETRYLIMIT:
4414 if (wrq->u.data.length != sizeof(ULONG))
4418 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4419 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4420 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4421 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4422 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4426 case OID_802_11_LONGRETRYLIMIT:
4427 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4428 if (wrq->u.data.length != sizeof(ULONG))
4432 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4433 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4434 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4435 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4436 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4440 case OID_802_11_WEPDEFAULTKEYVALUE:
4441 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4442 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4443 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4446 if ( pKey->Length != wrq->u.data.length)
4449 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4451 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4452 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4454 // it is a shared key
4459 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4460 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4461 if (pKey->KeyIndex & 0x80000000)
4463 // Default key for tx (shared key)
4464 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4466 //RestartAPIsRequired = TRUE;
4471 case OID_802_11_WEPDEFAULTKEYID:
4472 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4474 if (wrq->u.data.length != sizeof(UCHAR))
4477 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4482 case OID_802_11_CURRENTCHANNEL:
4483 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4484 if (wrq->u.data.length != sizeof(UCHAR))
4488 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4489 sprintf(&ctmp,"%d", ctmp);
4490 Set_Channel_Proc(pAdapter, &ctmp);
4498 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4499 Status = -EOPNOTSUPP;
4507 INT RTMPQueryInformation(
4508 IN PRTMP_ADAPTER pAdapter,
4509 IN OUT struct ifreq *rq,
4512 struct iwreq *wrq = (struct iwreq *) rq;
4513 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4514 PNDIS_WLAN_BSSID_EX pBss;
4515 NDIS_802_11_SSID Ssid;
4516 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4517 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4518 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4519 NDIS_802_11_STATISTICS *pStatistics = NULL;
4520 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4521 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4522 NDIS_802_11_POWER_MODE PowerMode;
4523 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4524 RT_802_11_PREAMBLE PreamType;
4525 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4526 NDIS_802_11_WEP_STATUS WepStatus;
4527 NDIS_MEDIA_STATE MediaState;
4528 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4530 PUCHAR pBuf = NULL, pPtr;
4531 INT Status = NDIS_STATUS_SUCCESS;
4532 UINT we_version_compiled;
4533 UCHAR i, Padding = 0;
4535 UCHAR driverVersion[8];
4536 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4541 DefaultKeyIdxValue *pKeyIdxValue;
4543 TX_RTY_CFG_STRUC tx_rty_cfg;
4544 ULONG ShortRetryLimit, LongRetryLimit;
4550 case RT_OID_DEVICE_NAME:
4551 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4552 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4554 case RT_OID_VERSION_INFO:
4555 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4556 wrq->u.data.length = 8*sizeof(UCHAR);
4557 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4558 driverVersion[7] = '\0';
4559 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4565 case RT_QUERY_ATE_TXDONE_COUNT:
4566 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4567 wrq->u.data.length = sizeof(UINT32);
4568 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4573 #endif // RALINK_ATE //
4574 case OID_802_11_BSSID_LIST:
4575 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4578 * Still scanning, indicate the caller should try again.
4580 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4583 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4584 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4585 // Claculate total buffer size required
4586 BssBufSize = sizeof(ULONG);
4588 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4590 // Align pointer to 4 bytes boundary.
4591 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4594 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4597 // For safety issue, we add 256 bytes just in case
4599 // Allocate the same size as passed from higher layer
4600 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4606 // Init 802_11_BSSID_LIST_EX structure
4607 NdisZeroMemory(pBuf, BssBufSize);
4608 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4609 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4611 // Calculate total buffer length
4612 BssLen = 4; // Consist of NumberOfItems
4613 // Point to start of NDIS_WLAN_BSSID_EX
4614 // pPtr = pBuf + sizeof(ULONG);
4615 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4616 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4618 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4619 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4620 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4623 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4624 // and then failed to send EAPOl farame.
4626 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4628 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4629 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4632 pBss->Ssid.SsidLength = 0;
4636 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4637 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4639 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4640 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4641 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4642 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4643 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4644 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4646 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4648 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4649 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4651 pBss->InfrastructureMode = Ndis802_11IBSS;
4653 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4654 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4655 pAdapter->ScanTab.BssEntry[i].ExtRate,
4656 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4658 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4660 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4661 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4662 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4666 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4667 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4668 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4669 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4670 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4672 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4674 #if WIRELESS_EXT < 17
4675 if ((BssLen + pBss->Length) < wrq->u.data.length)
4676 BssLen += pBss->Length;
4679 pBssidList->NumberOfItems = i;
4683 BssLen += pBss->Length;
4687 #if WIRELESS_EXT < 17
4688 wrq->u.data.length = BssLen;
4690 if (BssLen > wrq->u.data.length)
4696 wrq->u.data.length = BssLen;
4698 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4701 case OID_802_3_CURRENT_ADDRESS:
4702 wrq->u.data.length = MAC_ADDR_LEN;
4703 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4705 case OID_GEN_MEDIA_CONNECT_STATUS:
4706 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4707 MediaState = NdisMediaStateConnected;
4709 MediaState = NdisMediaStateDisconnected;
4711 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4712 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4714 case OID_802_11_BSSID:
4716 if (ATE_ON(pAdapter))
4718 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4719 Status = NDIS_STATUS_RESOURCES;
4722 #endif // RALINK_ATE //
4723 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4725 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4730 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4734 case OID_802_11_SSID:
4735 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4736 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4737 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4738 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4739 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4740 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4741 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4743 case RT_OID_802_11_QUERY_LINK_STATUS:
4744 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4747 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4748 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4749 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4750 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4751 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4752 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4753 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4755 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4759 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4763 case OID_802_11_CONFIGURATION:
4764 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4767 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4768 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4769 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4770 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4771 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4772 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4773 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4774 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4775 kfree(pConfiguration);
4779 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4783 case RT_OID_802_11_SNR_0:
4784 if ((pAdapter->StaCfg.LastSNR0 > 0))
4786 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4787 wrq->u.data.length = sizeof(ulInfo);
4788 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4789 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4794 case RT_OID_802_11_SNR_1:
4795 if ((pAdapter->Antenna.field.RxPath > 1) &&
4796 (pAdapter->StaCfg.LastSNR1 > 0))
4798 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4799 wrq->u.data.length = sizeof(ulInfo);
4800 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4801 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4805 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4807 case OID_802_11_RSSI_TRIGGER:
4808 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4809 wrq->u.data.length = sizeof(ulInfo);
4810 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4811 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4813 case OID_802_11_RSSI:
4814 case RT_OID_802_11_RSSI:
4815 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4816 wrq->u.data.length = sizeof(ulInfo);
4817 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4819 case RT_OID_802_11_RSSI_1:
4820 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4821 wrq->u.data.length = sizeof(ulInfo);
4822 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4824 case RT_OID_802_11_RSSI_2:
4825 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4826 wrq->u.data.length = sizeof(ulInfo);
4827 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4829 case OID_802_11_STATISTICS:
4830 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4833 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4834 // add the most up-to-date h/w raw counters into software counters
4835 NICUpdateRawCounters(pAdapter);
4837 // Sanity check for calculation of sucessful count
4838 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4839 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4841 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4842 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4843 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4844 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4845 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4846 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4847 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4848 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4849 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4850 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4851 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4853 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4855 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4856 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4858 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4859 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4864 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4868 case OID_GEN_RCV_OK:
4869 ulInfo = pAdapter->Counters8023.GoodReceives;
4870 wrq->u.data.length = sizeof(ulInfo);
4871 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4873 case OID_GEN_RCV_NO_BUFFER:
4874 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4875 wrq->u.data.length = sizeof(ulInfo);
4876 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4878 case RT_OID_802_11_PHY_MODE:
4879 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4880 wrq->u.data.length = sizeof(ulInfo);
4881 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4882 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4884 case RT_OID_802_11_STA_CONFIG:
4885 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4888 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4889 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4890 pStaConfig->EnableTurboRate = 0;
4891 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4892 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4893 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4894 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4895 pStaConfig->Rsv1 = 0;
4896 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4897 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4898 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4903 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4907 case OID_802_11_RTS_THRESHOLD:
4908 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4909 wrq->u.data.length = sizeof(RtsThresh);
4910 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4911 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4913 case OID_802_11_FRAGMENTATION_THRESHOLD:
4914 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4915 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4917 wrq->u.data.length = sizeof(FragThresh);
4918 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4919 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4921 case OID_802_11_POWER_MODE:
4922 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4923 wrq->u.data.length = sizeof(PowerMode);
4924 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4925 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4927 case RT_OID_802_11_RADIO:
4928 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4929 wrq->u.data.length = sizeof(RadioState);
4930 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4931 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4933 case OID_802_11_INFRASTRUCTURE_MODE:
4934 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4935 BssType = Ndis802_11IBSS;
4936 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4937 BssType = Ndis802_11Infrastructure;
4938 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4939 BssType = Ndis802_11Monitor;
4941 BssType = Ndis802_11AutoUnknown;
4943 wrq->u.data.length = sizeof(BssType);
4944 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4945 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4947 case RT_OID_802_11_PREAMBLE:
4948 PreamType = pAdapter->CommonCfg.TxPreamble;
4949 wrq->u.data.length = sizeof(PreamType);
4950 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4951 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4953 case OID_802_11_AUTHENTICATION_MODE:
4954 AuthMode = pAdapter->StaCfg.AuthMode;
4955 wrq->u.data.length = sizeof(AuthMode);
4956 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4957 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4959 case OID_802_11_WEP_STATUS:
4960 WepStatus = pAdapter->StaCfg.WepStatus;
4961 wrq->u.data.length = sizeof(WepStatus);
4962 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4963 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4965 case OID_802_11_TX_POWER_LEVEL:
4966 wrq->u.data.length = sizeof(ULONG);
4967 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4968 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4970 case RT_OID_802_11_TX_POWER_LEVEL_1:
4971 wrq->u.data.length = sizeof(ULONG);
4972 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4973 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4975 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4976 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4978 NetworkTypeList[0] = 3; // NumberOfItems = 3
4979 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4980 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4981 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4982 wrq->u.data.length = 16;
4983 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4987 NetworkTypeList[0] = 2; // NumberOfItems = 2
4988 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4989 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4990 wrq->u.data.length = 12;
4991 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4993 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4995 case OID_802_11_NETWORK_TYPE_IN_USE:
4996 wrq->u.data.length = sizeof(ULONG);
4997 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4998 ulInfo = Ndis802_11OFDM5;
4999 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5000 ulInfo = Ndis802_11OFDM24;
5002 ulInfo = Ndis802_11DS;
5003 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5005 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5006 ulInfo = (ULONG)pAdapter->LastRxRate;
5007 wrq->u.data.length = sizeof(ulInfo);
5008 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5009 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5011 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5012 //ulInfo = (ULONG)pAdapter->LastTxRate;
5013 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5014 wrq->u.data.length = sizeof(ulInfo);
5015 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5016 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5018 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5019 wrq->u.data.length = sizeof(ULONG);
5020 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5022 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5023 wrq->u.data.length = sizeof(ULONG);
5024 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5026 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5027 wrq->u.data.length = sizeof(UCHAR);
5028 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5029 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5031 case RT_OID_802_11_EXTRA_INFO:
5032 wrq->u.data.length = sizeof(ULONG);
5033 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5034 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5036 case RT_OID_WE_VERSION_COMPILED:
5037 wrq->u.data.length = sizeof(UINT);
5038 we_version_compiled = WIRELESS_EXT;
5039 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5041 case RT_OID_802_11_QUERY_APSD_SETTING:
5042 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5043 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5045 wrq->u.data.length = sizeof(ULONG);
5046 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5047 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",
5048 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5050 case RT_OID_802_11_QUERY_APSD_PSM:
5051 wrq->u.data.length = sizeof(ULONG);
5052 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5053 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5055 case RT_OID_802_11_QUERY_WMM:
5056 wrq->u.data.length = sizeof(BOOLEAN);
5057 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5058 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5060 #ifdef WPA_SUPPLICANT_SUPPORT
5061 case RT_OID_NEW_DRIVER:
5064 wrq->u.data.length = sizeof(UCHAR);
5065 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5066 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5069 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5070 wrq->u.data.length = sizeof(UCHAR);
5071 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5072 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5074 #endif // WPA_SUPPLICANT_SUPPORT //
5076 case RT_OID_DRIVER_DEVICE_NAME:
5077 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5078 wrq->u.data.length = 16;
5079 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5084 case RT_OID_802_11_QUERY_HT_PHYMODE:
5085 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5088 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5089 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5090 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5091 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5092 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5093 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5095 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5096 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5097 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5101 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5102 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5103 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5107 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5111 case RT_OID_802_11_COUNTRY_REGION:
5112 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5113 wrq->u.data.length = sizeof(ulInfo);
5114 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5115 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5116 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5121 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5122 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5125 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5126 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5127 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5128 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5129 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5130 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5132 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5133 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5137 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5138 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5139 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5143 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5147 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5148 wrq->u.data.length = sizeof(UCHAR);
5150 #ifdef MULTIPLE_CARD_SUPPORT
5152 #endif // MULTIPLE_CARD_SUPPORT //
5153 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5157 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5160 case RT_OID_802_11_MAC_ADDRESS:
5161 wrq->u.data.length = MAC_ADDR_LEN;
5162 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5165 case RT_OID_802_11_MANUFACTUREROUI:
5166 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5167 wrq->u.data.length = ManufacturerOUI_LEN;
5168 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5171 case RT_OID_802_11_MANUFACTURERNAME:
5172 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5173 wrq->u.data.length = strlen(ManufacturerNAME);
5174 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5177 case RT_OID_802_11_RESOURCETYPEIDNAME:
5178 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5179 wrq->u.data.length = strlen(ResourceTypeIdName);
5180 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5183 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5184 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5185 ulInfo = 1; // 1 is support wep else 2 is not support.
5186 wrq->u.data.length = sizeof(ulInfo);
5187 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5190 case RT_OID_802_11_POWERMANAGEMENTMODE:
5191 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5192 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5193 ulInfo = 1; // 1 is power active else 2 is power save.
5197 wrq->u.data.length = sizeof(ulInfo);
5198 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5201 case OID_802_11_WEPDEFAULTKEYVALUE:
5202 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5203 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5204 pKeyIdxValue = wrq->u.data.pointer;
5205 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5206 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5207 NdisMoveMemory(pKeyIdxValue->Value,
5208 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5210 pKeyIdxValue->Value[valueLen]='\0';
5212 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5214 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5215 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,
5216 pAdapter->SharedKey[BSS0][0].Key[0],
5217 pAdapter->SharedKey[BSS0][1].Key[0],
5218 pAdapter->SharedKey[BSS0][2].Key[0],
5219 pAdapter->SharedKey[BSS0][3].Key[0]));
5222 case OID_802_11_WEPDEFAULTKEYID:
5223 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5224 wrq->u.data.length = sizeof(UCHAR);
5225 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5226 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5229 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5230 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5231 wrq->u.data.length = sizeof(UCHAR);
5232 Status = copy_to_user(wrq->u.data.pointer,
5233 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5234 wrq->u.data.length);
5237 case OID_802_11_SHORTRETRYLIMIT:
5238 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5239 wrq->u.data.length = sizeof(ULONG);
5240 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5241 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5242 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5243 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5246 case OID_802_11_LONGRETRYLIMIT:
5247 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5248 wrq->u.data.length = sizeof(ULONG);
5249 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5250 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5251 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5252 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5255 case RT_OID_802_11_PRODUCTID:
5256 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5262 if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
5263 pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5265 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5266 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5269 wrq->u.data.length = strlen(tmp);
5270 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5273 case RT_OID_802_11_MANUFACTUREID:
5274 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5275 wrq->u.data.length = strlen(ManufacturerNAME);
5276 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5279 case OID_802_11_CURRENTCHANNEL:
5280 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5281 wrq->u.data.length = sizeof(UCHAR);
5282 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5283 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5284 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5286 #endif //SNMP_SUPPORT
5288 case OID_802_11_BUILD_CHANNEL_EX:
5291 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5292 wrq->u.data.length = sizeof(UCHAR);
5293 #ifdef EXT_BUILD_CHANNEL_LIST
5294 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5297 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5299 #endif // EXT_BUILD_CHANNEL_LIST //
5300 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5301 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5305 case OID_802_11_GET_CH_LIST:
5307 PRT_CHANNEL_LIST_INFO pChListBuf;
5309 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5310 if (pAdapter->ChannelListNum == 0)
5312 wrq->u.data.length = 0;
5316 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5317 if (pChListBuf == NULL)
5319 wrq->u.data.length = 0;
5323 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5324 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5325 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5327 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5328 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5329 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5336 case OID_802_11_GET_COUNTRY_CODE:
5337 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5338 wrq->u.data.length = 2;
5339 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5340 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5343 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5344 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5345 wrq->u.data.length = 1;
5346 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5347 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5351 #ifdef QOS_DLS_SUPPORT
5352 case RT_OID_802_11_QUERY_DLS:
5353 wrq->u.data.length = sizeof(BOOLEAN);
5354 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5355 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5358 case RT_OID_802_11_QUERY_DLS_PARAM:
5360 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5361 if (pDlsInfo == NULL)
5364 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5366 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5369 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5370 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5371 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5372 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5378 #endif // QOS_DLS_SUPPORT //
5380 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5381 Status = -EOPNOTSUPP;
5387 INT rt28xx_sta_ioctl(
5388 IN struct net_device *net_dev,
5389 IN OUT struct ifreq *rq,
5393 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5394 RTMP_ADAPTER *pAd = NULL;
5395 struct iwreq *wrq = (struct iwreq *) rq;
5396 BOOLEAN StateMachineTouched = FALSE;
5397 INT Status = NDIS_STATUS_SUCCESS;
5400 if (net_dev->priv_flags == INT_MAIN)
5402 pAd = net_dev->ml_priv;
5406 pVirtualAd = net_dev->ml_priv;
5407 pAd = pVirtualAd->RtmpDev->ml_priv;
5409 pObj = (POS_COOKIE) pAd->OS_Cookie;
5413 /* if 1st open fail, pAd will be free;
5414 So the net_dev->ml_priv will be NULL in 2rd open */
5418 //check if the interface is down
5419 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5421 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5422 if (wrq->u.data.pointer == NULL)
5427 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5428 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5430 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5435 { // determine this ioctl command is comming from which interface.
5436 pObj->ioctl_if_type = INT_MAIN;
5437 pObj->ioctl_if = MAIN_MBSSID;
5443 #ifdef RALINK_28xx_QA
5444 case RTPRIV_IOCTL_ATE:
5446 RtmpDoAte(pAd, wrq);
5449 #endif // RALINK_28xx_QA //
5450 #endif // RALINK_ATE //
5452 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5453 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5457 char *name=&wrq->u.name[0];
5458 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5461 case SIOCGIWESSID: //Get ESSID
5463 struct iw_point *essid=&wrq->u.essid;
5464 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5467 case SIOCSIWESSID: //Set ESSID
5469 struct iw_point *essid=&wrq->u.essid;
5470 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5473 case SIOCSIWNWID: // set network id (the cell)
5474 case SIOCGIWNWID: // get network id
5475 Status = -EOPNOTSUPP;
5477 case SIOCSIWFREQ: //set channel/frequency (Hz)
5479 struct iw_freq *freq=&wrq->u.freq;
5480 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5483 case SIOCGIWFREQ: // get channel/frequency (Hz)
5485 struct iw_freq *freq=&wrq->u.freq;
5486 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5489 case SIOCSIWNICKN: //set node name/nickname
5491 struct iw_point *data=&wrq->u.data;
5492 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5495 case SIOCGIWNICKN: //get node name/nickname
5497 struct iw_point *data=&wrq->u.data;
5498 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5501 case SIOCGIWRATE: //get default bit rate (bps)
5502 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5504 case SIOCSIWRATE: //set default bit rate (bps)
5505 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5507 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5509 struct iw_param *rts=&wrq->u.rts;
5510 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5513 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5515 struct iw_param *rts=&wrq->u.rts;
5516 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5519 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5521 struct iw_param *frag=&wrq->u.frag;
5522 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5525 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5527 struct iw_param *frag=&wrq->u.frag;
5528 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5531 case SIOCGIWENCODE: //get encoding token & mode
5533 struct iw_point *erq=&wrq->u.encoding;
5535 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5538 case SIOCSIWENCODE: //set encoding token & mode
5540 struct iw_point *erq=&wrq->u.encoding;
5542 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5545 case SIOCGIWAP: //get access point MAC addresses
5547 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5548 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5551 case SIOCSIWAP: //set access point MAC addresses
5553 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5554 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5557 case SIOCGIWMODE: //get operation mode
5559 __u32 *mode=&wrq->u.mode;
5560 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5563 case SIOCSIWMODE: //set operation mode
5565 __u32 *mode=&wrq->u.mode;
5566 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5569 case SIOCGIWSENS: //get sensitivity (dBm)
5570 case SIOCSIWSENS: //set sensitivity (dBm)
5571 case SIOCGIWPOWER: //get Power Management settings
5572 case SIOCSIWPOWER: //set Power Management settings
5573 case SIOCGIWTXPOW: //get transmit power (dBm)
5574 case SIOCSIWTXPOW: //set transmit power (dBm)
5575 case SIOCGIWRANGE: //Get range of parameters
5576 case SIOCGIWRETRY: //get retry limits and lifetime
5577 case SIOCSIWRETRY: //set retry limits and lifetime
5578 Status = -EOPNOTSUPP;
5581 subcmd = wrq->u.data.flags;
5582 if( subcmd & OID_GET_SET_TOGGLE)
5583 Status = RTMPSetInformation(pAd, rq, subcmd);
5585 Status = RTMPQueryInformation(pAd, rq, subcmd);
5588 if (wrq->u.data.pointer)
5590 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5592 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5593 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5597 case RTPRIV_IOCTL_SET:
5598 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5600 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5602 case RTPRIV_IOCTL_GSITESURVEY:
5603 RTMPIoctlGetSiteSurvey(pAd, wrq);
5606 case RTPRIV_IOCTL_MAC:
5607 RTMPIoctlMAC(pAd, wrq);
5609 case RTPRIV_IOCTL_E2P:
5610 RTMPIoctlE2PROM(pAd, wrq);
5616 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5617 Status = -EOPNOTSUPP;
5621 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5622 RT28XX_MLME_HANDLER(pAd);
5628 ==========================================================================
5632 TRUE if all parameters are OK, FALSE otherwise
5633 ==========================================================================
5636 IN PRTMP_ADAPTER pAdapter,
5639 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5640 BOOLEAN StateMachineTouched = FALSE;
5643 if( strlen(arg) <= MAX_LEN_OF_SSID)
5645 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5646 if (strlen(arg) != 0)
5648 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5649 Ssid.SsidLength = strlen(arg);
5653 Ssid.SsidLength = 0;
5654 memcpy(Ssid.Ssid, "", 0);
5655 pAdapter->StaCfg.BssType = BSS_INFRA;
5656 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5657 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5661 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5663 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5664 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5667 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5668 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5669 pAdapter->bConfigChanged = TRUE;
5671 MlmeEnqueue(pAdapter,
5672 MLME_CNTL_STATE_MACHINE,
5674 sizeof(NDIS_802_11_SSID),
5677 StateMachineTouched = TRUE;
5678 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5683 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5684 RT28XX_MLME_HANDLER(pAdapter);
5691 ==========================================================================
5693 Set WmmCapable Enable or Disable
5695 TRUE if all parameters are OK, FALSE otherwise
5696 ==========================================================================
5698 INT Set_WmmCapable_Proc(
5699 IN PRTMP_ADAPTER pAd,
5702 BOOLEAN bWmmCapable;
5704 bWmmCapable = simple_strtol(arg, 0, 10);
5706 if ((bWmmCapable == 1)
5708 pAd->CommonCfg.bWmmCapable = TRUE;
5709 else if (bWmmCapable == 0)
5710 pAd->CommonCfg.bWmmCapable = FALSE;
5712 return FALSE; //Invalid argument
5714 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5715 pAd->CommonCfg.bWmmCapable));
5719 #endif // WMM_SUPPORT //
5722 ==========================================================================
5724 Set Network Type(Infrastructure/Adhoc mode)
5726 TRUE if all parameters are OK, FALSE otherwise
5727 ==========================================================================
5729 INT Set_NetworkType_Proc(
5730 IN PRTMP_ADAPTER pAdapter,
5735 if (strcmp(arg, "Adhoc") == 0)
5737 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5739 // Config has changed
5740 pAdapter->bConfigChanged = TRUE;
5741 if (MONITOR_ON(pAdapter))
5743 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5744 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5746 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5747 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5748 pAdapter->StaCfg.bAutoReconnect = TRUE;
5749 LinkDown(pAdapter, FALSE);
5751 if (INFRA_ON(pAdapter))
5753 //BOOLEAN Cancelled;
5754 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5755 // Since calling this indicate user don't want to connect to that SSID anymore.
5756 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5757 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5759 LinkDown(pAdapter, FALSE);
5761 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5764 pAdapter->StaCfg.BssType = BSS_ADHOC;
5765 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5766 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5768 else if (strcmp(arg, "Infra") == 0)
5770 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5772 // Config has changed
5773 pAdapter->bConfigChanged = TRUE;
5774 if (MONITOR_ON(pAdapter))
5776 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5777 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5779 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5780 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5781 pAdapter->StaCfg.bAutoReconnect = TRUE;
5782 LinkDown(pAdapter, FALSE);
5784 if (ADHOC_ON(pAdapter))
5786 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5787 // Since calling this indicate user don't want to connect to that SSID anymore.
5788 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5789 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5791 LinkDown(pAdapter, FALSE);
5794 pAdapter->StaCfg.BssType = BSS_INFRA;
5795 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5796 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5798 pAdapter->StaCfg.BssType = BSS_INFRA;
5800 else if (strcmp(arg, "Monitor") == 0)
5803 BCN_TIME_CFG_STRUC csr;
5804 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5805 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5806 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5807 // disable all periodic state machine
5808 pAdapter->StaCfg.bAutoReconnect = FALSE;
5809 // reset all mlme state machine
5810 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5811 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5812 if (pAdapter->CommonCfg.CentralChannel == 0)
5814 #ifdef DOT11_N_SUPPORT
5815 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5816 pAdapter->CommonCfg.CentralChannel = 36;
5818 #endif // DOT11_N_SUPPORT //
5819 pAdapter->CommonCfg.CentralChannel = 6;
5821 #ifdef DOT11_N_SUPPORT
5823 N_ChannelCheck(pAdapter);
5824 #endif // DOT11_N_SUPPORT //
5826 #ifdef DOT11_N_SUPPORT
5827 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5828 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5829 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5831 // 40MHz ,control channel at lower
5832 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5833 bbpValue &= (~0x18);
5835 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5836 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5837 // RX : control channel at lower
5838 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5839 bbpValue &= (~0x20);
5840 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5842 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5843 Value &= 0xfffffffe;
5844 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5845 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5846 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5847 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5848 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5849 pAdapter->CommonCfg.Channel,
5850 pAdapter->CommonCfg.CentralChannel));
5852 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5853 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5854 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5856 // 40MHz ,control channel at upper
5857 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5858 bbpValue &= (~0x18);
5860 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5861 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5862 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5864 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5866 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5868 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5869 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5870 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5871 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5872 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5873 pAdapter->CommonCfg.Channel,
5874 pAdapter->CommonCfg.CentralChannel));
5877 #endif // DOT11_N_SUPPORT //
5880 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5881 bbpValue &= (~0x18);
5882 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5883 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5884 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5885 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5886 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5888 // Enable Rx with promiscuous reception
5889 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5890 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5891 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5893 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5895 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5896 csr.field.bBeaconGen = 0;
5897 csr.field.bTBTTEnable = 0;
5898 csr.field.TsfSyncMode = 0;
5899 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5901 pAdapter->StaCfg.BssType = BSS_MONITOR;
5902 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5903 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5906 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5907 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5909 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5915 ==========================================================================
5917 Set Authentication mode
5919 TRUE if all parameters are OK, FALSE otherwise
5920 ==========================================================================
5922 INT Set_AuthMode_Proc(
5923 IN PRTMP_ADAPTER pAdapter,
5926 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5927 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5928 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5929 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5930 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5931 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5932 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5933 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5934 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5935 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5936 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5937 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5938 #ifdef WPA_SUPPLICANT_SUPPORT
5939 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5940 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5941 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5942 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5943 #endif // WPA_SUPPLICANT_SUPPORT //
5947 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5949 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5955 ==========================================================================
5959 TRUE if all parameters are OK, FALSE otherwise
5960 ==========================================================================
5962 INT Set_EncrypType_Proc(
5963 IN PRTMP_ADAPTER pAdapter,
5966 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5968 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5969 return TRUE; // do nothing
5971 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5972 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5973 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5975 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5977 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5978 return TRUE; // do nothing
5980 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5981 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5982 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5984 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5986 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5987 return TRUE; // do nothing
5989 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5990 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5991 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5993 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5995 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5996 return TRUE; // do nothing
5998 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5999 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6000 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6005 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6007 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6013 ==========================================================================
6017 TRUE if all parameters are OK, FALSE otherwise
6018 ==========================================================================
6020 INT Set_DefaultKeyID_Proc(
6021 IN PRTMP_ADAPTER pAdapter,
6026 KeyIdx = simple_strtol(arg, 0, 10);
6027 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6028 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6030 return FALSE; //Invalid argument
6032 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6038 ==========================================================================
6042 TRUE if all parameters are OK, FALSE otherwise
6043 ==========================================================================
6046 IN PRTMP_ADAPTER pAdapter,
6051 UCHAR CipherAlg=CIPHER_WEP64;
6053 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6054 return TRUE; // do nothing
6056 KeyLen = strlen(arg);
6060 case 5: //wep 40 Ascii type
6061 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6062 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6063 CipherAlg = CIPHER_WEP64;
6064 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6066 case 10: //wep 40 Hex type
6067 for(i=0; i < KeyLen; i++)
6069 if( !isxdigit(*(arg+i)) )
6070 return FALSE; //Not Hex value;
6072 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6073 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6074 CipherAlg = CIPHER_WEP64;
6075 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6077 case 13: //wep 104 Ascii type
6078 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6079 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6080 CipherAlg = CIPHER_WEP128;
6081 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6083 case 26: //wep 104 Hex type
6084 for(i=0; i < KeyLen; i++)
6086 if( !isxdigit(*(arg+i)) )
6087 return FALSE; //Not Hex value;
6089 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6090 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6091 CipherAlg = CIPHER_WEP128;
6092 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6094 default: //Invalid argument
6095 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6099 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6101 // Set keys (into ASIC)
6102 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6104 else // Old WEP stuff
6106 AsicAddSharedKeyEntry(pAdapter,
6109 pAdapter->SharedKey[BSS0][0].CipherAlg,
6110 pAdapter->SharedKey[BSS0][0].Key,
6118 ==========================================================================
6123 TRUE if all parameters are OK, FALSE otherwise
6124 ==========================================================================
6127 IN PRTMP_ADAPTER pAdapter,
6132 UCHAR CipherAlg=CIPHER_WEP64;
6134 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6135 return TRUE; // do nothing
6137 KeyLen = strlen(arg);
6141 case 5: //wep 40 Ascii type
6142 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6143 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6144 CipherAlg = CIPHER_WEP64;
6145 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6147 case 10: //wep 40 Hex type
6148 for(i=0; i < KeyLen; i++)
6150 if( !isxdigit(*(arg+i)) )
6151 return FALSE; //Not Hex value;
6153 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6154 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6155 CipherAlg = CIPHER_WEP64;
6156 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6158 case 13: //wep 104 Ascii type
6159 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6160 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6161 CipherAlg = CIPHER_WEP128;
6162 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6164 case 26: //wep 104 Hex type
6165 for(i=0; i < KeyLen; i++)
6167 if( !isxdigit(*(arg+i)) )
6168 return FALSE; //Not Hex value;
6170 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6171 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6172 CipherAlg = CIPHER_WEP128;
6173 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6175 default: //Invalid argument
6176 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6179 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6181 // Set keys (into ASIC)
6182 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6184 else // Old WEP stuff
6186 AsicAddSharedKeyEntry(pAdapter,
6189 pAdapter->SharedKey[BSS0][1].CipherAlg,
6190 pAdapter->SharedKey[BSS0][1].Key,
6198 ==========================================================================
6202 TRUE if all parameters are OK, FALSE otherwise
6203 ==========================================================================
6206 IN PRTMP_ADAPTER pAdapter,
6211 UCHAR CipherAlg=CIPHER_WEP64;
6213 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6214 return TRUE; // do nothing
6216 KeyLen = strlen(arg);
6220 case 5: //wep 40 Ascii type
6221 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6222 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6223 CipherAlg = CIPHER_WEP64;
6224 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6226 case 10: //wep 40 Hex type
6227 for(i=0; i < KeyLen; i++)
6229 if( !isxdigit(*(arg+i)) )
6230 return FALSE; //Not Hex value;
6232 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6233 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6234 CipherAlg = CIPHER_WEP64;
6235 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6237 case 13: //wep 104 Ascii type
6238 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6239 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6240 CipherAlg = CIPHER_WEP128;
6241 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6243 case 26: //wep 104 Hex type
6244 for(i=0; i < KeyLen; i++)
6246 if( !isxdigit(*(arg+i)) )
6247 return FALSE; //Not Hex value;
6249 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6250 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6251 CipherAlg = CIPHER_WEP128;
6252 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6254 default: //Invalid argument
6255 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6258 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6260 // Set keys (into ASIC)
6261 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6263 else // Old WEP stuff
6265 AsicAddSharedKeyEntry(pAdapter,
6268 pAdapter->SharedKey[BSS0][2].CipherAlg,
6269 pAdapter->SharedKey[BSS0][2].Key,
6277 ==========================================================================
6281 TRUE if all parameters are OK, FALSE otherwise
6282 ==========================================================================
6285 IN PRTMP_ADAPTER pAdapter,
6290 UCHAR CipherAlg=CIPHER_WEP64;
6292 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6293 return TRUE; // do nothing
6295 KeyLen = strlen(arg);
6299 case 5: //wep 40 Ascii type
6300 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6301 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6302 CipherAlg = CIPHER_WEP64;
6303 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6305 case 10: //wep 40 Hex type
6306 for(i=0; i < KeyLen; i++)
6308 if( !isxdigit(*(arg+i)) )
6309 return FALSE; //Not Hex value;
6311 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6312 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6313 CipherAlg = CIPHER_WEP64;
6314 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6316 case 13: //wep 104 Ascii type
6317 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6318 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6319 CipherAlg = CIPHER_WEP128;
6320 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6322 case 26: //wep 104 Hex type
6323 for(i=0; i < KeyLen; i++)
6325 if( !isxdigit(*(arg+i)) )
6326 return FALSE; //Not Hex value;
6328 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6329 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6330 CipherAlg = CIPHER_WEP128;
6331 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6333 default: //Invalid argument
6334 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6337 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6339 // Set keys (into ASIC)
6340 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6342 else // Old WEP stuff
6344 AsicAddSharedKeyEntry(pAdapter,
6347 pAdapter->SharedKey[BSS0][3].CipherAlg,
6348 pAdapter->SharedKey[BSS0][3].Key,
6357 ==========================================================================
6361 TRUE if all parameters are OK, FALSE otherwise
6362 ==========================================================================
6364 INT Set_WPAPSK_Proc(
6365 IN PRTMP_ADAPTER pAdapter,
6368 UCHAR keyMaterial[40];
6370 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6371 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6372 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6374 return TRUE; // do nothing
6376 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6378 NdisZeroMemory(keyMaterial, 40);
6380 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6382 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6386 if (strlen(arg) == 64)
6388 AtoH(arg, keyMaterial, 32);
6389 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6394 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6395 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6400 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6401 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6403 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6407 // Start STA supplicant state machine
6408 pAdapter->StaCfg.WpaState = SS_START;
6415 ==========================================================================
6417 Set Power Saving mode
6419 TRUE if all parameters are OK, FALSE otherwise
6420 ==========================================================================
6422 INT Set_PSMode_Proc(
6423 IN PRTMP_ADAPTER pAdapter,
6426 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6428 if ((strcmp(arg, "Max_PSP") == 0) ||
6429 (strcmp(arg, "max_psp") == 0) ||
6430 (strcmp(arg, "MAX_PSP") == 0))
6432 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6433 // to exclude certain situations.
6434 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6435 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6436 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6437 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6438 pAdapter->StaCfg.DefaultListenCount = 5;
6441 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6442 (strcmp(arg, "fast_psp") == 0) ||
6443 (strcmp(arg, "FAST_PSP") == 0))
6445 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6446 // to exclude certain situations.
6447 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6448 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6449 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6450 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6451 pAdapter->StaCfg.DefaultListenCount = 3;
6453 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6454 (strcmp(arg, "legacy_psp") == 0) ||
6455 (strcmp(arg, "LEGACY_PSP") == 0))
6457 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6458 // to exclude certain situations.
6459 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6460 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6461 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6462 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6463 pAdapter->StaCfg.DefaultListenCount = 3;
6467 //Default Ndis802_11PowerModeCAM
6468 // clear PSM bit immediately
6469 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6470 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6471 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6472 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6473 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6476 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6485 #ifdef WPA_SUPPLICANT_SUPPORT
6487 ==========================================================================
6489 Set WpaSupport flag.
6491 0: Driver ignore wpa_supplicant.
6492 1: wpa_supplicant initiates scanning and AP selection.
6493 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6495 TRUE if all parameters are OK, FALSE otherwise
6496 ==========================================================================
6498 INT Set_Wpa_Support(
6499 IN PRTMP_ADAPTER pAd,
6503 if ( simple_strtol(arg, 0, 10) == 0)
6504 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6505 else if ( simple_strtol(arg, 0, 10) == 1)
6506 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6507 else if ( simple_strtol(arg, 0, 10) == 2)
6508 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6510 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6512 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6516 #endif // WPA_SUPPLICANT_SUPPORT //
6520 ==========================================================================
6524 pAdapter Pointer to our adapter
6525 wrq Pointer to the ioctl argument
6532 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6533 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6534 ==========================================================================
6537 IN PRTMP_ADAPTER pAdapter,
6538 IN struct iwreq *wrq)
6546 UCHAR temp[16], temp2[16];
6547 UINT32 macValue = 0;
6551 memset(msg, 0x00, 1024);
6552 if (wrq->u.data.length > 1) //No parameters.
6554 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6557 //Parsing Read or Write
6562 if ((value = rtstrchr(this_char, '=')) != NULL)
6565 if (!value || !*value)
6568 if(strlen(this_char) > 4)
6571 j = strlen(this_char);
6574 if(this_char[j] > 'f' || this_char[j] < '0')
6579 k = j = strlen(this_char);
6582 this_char[4-k+j] = this_char[j];
6586 this_char[3-k++]='0';
6589 if(strlen(this_char) == 4)
6591 AtoH(this_char, temp, 2);
6592 macAddr = *temp*256 + temp[1];
6593 if (macAddr < 0xFFFF)
6595 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6596 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6597 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6600 {//Invalid parametes, so default printk all bbp
6607 memcpy(&temp2, value, strlen(value));
6608 temp2[strlen(value)] = '\0';
6611 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6614 j = strlen(this_char);
6617 if(this_char[j] > 'f' || this_char[j] < '0')
6624 if(temp2[j] > 'f' || temp2[j] < '0')
6629 k = j = strlen(this_char);
6632 this_char[4-k+j] = this_char[j];
6636 this_char[3-k++]='0';
6640 k = j = strlen(temp2);
6643 temp2[8-k+j] = temp2[j];
6651 AtoH(this_char, temp, 2);
6652 macAddr = *temp*256 + temp[1];
6654 AtoH(temp2, temp, 4);
6655 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6658 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6660 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6661 if (macValue & 0x000000ff)
6663 pAdapter->BbpTuning.bEnable = TRUE;
6664 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6669 pAdapter->BbpTuning.bEnable = FALSE;
6670 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6672 if (ATE_ON(pAdapter))
6674 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6677 #endif // RALINK_ATE //
6678 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6679 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6684 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6686 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6687 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6692 if(strlen(msg) == 1)
6693 sprintf(msg+strlen(msg), "===>Error command format!");
6695 // Copy the information into the user buffer
6696 wrq->u.data.length = strlen(msg);
6697 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6699 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6703 ==========================================================================
6707 pAdapter Pointer to our adapter
6708 wrq Pointer to the ioctl argument
6715 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6716 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6717 ==========================================================================
6719 VOID RTMPIoctlE2PROM(
6720 IN PRTMP_ADAPTER pAdapter,
6721 IN struct iwreq *wrq)
6729 UCHAR temp[16], temp2[16];
6734 memset(msg, 0x00, 1024);
6735 if (wrq->u.data.length > 1) //No parameters.
6737 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6740 //Parsing Read or Write
6747 if ((value = rtstrchr(this_char, '=')) != NULL)
6750 if (!value || !*value)
6754 if(strlen(this_char) > 4)
6757 j = strlen(this_char);
6760 if(this_char[j] > 'f' || this_char[j] < '0')
6765 k = j = strlen(this_char);
6768 this_char[4-k+j] = this_char[j];
6772 this_char[3-k++]='0';
6775 if(strlen(this_char) == 4)
6777 AtoH(this_char, temp, 2);
6778 eepAddr = *temp*256 + temp[1];
6779 if (eepAddr < 0xFFFF)
6781 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6782 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6785 {//Invalid parametes, so default printk all bbp
6792 memcpy(&temp2, value, strlen(value));
6793 temp2[strlen(value)] = '\0';
6796 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6799 j = strlen(this_char);
6802 if(this_char[j] > 'f' || this_char[j] < '0')
6808 if(temp2[j] > 'f' || temp2[j] < '0')
6813 k = j = strlen(this_char);
6816 this_char[4-k+j] = this_char[j];
6820 this_char[3-k++]='0';
6824 k = j = strlen(temp2);
6827 temp2[4-k+j] = temp2[j];
6834 AtoH(this_char, temp, 2);
6835 eepAddr = *temp*256 + temp[1];
6837 AtoH(temp2, temp, 2);
6838 eepValue = *temp*256 + temp[1];
6840 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6841 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6845 if(strlen(msg) == 1)
6846 sprintf(msg+strlen(msg), "===>Error command format!");
6849 // Copy the information into the user buffer
6850 wrq->u.data.length = strlen(msg);
6851 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6853 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6860 INT Set_TGnWifiTest_Proc(
6861 IN PRTMP_ADAPTER pAd,
6864 if (simple_strtol(arg, 0, 10) == 0)
6865 pAd->StaCfg.bTGnWifiTest = FALSE;
6867 pAd->StaCfg.bTGnWifiTest = TRUE;
6869 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6873 INT Set_LongRetryLimit_Proc(
6874 IN PRTMP_ADAPTER pAdapter,
6877 TX_RTY_CFG_STRUC tx_rty_cfg;
6878 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6880 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6881 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6882 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6883 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6887 INT Set_ShortRetryLimit_Proc(
6888 IN PRTMP_ADAPTER pAdapter,
6891 TX_RTY_CFG_STRUC tx_rty_cfg;
6892 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6894 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6895 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6896 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6897 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6901 #ifdef EXT_BUILD_CHANNEL_LIST
6902 INT Set_Ieee80211dClientMode_Proc(
6903 IN PRTMP_ADAPTER pAdapter,
6906 if (simple_strtol(arg, 0, 10) == 0)
6907 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6908 else if (simple_strtol(arg, 0, 10) == 1)
6909 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6910 else if (simple_strtol(arg, 0, 10) == 2)
6911 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6915 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6918 #endif // EXT_BUILD_CHANNEL_LIST //
6920 #ifdef CARRIER_DETECTION_SUPPORT
6921 INT Set_CarrierDetect_Proc(
6922 IN PRTMP_ADAPTER pAd,
6925 if (simple_strtol(arg, 0, 10) == 0)
6926 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6928 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6930 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6933 #endif // CARRIER_DETECTION_SUPPORT //