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 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
356 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
358 if (pAd->StaCfg.bRadio == FALSE)
360 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
361 return (NDIS_STATUS_SUCCESS);
363 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
364 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
366 pAd->bPCIclkOff = FALSE;
369 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
371 if (pKey->KeyIndex & 0x80000000)
373 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
375 NdisZeroMemory(pAd->StaCfg.PMK, 32);
376 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
380 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
381 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
382 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
383 #ifdef WPA_SUPPLICANT_SUPPORT
384 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
386 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
387 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
390 #endif // WPA_SUPPLICANT_SUPPORT //
392 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
393 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
396 // Decide its ChiperAlg
397 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
398 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
399 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
400 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
402 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
404 // Update these related information to MAC_TABLE_ENTRY
405 pEntry = &pAd->MacTab.Content[BSSID_WCID];
406 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
407 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
408 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
409 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
411 // Update pairwise key information to ASIC Shared Key Table
412 AsicAddSharedKeyEntry(pAd,
415 pAd->SharedKey[BSS0][0].CipherAlg,
416 pAd->SharedKey[BSS0][0].Key,
417 pAd->SharedKey[BSS0][0].TxMic,
418 pAd->SharedKey[BSS0][0].RxMic);
420 // Update ASIC WCID attribute table and IVEIV table
421 RTMPAddWcidAttributeEntry(pAd,
424 pAd->SharedKey[BSS0][0].CipherAlg,
427 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
429 // set 802.1x port control
430 STA_PORT_SECURED(pAd);
432 // Indicate Connected for GUI
433 pAd->IndicateMediaState = NdisMediaStateConnected;
439 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
440 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
441 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
442 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
443 #ifdef WPA_SUPPLICANT_SUPPORT
444 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
446 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
447 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
450 #endif // WPA_SUPPLICANT_SUPPORT //
452 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
453 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
456 // Update Shared Key CipherAlg
457 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
458 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
459 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
460 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
461 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
463 // Update group key information to ASIC Shared Key Table
464 AsicAddSharedKeyEntry(pAd,
466 pAd->StaCfg.DefaultKeyId,
467 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
468 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
469 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
470 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
472 // Update ASIC WCID attribute table and IVEIV table
473 RTMPAddWcidAttributeEntry(pAd,
475 pAd->StaCfg.DefaultKeyId,
476 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
479 // set 802.1x port control
480 STA_PORT_SECURED(pAd);
482 // Indicate Connected for GUI
483 pAd->IndicateMediaState = NdisMediaStateConnected;
486 else // dynamic WEP from wpa_supplicant
491 if(pKey->KeyLength == 32)
494 KeyIdx = pKey->KeyIndex & 0x0fffffff;
498 // it is a default shared key, for Pairwise key setting
499 if (pKey->KeyIndex & 0x80000000)
501 pEntry = MacTableLookup(pAd, pKey->BSSID);
505 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
507 // set key material and key length
508 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
509 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
512 if (pKey->KeyLength == 5)
513 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
515 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
517 // Add Pair-wise key to Asic
518 AsicAddPairwiseKeyEntry(
522 &pEntry->PairwiseKey);
524 // update WCID attribute table and IVEIV table for this entry
525 RTMPAddWcidAttributeEntry(
528 KeyIdx, // The value may be not zero
529 pEntry->PairwiseKey.CipherAlg,
536 // Default key for tx (shared key)
537 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
539 // set key material and key length
540 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
541 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
544 if (pKey->KeyLength == 5)
545 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
547 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
549 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
550 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
552 // Set Group key material to Asic
553 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
555 // Update WCID attribute table and IVEIV table for this group key table
556 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
562 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
563 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
567 char * rtstrchr(const char * s, int c)
569 for(; *s != (char) c; ++s)
576 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
580 rt_ioctl_giwname(struct net_device *dev,
581 struct iw_request_info *info,
582 char *name, char *extra)
584 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
587 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
592 int rt_ioctl_siwfreq(struct net_device *dev,
593 struct iw_request_info *info,
594 struct iw_freq *freq, char *extra)
596 PRTMP_ADAPTER pAdapter = dev->ml_priv;
599 //check if the interface is down
600 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
602 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
610 if((freq->e == 0) && (freq->m <= 1000))
611 chan = freq->m; // Setting by channel number
613 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
615 if (ChannelSanity(pAdapter, chan) == TRUE)
617 pAdapter->CommonCfg.Channel = chan;
618 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
625 int rt_ioctl_giwfreq(struct net_device *dev,
626 struct iw_request_info *info,
627 struct iw_freq *freq, char *extra)
629 VIRTUAL_ADAPTER *pVirtualAd = NULL;
630 PRTMP_ADAPTER pAdapter = NULL;
634 if (dev->priv_flags == INT_MAIN)
636 pAdapter = dev->ml_priv;
640 pVirtualAd = dev->ml_priv;
641 if (pVirtualAd && pVirtualAd->RtmpDev)
642 pAdapter = pVirtualAd->RtmpDev->ml_priv;
645 if (pAdapter == NULL)
647 /* if 1st open fail, pAd will be free;
648 So the net_dev->ml_priv will be NULL in 2rd open */
652 ch = pAdapter->CommonCfg.Channel;
654 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
656 MAP_CHANNEL_ID_TO_KHZ(ch, m);
662 int rt_ioctl_siwmode(struct net_device *dev,
663 struct iw_request_info *info,
664 __u32 *mode, char *extra)
666 PRTMP_ADAPTER pAdapter = dev->ml_priv;
668 //check if the interface is down
669 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
671 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
678 Set_NetworkType_Proc(pAdapter, "Adhoc");
681 Set_NetworkType_Proc(pAdapter, "Infra");
683 case IW_MODE_MONITOR:
684 Set_NetworkType_Proc(pAdapter, "Monitor");
687 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
691 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
692 pAdapter->StaCfg.WpaState = SS_NOTUSE;
697 int rt_ioctl_giwmode(struct net_device *dev,
698 struct iw_request_info *info,
699 __u32 *mode, char *extra)
701 PRTMP_ADAPTER pAdapter = NULL;
702 VIRTUAL_ADAPTER *pVirtualAd = NULL;
704 if (dev->priv_flags == INT_MAIN)
706 pAdapter = dev->ml_priv;
710 pVirtualAd = dev->ml_priv;
711 if (pVirtualAd && pVirtualAd->RtmpDev)
712 pAdapter = pVirtualAd->RtmpDev->ml_priv;
715 if (pAdapter == NULL)
717 /* if 1st open fail, pAd will be free;
718 So the net_dev->ml_priv will be NULL in 2rd open */
722 if (ADHOC_ON(pAdapter))
723 *mode = IW_MODE_ADHOC;
724 else if (INFRA_ON(pAdapter))
725 *mode = IW_MODE_INFRA;
726 else if (MONITOR_ON(pAdapter))
728 *mode = IW_MODE_MONITOR;
731 *mode = IW_MODE_AUTO;
733 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
737 int rt_ioctl_siwsens(struct net_device *dev,
738 struct iw_request_info *info,
739 char *name, char *extra)
741 PRTMP_ADAPTER pAdapter = dev->ml_priv;
743 //check if the interface is down
744 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
746 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
753 int rt_ioctl_giwsens(struct net_device *dev,
754 struct iw_request_info *info,
755 char *name, char *extra)
760 int rt_ioctl_giwrange(struct net_device *dev,
761 struct iw_request_info *info,
762 struct iw_point *data, char *extra)
764 PRTMP_ADAPTER pAdapter = NULL;
765 VIRTUAL_ADAPTER *pVirtualAd = NULL;
766 struct iw_range *range = (struct iw_range *) extra;
770 if (dev->priv_flags == INT_MAIN)
772 pAdapter = dev->ml_priv;
776 pVirtualAd = dev->ml_priv;
777 if (pVirtualAd && pVirtualAd->RtmpDev)
778 pAdapter = pVirtualAd->RtmpDev->ml_priv;
781 if (pAdapter == NULL)
783 /* if 1st open fail, pAd will be free;
784 So the net_dev->ml_priv will be NULL in 2rd open */
788 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
789 data->length = sizeof(struct iw_range);
790 memset(range, 0, sizeof(struct iw_range));
792 range->txpower_capa = IW_TXPOW_DBM;
794 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
796 range->min_pmp = 1 * 1024;
797 range->max_pmp = 65535 * 1024;
798 range->min_pmt = 1 * 1024;
799 range->max_pmt = 1000 * 1024;
800 range->pmp_flags = IW_POWER_PERIOD;
801 range->pmt_flags = IW_POWER_TIMEOUT;
802 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
803 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
806 range->we_version_compiled = WIRELESS_EXT;
807 range->we_version_source = 14;
809 range->retry_capa = IW_RETRY_LIMIT;
810 range->retry_flags = IW_RETRY_LIMIT;
811 range->min_retry = 0;
812 range->max_retry = 255;
814 range->num_channels = pAdapter->ChannelListNum;
817 for (i = 1; i <= range->num_channels; i++)
820 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
821 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
822 range->freq[val].m = m * 100; /* HZ */
824 range->freq[val].e = 1;
826 if (val == IW_MAX_FREQUENCIES)
829 range->num_frequency = val;
831 range->max_qual.qual = 100; /* what is correct max? This was not
832 * documented exactly. At least
833 * 69 has been observed. */
834 range->max_qual.level = 0; /* dB */
835 range->max_qual.noise = 0; /* dB */
837 /* What would be suitable values for "average/typical" qual? */
838 range->avg_qual.qual = 20;
839 range->avg_qual.level = -60;
840 range->avg_qual.noise = -95;
841 range->sensitivity = 3;
843 range->max_encoding_tokens = NR_WEP_KEYS;
844 range->num_encoding_sizes = 2;
845 range->encoding_size[0] = 5;
846 range->encoding_size[1] = 13;
849 range->max_rts = 2347;
850 range->min_frag = 256;
851 range->max_frag = 2346;
853 #if WIRELESS_EXT > 17
854 /* IW_ENC_CAPA_* bit field */
855 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
856 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
862 int rt_ioctl_siwap(struct net_device *dev,
863 struct iw_request_info *info,
864 struct sockaddr *ap_addr, char *extra)
866 PRTMP_ADAPTER pAdapter = dev->ml_priv;
867 NDIS_802_11_MAC_ADDRESS Bssid;
869 //check if the interface is down
870 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
872 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
876 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
878 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
879 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
882 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
883 // this request, because this request is initiated by NDIS.
884 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
885 // Prevent to connect AP again in STAMlmePeriodicExec
886 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
888 memset(Bssid, 0, MAC_ADDR_LEN);
889 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
890 MlmeEnqueue(pAdapter,
891 MLME_CNTL_STATE_MACHINE,
893 sizeof(NDIS_802_11_MAC_ADDRESS),
896 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
897 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
902 int rt_ioctl_giwap(struct net_device *dev,
903 struct iw_request_info *info,
904 struct sockaddr *ap_addr, char *extra)
906 PRTMP_ADAPTER pAdapter = NULL;
907 VIRTUAL_ADAPTER *pVirtualAd = NULL;
909 if (dev->priv_flags == INT_MAIN)
911 pAdapter = dev->ml_priv;
915 pVirtualAd = dev->ml_priv;
916 if (pVirtualAd && pVirtualAd->RtmpDev)
917 pAdapter = pVirtualAd->RtmpDev->ml_priv;
920 if (pAdapter == NULL)
922 /* if 1st open fail, pAd will be free;
923 So the net_dev->ml_priv will be NULL in 2rd open */
927 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
929 ap_addr->sa_family = ARPHRD_ETHER;
930 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
932 #ifdef WPA_SUPPLICANT_SUPPORT
934 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
936 ap_addr->sa_family = ARPHRD_ETHER;
937 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
939 #endif // WPA_SUPPLICANT_SUPPORT //
942 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
950 * Units are in db above the noise floor. That means the
951 * rssi values reported in the tx/rx descriptors in the
952 * driver are the SNR expressed in db.
954 * If you assume that the noise floor is -95, which is an
955 * excellent assumption 99.5 % of the time, then you can
956 * derive the absolute signal level (i.e. -95 + rssi).
957 * There are some other slight factors to take into account
958 * depending on whether the rssi measurement is from 11b,
959 * 11g, or 11a. These differences are at most 2db and
962 * NB: various calculations are based on the orinoco/wavelan
963 * drivers for compatibility
965 static void set_quality(PRTMP_ADAPTER pAdapter,
966 struct iw_quality *iq,
973 ChannelQuality = 100;
974 else if (rssi >= -80) // between -50 ~ -80dbm
975 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
976 else if (rssi >= -90) // between -80 ~ -90dbm
977 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
981 iq->qual = (__u8)ChannelQuality;
983 iq->level = (__u8)(rssi);
984 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
985 iq->noise += 256 - 143;
986 iq->updated = pAdapter->iw_stats.qual.updated;
989 int rt_ioctl_iwaplist(struct net_device *dev,
990 struct iw_request_info *info,
991 struct iw_point *data, char *extra)
993 PRTMP_ADAPTER pAdapter = dev->ml_priv;
995 struct sockaddr addr[IW_MAX_AP];
996 struct iw_quality qual[IW_MAX_AP];
999 //check if the interface is down
1000 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1002 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1008 for (i = 0; i <IW_MAX_AP ; i++)
1010 if (i >= pAdapter->ScanTab.BssNr)
1012 addr[i].sa_family = ARPHRD_ETHER;
1013 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1014 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1017 memcpy(extra, &addr, i*sizeof(addr[0]));
1018 data->flags = 1; /* signal quality present (sort of) */
1019 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1025 int rt_ioctl_siwscan(struct net_device *dev,
1026 struct iw_request_info *info,
1027 struct iw_point *data, char *extra)
1029 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1032 int Status = NDIS_STATUS_SUCCESS;
1034 //check if the interface is down
1035 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1037 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1041 if (MONITOR_ON(pAdapter))
1043 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1047 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
1048 && (pAdapter->StaCfg.bRadio == TRUE)
1049 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
1051 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
1053 // Check if still radio off.
1054 else if (pAdapter->bPCIclkOff == TRUE)
1057 #ifdef WPA_SUPPLICANT_SUPPORT
1058 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1060 pAdapter->StaCfg.WpaSupplicantScanCount++;
1062 #endif // WPA_SUPPLICANT_SUPPORT //
1064 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1065 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1070 #ifdef WPA_SUPPLICANT_SUPPORT
1071 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1072 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1074 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1075 Status = NDIS_STATUS_SUCCESS;
1078 #endif // WPA_SUPPLICANT_SUPPORT //
1080 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1081 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1082 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1083 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1085 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1086 Status = NDIS_STATUS_SUCCESS;
1090 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1092 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1093 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1096 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1097 // this request, because this request is initiated by NDIS.
1098 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1099 // Reset allowed scan retries
1100 pAdapter->StaCfg.ScanCnt = 0;
1101 pAdapter->StaCfg.LastScanTime = Now;
1103 MlmeEnqueue(pAdapter,
1104 MLME_CNTL_STATE_MACHINE,
1105 OID_802_11_BSSID_LIST_SCAN,
1109 Status = NDIS_STATUS_SUCCESS;
1110 RT28XX_MLME_HANDLER(pAdapter);
1115 int rt_ioctl_giwscan(struct net_device *dev,
1116 struct iw_request_info *info,
1117 struct iw_point *data, char *extra)
1120 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1122 char *current_ev = extra, *previous_ev = extra;
1124 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1127 #endif // IWEVGENIE //
1128 struct iw_event iwe;
1130 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1133 * Still scanning, indicate the caller should try again.
1139 #ifdef WPA_SUPPLICANT_SUPPORT
1140 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1142 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1144 #endif // WPA_SUPPLICANT_SUPPORT //
1146 if (pAdapter->ScanTab.BssNr == 0)
1152 #if WIRELESS_EXT >= 17
1153 if (data->length > 0)
1154 end_buf = extra + data->length;
1156 end_buf = extra + IW_SCAN_MAX_DATA;
1158 end_buf = extra + IW_SCAN_MAX_DATA;
1161 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1163 if (current_ev >= end_buf)
1165 #if WIRELESS_EXT >= 17
1173 //================================
1174 memset(&iwe, 0, sizeof(iwe));
1175 iwe.cmd = SIOCGIWAP;
1176 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1177 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1179 previous_ev = current_ev;
1180 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1181 if (current_ev == previous_ev)
1182 #if WIRELESS_EXT >= 17
1189 //================================
1190 memset(&iwe, 0, sizeof(iwe));
1191 iwe.cmd = SIOCGIWESSID;
1192 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1193 iwe.u.data.flags = 1;
1195 previous_ev = current_ev;
1196 current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1197 if (current_ev == previous_ev)
1198 #if WIRELESS_EXT >= 17
1205 //================================
1206 memset(&iwe, 0, sizeof(iwe));
1207 iwe.cmd = SIOCGIWMODE;
1208 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1210 iwe.u.mode = IW_MODE_ADHOC;
1212 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1214 iwe.u.mode = IW_MODE_INFRA;
1218 iwe.u.mode = IW_MODE_AUTO;
1220 iwe.len = IW_EV_UINT_LEN;
1222 previous_ev = current_ev;
1223 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1224 if (current_ev == previous_ev)
1225 #if WIRELESS_EXT >= 17
1231 //Channel and Frequency
1232 //================================
1233 memset(&iwe, 0, sizeof(iwe));
1234 iwe.cmd = SIOCGIWFREQ;
1235 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1236 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1238 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1242 previous_ev = current_ev;
1243 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
1244 if (current_ev == previous_ev)
1245 #if WIRELESS_EXT >= 17
1251 //Add quality statistics
1252 //================================
1253 memset(&iwe, 0, sizeof(iwe));
1255 iwe.u.qual.level = 0;
1256 iwe.u.qual.noise = 0;
1257 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1258 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1259 if (current_ev == previous_ev)
1260 #if WIRELESS_EXT >= 17
1267 //================================
1268 memset(&iwe, 0, sizeof(iwe));
1269 iwe.cmd = SIOCGIWENCODE;
1270 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1271 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1273 iwe.u.data.flags = IW_ENCODE_DISABLED;
1275 previous_ev = current_ev;
1276 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);
1277 if (current_ev == previous_ev)
1278 #if WIRELESS_EXT >= 17
1285 //================================
1286 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1288 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1289 memset(&iwe, 0, sizeof(iwe));
1290 iwe.cmd = SIOCGIWRATE;
1291 current_val = current_ev + IW_EV_LCP_LEN;
1292 if (tmpRate == 0x82)
1293 iwe.u.bitrate.value = 1 * 1000000;
1294 else if (tmpRate == 0x84)
1295 iwe.u.bitrate.value = 2 * 1000000;
1296 else if (tmpRate == 0x8B)
1297 iwe.u.bitrate.value = 5.5 * 1000000;
1298 else if (tmpRate == 0x96)
1299 iwe.u.bitrate.value = 11 * 1000000;
1301 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1303 iwe.u.bitrate.disabled = 0;
1304 current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
1305 current_val, end_buf, &iwe,
1308 if((current_val-current_ev)>IW_EV_LCP_LEN)
1309 current_ev = current_val;
1311 #if WIRELESS_EXT >= 17
1320 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1322 memset(&iwe, 0, sizeof(iwe));
1323 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1324 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1325 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1326 iwe.cmd = IWEVGENIE;
1327 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1328 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1329 if (current_ev == previous_ev)
1330 #if WIRELESS_EXT >= 17
1338 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1340 memset(&iwe, 0, sizeof(iwe));
1341 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1342 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1343 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1344 iwe.cmd = IWEVGENIE;
1345 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1346 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1347 if (current_ev == previous_ev)
1348 #if WIRELESS_EXT >= 17
1356 //================================
1357 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1359 NdisZeroMemory(&iwe, sizeof(iwe));
1360 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1361 iwe.cmd = IWEVCUSTOM;
1362 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1363 NdisMoveMemory(custom, "wpa_ie=", 7);
1364 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1365 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1366 previous_ev = current_ev;
1367 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1368 if (current_ev == previous_ev)
1369 #if WIRELESS_EXT >= 17
1377 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1379 NdisZeroMemory(&iwe, sizeof(iwe));
1380 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1381 iwe.cmd = IWEVCUSTOM;
1382 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1383 NdisMoveMemory(custom, "rsn_ie=", 7);
1384 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1385 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1386 previous_ev = current_ev;
1387 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1388 if (current_ev == previous_ev)
1389 #if WIRELESS_EXT >= 17
1395 #endif // IWEVGENIE //
1398 data->length = current_ev - extra;
1399 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1400 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1405 int rt_ioctl_siwessid(struct net_device *dev,
1406 struct iw_request_info *info,
1407 struct iw_point *data, char *essid)
1409 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1411 //check if the interface is down
1412 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1414 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1420 PCHAR pSsidString = NULL;
1422 // Includes null character.
1423 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1426 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1429 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1430 NdisMoveMemory(pSsidString, essid, data->length);
1431 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1440 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1446 int rt_ioctl_giwessid(struct net_device *dev,
1447 struct iw_request_info *info,
1448 struct iw_point *data, char *essid)
1450 PRTMP_ADAPTER pAdapter = NULL;
1451 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1453 if (dev->priv_flags == INT_MAIN)
1455 pAdapter = dev->ml_priv;
1459 pVirtualAd = dev->ml_priv;
1460 if (pVirtualAd && pVirtualAd->RtmpDev)
1461 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1464 if (pAdapter == NULL)
1466 /* if 1st open fail, pAd will be free;
1467 So the net_dev->ml_priv will be NULL in 2rd open */
1472 if (MONITOR_ON(pAdapter))
1478 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1480 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1481 data->length = pAdapter->CommonCfg.SsidLen;
1482 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1485 {//the ANY ssid was specified
1487 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1494 int rt_ioctl_siwnickn(struct net_device *dev,
1495 struct iw_request_info *info,
1496 struct iw_point *data, char *nickname)
1498 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1500 //check if the interface is down
1501 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1503 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1507 if (data->length > IW_ESSID_MAX_SIZE)
1510 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1511 memcpy(pAdapter->nickname, nickname, data->length);
1517 int rt_ioctl_giwnickn(struct net_device *dev,
1518 struct iw_request_info *info,
1519 struct iw_point *data, char *nickname)
1521 PRTMP_ADAPTER pAdapter = NULL;
1522 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1524 if (dev->priv_flags == INT_MAIN)
1526 pAdapter = dev->ml_priv;
1530 pVirtualAd = dev->ml_priv;
1531 if (pVirtualAd && pVirtualAd->RtmpDev)
1532 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1535 if (pAdapter == NULL)
1537 /* if 1st open fail, pAd will be free;
1538 So the net_dev->ml_priv will be NULL in 2rd open */
1542 if (data->length > strlen(pAdapter->nickname) + 1)
1543 data->length = strlen(pAdapter->nickname) + 1;
1544 if (data->length > 0) {
1545 memcpy(nickname, pAdapter->nickname, data->length-1);
1546 nickname[data->length-1] = '\0';
1551 int rt_ioctl_siwrts(struct net_device *dev,
1552 struct iw_request_info *info,
1553 struct iw_param *rts, char *extra)
1555 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1558 //check if the interface is down
1559 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1561 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1566 val = MAX_RTS_THRESHOLD;
1567 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1569 else if (rts->value == 0)
1570 val = MAX_RTS_THRESHOLD;
1574 if (val != pAdapter->CommonCfg.RtsThreshold)
1575 pAdapter->CommonCfg.RtsThreshold = val;
1580 int rt_ioctl_giwrts(struct net_device *dev,
1581 struct iw_request_info *info,
1582 struct iw_param *rts, char *extra)
1584 PRTMP_ADAPTER pAdapter = NULL;
1585 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1587 if (dev->priv_flags == INT_MAIN)
1589 pAdapter = dev->ml_priv;
1593 pVirtualAd = dev->ml_priv;
1594 if (pVirtualAd && pVirtualAd->RtmpDev)
1595 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1598 if (pAdapter == NULL)
1600 /* if 1st open fail, pAd will be free;
1601 So the net_dev->ml_priv will be NULL in 2rd open */
1605 //check if the interface is down
1606 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1608 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1612 rts->value = pAdapter->CommonCfg.RtsThreshold;
1613 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1619 int rt_ioctl_siwfrag(struct net_device *dev,
1620 struct iw_request_info *info,
1621 struct iw_param *frag, char *extra)
1623 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1626 //check if the interface is down
1627 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1629 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1634 val = MAX_FRAG_THRESHOLD;
1635 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1636 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1637 else if (frag->value == 0)
1638 val = MAX_FRAG_THRESHOLD;
1642 pAdapter->CommonCfg.FragmentThreshold = val;
1646 int rt_ioctl_giwfrag(struct net_device *dev,
1647 struct iw_request_info *info,
1648 struct iw_param *frag, char *extra)
1650 PRTMP_ADAPTER pAdapter = NULL;
1651 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1653 if (dev->priv_flags == INT_MAIN)
1655 pAdapter = dev->ml_priv;
1659 pVirtualAd = dev->ml_priv;
1660 if (pVirtualAd && pVirtualAd->RtmpDev)
1661 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1664 if (pAdapter == NULL)
1666 /* if 1st open fail, pAd will be free;
1667 So the net_dev->ml_priv will be NULL in 2rd open */
1671 //check if the interface is down
1672 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1674 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1678 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1679 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1685 #define MAX_WEP_KEY_SIZE 13
1686 #define MIN_WEP_KEY_SIZE 5
1687 int rt_ioctl_siwencode(struct net_device *dev,
1688 struct iw_request_info *info,
1689 struct iw_point *erq, char *extra)
1691 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1693 //check if the interface is down
1694 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1696 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1700 if ((erq->length == 0) &&
1701 (erq->flags & IW_ENCODE_DISABLED))
1703 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1704 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1705 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1706 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1707 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1710 else if ((erq->length == 0) &&
1711 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1713 STA_PORT_SECURED(pAdapter);
1714 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1715 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1716 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1717 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1718 if (erq->flags & IW_ENCODE_RESTRICTED)
1719 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1721 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1725 if (erq->length > 0)
1727 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1728 /* Check the size of the key */
1729 if (erq->length > MAX_WEP_KEY_SIZE) {
1732 /* Check key index */
1733 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1735 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1736 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1739 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1742 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1744 if (erq->length == MAX_WEP_KEY_SIZE)
1746 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1747 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1749 else if (erq->length == MIN_WEP_KEY_SIZE)
1751 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1752 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1755 /* Disable the key */
1756 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1758 /* Check if the key is not marked as invalid */
1759 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1760 /* Copy the key in the driver */
1761 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1766 /* Do we want to just set the transmit key index ? */
1767 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1768 if ((index >= 0) && (index < 4))
1770 pAdapter->StaCfg.DefaultKeyId = index;
1773 /* Don't complain if only change the mode */
1774 if (!(erq->flags & IW_ENCODE_MODE)) {
1780 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1781 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1782 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1783 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1788 rt_ioctl_giwencode(struct net_device *dev,
1789 struct iw_request_info *info,
1790 struct iw_point *erq, char *key)
1793 PRTMP_ADAPTER pAdapter = NULL;
1794 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1796 if (dev->priv_flags == INT_MAIN)
1798 pAdapter = dev->ml_priv;
1802 pVirtualAd = dev->ml_priv;
1803 if (pVirtualAd && pVirtualAd->RtmpDev)
1804 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1807 if (pAdapter == NULL)
1809 /* if 1st open fail, pAd will be free;
1810 So the net_dev->ml_priv will be NULL in 2rd open */
1814 //check if the interface is down
1815 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1817 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1821 kid = erq->flags & IW_ENCODE_INDEX;
1822 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1824 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1827 erq->flags = IW_ENCODE_DISABLED;
1829 else if ((kid > 0) && (kid <=4))
1832 erq->flags = kid ; /* NB: base 1 */
1833 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1834 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1835 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1836 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1837 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1838 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1839 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1841 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1846 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1847 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1849 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1850 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1851 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1852 // copy default key ID
1853 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1854 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1856 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1857 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1858 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1866 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1867 void *w, char *extra)
1869 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1870 PRTMP_ADAPTER pAdapter;
1872 char *this_char = extra;
1876 if (dev->priv_flags == INT_MAIN)
1878 pAdapter = dev->ml_priv;
1882 pVirtualAd = dev->ml_priv;
1883 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1885 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1887 if (pAdapter == NULL)
1889 /* if 1st open fail, pAd will be free;
1890 So the net_dev->ml_priv will be NULL in 2rd open */
1895 pObj->ioctl_if_type = INT_MAIN;
1896 pObj->ioctl_if = MAIN_MBSSID;
1899 //check if the interface is down
1900 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1902 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1909 if ((value = rtstrchr(this_char, '=')) != NULL)
1915 // reject setting nothing besides ANY ssid(ssidLen=0)
1916 if (!*value && (strcmp(this_char, "SSID") != 0))
1919 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1921 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1923 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1924 { //FALSE:Set private failed then return Invalid argument
1927 break; //Exit for loop.
1931 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1932 { //Not found argument
1934 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1942 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1943 struct iw_point *wrq, char *extra)
1946 PRTMP_ADAPTER pAd = dev->ml_priv;
1954 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1955 sprintf(extra, "\n\n");
1960 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1961 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1964 #endif // RALINK_ATE //
1966 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1967 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1969 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1970 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1971 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1972 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1974 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1975 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1976 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1977 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1979 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1983 if (pAd->ate.RxAntennaSel == 0)
1985 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1986 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1987 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1991 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1995 #endif // RALINK_ATE //
1997 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1998 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1999 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
2001 #ifdef WPA_SUPPLICANT_SUPPORT
2002 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
2003 #endif // WPA_SUPPLICANT_SUPPORT //
2006 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2007 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2012 #ifdef DOT11_N_SUPPORT
2014 IN PRTMP_ADAPTER pAd,
2018 BA_ORI_ENTRY *pOriBAEntry;
2019 BA_REC_ENTRY *pRecBAEntry;
2021 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2023 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2024 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2025 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2027 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2029 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2030 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2032 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2033 for (j=0; j < NUM_OF_TID; j++)
2035 if (pEntry->BARecWcidArray[j] != 0)
2037 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2038 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2041 sprintf(pOutBuf, "%s\n", pOutBuf);
2043 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2044 for (j=0; j < NUM_OF_TID; j++)
2046 if (pEntry->BAOriWcidArray[j] != 0)
2048 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2049 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2052 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2054 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2060 #endif // DOT11_N_SUPPORT //
2063 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2064 struct iw_point *wrq, char *extra)
2067 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2070 u32 subcmd = wrq->flags;
2072 if (dev->priv_flags == INT_MAIN)
2076 pVirtualAd = dev->ml_priv;
2077 pAd = pVirtualAd->RtmpDev->ml_priv;
2079 pObj = (POS_COOKIE) pAd->OS_Cookie;
2083 /* if 1st open fail, pAd will be free;
2084 So the net_dev->ml_priv will be NULL in 2rd open */
2093 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2096 pObj->ioctl_if_type = INT_MAIN;
2097 pObj->ioctl_if = MAIN_MBSSID;
2103 case SHOW_CONN_STATUS:
2104 if (MONITOR_ON(pAd))
2106 #ifdef DOT11_N_SUPPORT
2107 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2108 pAd->CommonCfg.RegTransmitSetting.field.BW)
2109 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2111 #endif // DOT11_N_SUPPORT //
2112 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2116 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2120 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2121 pAd->CommonCfg.Ssid,
2122 pAd->CommonCfg.Bssid[0],
2123 pAd->CommonCfg.Bssid[1],
2124 pAd->CommonCfg.Bssid[2],
2125 pAd->CommonCfg.Bssid[3],
2126 pAd->CommonCfg.Bssid[4],
2127 pAd->CommonCfg.Bssid[5]);
2128 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2130 else if (ADHOC_ON(pAd))
2131 sprintf(extra, "Connected\n");
2135 sprintf(extra, "Disconnected\n");
2136 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2139 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2141 case SHOW_DRVIER_VERION:
2142 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2143 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2145 #ifdef DOT11_N_SUPPORT
2147 getBaInfo(pAd, extra);
2148 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2150 #endif // DOT11_N_SUPPORT //
2151 case SHOW_DESC_INFO:
2153 Show_DescInfo_Proc(pAd, NULL);
2154 wrq->length = 0; // 1: size of '\0'
2158 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2160 sprintf(extra, "Scanning\n");
2161 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2164 pAd->StaCfg.bSwRadio = FALSE;
2165 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2167 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2168 if (pAd->StaCfg.bRadio == FALSE)
2171 // Update extra information
2172 pAd->ExtraInfo = SW_RADIO_OFF;
2175 sprintf(extra, "Radio Off\n");
2176 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2179 pAd->StaCfg.bSwRadio = TRUE;
2180 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2182 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2183 if (pAd->StaCfg.bRadio == TRUE)
2186 // Update extra information
2187 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2190 sprintf(extra, "Radio On\n");
2191 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2195 #ifdef QOS_DLS_SUPPORT
2196 case SHOW_DLS_ENTRY_INFO:
2198 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2199 wrq->length = 0; // 1: size of '\0'
2202 #endif // QOS_DLS_SUPPORT //
2204 case SHOW_CFG_VALUE:
2206 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2208 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2212 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2220 int rt_ioctl_siwmlme(struct net_device *dev,
2221 struct iw_request_info *info,
2222 union iwreq_data *wrqu,
2225 PRTMP_ADAPTER pAd = dev->ml_priv;
2226 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2227 MLME_QUEUE_ELEM MsgElem;
2228 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2229 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2231 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2238 #ifdef IW_MLME_DEAUTH
2239 case IW_MLME_DEAUTH:
2240 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2241 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2242 DeAuthReq.Reason = pMlme->reason_code;
2243 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2244 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2245 MlmeDeauthReqAction(pAd, &MsgElem);
2248 LinkDown(pAd, FALSE);
2249 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2252 #endif // IW_MLME_DEAUTH //
2253 #ifdef IW_MLME_DISASSOC
2254 case IW_MLME_DISASSOC:
2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2256 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2257 DisAssocReq.Reason = pMlme->reason_code;
2259 MsgElem.Machine = ASSOC_STATE_MACHINE;
2260 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2261 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2262 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2264 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2265 MlmeDisassocReqAction(pAd, &MsgElem);
2267 #endif // IW_MLME_DISASSOC //
2269 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2275 #endif // SIOCSIWMLME //
2277 #if WIRELESS_EXT > 17
2278 int rt_ioctl_siwauth(struct net_device *dev,
2279 struct iw_request_info *info,
2280 union iwreq_data *wrqu, char *extra)
2282 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2283 struct iw_param *param = &wrqu->param;
2285 //check if the interface is down
2286 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2288 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2291 switch (param->flags & IW_AUTH_INDEX) {
2292 case IW_AUTH_WPA_VERSION:
2293 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2295 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2296 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2297 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2299 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2300 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2302 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2304 case IW_AUTH_CIPHER_PAIRWISE:
2305 if (param->value == IW_AUTH_CIPHER_NONE)
2307 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2308 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2309 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2311 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2312 param->value == IW_AUTH_CIPHER_WEP104)
2314 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2315 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2316 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2317 #ifdef WPA_SUPPLICANT_SUPPORT
2318 pAdapter->StaCfg.IEEE8021X = FALSE;
2319 #endif // WPA_SUPPLICANT_SUPPORT //
2321 else if (param->value == IW_AUTH_CIPHER_TKIP)
2323 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2324 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2325 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2327 else if (param->value == IW_AUTH_CIPHER_CCMP)
2329 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2330 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2331 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2333 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2335 case IW_AUTH_CIPHER_GROUP:
2336 if (param->value == IW_AUTH_CIPHER_NONE)
2338 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2340 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2341 param->value == IW_AUTH_CIPHER_WEP104)
2343 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2345 else if (param->value == IW_AUTH_CIPHER_TKIP)
2347 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2349 else if (param->value == IW_AUTH_CIPHER_CCMP)
2351 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2353 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2355 case IW_AUTH_KEY_MGMT:
2356 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2358 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2360 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2361 #ifdef WPA_SUPPLICANT_SUPPORT
2362 pAdapter->StaCfg.IEEE8021X = FALSE;
2363 #endif // WPA_SUPPLICANT_SUPPORT //
2365 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2367 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2368 #ifdef WPA_SUPPLICANT_SUPPORT
2369 pAdapter->StaCfg.IEEE8021X = FALSE;
2370 #endif // WPA_SUPPLICANT_SUPPORT //
2372 #ifdef WPA_SUPPLICANT_SUPPORT
2375 pAdapter->StaCfg.IEEE8021X = TRUE;
2376 #endif // WPA_SUPPLICANT_SUPPORT //
2378 else if (param->value == 0)
2380 STA_PORT_SECURED(pAdapter);
2382 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2384 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2386 case IW_AUTH_PRIVACY_INVOKED:
2387 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2389 case IW_AUTH_DROP_UNENCRYPTED:
2390 if (param->value != 0)
2391 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2394 STA_PORT_SECURED(pAdapter);
2396 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2398 case IW_AUTH_80211_AUTH_ALG:
2399 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2401 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2403 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2405 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2409 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2411 case IW_AUTH_WPA_ENABLED:
2412 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2421 int rt_ioctl_giwauth(struct net_device *dev,
2422 struct iw_request_info *info,
2423 union iwreq_data *wrqu, char *extra)
2425 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2426 struct iw_param *param = &wrqu->param;
2428 //check if the interface is down
2429 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2431 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2435 switch (param->flags & IW_AUTH_INDEX) {
2436 case IW_AUTH_DROP_UNENCRYPTED:
2437 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2440 case IW_AUTH_80211_AUTH_ALG:
2441 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2444 case IW_AUTH_WPA_ENABLED:
2445 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2451 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2455 void fnSetCipherKey(
2456 IN PRTMP_ADAPTER pAdapter,
2460 IN struct iw_encode_ext *ext)
2462 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2463 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2465 if (pAdapter->StaCfg.bRadio == FALSE)
2467 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2468 return (NDIS_STATUS_SUCCESS);
2470 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2471 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2472 RTMPusecDelay(6000);
2473 pAdapter->bPCIclkOff = FALSE;
2476 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2477 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2478 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2479 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2480 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2481 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2483 // Update group key information to ASIC Shared Key Table
2484 AsicAddSharedKeyEntry(pAdapter,
2487 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2488 pAdapter->SharedKey[BSS0][keyIdx].Key,
2489 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2490 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2493 // Update ASIC WCID attribute table and IVEIV table
2494 RTMPAddWcidAttributeEntry(pAdapter,
2497 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2500 // Update ASIC WCID attribute table and IVEIV table
2501 RTMPAddWcidAttributeEntry(pAdapter,
2504 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2505 &pAdapter->MacTab.Content[BSSID_WCID]);
2507 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2510 int rt_ioctl_siwencodeext(struct net_device *dev,
2511 struct iw_request_info *info,
2512 union iwreq_data *wrqu,
2515 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2516 struct iw_point *encoding = &wrqu->encoding;
2517 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2518 int keyIdx, alg = ext->alg;
2520 //check if the interface is down
2521 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2523 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2527 if (encoding->flags & IW_ENCODE_DISABLED)
2529 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2530 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2531 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2532 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2533 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2534 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2535 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2536 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2540 // Get Key Index and convet to our own defined key index
2541 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2542 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2545 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2547 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2548 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2552 case IW_ENCODE_ALG_NONE:
2553 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2555 case IW_ENCODE_ALG_WEP:
2556 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2557 if (ext->key_len == MAX_WEP_KEY_SIZE)
2559 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2560 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2562 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2564 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2565 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2570 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2571 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2573 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2574 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2576 // Set Group key material to Asic
2577 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2579 // Update WCID attribute table and IVEIV table for this group key table
2580 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2582 STA_PORT_SECURED(pAdapter);
2584 // Indicate Connected for GUI
2585 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2588 case IW_ENCODE_ALG_TKIP:
2589 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2590 if (ext->key_len == 32)
2592 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2594 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2595 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2597 STA_PORT_SECURED(pAdapter);
2600 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2602 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2604 // set 802.1x port control
2605 STA_PORT_SECURED(pAdapter);
2611 case IW_ENCODE_ALG_CCMP:
2612 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2614 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2615 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2616 STA_PORT_SECURED(pAdapter);
2618 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2620 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2622 // set 802.1x port control
2623 STA_PORT_SECURED(pAdapter);
2635 rt_ioctl_giwencodeext(struct net_device *dev,
2636 struct iw_request_info *info,
2637 union iwreq_data *wrqu, char *extra)
2639 PRTMP_ADAPTER pAd = dev->ml_priv;
2641 struct iw_point *encoding = &wrqu->encoding;
2642 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2643 int idx, max_key_len;
2645 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2647 max_key_len = encoding->length - sizeof(*ext);
2648 if (max_key_len < 0)
2651 idx = encoding->flags & IW_ENCODE_INDEX;
2654 if (idx < 1 || idx > 4)
2658 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2659 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2661 if (idx != pAd->StaCfg.DefaultKeyId)
2669 idx = pAd->StaCfg.DefaultKeyId;
2671 encoding->flags = idx + 1;
2672 memset(ext, 0, sizeof(*ext));
2675 switch(pAd->StaCfg.WepStatus) {
2676 case Ndis802_11WEPDisabled:
2677 ext->alg = IW_ENCODE_ALG_NONE;
2678 encoding->flags |= IW_ENCODE_DISABLED;
2680 case Ndis802_11WEPEnabled:
2681 ext->alg = IW_ENCODE_ALG_WEP;
2682 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2686 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2687 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2690 case Ndis802_11Encryption2Enabled:
2691 case Ndis802_11Encryption3Enabled:
2692 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2693 ext->alg = IW_ENCODE_ALG_TKIP;
2695 ext->alg = IW_ENCODE_ALG_CCMP;
2697 if (max_key_len < 32)
2702 pKey = &pAd->StaCfg.PMK[0];
2709 if (ext->key_len && pKey)
2711 encoding->flags |= IW_ENCODE_ENABLED;
2712 memcpy(ext->key, pKey, ext->key_len);
2719 int rt_ioctl_siwgenie(struct net_device *dev,
2720 struct iw_request_info *info,
2721 union iwreq_data *wrqu, char *extra)
2723 PRTMP_ADAPTER pAd = dev->ml_priv;
2725 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2726 (wrqu->data.length && extra == NULL))
2729 if (wrqu->data.length)
2731 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2732 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2736 pAd->StaCfg.RSNIE_Len = 0;
2737 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2742 #endif // SIOCSIWGENIE //
2744 int rt_ioctl_giwgenie(struct net_device *dev,
2745 struct iw_request_info *info,
2746 union iwreq_data *wrqu, char *extra)
2748 PRTMP_ADAPTER pAd = dev->ml_priv;
2750 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2751 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2753 wrqu->data.length = 0;
2757 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2759 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2761 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2764 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2765 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2768 #endif // SIOCSIWGENIE //
2769 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2771 UCHAR RSNIe = IE_WPA;
2773 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2775 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2777 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2778 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2781 extra[0] = (char)RSNIe;
2782 extra[1] = pAd->StaCfg.RSNIE_Len;
2783 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2789 int rt_ioctl_siwpmksa(struct net_device *dev,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu,
2794 PRTMP_ADAPTER pAd = dev->ml_priv;
2795 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2796 INT CachedIdx = 0, idx = 0;
2801 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2804 case IW_PMKSA_FLUSH:
2805 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2806 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2808 case IW_PMKSA_REMOVE:
2809 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2811 // compare the BSSID
2812 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2814 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2815 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2816 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2818 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2819 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2821 pAd->StaCfg.SavedPMKNum--;
2826 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2829 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2831 // compare the BSSID
2832 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2836 // Found, replace it
2837 if (CachedIdx < PMKID_NO)
2839 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2840 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2841 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2842 pAd->StaCfg.SavedPMKNum++;
2844 // Not found, replace the last one
2847 // Randomly replace one
2848 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2849 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2850 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2851 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2854 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2857 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2863 #endif // #if WIRELESS_EXT > 17
2867 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2868 struct iw_point *wrq, char *extra)
2875 BOOLEAN bIsPrintAllBBP = FALSE;
2877 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2880 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2882 if (wrq->length > 1) //No parameters.
2884 sprintf(extra, "\n");
2886 //Parsing Read or Write
2887 this_char = wrq->pointer;
2888 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2892 if ((value = rtstrchr(this_char, '=')) != NULL)
2895 if (!value || !*value)
2897 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2898 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2903 if (ATE_ON(pAdapter))
2905 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2908 #endif // RALINK_ATE //
2910 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2912 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2913 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2914 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2917 {//Invalid parametes, so default printk all bbp
2918 bIsPrintAllBBP = TRUE;
2923 { //Invalid parametes, so default printk all bbp
2924 bIsPrintAllBBP = TRUE;
2930 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2935 if (ATE_ON(pAdapter))
2937 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2938 //Read it back for showing
2939 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2942 #endif // RALINK_ATE //
2944 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2945 //Read it back for showing
2946 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2948 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2949 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2950 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2953 {//Invalid parametes, so default printk all bbp
2954 bIsPrintAllBBP = TRUE;
2959 { //Invalid parametes, so default printk all bbp
2960 bIsPrintAllBBP = TRUE;
2966 bIsPrintAllBBP = TRUE;
2971 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2972 sprintf(extra, "\n");
2973 for (bbpId = 0; bbpId <= 136; bbpId++)
2975 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2978 if (ATE_ON(pAdapter))
2980 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2983 #endif // RALINK_ATE //
2984 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2985 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2987 sprintf(extra+strlen(extra), "\n");
2990 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2991 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2994 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
3000 int rt_ioctl_siwrate(struct net_device *dev,
3001 struct iw_request_info *info,
3002 union iwreq_data *wrqu, char *extra)
3004 PRTMP_ADAPTER pAd = dev->ml_priv;
3005 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3007 //check if the interface is down
3008 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3010 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3014 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3015 /* rate = -1 => auto rate
3016 rate = X, fixed = 1 => (fixed rate X)
3021 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3022 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3023 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3024 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3025 RTMPSetDesiredRates(pAd, -1);
3027 #ifdef DOT11_N_SUPPORT
3029 #endif // DOT11_N_SUPPORT //
3035 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3036 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3037 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3038 RTMPSetDesiredRates(pAd, rate);
3041 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3042 #ifdef DOT11_N_SUPPORT
3044 #endif // DOT11_N_SUPPORT //
3046 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3050 // TODO: rate = X, fixed = 0 => (rates <= X)
3058 int rt_ioctl_giwrate(struct net_device *dev,
3059 struct iw_request_info *info,
3060 union iwreq_data *wrqu, char *extra)
3062 PRTMP_ADAPTER pAd = dev->ml_priv;
3063 int rate_index = 0, rate_count = 0;
3064 HTTRANSMIT_SETTING ht_setting;
3065 __s32 ralinkrate[] =
3066 {2, 4, 11, 22, // CCK
3067 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3068 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3069 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3070 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3071 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3072 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3073 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3074 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3075 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3077 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3078 //check if the interface is down
3079 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3081 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3085 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3087 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3088 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3090 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3092 #ifdef DOT11_N_SUPPORT
3093 if (ht_setting.field.MODE >= MODE_HTMIX)
3095 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3098 #endif // DOT11_N_SUPPORT //
3099 if (ht_setting.field.MODE == MODE_OFDM)
3100 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3101 else if (ht_setting.field.MODE == MODE_CCK)
3102 rate_index = (UCHAR)(ht_setting.field.MCS);
3107 if (rate_index > rate_count)
3108 rate_index = rate_count;
3110 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3111 wrqu->bitrate.disabled = 0;
3116 static const iw_handler rt_handler[] =
3118 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3119 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3120 (iw_handler) NULL, /* SIOCSIWNWID */
3121 (iw_handler) NULL, /* SIOCGIWNWID */
3122 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3123 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3124 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3125 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3126 (iw_handler) NULL, /* SIOCSIWSENS */
3127 (iw_handler) NULL, /* SIOCGIWSENS */
3128 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3129 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3130 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3131 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3132 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3133 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3134 (iw_handler) NULL, /* SIOCSIWSPY */
3135 (iw_handler) NULL, /* SIOCGIWSPY */
3136 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3137 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3138 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3139 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3141 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3143 (iw_handler) NULL, /* SIOCSIWMLME */
3144 #endif // SIOCSIWMLME //
3145 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3147 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3148 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3150 (iw_handler) NULL, /* SIOCSIWSCAN */
3151 (iw_handler) NULL, /* SIOCGIWSCAN */
3152 #endif /* SIOCGIWSCAN */
3153 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3154 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3155 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3156 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3157 (iw_handler) NULL, /* -- hole -- */
3158 (iw_handler) NULL, /* -- hole -- */
3159 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3160 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3161 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3162 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3163 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3164 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3165 (iw_handler) NULL, /* SIOCSIWTXPOW */
3166 (iw_handler) NULL, /* SIOCGIWTXPOW */
3167 (iw_handler) NULL, /* SIOCSIWRETRY */
3168 (iw_handler) NULL, /* SIOCGIWRETRY */
3169 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3170 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3171 (iw_handler) NULL, /* SIOCSIWPOWER */
3172 (iw_handler) NULL, /* SIOCGIWPOWER */
3173 (iw_handler) NULL, /* -- hole -- */
3174 (iw_handler) NULL, /* -- hole -- */
3175 #if WIRELESS_EXT > 17
3176 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3177 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3178 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3179 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3180 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3181 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3182 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3186 static const iw_handler rt_priv_handlers[] = {
3187 (iw_handler) NULL, /* + 0x00 */
3188 (iw_handler) NULL, /* + 0x01 */
3189 #ifndef CONFIG_AP_SUPPORT
3190 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3192 (iw_handler) NULL, /* + 0x02 */
3193 #endif // CONFIG_AP_SUPPORT //
3195 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3197 (iw_handler) NULL, /* + 0x03 */
3199 (iw_handler) NULL, /* + 0x04 */
3200 (iw_handler) NULL, /* + 0x05 */
3201 (iw_handler) NULL, /* + 0x06 */
3202 (iw_handler) NULL, /* + 0x07 */
3203 (iw_handler) NULL, /* + 0x08 */
3204 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3205 (iw_handler) NULL, /* + 0x0A */
3206 (iw_handler) NULL, /* + 0x0B */
3207 (iw_handler) NULL, /* + 0x0C */
3208 (iw_handler) NULL, /* + 0x0D */
3209 (iw_handler) NULL, /* + 0x0E */
3210 (iw_handler) NULL, /* + 0x0F */
3211 (iw_handler) NULL, /* + 0x10 */
3212 (iw_handler) rt_private_show, /* + 0x11 */
3213 (iw_handler) NULL, /* + 0x12 */
3214 (iw_handler) NULL, /* + 0x13 */
3215 (iw_handler) NULL, /* + 0x15 */
3216 (iw_handler) NULL, /* + 0x17 */
3217 (iw_handler) NULL, /* + 0x18 */
3220 const struct iw_handler_def rt28xx_iw_handler_def =
3222 #define N(a) (sizeof (a) / sizeof (a[0]))
3223 .standard = (iw_handler *) rt_handler,
3224 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3225 .private = (iw_handler *) rt_priv_handlers,
3226 .num_private = N(rt_priv_handlers),
3227 .private_args = (struct iw_priv_args *) privtab,
3228 .num_private_args = N(privtab),
3229 #if IW_HANDLER_VERSION >= 7
3230 .get_wireless_stats = rt28xx_get_wireless_stats,
3234 INT RTMPSetInformation(
3235 IN PRTMP_ADAPTER pAdapter,
3236 IN OUT struct ifreq *rq,
3239 struct iwreq *wrq = (struct iwreq *) rq;
3240 NDIS_802_11_SSID Ssid;
3241 NDIS_802_11_MAC_ADDRESS Bssid;
3242 RT_802_11_PHY_MODE PhyMode;
3243 RT_802_11_STA_CONFIG StaConfig;
3244 NDIS_802_11_RATES aryRates;
3245 RT_802_11_PREAMBLE Preamble;
3246 NDIS_802_11_WEP_STATUS WepStatus;
3247 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3248 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3249 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3250 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3251 NDIS_802_11_POWER_MODE PowerMode;
3252 PNDIS_802_11_KEY pKey = NULL;
3253 PNDIS_802_11_WEP pWepKey =NULL;
3254 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3255 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3256 NDIS_802_11_NETWORK_TYPE NetType;
3259 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3262 BOOLEAN StateMachineTouched = FALSE;
3263 #ifdef DOT11_N_SUPPORT
3264 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3265 #endif // DOT11_N_SUPPORT //
3266 #ifdef WPA_SUPPLICANT_SUPPORT
3267 PNDIS_802_11_PMKID pPmkId = NULL;
3268 BOOLEAN IEEE8021xState = FALSE;
3269 BOOLEAN IEEE8021x_required_keys = FALSE;
3270 UCHAR wpa_supplicant_enable = 0;
3271 #endif // WPA_SUPPLICANT_SUPPORT //
3274 TX_RTY_CFG_STRUC tx_rty_cfg;
3275 ULONG ShortRetryLimit, LongRetryLimit;
3277 #endif // SNMP_SUPPORT //
3280 #ifdef DOT11_N_SUPPORT
3281 MaxPhyMode = PHY_11N_5G;
3282 #endif // DOT11_N_SUPPORT //
3285 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3286 switch(cmd & 0x7FFF) {
3287 case RT_OID_802_11_COUNTRY_REGION:
3288 if (wrq->u.data.length < sizeof(UCHAR))
3290 // Only avaliable when EEPROM not programming
3291 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3296 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3297 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3298 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3299 TmpPhy = pAdapter->CommonCfg.PhyMode;
3300 pAdapter->CommonCfg.PhyMode = 0xff;
3301 // Build all corresponding channel information
3302 RTMPSetPhyMode(pAdapter, TmpPhy);
3303 #ifdef DOT11_N_SUPPORT
3304 SetCommonHT(pAdapter);
3305 #endif // DOT11_N_SUPPORT //
3306 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3307 pAdapter->CommonCfg.CountryRegion));
3310 case OID_802_11_BSSID_LIST_SCAN:
3312 if (ATE_ON(pAdapter))
3314 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3317 #endif // RALINK_ATE //
3319 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3321 if (MONITOR_ON(pAdapter))
3323 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3327 //Benson add 20080527, when radio off, sta don't need to scan
3328 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3331 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3333 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3334 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3335 Status = NDIS_STATUS_SUCCESS;
3339 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3341 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3342 Status = NDIS_STATUS_SUCCESS;
3343 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3347 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3348 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3349 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3350 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3351 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3352 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3354 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3355 Status = NDIS_STATUS_SUCCESS;
3356 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3361 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3363 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3364 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3367 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3368 // this request, because this request is initiated by NDIS.
3369 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3370 // Reset allowed scan retries
3371 pAdapter->StaCfg.ScanCnt = 0;
3372 pAdapter->StaCfg.LastScanTime = Now;
3374 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3375 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3376 MlmeEnqueue(pAdapter,
3377 MLME_CNTL_STATE_MACHINE,
3378 OID_802_11_BSSID_LIST_SCAN,
3382 Status = NDIS_STATUS_SUCCESS;
3383 StateMachineTouched = TRUE;
3385 case OID_802_11_SSID:
3386 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3390 PCHAR pSsidString = NULL;
3391 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3393 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3394 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3398 if (Ssid.SsidLength == 0)
3400 Set_SSID_Proc(pAdapter, "");
3404 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3407 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3408 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3409 Set_SSID_Proc(pAdapter, pSsidString);
3418 case OID_802_11_BSSID:
3420 if (ATE_ON(pAdapter))
3422 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3425 #endif // RALINK_ATE //
3426 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3430 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3432 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3433 // this request, because this request is initiated by NDIS.
3434 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3436 // Prevent to connect AP again in STAMlmePeriodicExec
3437 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3439 // Reset allowed scan retries
3440 pAdapter->StaCfg.ScanCnt = 0;
3442 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3444 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3445 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3447 MlmeEnqueue(pAdapter,
3448 MLME_CNTL_STATE_MACHINE,
3450 sizeof(NDIS_802_11_MAC_ADDRESS),
3452 Status = NDIS_STATUS_SUCCESS;
3453 StateMachineTouched = TRUE;
3455 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3456 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3459 case RT_OID_802_11_RADIO:
3460 if (wrq->u.data.length != sizeof(BOOLEAN))
3464 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3465 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3466 if (pAdapter->StaCfg.bSwRadio != RadioState)
3468 pAdapter->StaCfg.bSwRadio = RadioState;
3469 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3471 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3472 if (pAdapter->StaCfg.bRadio == TRUE)
3474 MlmeRadioOn(pAdapter);
3475 // Update extra information
3476 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3480 MlmeRadioOff(pAdapter);
3481 // Update extra information
3482 pAdapter->ExtraInfo = SW_RADIO_OFF;
3488 case RT_OID_802_11_PHY_MODE:
3489 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3493 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3494 if (PhyMode <= MaxPhyMode)
3496 RTMPSetPhyMode(pAdapter, PhyMode);
3497 #ifdef DOT11_N_SUPPORT
3498 SetCommonHT(pAdapter);
3499 #endif // DOT11_N_SUPPORT //
3501 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3504 case RT_OID_802_11_STA_CONFIG:
3505 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3509 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3510 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3511 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3512 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3513 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3514 (StaConfig.AdhocMode <= MaxPhyMode))
3516 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3517 // if setting changed, need to reset current TX rate as well as BEACON frame format
3518 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3520 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3521 RTMPSetPhyMode(pAdapter, PhyMode);
3522 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3523 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3524 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3527 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3528 pAdapter->CommonCfg.bEnableTxBurst,
3529 pAdapter->CommonCfg.UseBGProtection,
3530 pAdapter->CommonCfg.bUseShortSlotTime));
3533 case OID_802_11_DESIRED_RATES:
3534 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3538 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3539 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3540 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3541 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3542 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3543 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3544 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3545 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3546 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3547 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3550 case RT_OID_802_11_PREAMBLE:
3551 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3555 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3556 if (Preamble == Rt802_11PreambleShort)
3558 pAdapter->CommonCfg.TxPreamble = Preamble;
3559 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3561 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3563 // if user wants AUTO, initialize to LONG here, then change according to AP's
3564 // capability upon association.
3565 pAdapter->CommonCfg.TxPreamble = Preamble;
3566 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3573 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3576 case OID_802_11_WEP_STATUS:
3577 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3581 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3582 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3583 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3585 if (pAdapter->StaCfg.WepStatus != WepStatus)
3587 // Config has changed
3588 pAdapter->bConfigChanged = TRUE;
3590 pAdapter->StaCfg.WepStatus = WepStatus;
3591 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3592 pAdapter->StaCfg.PairCipher = WepStatus;
3593 pAdapter->StaCfg.GroupCipher = WepStatus;
3600 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3603 case OID_802_11_AUTHENTICATION_MODE:
3604 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3608 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3609 if (AuthMode > Ndis802_11AuthModeMax)
3616 if (pAdapter->StaCfg.AuthMode != AuthMode)
3618 // Config has changed
3619 pAdapter->bConfigChanged = TRUE;
3621 pAdapter->StaCfg.AuthMode = AuthMode;
3623 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3624 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3627 case OID_802_11_INFRASTRUCTURE_MODE:
3628 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3632 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3634 if (BssType == Ndis802_11IBSS)
3635 Set_NetworkType_Proc(pAdapter, "Adhoc");
3636 else if (BssType == Ndis802_11Infrastructure)
3637 Set_NetworkType_Proc(pAdapter, "Infra");
3638 else if (BssType == Ndis802_11Monitor)
3639 Set_NetworkType_Proc(pAdapter, "Monitor");
3643 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3647 case OID_802_11_REMOVE_WEP:
3648 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3649 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3655 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3657 if (KeyIdx & 0x80000000)
3659 // Should never set default bit when remove key
3664 KeyIdx = KeyIdx & 0x0fffffff;
3670 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3671 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3672 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3677 case RT_OID_802_11_RESET_COUNTERS:
3678 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3679 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3680 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3681 pAdapter->Counters8023.RxNoBuffer = 0;
3682 pAdapter->Counters8023.GoodReceives = 0;
3683 pAdapter->Counters8023.RxNoBuffer = 0;
3684 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3686 case OID_802_11_RTS_THRESHOLD:
3687 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3691 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3692 if (RtsThresh > MAX_RTS_THRESHOLD)
3695 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3697 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3699 case OID_802_11_FRAGMENTATION_THRESHOLD:
3700 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3704 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3705 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3706 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3708 if (FragThresh == 0)
3710 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3711 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3717 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3719 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3721 case OID_802_11_POWER_MODE:
3722 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3726 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3727 if (PowerMode == Ndis802_11PowerModeCAM)
3728 Set_PSMode_Proc(pAdapter, "CAM");
3729 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3730 Set_PSMode_Proc(pAdapter, "Max_PSP");
3731 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3732 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3733 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3734 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3738 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3740 case RT_OID_802_11_TX_POWER_LEVEL_1:
3741 if (wrq->u.data.length < sizeof(ULONG))
3745 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3746 if (PowerTemp > 100)
3747 PowerTemp = 0xffffffff; // AUTO
3748 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3749 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3750 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3753 case OID_802_11_NETWORK_TYPE_IN_USE:
3754 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3758 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3760 if (NetType == Ndis802_11DS)
3761 RTMPSetPhyMode(pAdapter, PHY_11B);
3762 else if (NetType == Ndis802_11OFDM24)
3763 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3764 else if (NetType == Ndis802_11OFDM5)
3765 RTMPSetPhyMode(pAdapter, PHY_11A);
3768 #ifdef DOT11_N_SUPPORT
3769 if (Status == NDIS_STATUS_SUCCESS)
3770 SetCommonHT(pAdapter);
3771 #endif // DOT11_N_SUPPORT //
3772 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3775 // For WPA PSK PMK key
3776 case RT_OID_802_11_ADD_WPA:
3777 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3784 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3785 if (pKey->Length != wrq->u.data.length)
3788 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3792 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3793 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3794 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3796 Status = -EOPNOTSUPP;
3797 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3799 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3800 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3801 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3803 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3804 // Use RaConfig as PSK agent.
3805 // Start STA supplicant state machine
3806 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3807 pAdapter->StaCfg.WpaState = SS_START;
3809 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3813 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3814 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3819 case OID_802_11_REMOVE_KEY:
3820 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3821 if(pRemoveKey == NULL)
3827 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3828 if (pRemoveKey->Length != wrq->u.data.length)
3831 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3835 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3837 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3838 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3842 KeyIdx = pRemoveKey->KeyIndex;
3844 if (KeyIdx & 0x80000000)
3846 // Should never set default bit when remove key
3848 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3852 KeyIdx = KeyIdx & 0x0fffffff;
3856 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3860 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3861 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3862 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3863 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3871 case OID_802_11_ADD_KEY:
3872 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3878 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3879 if (pKey->Length != wrq->u.data.length)
3882 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3886 RTMPAddKey(pAdapter, pKey);
3887 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3891 case OID_802_11_CONFIGURATION:
3892 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3896 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3899 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3900 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3902 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3903 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3905 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3907 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3909 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3910 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3911 // Config has changed
3912 pAdapter->bConfigChanged = TRUE;
3915 #ifdef DOT11_N_SUPPORT
3916 case RT_OID_802_11_SET_HT_PHYMODE:
3917 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3921 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3923 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3924 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3925 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3926 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3927 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3928 RTMPSetHT(pAdapter, pHTPhyMode);
3930 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3931 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3932 pAdapter->StaCfg.HTPhyMode.field.STBC));
3934 #endif // DOT11_N_SUPPORT //
3935 case RT_OID_802_11_SET_APSD_SETTING:
3936 if (wrq->u.data.length != sizeof(ULONG))
3941 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3943 /*-------------------------------------------------------------------
3944 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3945 ---------------------------------------------------------------------
3946 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3947 ---------------------------------------------------------------------*/
3948 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3949 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3950 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3951 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3952 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3953 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3955 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,
3956 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3960 case RT_OID_802_11_SET_APSD_PSM:
3961 if (wrq->u.data.length != sizeof(ULONG))
3965 // Driver needs to notify AP when PSM changes
3966 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3967 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3969 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3970 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3972 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3975 #ifdef QOS_DLS_SUPPORT
3976 case RT_OID_802_11_SET_DLS:
3977 if (wrq->u.data.length != sizeof(ULONG))
3981 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3982 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3983 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3986 // tear down local dls table entry
3987 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3989 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3991 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3992 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3993 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3997 // tear down peer dls table entry
3998 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
4000 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4002 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
4003 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
4004 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4009 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
4013 case RT_OID_802_11_SET_DLS_PARAM:
4014 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4020 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4021 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4022 MlmeEnqueue(pAdapter,
4023 MLME_CNTL_STATE_MACHINE,
4024 RT_OID_802_11_SET_DLS_PARAM,
4025 sizeof(RT_802_11_DLS),
4027 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4030 #endif // QOS_DLS_SUPPORT //
4031 case RT_OID_802_11_SET_WMM:
4032 if (wrq->u.data.length != sizeof(BOOLEAN))
4036 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4037 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
4041 case OID_802_11_DISASSOCIATE:
4043 if (ATE_ON(pAdapter))
4045 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4048 #endif // RALINK_ATE //
4050 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4051 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4052 // when query OID_802_11_BSSID_LIST.
4054 // TRUE: NumberOfItems will set to 0.
4055 // FALSE: NumberOfItems no change.
4057 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4058 // Set to immediately send the media disconnect event
4059 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4060 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4062 if (INFRA_ON(pAdapter))
4064 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4066 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4067 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4070 MlmeEnqueue(pAdapter,
4071 MLME_CNTL_STATE_MACHINE,
4072 OID_802_11_DISASSOCIATE,
4076 StateMachineTouched = TRUE;
4080 #ifdef DOT11_N_SUPPORT
4081 case RT_OID_802_11_SET_IMME_BA_CAP:
4082 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4086 OID_BACAP_STRUC Orde ;
4087 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4088 if (Orde.Policy > BA_NOTUSE)
4090 Status = NDIS_STATUS_INVALID_DATA;
4092 else if (Orde.Policy == BA_NOTUSE)
4094 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4095 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4096 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4097 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4098 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4099 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4100 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4102 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4103 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4104 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4108 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4109 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4110 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4111 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4112 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4113 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4114 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4115 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4118 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4119 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4120 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4122 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4123 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4127 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4128 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4129 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4130 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4131 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4135 case RT_OID_802_11_ADD_IMME_BA:
4136 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4137 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4142 OID_ADD_BA_ENTRY BA;
4143 MAC_TABLE_ENTRY *pEntry;
4145 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4148 Status = NDIS_STATUS_INVALID_DATA;
4153 //BATableInsertEntry
4154 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4156 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4157 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4160 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4163 if (BA.IsRecipient == FALSE)
4165 if (pEntry->bIAmBadAtheros == TRUE)
4166 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4168 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4172 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4175 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4176 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4177 , BA.MACAddr[4], BA.MACAddr[5]));
4182 case RT_OID_802_11_TEAR_IMME_BA:
4183 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4184 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4188 POID_ADD_BA_ENTRY pBA;
4189 MAC_TABLE_ENTRY *pEntry;
4191 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4195 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4196 Status = NDIS_STATUS_FAILURE;
4200 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4201 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4203 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4205 Status = NDIS_STATUS_INVALID_DATA;
4209 if (pBA->IsRecipient == FALSE)
4211 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4212 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4215 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4216 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4219 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4223 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4226 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4229 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4235 #endif // DOT11_N_SUPPORT //
4237 // For WPA_SUPPLICANT to set static wep key
4238 case OID_802_11_ADD_WEP:
4239 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4244 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4247 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4251 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4255 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4256 // KeyIdx must be 0 ~ 3
4260 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4264 UCHAR CipherAlg = 0;
4267 // set key material and key length
4268 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4269 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4270 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4272 switch(pWepKey->KeyLength)
4275 CipherAlg = CIPHER_WEP64;
4278 CipherAlg = CIPHER_WEP128;
4281 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4285 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4287 // Default key for tx (shared key)
4288 if (pWepKey->KeyIndex & 0x80000000)
4290 #ifdef WPA_SUPPLICANT_SUPPORT
4291 // set key material and key length
4292 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4293 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4294 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4295 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4296 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4297 #endif // WPA_SUPPLICANT_SUPPORT //
4298 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4301 #ifdef WPA_SUPPLICANT_SUPPORT
4302 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4303 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4305 Key = pWepKey->KeyMaterial;
4307 // Set Group key material to Asic
4308 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4310 // Update WCID attribute table and IVEIV table for this group key table
4311 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4313 STA_PORT_SECURED(pAdapter);
4315 // Indicate Connected for GUI
4316 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4318 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4319 #endif // WPA_SUPPLICANT_SUPPORT
4321 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4323 // Set key material and cipherAlg to Asic
4324 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4326 if (pWepKey->KeyIndex & 0x80000000)
4328 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4329 // Assign group key info
4330 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4331 // Assign pairwise key info
4332 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4335 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"));
4340 #ifdef WPA_SUPPLICANT_SUPPORT
4341 case OID_SET_COUNTERMEASURES:
4342 if (wrq->u.data.length != sizeof(int))
4347 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4349 pAdapter->StaCfg.bBlockAssoc = TRUE;
4351 // WPA MIC error should block association attempt for 60 seconds
4352 pAdapter->StaCfg.bBlockAssoc = FALSE;
4353 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4356 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4357 if (wrq->u.data.length != sizeof(UCHAR))
4361 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4362 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4363 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4366 case OID_802_11_DEAUTHENTICATION:
4367 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4371 MLME_DEAUTH_REQ_STRUCT *pInfo;
4372 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4374 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4375 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4376 MlmeDeauthReqAction(pAdapter, MsgElem);
4379 if (INFRA_ON(pAdapter))
4381 LinkDown(pAdapter, FALSE);
4382 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4384 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4387 case OID_802_11_DROP_UNENCRYPTED:
4388 if (wrq->u.data.length != sizeof(int))
4393 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4395 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4397 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4398 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4399 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4400 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4401 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4404 case OID_802_11_SET_IEEE8021X:
4405 if (wrq->u.data.length != sizeof(BOOLEAN))
4409 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4410 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4411 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4414 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4415 if (wrq->u.data.length != sizeof(BOOLEAN))
4419 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4420 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4421 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4424 case OID_802_11_PMKID:
4425 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4427 if(pPmkId == NULL) {
4431 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4433 // check the PMKID information
4434 if (pPmkId->BSSIDInfoCount == 0)
4435 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4438 PBSSID_INFO pBssIdInfo;
4442 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4444 // point to the indexed BSSID_INFO structure
4445 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4446 // Find the entry in the saved data base.
4447 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4449 // compare the BSSID
4450 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4454 // Found, replace it
4455 if (CachedIdx < PMKID_NO)
4457 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4458 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4459 pAdapter->StaCfg.SavedPMKNum++;
4461 // Not found, replace the last one
4464 // Randomly replace one
4465 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4466 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4467 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4474 #endif // WPA_SUPPLICANT_SUPPORT //
4479 case OID_802_11_SHORTRETRYLIMIT:
4480 if (wrq->u.data.length != sizeof(ULONG))
4484 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4485 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4486 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4487 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4488 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4492 case OID_802_11_LONGRETRYLIMIT:
4493 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4494 if (wrq->u.data.length != sizeof(ULONG))
4498 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4499 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4500 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4501 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4502 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4506 case OID_802_11_WEPDEFAULTKEYVALUE:
4507 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4508 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4509 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4512 if ( pKey->Length != wrq->u.data.length)
4515 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4517 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4518 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4520 // it is a shared key
4525 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4526 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4527 if (pKey->KeyIndex & 0x80000000)
4529 // Default key for tx (shared key)
4530 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4532 //RestartAPIsRequired = TRUE;
4537 case OID_802_11_WEPDEFAULTKEYID:
4538 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4540 if (wrq->u.data.length != sizeof(UCHAR))
4543 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4548 case OID_802_11_CURRENTCHANNEL:
4549 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4550 if (wrq->u.data.length != sizeof(UCHAR))
4554 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4555 sprintf(&ctmp,"%d", ctmp);
4556 Set_Channel_Proc(pAdapter, &ctmp);
4564 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4565 Status = -EOPNOTSUPP;
4573 INT RTMPQueryInformation(
4574 IN PRTMP_ADAPTER pAdapter,
4575 IN OUT struct ifreq *rq,
4578 struct iwreq *wrq = (struct iwreq *) rq;
4579 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4580 PNDIS_WLAN_BSSID_EX pBss;
4581 NDIS_802_11_SSID Ssid;
4582 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4583 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4584 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4585 NDIS_802_11_STATISTICS *pStatistics = NULL;
4586 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4587 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4588 NDIS_802_11_POWER_MODE PowerMode;
4589 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4590 RT_802_11_PREAMBLE PreamType;
4591 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4592 NDIS_802_11_WEP_STATUS WepStatus;
4593 NDIS_MEDIA_STATE MediaState;
4594 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4596 PUCHAR pBuf = NULL, pPtr;
4597 INT Status = NDIS_STATUS_SUCCESS;
4598 UINT we_version_compiled;
4599 UCHAR i, Padding = 0;
4601 UCHAR driverVersion[8];
4602 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4607 DefaultKeyIdxValue *pKeyIdxValue;
4609 TX_RTY_CFG_STRUC tx_rty_cfg;
4610 ULONG ShortRetryLimit, LongRetryLimit;
4616 case RT_OID_DEVICE_NAME:
4617 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4618 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4620 case RT_OID_VERSION_INFO:
4621 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4622 wrq->u.data.length = 8*sizeof(UCHAR);
4623 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4624 driverVersion[7] = '\0';
4625 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4631 case RT_QUERY_ATE_TXDONE_COUNT:
4632 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4633 wrq->u.data.length = sizeof(UINT32);
4634 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4639 #endif // RALINK_ATE //
4640 case OID_802_11_BSSID_LIST:
4641 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4644 * Still scanning, indicate the caller should try again.
4646 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4649 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4650 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4651 // Claculate total buffer size required
4652 BssBufSize = sizeof(ULONG);
4654 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4656 // Align pointer to 4 bytes boundary.
4657 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4660 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4663 // For safety issue, we add 256 bytes just in case
4665 // Allocate the same size as passed from higher layer
4666 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4672 // Init 802_11_BSSID_LIST_EX structure
4673 NdisZeroMemory(pBuf, BssBufSize);
4674 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4675 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4677 // Calculate total buffer length
4678 BssLen = 4; // Consist of NumberOfItems
4679 // Point to start of NDIS_WLAN_BSSID_EX
4680 // pPtr = pBuf + sizeof(ULONG);
4681 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4682 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4684 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4685 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4686 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4689 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4690 // and then failed to send EAPOl farame.
4692 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4694 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4695 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4698 pBss->Ssid.SsidLength = 0;
4702 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4703 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4705 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4706 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4707 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4708 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4709 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4710 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4712 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4714 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4715 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4717 pBss->InfrastructureMode = Ndis802_11IBSS;
4719 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4720 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4721 pAdapter->ScanTab.BssEntry[i].ExtRate,
4722 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4724 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4726 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4727 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4728 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4732 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4733 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4734 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4735 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4736 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4738 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4740 #if WIRELESS_EXT < 17
4741 if ((BssLen + pBss->Length) < wrq->u.data.length)
4742 BssLen += pBss->Length;
4745 pBssidList->NumberOfItems = i;
4749 BssLen += pBss->Length;
4753 #if WIRELESS_EXT < 17
4754 wrq->u.data.length = BssLen;
4756 if (BssLen > wrq->u.data.length)
4762 wrq->u.data.length = BssLen;
4764 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4767 case OID_802_3_CURRENT_ADDRESS:
4768 wrq->u.data.length = MAC_ADDR_LEN;
4769 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4771 case OID_GEN_MEDIA_CONNECT_STATUS:
4772 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4773 MediaState = NdisMediaStateConnected;
4775 MediaState = NdisMediaStateDisconnected;
4777 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4778 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4780 case OID_802_11_BSSID:
4782 if (ATE_ON(pAdapter))
4784 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4785 Status = NDIS_STATUS_RESOURCES;
4788 #endif // RALINK_ATE //
4789 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4791 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4796 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4800 case OID_802_11_SSID:
4801 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4802 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4803 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4804 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4805 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4806 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4807 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4809 case RT_OID_802_11_QUERY_LINK_STATUS:
4810 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4813 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4814 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4815 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4816 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4817 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4818 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4819 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4821 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4825 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4829 case OID_802_11_CONFIGURATION:
4830 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4833 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4834 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4835 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4836 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4837 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4838 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4839 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4840 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4841 kfree(pConfiguration);
4845 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4849 case RT_OID_802_11_SNR_0:
4850 if ((pAdapter->StaCfg.LastSNR0 > 0))
4852 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4853 wrq->u.data.length = sizeof(ulInfo);
4854 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4855 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4860 case RT_OID_802_11_SNR_1:
4861 if ((pAdapter->Antenna.field.RxPath > 1) &&
4862 (pAdapter->StaCfg.LastSNR1 > 0))
4864 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4865 wrq->u.data.length = sizeof(ulInfo);
4866 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4867 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4871 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4873 case OID_802_11_RSSI_TRIGGER:
4874 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4875 wrq->u.data.length = sizeof(ulInfo);
4876 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4877 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4879 case OID_802_11_RSSI:
4880 case RT_OID_802_11_RSSI:
4881 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4882 wrq->u.data.length = sizeof(ulInfo);
4883 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4885 case RT_OID_802_11_RSSI_1:
4886 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4887 wrq->u.data.length = sizeof(ulInfo);
4888 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4890 case RT_OID_802_11_RSSI_2:
4891 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4892 wrq->u.data.length = sizeof(ulInfo);
4893 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4895 case OID_802_11_STATISTICS:
4896 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4899 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4900 // add the most up-to-date h/w raw counters into software counters
4901 NICUpdateRawCounters(pAdapter);
4903 // Sanity check for calculation of sucessful count
4904 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4905 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4907 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4908 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4909 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4910 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4911 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4912 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4913 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4914 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4915 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4916 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4917 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4919 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4921 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4922 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4924 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4925 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4930 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4934 case OID_GEN_RCV_OK:
4935 ulInfo = pAdapter->Counters8023.GoodReceives;
4936 wrq->u.data.length = sizeof(ulInfo);
4937 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4939 case OID_GEN_RCV_NO_BUFFER:
4940 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4941 wrq->u.data.length = sizeof(ulInfo);
4942 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4944 case RT_OID_802_11_PHY_MODE:
4945 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4946 wrq->u.data.length = sizeof(ulInfo);
4947 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4948 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4950 case RT_OID_802_11_STA_CONFIG:
4951 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4954 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4955 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4956 pStaConfig->EnableTurboRate = 0;
4957 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4958 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4959 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4960 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4961 pStaConfig->Rsv1 = 0;
4962 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4963 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4964 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4969 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4973 case OID_802_11_RTS_THRESHOLD:
4974 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4975 wrq->u.data.length = sizeof(RtsThresh);
4976 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4977 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4979 case OID_802_11_FRAGMENTATION_THRESHOLD:
4980 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4981 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4983 wrq->u.data.length = sizeof(FragThresh);
4984 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4985 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4987 case OID_802_11_POWER_MODE:
4988 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4989 wrq->u.data.length = sizeof(PowerMode);
4990 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4991 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4993 case RT_OID_802_11_RADIO:
4994 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4995 wrq->u.data.length = sizeof(RadioState);
4996 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4997 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4999 case OID_802_11_INFRASTRUCTURE_MODE:
5000 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
5001 BssType = Ndis802_11IBSS;
5002 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
5003 BssType = Ndis802_11Infrastructure;
5004 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
5005 BssType = Ndis802_11Monitor;
5007 BssType = Ndis802_11AutoUnknown;
5009 wrq->u.data.length = sizeof(BssType);
5010 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5011 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5013 case RT_OID_802_11_PREAMBLE:
5014 PreamType = pAdapter->CommonCfg.TxPreamble;
5015 wrq->u.data.length = sizeof(PreamType);
5016 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5017 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5019 case OID_802_11_AUTHENTICATION_MODE:
5020 AuthMode = pAdapter->StaCfg.AuthMode;
5021 wrq->u.data.length = sizeof(AuthMode);
5022 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5023 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5025 case OID_802_11_WEP_STATUS:
5026 WepStatus = pAdapter->StaCfg.WepStatus;
5027 wrq->u.data.length = sizeof(WepStatus);
5028 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5029 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5031 case OID_802_11_TX_POWER_LEVEL:
5032 wrq->u.data.length = sizeof(ULONG);
5033 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
5034 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
5036 case RT_OID_802_11_TX_POWER_LEVEL_1:
5037 wrq->u.data.length = sizeof(ULONG);
5038 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5039 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
5041 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5042 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
5044 NetworkTypeList[0] = 3; // NumberOfItems = 3
5045 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5046 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5047 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5048 wrq->u.data.length = 16;
5049 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5053 NetworkTypeList[0] = 2; // NumberOfItems = 2
5054 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5055 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5056 wrq->u.data.length = 12;
5057 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5059 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5061 case OID_802_11_NETWORK_TYPE_IN_USE:
5062 wrq->u.data.length = sizeof(ULONG);
5063 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5064 ulInfo = Ndis802_11OFDM5;
5065 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5066 ulInfo = Ndis802_11OFDM24;
5068 ulInfo = Ndis802_11DS;
5069 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5071 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5072 ulInfo = (ULONG)pAdapter->LastRxRate;
5073 wrq->u.data.length = sizeof(ulInfo);
5074 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5075 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5077 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5078 //ulInfo = (ULONG)pAdapter->LastTxRate;
5079 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5080 wrq->u.data.length = sizeof(ulInfo);
5081 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5082 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5084 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5085 wrq->u.data.length = sizeof(ULONG);
5086 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5088 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5089 wrq->u.data.length = sizeof(ULONG);
5090 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5092 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5093 wrq->u.data.length = sizeof(UCHAR);
5094 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5095 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5097 case RT_OID_802_11_EXTRA_INFO:
5098 wrq->u.data.length = sizeof(ULONG);
5099 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5100 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5102 case RT_OID_WE_VERSION_COMPILED:
5103 wrq->u.data.length = sizeof(UINT);
5104 we_version_compiled = WIRELESS_EXT;
5105 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5107 case RT_OID_802_11_QUERY_APSD_SETTING:
5108 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5109 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5111 wrq->u.data.length = sizeof(ULONG);
5112 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5113 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",
5114 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5116 case RT_OID_802_11_QUERY_APSD_PSM:
5117 wrq->u.data.length = sizeof(ULONG);
5118 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5119 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5121 case RT_OID_802_11_QUERY_WMM:
5122 wrq->u.data.length = sizeof(BOOLEAN);
5123 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5124 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5126 #ifdef WPA_SUPPLICANT_SUPPORT
5127 case RT_OID_NEW_DRIVER:
5130 wrq->u.data.length = sizeof(UCHAR);
5131 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5132 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5135 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5136 wrq->u.data.length = sizeof(UCHAR);
5137 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5138 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5140 #endif // WPA_SUPPLICANT_SUPPORT //
5142 case RT_OID_DRIVER_DEVICE_NAME:
5143 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5144 wrq->u.data.length = 16;
5145 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5150 case RT_OID_802_11_QUERY_HT_PHYMODE:
5151 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5154 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5155 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5156 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5157 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5158 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5159 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5161 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5162 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5163 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5167 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5168 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5169 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5173 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5177 case RT_OID_802_11_COUNTRY_REGION:
5178 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5179 wrq->u.data.length = sizeof(ulInfo);
5180 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5181 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5182 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5187 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5188 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5191 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5192 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5193 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5194 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5195 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5196 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5198 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5199 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5203 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5204 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5205 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5209 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5213 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5214 wrq->u.data.length = sizeof(UCHAR);
5216 #ifdef MULTIPLE_CARD_SUPPORT
5218 #endif // MULTIPLE_CARD_SUPPORT //
5219 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5223 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5226 case RT_OID_802_11_MAC_ADDRESS:
5227 wrq->u.data.length = MAC_ADDR_LEN;
5228 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5231 case RT_OID_802_11_MANUFACTUREROUI:
5232 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5233 wrq->u.data.length = ManufacturerOUI_LEN;
5234 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5237 case RT_OID_802_11_MANUFACTURERNAME:
5238 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5239 wrq->u.data.length = strlen(ManufacturerNAME);
5240 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5243 case RT_OID_802_11_RESOURCETYPEIDNAME:
5244 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5245 wrq->u.data.length = strlen(ResourceTypeIdName);
5246 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5249 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5250 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5251 ulInfo = 1; // 1 is support wep else 2 is not support.
5252 wrq->u.data.length = sizeof(ulInfo);
5253 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5256 case RT_OID_802_11_POWERMANAGEMENTMODE:
5257 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5258 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5259 ulInfo = 1; // 1 is power active else 2 is power save.
5263 wrq->u.data.length = sizeof(ulInfo);
5264 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5267 case OID_802_11_WEPDEFAULTKEYVALUE:
5268 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5269 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5270 pKeyIdxValue = wrq->u.data.pointer;
5271 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5272 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5273 NdisMoveMemory(pKeyIdxValue->Value,
5274 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5276 pKeyIdxValue->Value[valueLen]='\0';
5278 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5280 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5281 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,
5282 pAdapter->SharedKey[BSS0][0].Key[0],
5283 pAdapter->SharedKey[BSS0][1].Key[0],
5284 pAdapter->SharedKey[BSS0][2].Key[0],
5285 pAdapter->SharedKey[BSS0][3].Key[0]));
5288 case OID_802_11_WEPDEFAULTKEYID:
5289 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5290 wrq->u.data.length = sizeof(UCHAR);
5291 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5292 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5295 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5296 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5297 wrq->u.data.length = sizeof(UCHAR);
5298 Status = copy_to_user(wrq->u.data.pointer,
5299 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5300 wrq->u.data.length);
5303 case OID_802_11_SHORTRETRYLIMIT:
5304 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5305 wrq->u.data.length = sizeof(ULONG);
5306 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5307 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5308 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5309 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5312 case OID_802_11_LONGRETRYLIMIT:
5313 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5314 wrq->u.data.length = sizeof(ULONG);
5315 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5316 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5317 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5318 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5321 case RT_OID_802_11_PRODUCTID:
5322 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5328 if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
5329 pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5331 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5332 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5335 wrq->u.data.length = strlen(tmp);
5336 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5339 case RT_OID_802_11_MANUFACTUREID:
5340 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5341 wrq->u.data.length = strlen(ManufacturerNAME);
5342 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5345 case OID_802_11_CURRENTCHANNEL:
5346 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5347 wrq->u.data.length = sizeof(UCHAR);
5348 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5349 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5350 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5352 #endif //SNMP_SUPPORT
5354 case OID_802_11_BUILD_CHANNEL_EX:
5357 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5358 wrq->u.data.length = sizeof(UCHAR);
5359 #ifdef EXT_BUILD_CHANNEL_LIST
5360 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5363 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5365 #endif // EXT_BUILD_CHANNEL_LIST //
5366 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5367 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5371 case OID_802_11_GET_CH_LIST:
5373 PRT_CHANNEL_LIST_INFO pChListBuf;
5375 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5376 if (pAdapter->ChannelListNum == 0)
5378 wrq->u.data.length = 0;
5382 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5383 if (pChListBuf == NULL)
5385 wrq->u.data.length = 0;
5389 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5390 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5391 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5393 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5394 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5395 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5402 case OID_802_11_GET_COUNTRY_CODE:
5403 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5404 wrq->u.data.length = 2;
5405 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5406 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5409 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5410 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5411 wrq->u.data.length = 1;
5412 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5413 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5417 #ifdef QOS_DLS_SUPPORT
5418 case RT_OID_802_11_QUERY_DLS:
5419 wrq->u.data.length = sizeof(BOOLEAN);
5420 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5421 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5424 case RT_OID_802_11_QUERY_DLS_PARAM:
5426 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5427 if (pDlsInfo == NULL)
5430 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5432 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5435 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5436 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5437 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5438 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5444 #endif // QOS_DLS_SUPPORT //
5446 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5447 Status = -EOPNOTSUPP;
5453 INT rt28xx_sta_ioctl(
5454 IN struct net_device *net_dev,
5455 IN OUT struct ifreq *rq,
5459 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5460 RTMP_ADAPTER *pAd = NULL;
5461 struct iwreq *wrq = (struct iwreq *) rq;
5462 BOOLEAN StateMachineTouched = FALSE;
5463 INT Status = NDIS_STATUS_SUCCESS;
5466 if (net_dev->priv_flags == INT_MAIN)
5468 pAd = net_dev->ml_priv;
5472 pVirtualAd = net_dev->ml_priv;
5473 pAd = pVirtualAd->RtmpDev->ml_priv;
5475 pObj = (POS_COOKIE) pAd->OS_Cookie;
5479 /* if 1st open fail, pAd will be free;
5480 So the net_dev->ml_priv will be NULL in 2rd open */
5484 //check if the interface is down
5485 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5487 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5488 if (wrq->u.data.pointer == NULL)
5493 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5494 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5496 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5501 { // determine this ioctl command is comming from which interface.
5502 pObj->ioctl_if_type = INT_MAIN;
5503 pObj->ioctl_if = MAIN_MBSSID;
5509 #ifdef RALINK_28xx_QA
5510 case RTPRIV_IOCTL_ATE:
5512 RtmpDoAte(pAd, wrq);
5515 #endif // RALINK_28xx_QA //
5516 #endif // RALINK_ATE //
5518 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5519 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5523 char *name=&wrq->u.name[0];
5524 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5527 case SIOCGIWESSID: //Get ESSID
5529 struct iw_point *essid=&wrq->u.essid;
5530 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5533 case SIOCSIWESSID: //Set ESSID
5535 struct iw_point *essid=&wrq->u.essid;
5536 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5539 case SIOCSIWNWID: // set network id (the cell)
5540 case SIOCGIWNWID: // get network id
5541 Status = -EOPNOTSUPP;
5543 case SIOCSIWFREQ: //set channel/frequency (Hz)
5545 struct iw_freq *freq=&wrq->u.freq;
5546 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5549 case SIOCGIWFREQ: // get channel/frequency (Hz)
5551 struct iw_freq *freq=&wrq->u.freq;
5552 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5555 case SIOCSIWNICKN: //set node name/nickname
5557 struct iw_point *data=&wrq->u.data;
5558 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5561 case SIOCGIWNICKN: //get node name/nickname
5563 struct iw_point *data=&wrq->u.data;
5564 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5567 case SIOCGIWRATE: //get default bit rate (bps)
5568 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5570 case SIOCSIWRATE: //set default bit rate (bps)
5571 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5573 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5575 struct iw_param *rts=&wrq->u.rts;
5576 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5579 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5581 struct iw_param *rts=&wrq->u.rts;
5582 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5585 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5587 struct iw_param *frag=&wrq->u.frag;
5588 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5591 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5593 struct iw_param *frag=&wrq->u.frag;
5594 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5597 case SIOCGIWENCODE: //get encoding token & mode
5599 struct iw_point *erq=&wrq->u.encoding;
5601 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5604 case SIOCSIWENCODE: //set encoding token & mode
5606 struct iw_point *erq=&wrq->u.encoding;
5608 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5611 case SIOCGIWAP: //get access point MAC addresses
5613 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5614 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5617 case SIOCSIWAP: //set access point MAC addresses
5619 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5620 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5623 case SIOCGIWMODE: //get operation mode
5625 __u32 *mode=&wrq->u.mode;
5626 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5629 case SIOCSIWMODE: //set operation mode
5631 __u32 *mode=&wrq->u.mode;
5632 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5635 case SIOCGIWSENS: //get sensitivity (dBm)
5636 case SIOCSIWSENS: //set sensitivity (dBm)
5637 case SIOCGIWPOWER: //get Power Management settings
5638 case SIOCSIWPOWER: //set Power Management settings
5639 case SIOCGIWTXPOW: //get transmit power (dBm)
5640 case SIOCSIWTXPOW: //set transmit power (dBm)
5641 case SIOCGIWRANGE: //Get range of parameters
5642 case SIOCGIWRETRY: //get retry limits and lifetime
5643 case SIOCSIWRETRY: //set retry limits and lifetime
5644 Status = -EOPNOTSUPP;
5647 subcmd = wrq->u.data.flags;
5648 if( subcmd & OID_GET_SET_TOGGLE)
5649 Status = RTMPSetInformation(pAd, rq, subcmd);
5651 Status = RTMPQueryInformation(pAd, rq, subcmd);
5654 if (wrq->u.data.pointer)
5656 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5658 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5659 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5663 case RTPRIV_IOCTL_SET:
5664 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5666 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5668 case RTPRIV_IOCTL_GSITESURVEY:
5669 RTMPIoctlGetSiteSurvey(pAd, wrq);
5672 case RTPRIV_IOCTL_MAC:
5673 RTMPIoctlMAC(pAd, wrq);
5675 case RTPRIV_IOCTL_E2P:
5676 RTMPIoctlE2PROM(pAd, wrq);
5682 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5683 Status = -EOPNOTSUPP;
5687 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5688 RT28XX_MLME_HANDLER(pAd);
5694 ==========================================================================
5698 TRUE if all parameters are OK, FALSE otherwise
5699 ==========================================================================
5702 IN PRTMP_ADAPTER pAdapter,
5705 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5706 BOOLEAN StateMachineTouched = FALSE;
5709 if( strlen(arg) <= MAX_LEN_OF_SSID)
5711 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5712 if (strlen(arg) != 0)
5714 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5715 Ssid.SsidLength = strlen(arg);
5719 Ssid.SsidLength = 0;
5720 memcpy(Ssid.Ssid, "", 0);
5721 pAdapter->StaCfg.BssType = BSS_INFRA;
5722 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5723 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5727 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5729 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5730 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5733 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5734 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5735 pAdapter->bConfigChanged = TRUE;
5737 MlmeEnqueue(pAdapter,
5738 MLME_CNTL_STATE_MACHINE,
5740 sizeof(NDIS_802_11_SSID),
5743 StateMachineTouched = TRUE;
5744 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5749 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5750 RT28XX_MLME_HANDLER(pAdapter);
5757 ==========================================================================
5759 Set WmmCapable Enable or Disable
5761 TRUE if all parameters are OK, FALSE otherwise
5762 ==========================================================================
5764 INT Set_WmmCapable_Proc(
5765 IN PRTMP_ADAPTER pAd,
5768 BOOLEAN bWmmCapable;
5770 bWmmCapable = simple_strtol(arg, 0, 10);
5772 if ((bWmmCapable == 1)
5774 pAd->CommonCfg.bWmmCapable = TRUE;
5775 else if (bWmmCapable == 0)
5776 pAd->CommonCfg.bWmmCapable = FALSE;
5778 return FALSE; //Invalid argument
5780 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5781 pAd->CommonCfg.bWmmCapable));
5785 #endif // WMM_SUPPORT //
5788 ==========================================================================
5790 Set Network Type(Infrastructure/Adhoc mode)
5792 TRUE if all parameters are OK, FALSE otherwise
5793 ==========================================================================
5795 INT Set_NetworkType_Proc(
5796 IN PRTMP_ADAPTER pAdapter,
5801 if (strcmp(arg, "Adhoc") == 0)
5803 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5805 // Config has changed
5806 pAdapter->bConfigChanged = TRUE;
5807 if (MONITOR_ON(pAdapter))
5809 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5810 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5812 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5813 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5814 pAdapter->StaCfg.bAutoReconnect = TRUE;
5815 LinkDown(pAdapter, FALSE);
5817 if (INFRA_ON(pAdapter))
5819 //BOOLEAN Cancelled;
5820 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5821 // Since calling this indicate user don't want to connect to that SSID anymore.
5822 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5823 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5825 LinkDown(pAdapter, FALSE);
5827 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5830 pAdapter->StaCfg.BssType = BSS_ADHOC;
5831 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5832 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5834 else if (strcmp(arg, "Infra") == 0)
5836 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5838 // Config has changed
5839 pAdapter->bConfigChanged = TRUE;
5840 if (MONITOR_ON(pAdapter))
5842 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5843 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5845 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5846 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5847 pAdapter->StaCfg.bAutoReconnect = TRUE;
5848 LinkDown(pAdapter, FALSE);
5850 if (ADHOC_ON(pAdapter))
5852 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5853 // Since calling this indicate user don't want to connect to that SSID anymore.
5854 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5855 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5857 LinkDown(pAdapter, FALSE);
5860 pAdapter->StaCfg.BssType = BSS_INFRA;
5861 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5862 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5864 pAdapter->StaCfg.BssType = BSS_INFRA;
5866 else if (strcmp(arg, "Monitor") == 0)
5869 BCN_TIME_CFG_STRUC csr;
5870 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5871 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5872 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5873 // disable all periodic state machine
5874 pAdapter->StaCfg.bAutoReconnect = FALSE;
5875 // reset all mlme state machine
5876 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5877 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5878 if (pAdapter->CommonCfg.CentralChannel == 0)
5880 #ifdef DOT11_N_SUPPORT
5881 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5882 pAdapter->CommonCfg.CentralChannel = 36;
5884 #endif // DOT11_N_SUPPORT //
5885 pAdapter->CommonCfg.CentralChannel = 6;
5887 #ifdef DOT11_N_SUPPORT
5889 N_ChannelCheck(pAdapter);
5890 #endif // DOT11_N_SUPPORT //
5892 #ifdef DOT11_N_SUPPORT
5893 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5894 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5895 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5897 // 40MHz ,control channel at lower
5898 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5899 bbpValue &= (~0x18);
5901 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5902 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5903 // RX : control channel at lower
5904 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5905 bbpValue &= (~0x20);
5906 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5908 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5909 Value &= 0xfffffffe;
5910 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5911 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5912 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5913 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5914 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5915 pAdapter->CommonCfg.Channel,
5916 pAdapter->CommonCfg.CentralChannel));
5918 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5919 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5920 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5922 // 40MHz ,control channel at upper
5923 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5924 bbpValue &= (~0x18);
5926 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5927 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5928 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5930 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5932 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5934 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5935 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5936 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5937 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5938 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5939 pAdapter->CommonCfg.Channel,
5940 pAdapter->CommonCfg.CentralChannel));
5943 #endif // DOT11_N_SUPPORT //
5946 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5947 bbpValue &= (~0x18);
5948 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5949 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5950 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5951 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5952 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5954 // Enable Rx with promiscuous reception
5955 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5956 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5957 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5959 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5961 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5962 csr.field.bBeaconGen = 0;
5963 csr.field.bTBTTEnable = 0;
5964 csr.field.TsfSyncMode = 0;
5965 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5967 pAdapter->StaCfg.BssType = BSS_MONITOR;
5968 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5969 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5972 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5973 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5975 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5981 ==========================================================================
5983 Set Authentication mode
5985 TRUE if all parameters are OK, FALSE otherwise
5986 ==========================================================================
5988 INT Set_AuthMode_Proc(
5989 IN PRTMP_ADAPTER pAdapter,
5992 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5993 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5994 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5995 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5996 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5997 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5998 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5999 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
6000 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
6001 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
6002 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
6003 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
6004 #ifdef WPA_SUPPLICANT_SUPPORT
6005 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
6006 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
6007 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
6008 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
6009 #endif // WPA_SUPPLICANT_SUPPORT //
6013 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
6015 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6021 ==========================================================================
6025 TRUE if all parameters are OK, FALSE otherwise
6026 ==========================================================================
6028 INT Set_EncrypType_Proc(
6029 IN PRTMP_ADAPTER pAdapter,
6032 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6034 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6035 return TRUE; // do nothing
6037 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6038 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6039 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6041 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6043 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6044 return TRUE; // do nothing
6046 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6047 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6048 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6050 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6052 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6053 return TRUE; // do nothing
6055 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6056 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6057 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6059 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6061 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6062 return TRUE; // do nothing
6064 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6065 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6066 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6071 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6073 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6079 ==========================================================================
6083 TRUE if all parameters are OK, FALSE otherwise
6084 ==========================================================================
6086 INT Set_DefaultKeyID_Proc(
6087 IN PRTMP_ADAPTER pAdapter,
6092 KeyIdx = simple_strtol(arg, 0, 10);
6093 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6094 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6096 return FALSE; //Invalid argument
6098 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6104 ==========================================================================
6108 TRUE if all parameters are OK, FALSE otherwise
6109 ==========================================================================
6112 IN PRTMP_ADAPTER pAdapter,
6117 UCHAR CipherAlg=CIPHER_WEP64;
6119 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6120 return TRUE; // do nothing
6122 KeyLen = strlen(arg);
6126 case 5: //wep 40 Ascii type
6127 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6128 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6129 CipherAlg = CIPHER_WEP64;
6130 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6132 case 10: //wep 40 Hex type
6133 for(i=0; i < KeyLen; i++)
6135 if( !isxdigit(*(arg+i)) )
6136 return FALSE; //Not Hex value;
6138 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6139 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6140 CipherAlg = CIPHER_WEP64;
6141 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6143 case 13: //wep 104 Ascii type
6144 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6145 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6146 CipherAlg = CIPHER_WEP128;
6147 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6149 case 26: //wep 104 Hex type
6150 for(i=0; i < KeyLen; i++)
6152 if( !isxdigit(*(arg+i)) )
6153 return FALSE; //Not Hex value;
6155 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6156 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6157 CipherAlg = CIPHER_WEP128;
6158 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6160 default: //Invalid argument
6161 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6165 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6167 // Set keys (into ASIC)
6168 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6170 else // Old WEP stuff
6172 AsicAddSharedKeyEntry(pAdapter,
6175 pAdapter->SharedKey[BSS0][0].CipherAlg,
6176 pAdapter->SharedKey[BSS0][0].Key,
6184 ==========================================================================
6189 TRUE if all parameters are OK, FALSE otherwise
6190 ==========================================================================
6193 IN PRTMP_ADAPTER pAdapter,
6198 UCHAR CipherAlg=CIPHER_WEP64;
6200 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6201 return TRUE; // do nothing
6203 KeyLen = strlen(arg);
6207 case 5: //wep 40 Ascii type
6208 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6209 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6210 CipherAlg = CIPHER_WEP64;
6211 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6213 case 10: //wep 40 Hex type
6214 for(i=0; i < KeyLen; i++)
6216 if( !isxdigit(*(arg+i)) )
6217 return FALSE; //Not Hex value;
6219 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6220 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6221 CipherAlg = CIPHER_WEP64;
6222 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6224 case 13: //wep 104 Ascii type
6225 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6226 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6227 CipherAlg = CIPHER_WEP128;
6228 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6230 case 26: //wep 104 Hex type
6231 for(i=0; i < KeyLen; i++)
6233 if( !isxdigit(*(arg+i)) )
6234 return FALSE; //Not Hex value;
6236 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6237 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6238 CipherAlg = CIPHER_WEP128;
6239 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6241 default: //Invalid argument
6242 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6245 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6247 // Set keys (into ASIC)
6248 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6250 else // Old WEP stuff
6252 AsicAddSharedKeyEntry(pAdapter,
6255 pAdapter->SharedKey[BSS0][1].CipherAlg,
6256 pAdapter->SharedKey[BSS0][1].Key,
6264 ==========================================================================
6268 TRUE if all parameters are OK, FALSE otherwise
6269 ==========================================================================
6272 IN PRTMP_ADAPTER pAdapter,
6277 UCHAR CipherAlg=CIPHER_WEP64;
6279 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6280 return TRUE; // do nothing
6282 KeyLen = strlen(arg);
6286 case 5: //wep 40 Ascii type
6287 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6288 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6289 CipherAlg = CIPHER_WEP64;
6290 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6292 case 10: //wep 40 Hex type
6293 for(i=0; i < KeyLen; i++)
6295 if( !isxdigit(*(arg+i)) )
6296 return FALSE; //Not Hex value;
6298 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6299 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6300 CipherAlg = CIPHER_WEP64;
6301 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6303 case 13: //wep 104 Ascii type
6304 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6305 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6306 CipherAlg = CIPHER_WEP128;
6307 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6309 case 26: //wep 104 Hex type
6310 for(i=0; i < KeyLen; i++)
6312 if( !isxdigit(*(arg+i)) )
6313 return FALSE; //Not Hex value;
6315 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6316 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6317 CipherAlg = CIPHER_WEP128;
6318 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6320 default: //Invalid argument
6321 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6324 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6326 // Set keys (into ASIC)
6327 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6329 else // Old WEP stuff
6331 AsicAddSharedKeyEntry(pAdapter,
6334 pAdapter->SharedKey[BSS0][2].CipherAlg,
6335 pAdapter->SharedKey[BSS0][2].Key,
6343 ==========================================================================
6347 TRUE if all parameters are OK, FALSE otherwise
6348 ==========================================================================
6351 IN PRTMP_ADAPTER pAdapter,
6356 UCHAR CipherAlg=CIPHER_WEP64;
6358 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6359 return TRUE; // do nothing
6361 KeyLen = strlen(arg);
6365 case 5: //wep 40 Ascii type
6366 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6367 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6368 CipherAlg = CIPHER_WEP64;
6369 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6371 case 10: //wep 40 Hex type
6372 for(i=0; i < KeyLen; i++)
6374 if( !isxdigit(*(arg+i)) )
6375 return FALSE; //Not Hex value;
6377 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6378 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6379 CipherAlg = CIPHER_WEP64;
6380 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6382 case 13: //wep 104 Ascii type
6383 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6384 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6385 CipherAlg = CIPHER_WEP128;
6386 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6388 case 26: //wep 104 Hex type
6389 for(i=0; i < KeyLen; i++)
6391 if( !isxdigit(*(arg+i)) )
6392 return FALSE; //Not Hex value;
6394 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6395 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6396 CipherAlg = CIPHER_WEP128;
6397 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6399 default: //Invalid argument
6400 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6403 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6405 // Set keys (into ASIC)
6406 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6408 else // Old WEP stuff
6410 AsicAddSharedKeyEntry(pAdapter,
6413 pAdapter->SharedKey[BSS0][3].CipherAlg,
6414 pAdapter->SharedKey[BSS0][3].Key,
6423 ==========================================================================
6427 TRUE if all parameters are OK, FALSE otherwise
6428 ==========================================================================
6430 INT Set_WPAPSK_Proc(
6431 IN PRTMP_ADAPTER pAdapter,
6434 UCHAR keyMaterial[40];
6436 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6437 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6438 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6440 return TRUE; // do nothing
6442 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6444 NdisZeroMemory(keyMaterial, 40);
6446 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6448 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6452 if (strlen(arg) == 64)
6454 AtoH(arg, keyMaterial, 32);
6455 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6460 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6461 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6466 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6467 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6469 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6473 // Start STA supplicant state machine
6474 pAdapter->StaCfg.WpaState = SS_START;
6481 ==========================================================================
6483 Set Power Saving mode
6485 TRUE if all parameters are OK, FALSE otherwise
6486 ==========================================================================
6488 INT Set_PSMode_Proc(
6489 IN PRTMP_ADAPTER pAdapter,
6492 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6494 if ((strcmp(arg, "Max_PSP") == 0) ||
6495 (strcmp(arg, "max_psp") == 0) ||
6496 (strcmp(arg, "MAX_PSP") == 0))
6498 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6499 // to exclude certain situations.
6500 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6501 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6502 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6503 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6504 pAdapter->StaCfg.DefaultListenCount = 5;
6507 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6508 (strcmp(arg, "fast_psp") == 0) ||
6509 (strcmp(arg, "FAST_PSP") == 0))
6511 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6512 // to exclude certain situations.
6513 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6514 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6515 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6516 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6517 pAdapter->StaCfg.DefaultListenCount = 3;
6519 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6520 (strcmp(arg, "legacy_psp") == 0) ||
6521 (strcmp(arg, "LEGACY_PSP") == 0))
6523 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6524 // to exclude certain situations.
6525 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6526 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6527 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6528 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6529 pAdapter->StaCfg.DefaultListenCount = 3;
6533 //Default Ndis802_11PowerModeCAM
6534 // clear PSM bit immediately
6535 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6536 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6537 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6538 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6539 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6542 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6551 #ifdef WPA_SUPPLICANT_SUPPORT
6553 ==========================================================================
6555 Set WpaSupport flag.
6557 0: Driver ignore wpa_supplicant.
6558 1: wpa_supplicant initiates scanning and AP selection.
6559 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6561 TRUE if all parameters are OK, FALSE otherwise
6562 ==========================================================================
6564 INT Set_Wpa_Support(
6565 IN PRTMP_ADAPTER pAd,
6569 if ( simple_strtol(arg, 0, 10) == 0)
6570 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6571 else if ( simple_strtol(arg, 0, 10) == 1)
6572 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6573 else if ( simple_strtol(arg, 0, 10) == 2)
6574 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6576 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6578 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6582 #endif // WPA_SUPPLICANT_SUPPORT //
6586 ==========================================================================
6590 pAdapter Pointer to our adapter
6591 wrq Pointer to the ioctl argument
6598 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6599 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6600 ==========================================================================
6603 IN PRTMP_ADAPTER pAdapter,
6604 IN struct iwreq *wrq)
6612 UCHAR temp[16], temp2[16];
6613 UINT32 macValue = 0;
6617 memset(msg, 0x00, 1024);
6618 if (wrq->u.data.length > 1) //No parameters.
6620 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6623 //Parsing Read or Write
6628 if ((value = rtstrchr(this_char, '=')) != NULL)
6631 if (!value || !*value)
6634 if(strlen(this_char) > 4)
6637 j = strlen(this_char);
6640 if(this_char[j] > 'f' || this_char[j] < '0')
6645 k = j = strlen(this_char);
6648 this_char[4-k+j] = this_char[j];
6652 this_char[3-k++]='0';
6655 if(strlen(this_char) == 4)
6657 AtoH(this_char, temp, 2);
6658 macAddr = *temp*256 + temp[1];
6659 if (macAddr < 0xFFFF)
6661 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6662 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6663 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6666 {//Invalid parametes, so default printk all bbp
6673 memcpy(&temp2, value, strlen(value));
6674 temp2[strlen(value)] = '\0';
6677 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6680 j = strlen(this_char);
6683 if(this_char[j] > 'f' || this_char[j] < '0')
6690 if(temp2[j] > 'f' || temp2[j] < '0')
6695 k = j = strlen(this_char);
6698 this_char[4-k+j] = this_char[j];
6702 this_char[3-k++]='0';
6706 k = j = strlen(temp2);
6709 temp2[8-k+j] = temp2[j];
6717 AtoH(this_char, temp, 2);
6718 macAddr = *temp*256 + temp[1];
6720 AtoH(temp2, temp, 4);
6721 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6724 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6726 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6727 if (macValue & 0x000000ff)
6729 pAdapter->BbpTuning.bEnable = TRUE;
6730 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6735 pAdapter->BbpTuning.bEnable = FALSE;
6736 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6738 if (ATE_ON(pAdapter))
6740 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6743 #endif // RALINK_ATE //
6744 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6745 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6750 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6752 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6753 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6758 if(strlen(msg) == 1)
6759 sprintf(msg+strlen(msg), "===>Error command format!");
6761 // Copy the information into the user buffer
6762 wrq->u.data.length = strlen(msg);
6763 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6765 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6769 ==========================================================================
6773 pAdapter Pointer to our adapter
6774 wrq Pointer to the ioctl argument
6781 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6782 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6783 ==========================================================================
6785 VOID RTMPIoctlE2PROM(
6786 IN PRTMP_ADAPTER pAdapter,
6787 IN struct iwreq *wrq)
6795 UCHAR temp[16], temp2[16];
6800 memset(msg, 0x00, 1024);
6801 if (wrq->u.data.length > 1) //No parameters.
6803 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6806 //Parsing Read or Write
6813 if ((value = rtstrchr(this_char, '=')) != NULL)
6816 if (!value || !*value)
6820 if(strlen(this_char) > 4)
6823 j = strlen(this_char);
6826 if(this_char[j] > 'f' || this_char[j] < '0')
6831 k = j = strlen(this_char);
6834 this_char[4-k+j] = this_char[j];
6838 this_char[3-k++]='0';
6841 if(strlen(this_char) == 4)
6843 AtoH(this_char, temp, 2);
6844 eepAddr = *temp*256 + temp[1];
6845 if (eepAddr < 0xFFFF)
6847 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6848 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6851 {//Invalid parametes, so default printk all bbp
6858 memcpy(&temp2, value, strlen(value));
6859 temp2[strlen(value)] = '\0';
6862 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6865 j = strlen(this_char);
6868 if(this_char[j] > 'f' || this_char[j] < '0')
6874 if(temp2[j] > 'f' || temp2[j] < '0')
6879 k = j = strlen(this_char);
6882 this_char[4-k+j] = this_char[j];
6886 this_char[3-k++]='0';
6890 k = j = strlen(temp2);
6893 temp2[4-k+j] = temp2[j];
6900 AtoH(this_char, temp, 2);
6901 eepAddr = *temp*256 + temp[1];
6903 AtoH(temp2, temp, 2);
6904 eepValue = *temp*256 + temp[1];
6906 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6907 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6911 if(strlen(msg) == 1)
6912 sprintf(msg+strlen(msg), "===>Error command format!");
6915 // Copy the information into the user buffer
6916 wrq->u.data.length = strlen(msg);
6917 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6919 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6926 INT Set_TGnWifiTest_Proc(
6927 IN PRTMP_ADAPTER pAd,
6930 if (simple_strtol(arg, 0, 10) == 0)
6931 pAd->StaCfg.bTGnWifiTest = FALSE;
6933 pAd->StaCfg.bTGnWifiTest = TRUE;
6935 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6939 INT Set_LongRetryLimit_Proc(
6940 IN PRTMP_ADAPTER pAdapter,
6943 TX_RTY_CFG_STRUC tx_rty_cfg;
6944 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6946 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6947 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6948 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6949 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6953 INT Set_ShortRetryLimit_Proc(
6954 IN PRTMP_ADAPTER pAdapter,
6957 TX_RTY_CFG_STRUC tx_rty_cfg;
6958 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6960 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6961 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6962 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6963 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6967 #ifdef EXT_BUILD_CHANNEL_LIST
6968 INT Set_Ieee80211dClientMode_Proc(
6969 IN PRTMP_ADAPTER pAdapter,
6972 if (simple_strtol(arg, 0, 10) == 0)
6973 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6974 else if (simple_strtol(arg, 0, 10) == 1)
6975 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6976 else if (simple_strtol(arg, 0, 10) == 2)
6977 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6981 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6984 #endif // EXT_BUILD_CHANNEL_LIST //
6986 #ifdef CARRIER_DETECTION_SUPPORT
6987 INT Set_CarrierDetect_Proc(
6988 IN PRTMP_ADAPTER pAd,
6991 if (simple_strtol(arg, 0, 10) == 0)
6992 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6994 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6996 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6999 #endif // CARRIER_DETECTION_SUPPORT //