2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90 /* --- sub-ioctls relations --- */
92 { RTPRIV_IOCTL_STATISTICS,
93 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
95 { RTPRIV_IOCTL_GSITESURVEY,
96 0, IW_PRIV_TYPE_CHAR | 1024,
101 IN PRTMP_ADAPTER pAdapter,
105 INT Set_WmmCapable_Proc(
106 IN PRTMP_ADAPTER pAd,
110 INT Set_NetworkType_Proc(
111 IN PRTMP_ADAPTER pAdapter,
114 INT Set_AuthMode_Proc(
115 IN PRTMP_ADAPTER pAdapter,
118 INT Set_EncrypType_Proc(
119 IN PRTMP_ADAPTER pAdapter,
122 INT Set_DefaultKeyID_Proc(
123 IN PRTMP_ADAPTER pAdapter,
127 IN PRTMP_ADAPTER pAdapter,
131 IN PRTMP_ADAPTER pAdapter,
135 IN PRTMP_ADAPTER pAdapter,
139 IN PRTMP_ADAPTER pAdapter,
143 IN PRTMP_ADAPTER pAdapter,
148 IN PRTMP_ADAPTER pAdapter,
152 IN PRTMP_ADAPTER pAd,
155 NDIS_STATUS RTMPWPANoneAddKeyProc(
156 IN PRTMP_ADAPTER pAd,
159 INT Set_FragTest_Proc(
160 IN PRTMP_ADAPTER pAdapter,
163 INT Set_TGnWifiTest_Proc(
164 IN PRTMP_ADAPTER pAd,
167 INT Set_LongRetryLimit_Proc(
168 IN PRTMP_ADAPTER pAdapter,
171 INT Set_ShortRetryLimit_Proc(
172 IN PRTMP_ADAPTER pAdapter,
177 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
178 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
179 {"DriverVersion", Set_DriverVersion_Proc},
180 {"CountryRegion", Set_CountryRegion_Proc},
181 {"CountryRegionABand", Set_CountryRegionABand_Proc},
182 {"SSID", Set_SSID_Proc},
183 {"WirelessMode", Set_WirelessMode_Proc},
184 {"TxBurst", Set_TxBurst_Proc},
185 {"TxPreamble", Set_TxPreamble_Proc},
186 {"TxPower", Set_TxPower_Proc},
187 {"Channel", Set_Channel_Proc},
188 {"BGProtection", Set_BGProtection_Proc},
189 {"RTSThreshold", Set_RTSThreshold_Proc},
190 {"FragThreshold", Set_FragThreshold_Proc},
191 {"HtBw", Set_HtBw_Proc},
192 {"HtMcs", Set_HtMcs_Proc},
193 {"HtGi", Set_HtGi_Proc},
194 {"HtOpMode", Set_HtOpMode_Proc},
195 {"HtExtcha", Set_HtExtcha_Proc},
196 {"HtMpduDensity", Set_HtMpduDensity_Proc},
197 {"HtBaWinSize", Set_HtBaWinSize_Proc},
198 {"HtRdg", Set_HtRdg_Proc},
199 {"HtAmsdu", Set_HtAmsdu_Proc},
200 {"HtAutoBa", Set_HtAutoBa_Proc},
201 {"HtBaDecline", Set_BADecline_Proc},
202 {"HtProtect", Set_HtProtect_Proc},
203 {"HtMimoPs", Set_HtMimoPs_Proc},
204 #ifdef AGGREGATION_SUPPORT
205 {"PktAggregate", Set_PktAggregate_Proc},
209 {"WmmCapable", Set_WmmCapable_Proc},
211 {"IEEE80211H", Set_IEEE80211H_Proc},
212 {"NetworkType", Set_NetworkType_Proc},
213 {"AuthMode", Set_AuthMode_Proc},
214 {"EncrypType", Set_EncrypType_Proc},
215 {"DefaultKeyID", Set_DefaultKeyID_Proc},
216 {"Key1", Set_Key1_Proc},
217 {"Key2", Set_Key2_Proc},
218 {"Key3", Set_Key3_Proc},
219 {"Key4", Set_Key4_Proc},
220 {"WPAPSK", Set_WPAPSK_Proc},
221 {"ResetCounter", Set_ResetStatCounter_Proc},
222 {"PSMode", Set_PSMode_Proc},
224 {"Debug", Set_Debug_Proc},
226 {"WpaSupport", Set_Wpa_Support},
227 {"FixedTxMode", Set_FixedTxMode_Proc},
228 {"TGnWifiTest", Set_TGnWifiTest_Proc},
229 {"ForceGF", Set_ForceGF_Proc},
230 {"LongRetry", Set_LongRetryLimit_Proc},
231 {"ShortRetry", Set_ShortRetryLimit_Proc},
232 //2008/09/11:KH add to support efuse<--
234 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
235 {"efuseDump", set_eFusedump_Proc},
236 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
238 //2008/09/11:KH add to support efuse-->
244 IN PRTMP_ADAPTER pAd,
245 IN PNDIS_802_11_KEY pKey)
248 MAC_TABLE_ENTRY *pEntry;
250 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
253 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
254 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
256 if (pAd->StaCfg.bRadio == FALSE)
258 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
261 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
262 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
264 pAd->bPCIclkOff = FALSE;
268 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
270 if (pKey->KeyIndex & 0x80000000)
272 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
274 NdisZeroMemory(pAd->StaCfg.PMK, 32);
275 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
279 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
280 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
281 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
283 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
285 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
286 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
290 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
291 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
294 // Decide its ChiperAlg
295 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
296 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
297 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
298 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
300 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
302 // Update these related information to MAC_TABLE_ENTRY
303 pEntry = &pAd->MacTab.Content[BSSID_WCID];
304 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
305 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
306 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
307 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
309 // Update pairwise key information to ASIC Shared Key Table
310 AsicAddSharedKeyEntry(pAd,
313 pAd->SharedKey[BSS0][0].CipherAlg,
314 pAd->SharedKey[BSS0][0].Key,
315 pAd->SharedKey[BSS0][0].TxMic,
316 pAd->SharedKey[BSS0][0].RxMic);
318 // Update ASIC WCID attribute table and IVEIV table
319 RTMPAddWcidAttributeEntry(pAd,
322 pAd->SharedKey[BSS0][0].CipherAlg,
325 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
327 // set 802.1x port control
328 STA_PORT_SECURED(pAd);
330 // Indicate Connected for GUI
331 pAd->IndicateMediaState = NdisMediaStateConnected;
337 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
338 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
339 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
340 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
342 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
344 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
345 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
349 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
350 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
353 // Update Shared Key CipherAlg
354 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
355 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
356 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
357 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
358 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
360 // Update group key information to ASIC Shared Key Table
361 AsicAddSharedKeyEntry(pAd,
363 pAd->StaCfg.DefaultKeyId,
364 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
365 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
366 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
367 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
369 // Update ASIC WCID attribute table and IVEIV table
370 RTMPAddWcidAttributeEntry(pAd,
372 pAd->StaCfg.DefaultKeyId,
373 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
376 // set 802.1x port control
377 STA_PORT_SECURED(pAd);
379 // Indicate Connected for GUI
380 pAd->IndicateMediaState = NdisMediaStateConnected;
383 else // dynamic WEP from wpa_supplicant
388 if(pKey->KeyLength == 32)
391 KeyIdx = pKey->KeyIndex & 0x0fffffff;
395 // it is a default shared key, for Pairwise key setting
396 if (pKey->KeyIndex & 0x80000000)
398 pEntry = MacTableLookup(pAd, pKey->BSSID);
402 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
404 // set key material and key length
405 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
406 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
409 if (pKey->KeyLength == 5)
410 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
412 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
414 // Add Pair-wise key to Asic
415 AsicAddPairwiseKeyEntry(
419 &pEntry->PairwiseKey);
421 // update WCID attribute table and IVEIV table for this entry
422 RTMPAddWcidAttributeEntry(
425 KeyIdx, // The value may be not zero
426 pEntry->PairwiseKey.CipherAlg,
433 // Default key for tx (shared key)
434 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
436 // set key material and key length
437 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
438 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
441 if (pKey->KeyLength == 5)
442 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
444 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
446 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
447 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
449 // Set Group key material to Asic
450 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
452 // Update WCID attribute table and IVEIV table for this group key table
453 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
460 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
461 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
466 char * rtstrchr(const char * s, int c)
468 for(; *s != (char) c; ++s)
475 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
479 rt_ioctl_giwname(struct net_device *dev,
480 struct iw_request_info *info,
481 char *name, char *extra)
483 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
484 strncpy(name, RT28xx_CHIP_NAME " Wireless", IFNAMSIZ);
488 int rt_ioctl_siwfreq(struct net_device *dev,
489 struct iw_request_info *info,
490 struct iw_freq *freq, char *extra)
492 PRTMP_ADAPTER pAdapter = dev->ml_priv;
495 //check if the interface is down
496 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
498 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
506 if((freq->e == 0) && (freq->m <= 1000))
507 chan = freq->m; // Setting by channel number
509 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
511 if (ChannelSanity(pAdapter, chan) == TRUE)
513 pAdapter->CommonCfg.Channel = chan;
514 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
521 int rt_ioctl_giwfreq(struct net_device *dev,
522 struct iw_request_info *info,
523 struct iw_freq *freq, char *extra)
525 PRTMP_ADAPTER pAdapter = dev->ml_priv;
526 UCHAR ch = pAdapter->CommonCfg.Channel;
529 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
531 MAP_CHANNEL_ID_TO_KHZ(ch, m);
537 int rt_ioctl_siwmode(struct net_device *dev,
538 struct iw_request_info *info,
539 __u32 *mode, char *extra)
541 PRTMP_ADAPTER pAdapter = dev->ml_priv;
543 //check if the interface is down
544 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
546 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
553 Set_NetworkType_Proc(pAdapter, "Adhoc");
556 Set_NetworkType_Proc(pAdapter, "Infra");
558 case IW_MODE_MONITOR:
559 Set_NetworkType_Proc(pAdapter, "Monitor");
562 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
566 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
567 pAdapter->StaCfg.WpaState = SS_NOTUSE;
572 int rt_ioctl_giwmode(struct net_device *dev,
573 struct iw_request_info *info,
574 __u32 *mode, char *extra)
576 PRTMP_ADAPTER pAdapter = dev->ml_priv;
578 if (ADHOC_ON(pAdapter))
579 *mode = IW_MODE_ADHOC;
580 else if (INFRA_ON(pAdapter))
581 *mode = IW_MODE_INFRA;
582 else if (MONITOR_ON(pAdapter))
584 *mode = IW_MODE_MONITOR;
587 *mode = IW_MODE_AUTO;
589 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
593 int rt_ioctl_siwsens(struct net_device *dev,
594 struct iw_request_info *info,
595 char *name, char *extra)
597 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"));
609 int rt_ioctl_giwsens(struct net_device *dev,
610 struct iw_request_info *info,
611 char *name, char *extra)
616 int rt_ioctl_giwrange(struct net_device *dev,
617 struct iw_request_info *info,
618 struct iw_point *data, char *extra)
620 PRTMP_ADAPTER pAdapter = dev->ml_priv;
621 struct iw_range *range = (struct iw_range *) extra;
625 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
626 data->length = sizeof(struct iw_range);
627 memset(range, 0, sizeof(struct iw_range));
629 range->txpower_capa = IW_TXPOW_DBM;
631 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
633 range->min_pmp = 1 * 1024;
634 range->max_pmp = 65535 * 1024;
635 range->min_pmt = 1 * 1024;
636 range->max_pmt = 1000 * 1024;
637 range->pmp_flags = IW_POWER_PERIOD;
638 range->pmt_flags = IW_POWER_TIMEOUT;
639 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
640 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
643 range->we_version_compiled = WIRELESS_EXT;
644 range->we_version_source = 14;
646 range->retry_capa = IW_RETRY_LIMIT;
647 range->retry_flags = IW_RETRY_LIMIT;
648 range->min_retry = 0;
649 range->max_retry = 255;
651 range->num_channels = pAdapter->ChannelListNum;
654 for (i = 1; i <= range->num_channels; i++)
657 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
658 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
659 range->freq[val].m = m * 100; /* HZ */
661 range->freq[val].e = 1;
663 if (val == IW_MAX_FREQUENCIES)
666 range->num_frequency = val;
668 range->max_qual.qual = 100; /* what is correct max? This was not
669 * documented exactly. At least
670 * 69 has been observed. */
671 range->max_qual.level = 0; /* dB */
672 range->max_qual.noise = 0; /* dB */
674 /* What would be suitable values for "average/typical" qual? */
675 range->avg_qual.qual = 20;
676 range->avg_qual.level = -60;
677 range->avg_qual.noise = -95;
678 range->sensitivity = 3;
680 range->max_encoding_tokens = NR_WEP_KEYS;
681 range->num_encoding_sizes = 2;
682 range->encoding_size[0] = 5;
683 range->encoding_size[1] = 13;
686 range->max_rts = 2347;
687 range->min_frag = 256;
688 range->max_frag = 2346;
690 /* IW_ENC_CAPA_* bit field */
691 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
692 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
697 int rt_ioctl_siwap(struct net_device *dev,
698 struct iw_request_info *info,
699 struct sockaddr *ap_addr, char *extra)
701 PRTMP_ADAPTER pAdapter = dev->ml_priv;
702 NDIS_802_11_MAC_ADDRESS Bssid;
704 //check if the interface is down
705 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
707 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
711 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
713 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
714 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
717 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
718 // this request, because this request is initiated by NDIS.
719 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
720 // Prevent to connect AP again in STAMlmePeriodicExec
721 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
723 memset(Bssid, 0, MAC_ADDR_LEN);
724 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
725 MlmeEnqueue(pAdapter,
726 MLME_CNTL_STATE_MACHINE,
728 sizeof(NDIS_802_11_MAC_ADDRESS),
731 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
732 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
737 int rt_ioctl_giwap(struct net_device *dev,
738 struct iw_request_info *info,
739 struct sockaddr *ap_addr, char *extra)
741 PRTMP_ADAPTER pAdapter = dev->ml_priv;
743 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
745 ap_addr->sa_family = ARPHRD_ETHER;
746 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
749 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
751 ap_addr->sa_family = ARPHRD_ETHER;
752 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
756 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
764 * Units are in db above the noise floor. That means the
765 * rssi values reported in the tx/rx descriptors in the
766 * driver are the SNR expressed in db.
768 * If you assume that the noise floor is -95, which is an
769 * excellent assumption 99.5 % of the time, then you can
770 * derive the absolute signal level (i.e. -95 + rssi).
771 * There are some other slight factors to take into account
772 * depending on whether the rssi measurement is from 11b,
773 * 11g, or 11a. These differences are at most 2db and
776 * NB: various calculations are based on the orinoco/wavelan
777 * drivers for compatibility
779 static void set_quality(PRTMP_ADAPTER pAdapter,
780 struct iw_quality *iq,
787 ChannelQuality = 100;
788 else if (rssi >= -80) // between -50 ~ -80dbm
789 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
790 else if (rssi >= -90) // between -80 ~ -90dbm
791 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
795 iq->qual = (__u8)ChannelQuality;
797 iq->level = (__u8)(rssi);
798 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
799 iq->noise += 256 - 143;
800 iq->updated = pAdapter->iw_stats.qual.updated;
803 int rt_ioctl_iwaplist(struct net_device *dev,
804 struct iw_request_info *info,
805 struct iw_point *data, char *extra)
807 PRTMP_ADAPTER pAdapter = dev->ml_priv;
809 struct sockaddr addr[IW_MAX_AP];
810 struct iw_quality qual[IW_MAX_AP];
813 //check if the interface is down
814 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
816 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
822 for (i = 0; i <IW_MAX_AP ; i++)
824 if (i >= pAdapter->ScanTab.BssNr)
826 addr[i].sa_family = ARPHRD_ETHER;
827 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
828 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
831 memcpy(extra, &addr, i*sizeof(addr[0]));
832 data->flags = 1; /* signal quality present (sort of) */
833 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
838 int rt_ioctl_siwscan(struct net_device *dev,
839 struct iw_request_info *info,
840 struct iw_point *data, char *extra)
842 PRTMP_ADAPTER pAdapter = dev->ml_priv;
845 int Status = NDIS_STATUS_SUCCESS;
847 //check if the interface is down
848 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
850 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
854 if (MONITOR_ON(pAdapter))
856 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
860 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
861 && (pAdapter->StaCfg.bRadio == TRUE)
862 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
864 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
866 // Check if still radio off.
867 else if (pAdapter->bPCIclkOff == TRUE)
870 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
872 pAdapter->StaCfg.WpaSupplicantScanCount++;
875 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
876 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
881 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
882 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
884 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
885 Status = NDIS_STATUS_SUCCESS;
889 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
890 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
891 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
892 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
894 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
895 Status = NDIS_STATUS_SUCCESS;
899 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
901 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
902 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
905 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
906 // this request, because this request is initiated by NDIS.
907 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
908 // Reset allowed scan retries
909 pAdapter->StaCfg.ScanCnt = 0;
910 pAdapter->StaCfg.LastScanTime = Now;
912 MlmeEnqueue(pAdapter,
913 MLME_CNTL_STATE_MACHINE,
914 OID_802_11_BSSID_LIST_SCAN,
918 Status = NDIS_STATUS_SUCCESS;
919 RT28XX_MLME_HANDLER(pAdapter);
924 int rt_ioctl_giwscan(struct net_device *dev,
925 struct iw_request_info *info,
926 struct iw_point *data, char *extra)
929 PRTMP_ADAPTER pAdapter = dev->ml_priv;
931 char *current_ev = extra, *previous_ev = extra;
933 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
936 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
939 * Still scanning, indicate the caller should try again.
944 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
946 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
949 if (pAdapter->ScanTab.BssNr == 0)
955 if (data->length > 0)
956 end_buf = extra + data->length;
958 end_buf = extra + IW_SCAN_MAX_DATA;
960 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
962 if (current_ev >= end_buf)
966 //================================
967 memset(&iwe, 0, sizeof(iwe));
969 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
970 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
972 previous_ev = current_ev;
973 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
974 if (current_ev == previous_ev)
979 it will show scanned AP's WirelessMode .
988 memset(&iwe, 0, sizeof(iwe));
989 iwe.cmd = SIOCGIWNAME;
993 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
994 BOOLEAN isGonly=FALSE;
997 if (pBssEntry->Channel>14)
999 if (pBssEntry->HtCapabilityLen!=0)
1000 strcpy(iwe.u.name,"802.11a/n");
1002 strcpy(iwe.u.name,"802.11a");
1007 if one of non B mode rate is set supported rate . it mean G only.
1009 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1012 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1014 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1018 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1020 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1025 if (pBssEntry->HtCapabilityLen!=0)
1028 strcpy(iwe.u.name,"802.11g/n");
1030 strcpy(iwe.u.name,"802.11b/g/n");
1035 strcpy(iwe.u.name,"802.11g");
1038 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1039 strcpy(iwe.u.name,"802.11b");
1041 strcpy(iwe.u.name,"802.11b/g");
1047 previous_ev = current_ev;
1048 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1049 if (current_ev == previous_ev)
1053 //================================
1054 memset(&iwe, 0, sizeof(iwe));
1055 iwe.cmd = SIOCGIWESSID;
1056 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1057 iwe.u.data.flags = 1;
1059 previous_ev = current_ev;
1060 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1061 if (current_ev == previous_ev)
1065 //================================
1066 memset(&iwe, 0, sizeof(iwe));
1067 iwe.cmd = SIOCGIWMODE;
1068 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1070 iwe.u.mode = IW_MODE_ADHOC;
1072 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1074 iwe.u.mode = IW_MODE_INFRA;
1078 iwe.u.mode = IW_MODE_AUTO;
1080 iwe.len = IW_EV_UINT_LEN;
1082 previous_ev = current_ev;
1083 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1084 if (current_ev == previous_ev)
1087 //Channel and Frequency
1088 //================================
1089 memset(&iwe, 0, sizeof(iwe));
1090 iwe.cmd = SIOCGIWFREQ;
1091 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1092 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1094 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1098 previous_ev = current_ev;
1099 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1100 if (current_ev == previous_ev)
1103 //Add quality statistics
1104 //================================
1105 memset(&iwe, 0, sizeof(iwe));
1107 iwe.u.qual.level = 0;
1108 iwe.u.qual.noise = 0;
1109 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1110 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1111 if (current_ev == previous_ev)
1115 //================================
1116 memset(&iwe, 0, sizeof(iwe));
1117 iwe.cmd = SIOCGIWENCODE;
1118 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1119 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1121 iwe.u.data.flags = IW_ENCODE_DISABLED;
1123 previous_ev = current_ev;
1124 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);
1125 if (current_ev == previous_ev)
1129 //================================
1130 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1132 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1133 memset(&iwe, 0, sizeof(iwe));
1134 iwe.cmd = SIOCGIWRATE;
1135 current_val = current_ev + IW_EV_LCP_LEN;
1136 if (tmpRate == 0x82)
1137 iwe.u.bitrate.value = 1 * 1000000;
1138 else if (tmpRate == 0x84)
1139 iwe.u.bitrate.value = 2 * 1000000;
1140 else if (tmpRate == 0x8B)
1141 iwe.u.bitrate.value = 5.5 * 1000000;
1142 else if (tmpRate == 0x96)
1143 iwe.u.bitrate.value = 11 * 1000000;
1145 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1147 iwe.u.bitrate.disabled = 0;
1148 current_val = iwe_stream_add_value(info, current_ev,
1149 current_val, end_buf, &iwe,
1152 if((current_val-current_ev)>IW_EV_LCP_LEN)
1153 current_ev = current_val;
1159 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1161 memset(&iwe, 0, sizeof(iwe));
1162 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1163 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1164 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1165 iwe.cmd = IWEVGENIE;
1166 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1167 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1168 if (current_ev == previous_ev)
1173 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1175 memset(&iwe, 0, sizeof(iwe));
1176 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1177 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1178 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1179 iwe.cmd = IWEVGENIE;
1180 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1181 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1182 if (current_ev == previous_ev)
1187 data->length = current_ev - extra;
1188 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1189 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1193 int rt_ioctl_siwessid(struct net_device *dev,
1194 struct iw_request_info *info,
1195 struct iw_point *data, char *essid)
1197 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1199 //check if the interface is down
1200 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1202 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1208 PCHAR pSsidString = NULL;
1210 // Includes null character.
1211 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1214 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1217 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1218 NdisMoveMemory(pSsidString, essid, data->length);
1219 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1228 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1234 int rt_ioctl_giwessid(struct net_device *dev,
1235 struct iw_request_info *info,
1236 struct iw_point *data, char *essid)
1238 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1241 if (MONITOR_ON(pAdapter))
1247 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1249 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1250 data->length = pAdapter->CommonCfg.SsidLen;
1251 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1255 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1257 data->length = pAdapter->CommonCfg.SsidLen;
1258 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1262 {//the ANY ssid was specified
1264 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1271 int rt_ioctl_siwnickn(struct net_device *dev,
1272 struct iw_request_info *info,
1273 struct iw_point *data, char *nickname)
1275 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1277 //check if the interface is down
1278 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1280 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1284 if (data->length > IW_ESSID_MAX_SIZE)
1287 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1288 memcpy(pAdapter->nickname, nickname, data->length);
1294 int rt_ioctl_giwnickn(struct net_device *dev,
1295 struct iw_request_info *info,
1296 struct iw_point *data, char *nickname)
1298 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1300 if (data->length > strlen(pAdapter->nickname) + 1)
1301 data->length = strlen(pAdapter->nickname) + 1;
1302 if (data->length > 0) {
1303 memcpy(nickname, pAdapter->nickname, data->length-1);
1304 nickname[data->length-1] = '\0';
1309 int rt_ioctl_siwrts(struct net_device *dev,
1310 struct iw_request_info *info,
1311 struct iw_param *rts, char *extra)
1313 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1316 //check if the interface is down
1317 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1319 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1324 val = MAX_RTS_THRESHOLD;
1325 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1327 else if (rts->value == 0)
1328 val = MAX_RTS_THRESHOLD;
1332 if (val != pAdapter->CommonCfg.RtsThreshold)
1333 pAdapter->CommonCfg.RtsThreshold = val;
1338 int rt_ioctl_giwrts(struct net_device *dev,
1339 struct iw_request_info *info,
1340 struct iw_param *rts, char *extra)
1342 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1344 //check if the interface is down
1345 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1347 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1351 rts->value = pAdapter->CommonCfg.RtsThreshold;
1352 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1358 int rt_ioctl_siwfrag(struct net_device *dev,
1359 struct iw_request_info *info,
1360 struct iw_param *frag, char *extra)
1362 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1365 //check if the interface is down
1366 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1368 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1373 val = MAX_FRAG_THRESHOLD;
1374 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1375 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1376 else if (frag->value == 0)
1377 val = MAX_FRAG_THRESHOLD;
1381 pAdapter->CommonCfg.FragmentThreshold = val;
1385 int rt_ioctl_giwfrag(struct net_device *dev,
1386 struct iw_request_info *info,
1387 struct iw_param *frag, char *extra)
1389 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1391 //check if the interface is down
1392 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1394 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1398 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1399 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1405 #define MAX_WEP_KEY_SIZE 13
1406 #define MIN_WEP_KEY_SIZE 5
1407 int rt_ioctl_siwencode(struct net_device *dev,
1408 struct iw_request_info *info,
1409 struct iw_point *erq, char *extra)
1411 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1413 //check if the interface is down
1414 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1416 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1420 if ((erq->length == 0) &&
1421 (erq->flags & IW_ENCODE_DISABLED))
1423 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1424 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1425 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1426 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1427 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1430 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)) {
1431 STA_PORT_SECURED(pAdapter);
1432 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1433 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1434 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1435 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1436 if (erq->flags & IW_ENCODE_RESTRICTED)
1437 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1439 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1442 if (erq->length > 0)
1444 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1445 /* Check the size of the key */
1446 if (erq->length > MAX_WEP_KEY_SIZE) {
1449 /* Check key index */
1450 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1452 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1453 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1456 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1459 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1461 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1463 if (erq->length == MAX_WEP_KEY_SIZE)
1465 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1466 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1468 else if (erq->length == MIN_WEP_KEY_SIZE)
1470 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1471 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1474 /* Disable the key */
1475 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1477 /* Check if the key is not marked as invalid */
1478 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1479 /* Copy the key in the driver */
1480 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1485 /* Do we want to just set the transmit key index ? */
1486 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1487 if ((index >= 0) && (index < 4))
1489 pAdapter->StaCfg.DefaultKeyId = index;
1492 /* Don't complain if only change the mode */
1493 if (!(erq->flags & IW_ENCODE_MODE)) {
1499 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1500 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1501 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1502 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1507 rt_ioctl_giwencode(struct net_device *dev,
1508 struct iw_request_info *info,
1509 struct iw_point *erq, char *key)
1511 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1514 //check if the interface is down
1515 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1517 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1521 kid = erq->flags & IW_ENCODE_INDEX;
1522 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1524 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1527 erq->flags = IW_ENCODE_DISABLED;
1529 else if ((kid > 0) && (kid <=4))
1532 erq->flags = kid ; /* NB: base 1 */
1533 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1534 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1535 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1536 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1537 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1538 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1539 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1541 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1546 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1547 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1549 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1550 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1551 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1552 // copy default key ID
1553 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1554 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1556 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1557 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1558 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1566 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1567 void *w, char *extra)
1569 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1570 POS_COOKIE pObj = (POS_COOKIE)pAdapter->OS_Cookie;
1571 char *this_char = extra;
1576 pObj->ioctl_if_type = INT_MAIN;
1577 pObj->ioctl_if = MAIN_MBSSID;
1580 //check if the interface is down
1581 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1583 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1590 if ((value = rtstrchr(this_char, '=')) != NULL)
1596 // reject setting nothing besides ANY ssid(ssidLen=0)
1597 if (!*value && (strcmp(this_char, "SSID") != 0))
1600 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1602 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1604 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1605 { //FALSE:Set private failed then return Invalid argument
1608 break; //Exit for loop.
1612 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1613 { //Not found argument
1615 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1623 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1624 struct iw_point *wrq, char *extra)
1627 PRTMP_ADAPTER pAd = dev->ml_priv;
1635 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1636 sprintf(extra, "\n\n");
1639 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1640 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1642 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1643 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1644 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1645 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1647 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1648 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1649 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1650 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1652 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1654 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1655 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1656 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1658 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1660 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1661 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1667 IN PRTMP_ADAPTER pAd,
1671 BA_ORI_ENTRY *pOriBAEntry;
1672 BA_REC_ENTRY *pRecBAEntry;
1674 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1676 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1677 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1678 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1680 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1681 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1682 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1684 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1685 for (j=0; j < NUM_OF_TID; j++)
1687 if (pEntry->BARecWcidArray[j] != 0)
1689 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1690 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1693 sprintf(pOutBuf, "%s\n", pOutBuf);
1695 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1696 for (j=0; j < NUM_OF_TID; j++)
1698 if (pEntry->BAOriWcidArray[j] != 0)
1700 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1701 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1704 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1706 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1714 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1715 struct iw_point *wrq, char *extra)
1718 PRTMP_ADAPTER pAd = dev->ml_priv;
1719 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
1720 u32 subcmd = wrq->flags;
1727 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1730 pObj->ioctl_if_type = INT_MAIN;
1731 pObj->ioctl_if = MAIN_MBSSID;
1737 case SHOW_CONN_STATUS:
1738 if (MONITOR_ON(pAd))
1740 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1741 pAd->CommonCfg.RegTransmitSetting.field.BW)
1742 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1744 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1748 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1752 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1753 pAd->CommonCfg.Ssid,
1754 pAd->CommonCfg.Bssid[0],
1755 pAd->CommonCfg.Bssid[1],
1756 pAd->CommonCfg.Bssid[2],
1757 pAd->CommonCfg.Bssid[3],
1758 pAd->CommonCfg.Bssid[4],
1759 pAd->CommonCfg.Bssid[5]);
1760 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
1762 else if (ADHOC_ON(pAd))
1763 sprintf(extra, "Connected\n");
1767 sprintf(extra, "Disconnected\n");
1768 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
1771 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1773 case SHOW_DRVIER_VERION:
1774 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
1775 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1778 getBaInfo(pAd, extra);
1779 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1781 case SHOW_DESC_INFO:
1783 Show_DescInfo_Proc(pAd, NULL);
1784 wrq->length = 0; // 1: size of '\0'
1788 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1790 sprintf(extra, "Scanning\n");
1791 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1794 pAd->StaCfg.bSwRadio = FALSE;
1795 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
1797 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
1798 if (pAd->StaCfg.bRadio == FALSE)
1801 // Update extra information
1802 pAd->ExtraInfo = SW_RADIO_OFF;
1805 sprintf(extra, "Radio Off\n");
1806 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1810 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1812 sprintf(extra, "Scanning\n");
1813 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1817 pAd->StaCfg.bSwRadio = TRUE;
1818 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
1820 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
1821 if (pAd->StaCfg.bRadio == TRUE)
1824 // Update extra information
1825 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
1828 sprintf(extra, "Radio On\n");
1829 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1832 case SHOW_CFG_VALUE:
1834 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
1836 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1840 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
1847 int rt_ioctl_siwmlme(struct net_device *dev,
1848 struct iw_request_info *info,
1849 union iwreq_data *wrqu,
1852 PRTMP_ADAPTER pAd = dev->ml_priv;
1853 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
1854 MLME_QUEUE_ELEM MsgElem;
1855 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
1856 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
1858 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
1865 #ifdef IW_MLME_DEAUTH
1866 case IW_MLME_DEAUTH:
1867 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
1868 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
1869 DeAuthReq.Reason = pMlme->reason_code;
1870 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
1871 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
1872 MlmeDeauthReqAction(pAd, &MsgElem);
1875 LinkDown(pAd, FALSE);
1876 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1879 #endif // IW_MLME_DEAUTH //
1880 #ifdef IW_MLME_DISASSOC
1881 case IW_MLME_DISASSOC:
1882 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
1883 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
1884 DisAssocReq.Reason = pMlme->reason_code;
1886 MsgElem.Machine = ASSOC_STATE_MACHINE;
1887 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
1888 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
1889 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
1891 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
1892 MlmeDisassocReqAction(pAd, &MsgElem);
1894 #endif // IW_MLME_DISASSOC //
1896 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
1903 int rt_ioctl_siwauth(struct net_device *dev,
1904 struct iw_request_info *info,
1905 union iwreq_data *wrqu, char *extra)
1907 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1908 struct iw_param *param = &wrqu->param;
1910 //check if the interface is down
1911 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1913 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1916 switch (param->flags & IW_AUTH_INDEX) {
1917 case IW_AUTH_WPA_VERSION:
1918 if (param->value == IW_AUTH_WPA_VERSION_WPA)
1920 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1921 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
1922 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1924 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
1925 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1927 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
1929 case IW_AUTH_CIPHER_PAIRWISE:
1930 if (param->value == IW_AUTH_CIPHER_NONE)
1932 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1933 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1934 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1936 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
1937 param->value == IW_AUTH_CIPHER_WEP104)
1939 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1940 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1941 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1942 pAdapter->StaCfg.IEEE8021X = FALSE;
1944 else if (param->value == IW_AUTH_CIPHER_TKIP)
1946 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1947 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1948 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
1950 else if (param->value == IW_AUTH_CIPHER_CCMP)
1952 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1953 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1954 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
1956 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
1958 case IW_AUTH_CIPHER_GROUP:
1959 if (param->value == IW_AUTH_CIPHER_NONE)
1961 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1963 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
1964 param->value == IW_AUTH_CIPHER_WEP104)
1966 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1968 else if (param->value == IW_AUTH_CIPHER_TKIP)
1970 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
1972 else if (param->value == IW_AUTH_CIPHER_CCMP)
1974 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
1976 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
1978 case IW_AUTH_KEY_MGMT:
1979 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
1981 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
1983 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1984 pAdapter->StaCfg.IEEE8021X = FALSE;
1986 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
1988 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1989 pAdapter->StaCfg.IEEE8021X = FALSE;
1993 pAdapter->StaCfg.IEEE8021X = TRUE;
1995 else if (param->value == 0)
1997 STA_PORT_SECURED(pAdapter);
1999 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2001 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2003 case IW_AUTH_PRIVACY_INVOKED:
2004 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2006 case IW_AUTH_DROP_UNENCRYPTED:
2007 if (param->value != 0)
2008 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2011 STA_PORT_SECURED(pAdapter);
2013 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2015 case IW_AUTH_80211_AUTH_ALG:
2016 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2018 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2020 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2022 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2026 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2028 case IW_AUTH_WPA_ENABLED:
2029 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2038 int rt_ioctl_giwauth(struct net_device *dev,
2039 struct iw_request_info *info,
2040 union iwreq_data *wrqu, char *extra)
2042 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2043 struct iw_param *param = &wrqu->param;
2045 //check if the interface is down
2046 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2048 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2052 switch (param->flags & IW_AUTH_INDEX) {
2053 case IW_AUTH_DROP_UNENCRYPTED:
2054 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2057 case IW_AUTH_80211_AUTH_ALG:
2058 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2061 case IW_AUTH_WPA_ENABLED:
2062 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2068 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2072 void fnSetCipherKey(
2073 IN PRTMP_ADAPTER pAdapter,
2077 IN struct iw_encode_ext *ext)
2080 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2081 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2083 if (pAdapter->StaCfg.bRadio == FALSE)
2085 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2088 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2089 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2090 RTMPusecDelay(6000);
2091 pAdapter->bPCIclkOff = FALSE;
2094 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2095 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2096 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2097 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2098 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2099 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2101 // Update group key information to ASIC Shared Key Table
2102 AsicAddSharedKeyEntry(pAdapter,
2105 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2106 pAdapter->SharedKey[BSS0][keyIdx].Key,
2107 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2108 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2111 // Update ASIC WCID attribute table and IVEIV table
2112 RTMPAddWcidAttributeEntry(pAdapter,
2115 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2118 // Update ASIC WCID attribute table and IVEIV table
2119 RTMPAddWcidAttributeEntry(pAdapter,
2122 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2123 &pAdapter->MacTab.Content[BSSID_WCID]);
2125 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2129 int rt_ioctl_siwencodeext(struct net_device *dev,
2130 struct iw_request_info *info,
2131 union iwreq_data *wrqu,
2134 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2135 struct iw_point *encoding = &wrqu->encoding;
2136 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2137 int keyIdx, alg = ext->alg;
2139 //check if the interface is down
2140 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2142 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2146 if (encoding->flags & IW_ENCODE_DISABLED)
2148 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2149 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2150 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2151 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2152 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2153 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2154 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2155 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2159 // Get Key Index and convet to our own defined key index
2160 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2161 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2164 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2166 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2167 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2171 case IW_ENCODE_ALG_NONE:
2172 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2174 case IW_ENCODE_ALG_WEP:
2175 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2176 if (ext->key_len == MAX_WEP_KEY_SIZE)
2178 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2179 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2181 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2183 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2184 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2189 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2190 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2191 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2192 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2194 // Set Group key material to Asic
2195 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2197 // Update WCID attribute table and IVEIV table for this group key table
2198 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2200 STA_PORT_SECURED(pAdapter);
2202 // Indicate Connected for GUI
2203 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2206 case IW_ENCODE_ALG_TKIP:
2207 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2208 if (ext->key_len == 32)
2210 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2212 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2213 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2215 STA_PORT_SECURED(pAdapter);
2218 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2220 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2222 // set 802.1x port control
2223 STA_PORT_SECURED(pAdapter);
2229 case IW_ENCODE_ALG_CCMP:
2230 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2232 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2233 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2234 STA_PORT_SECURED(pAdapter);
2236 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2238 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2240 // set 802.1x port control
2241 STA_PORT_SECURED(pAdapter);
2253 rt_ioctl_giwencodeext(struct net_device *dev,
2254 struct iw_request_info *info,
2255 union iwreq_data *wrqu, char *extra)
2257 PRTMP_ADAPTER pAd = dev->ml_priv;
2259 struct iw_point *encoding = &wrqu->encoding;
2260 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2261 int idx, max_key_len;
2263 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2265 max_key_len = encoding->length - sizeof(*ext);
2266 if (max_key_len < 0)
2269 idx = encoding->flags & IW_ENCODE_INDEX;
2272 if (idx < 1 || idx > 4)
2276 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2277 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2279 if (idx != pAd->StaCfg.DefaultKeyId)
2287 idx = pAd->StaCfg.DefaultKeyId;
2289 encoding->flags = idx + 1;
2290 memset(ext, 0, sizeof(*ext));
2293 switch(pAd->StaCfg.WepStatus) {
2294 case Ndis802_11WEPDisabled:
2295 ext->alg = IW_ENCODE_ALG_NONE;
2296 encoding->flags |= IW_ENCODE_DISABLED;
2298 case Ndis802_11WEPEnabled:
2299 ext->alg = IW_ENCODE_ALG_WEP;
2300 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2304 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2305 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2308 case Ndis802_11Encryption2Enabled:
2309 case Ndis802_11Encryption3Enabled:
2310 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2311 ext->alg = IW_ENCODE_ALG_TKIP;
2313 ext->alg = IW_ENCODE_ALG_CCMP;
2315 if (max_key_len < 32)
2320 pKey = &pAd->StaCfg.PMK[0];
2327 if (ext->key_len && pKey)
2329 encoding->flags |= IW_ENCODE_ENABLED;
2330 memcpy(ext->key, pKey, ext->key_len);
2336 int rt_ioctl_siwgenie(struct net_device *dev,
2337 struct iw_request_info *info,
2338 union iwreq_data *wrqu, char *extra)
2340 PRTMP_ADAPTER pAd = dev->ml_priv;
2342 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2343 (wrqu->data.length && extra == NULL))
2346 if (wrqu->data.length)
2348 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2349 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2353 pAd->StaCfg.RSNIE_Len = 0;
2354 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2360 int rt_ioctl_giwgenie(struct net_device *dev,
2361 struct iw_request_info *info,
2362 union iwreq_data *wrqu, char *extra)
2364 PRTMP_ADAPTER pAd = dev->ml_priv;
2366 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2367 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2369 wrqu->data.length = 0;
2373 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2375 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2378 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2379 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2383 UCHAR RSNIe = IE_WPA;
2385 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2387 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2389 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2390 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2393 extra[0] = (char)RSNIe;
2394 extra[1] = pAd->StaCfg.RSNIE_Len;
2395 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2401 int rt_ioctl_siwpmksa(struct net_device *dev,
2402 struct iw_request_info *info,
2403 union iwreq_data *wrqu,
2406 PRTMP_ADAPTER pAd = dev->ml_priv;
2407 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2408 INT CachedIdx = 0, idx = 0;
2413 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2416 case IW_PMKSA_FLUSH:
2417 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2418 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2420 case IW_PMKSA_REMOVE:
2421 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2423 // compare the BSSID
2424 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2426 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2427 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2428 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2430 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2431 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2433 pAd->StaCfg.SavedPMKNum--;
2438 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2441 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2443 // compare the BSSID
2444 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2448 // Found, replace it
2449 if (CachedIdx < PMKID_NO)
2451 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2452 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2453 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2454 pAd->StaCfg.SavedPMKNum++;
2456 // Not found, replace the last one
2459 // Randomly replace one
2460 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2461 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2462 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2463 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2466 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2469 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2476 int rt_ioctl_siwrate(struct net_device *dev,
2477 struct iw_request_info *info,
2478 union iwreq_data *wrqu, char *extra)
2480 PRTMP_ADAPTER pAd = dev->ml_priv;
2481 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2483 //check if the interface is down
2484 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2486 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2490 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2491 /* rate = -1 => auto rate
2492 rate = X, fixed = 1 => (fixed rate X)
2497 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2498 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2499 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2500 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2501 RTMPSetDesiredRates(pAd, -1);
2509 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2510 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2511 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2512 RTMPSetDesiredRates(pAd, rate);
2515 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2518 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2522 // TODO: rate = X, fixed = 0 => (rates <= X)
2530 int rt_ioctl_giwrate(struct net_device *dev,
2531 struct iw_request_info *info,
2532 union iwreq_data *wrqu, char *extra)
2534 PRTMP_ADAPTER pAd = dev->ml_priv;
2535 int rate_index = 0, rate_count = 0;
2536 HTTRANSMIT_SETTING ht_setting;
2537 __s32 ralinkrate[] =
2538 {2, 4, 11, 22, // CCK
2539 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2540 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2541 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2542 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2543 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2544 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2545 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2546 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2547 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2549 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2550 //check if the interface is down
2551 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2553 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2557 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2559 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2560 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2562 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2564 if (ht_setting.field.MODE >= MODE_HTMIX)
2566 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2569 if (ht_setting.field.MODE == MODE_OFDM)
2570 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2571 else if (ht_setting.field.MODE == MODE_CCK)
2572 rate_index = (UCHAR)(ht_setting.field.MCS);
2577 if (rate_index > rate_count)
2578 rate_index = rate_count;
2580 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2581 wrqu->bitrate.disabled = 0;
2586 static const iw_handler rt_handler[] =
2588 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2589 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2590 (iw_handler) NULL, /* SIOCSIWNWID */
2591 (iw_handler) NULL, /* SIOCGIWNWID */
2592 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2593 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2594 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2595 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2596 (iw_handler) NULL, /* SIOCSIWSENS */
2597 (iw_handler) NULL, /* SIOCGIWSENS */
2598 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2599 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2600 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2601 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2602 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2603 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2604 (iw_handler) NULL, /* SIOCSIWSPY */
2605 (iw_handler) NULL, /* SIOCGIWSPY */
2606 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2607 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2608 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2609 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2610 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2611 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2612 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2613 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2614 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2615 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
2616 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
2617 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
2618 (iw_handler) NULL, /* -- hole -- */
2619 (iw_handler) NULL, /* -- hole -- */
2620 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
2621 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
2622 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
2623 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
2624 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
2625 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
2626 (iw_handler) NULL, /* SIOCSIWTXPOW */
2627 (iw_handler) NULL, /* SIOCGIWTXPOW */
2628 (iw_handler) NULL, /* SIOCSIWRETRY */
2629 (iw_handler) NULL, /* SIOCGIWRETRY */
2630 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
2631 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
2632 (iw_handler) NULL, /* SIOCSIWPOWER */
2633 (iw_handler) NULL, /* SIOCGIWPOWER */
2634 (iw_handler) NULL, /* -- hole -- */
2635 (iw_handler) NULL, /* -- hole -- */
2636 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
2637 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
2638 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
2639 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
2640 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
2641 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
2642 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
2645 static const iw_handler rt_priv_handlers[] = {
2646 (iw_handler) NULL, /* + 0x00 */
2647 (iw_handler) NULL, /* + 0x01 */
2648 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
2649 (iw_handler) NULL, /* + 0x03 */
2650 (iw_handler) NULL, /* + 0x04 */
2651 (iw_handler) NULL, /* + 0x05 */
2652 (iw_handler) NULL, /* + 0x06 */
2653 (iw_handler) NULL, /* + 0x07 */
2654 (iw_handler) NULL, /* + 0x08 */
2655 (iw_handler) rt_private_get_statistics, /* + 0x09 */
2656 (iw_handler) NULL, /* + 0x0A */
2657 (iw_handler) NULL, /* + 0x0B */
2658 (iw_handler) NULL, /* + 0x0C */
2659 (iw_handler) NULL, /* + 0x0D */
2660 (iw_handler) NULL, /* + 0x0E */
2661 (iw_handler) NULL, /* + 0x0F */
2662 (iw_handler) NULL, /* + 0x10 */
2663 (iw_handler) rt_private_show, /* + 0x11 */
2664 (iw_handler) NULL, /* + 0x12 */
2665 (iw_handler) NULL, /* + 0x13 */
2666 (iw_handler) NULL, /* + 0x15 */
2667 (iw_handler) NULL, /* + 0x17 */
2668 (iw_handler) NULL, /* + 0x18 */
2671 const struct iw_handler_def rt28xx_iw_handler_def =
2673 #define N(a) (sizeof (a) / sizeof (a[0]))
2674 .standard = (iw_handler *) rt_handler,
2675 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
2676 .private = (iw_handler *) rt_priv_handlers,
2677 .num_private = N(rt_priv_handlers),
2678 .private_args = (struct iw_priv_args *) privtab,
2679 .num_private_args = N(privtab),
2680 #if IW_HANDLER_VERSION >= 7
2681 .get_wireless_stats = rt28xx_get_wireless_stats,
2685 INT rt28xx_sta_ioctl(
2686 IN struct net_device *net_dev,
2687 IN OUT struct ifreq *rq,
2690 RTMP_ADAPTER *pAd = net_dev->ml_priv;
2691 POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
2692 struct iwreq *wrq = (struct iwreq *) rq;
2693 BOOLEAN StateMachineTouched = FALSE;
2694 INT Status = NDIS_STATUS_SUCCESS;
2696 //check if the interface is down
2697 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2700 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2705 { // determine this ioctl command is comming from which interface.
2706 pObj->ioctl_if_type = INT_MAIN;
2707 pObj->ioctl_if = MAIN_MBSSID;
2713 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
2714 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
2718 char *name=&wrq->u.name[0];
2719 rt_ioctl_giwname(net_dev, NULL, name, NULL);
2722 case SIOCGIWESSID: //Get ESSID
2724 struct iw_point *essid=&wrq->u.essid;
2725 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
2728 case SIOCSIWESSID: //Set ESSID
2730 struct iw_point *essid=&wrq->u.essid;
2731 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
2734 case SIOCSIWNWID: // set network id (the cell)
2735 case SIOCGIWNWID: // get network id
2736 Status = -EOPNOTSUPP;
2738 case SIOCSIWFREQ: //set channel/frequency (Hz)
2740 struct iw_freq *freq=&wrq->u.freq;
2741 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
2744 case SIOCGIWFREQ: // get channel/frequency (Hz)
2746 struct iw_freq *freq=&wrq->u.freq;
2747 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
2750 case SIOCSIWNICKN: //set node name/nickname
2752 struct iw_point *data=&wrq->u.data;
2753 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
2756 case SIOCGIWNICKN: //get node name/nickname
2758 struct iw_point *data=&wrq->u.data;
2759 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
2762 case SIOCGIWRATE: //get default bit rate (bps)
2763 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
2765 case SIOCSIWRATE: //set default bit rate (bps)
2766 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
2768 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
2770 struct iw_param *rts=&wrq->u.rts;
2771 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
2774 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
2776 struct iw_param *rts=&wrq->u.rts;
2777 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
2780 case SIOCGIWFRAG: //get fragmentation thr (bytes)
2782 struct iw_param *frag=&wrq->u.frag;
2783 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
2786 case SIOCSIWFRAG: //set fragmentation thr (bytes)
2788 struct iw_param *frag=&wrq->u.frag;
2789 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
2792 case SIOCGIWENCODE: //get encoding token & mode
2794 struct iw_point *erq=&wrq->u.encoding;
2796 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
2799 case SIOCSIWENCODE: //set encoding token & mode
2801 struct iw_point *erq=&wrq->u.encoding;
2803 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
2806 case SIOCGIWAP: //get access point MAC addresses
2808 struct sockaddr *ap_addr=&wrq->u.ap_addr;
2809 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
2812 case SIOCSIWAP: //set access point MAC addresses
2814 struct sockaddr *ap_addr=&wrq->u.ap_addr;
2815 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
2818 case SIOCGIWMODE: //get operation mode
2820 __u32 *mode=&wrq->u.mode;
2821 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
2824 case SIOCSIWMODE: //set operation mode
2826 __u32 *mode=&wrq->u.mode;
2827 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
2830 case SIOCGIWSENS: //get sensitivity (dBm)
2831 case SIOCSIWSENS: //set sensitivity (dBm)
2832 case SIOCGIWPOWER: //get Power Management settings
2833 case SIOCSIWPOWER: //set Power Management settings
2834 case SIOCGIWTXPOW: //get transmit power (dBm)
2835 case SIOCSIWTXPOW: //set transmit power (dBm)
2836 case SIOCGIWRANGE: //Get range of parameters
2837 case SIOCGIWRETRY: //get retry limits and lifetime
2838 case SIOCSIWRETRY: //set retry limits and lifetime
2840 case RT_PRIV_IOCTL_EXT:
2841 Status = -EOPNOTSUPP;
2844 if (wrq->u.data.pointer)
2846 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
2848 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
2849 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
2853 case RTPRIV_IOCTL_SET:
2854 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
2856 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
2858 case RTPRIV_IOCTL_GSITESURVEY:
2859 RTMPIoctlGetSiteSurvey(pAd, wrq);
2864 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
2865 Status = -EOPNOTSUPP;
2869 if(StateMachineTouched) // Upper layer sent a MLME-related operations
2870 RT28XX_MLME_HANDLER(pAd);
2876 ==========================================================================
2880 TRUE if all parameters are OK, FALSE otherwise
2881 ==========================================================================
2884 IN PRTMP_ADAPTER pAdapter,
2887 NDIS_802_11_SSID Ssid, *pSsid=NULL;
2888 BOOLEAN StateMachineTouched = FALSE;
2891 if( strlen(arg) <= MAX_LEN_OF_SSID)
2893 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
2894 if (strlen(arg) != 0)
2896 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
2897 Ssid.SsidLength = strlen(arg);
2901 Ssid.SsidLength = 0;
2902 memcpy(Ssid.Ssid, "", 0);
2903 pAdapter->StaCfg.BssType = BSS_INFRA;
2904 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2905 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
2909 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
2911 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
2912 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
2915 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
2916 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2917 pAdapter->bConfigChanged = TRUE;
2919 MlmeEnqueue(pAdapter,
2920 MLME_CNTL_STATE_MACHINE,
2922 sizeof(NDIS_802_11_SSID),
2925 StateMachineTouched = TRUE;
2926 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
2931 if (StateMachineTouched) // Upper layer sent a MLME-related operations
2932 RT28XX_MLME_HANDLER(pAdapter);
2939 ==========================================================================
2941 Set WmmCapable Enable or Disable
2943 TRUE if all parameters are OK, FALSE otherwise
2944 ==========================================================================
2946 INT Set_WmmCapable_Proc(
2947 IN PRTMP_ADAPTER pAd,
2950 BOOLEAN bWmmCapable;
2952 bWmmCapable = simple_strtol(arg, 0, 10);
2954 if ((bWmmCapable == 1)
2956 && (pAd->NumberOfPipes >= 5)
2959 pAd->CommonCfg.bWmmCapable = TRUE;
2960 else if (bWmmCapable == 0)
2961 pAd->CommonCfg.bWmmCapable = FALSE;
2963 return FALSE; //Invalid argument
2965 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
2966 pAd->CommonCfg.bWmmCapable));
2970 #endif // WMM_SUPPORT //
2973 ==========================================================================
2975 Set Network Type(Infrastructure/Adhoc mode)
2977 TRUE if all parameters are OK, FALSE otherwise
2978 ==========================================================================
2980 INT Set_NetworkType_Proc(
2981 IN PRTMP_ADAPTER pAdapter,
2986 if (strcmp(arg, "Adhoc") == 0)
2988 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
2990 // Config has changed
2991 pAdapter->bConfigChanged = TRUE;
2992 if (MONITOR_ON(pAdapter))
2994 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
2995 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
2997 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
2998 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
2999 pAdapter->StaCfg.bAutoReconnect = TRUE;
3000 LinkDown(pAdapter, FALSE);
3002 if (INFRA_ON(pAdapter))
3004 //BOOLEAN Cancelled;
3005 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
3006 // Since calling this indicate user don't want to connect to that SSID anymore.
3007 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3008 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
3010 LinkDown(pAdapter, FALSE);
3012 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
3015 pAdapter->StaCfg.BssType = BSS_ADHOC;
3016 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
3017 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
3019 else if (strcmp(arg, "Infra") == 0)
3021 if (pAdapter->StaCfg.BssType != BSS_INFRA)
3023 // Config has changed
3024 pAdapter->bConfigChanged = TRUE;
3025 if (MONITOR_ON(pAdapter))
3027 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
3028 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
3030 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
3031 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
3032 pAdapter->StaCfg.bAutoReconnect = TRUE;
3033 LinkDown(pAdapter, FALSE);
3035 if (ADHOC_ON(pAdapter))
3037 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
3038 // Since calling this indicate user don't want to connect to that SSID anymore.
3039 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3040 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
3042 LinkDown(pAdapter, FALSE);
3045 pAdapter->StaCfg.BssType = BSS_INFRA;
3046 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
3047 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
3049 pAdapter->StaCfg.BssType = BSS_INFRA;
3051 else if (strcmp(arg, "Monitor") == 0)
3054 BCN_TIME_CFG_STRUC csr;
3055 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
3056 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
3057 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
3058 // disable all periodic state machine
3059 pAdapter->StaCfg.bAutoReconnect = FALSE;
3060 // reset all mlme state machine
3061 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3062 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
3063 if (pAdapter->CommonCfg.CentralChannel == 0)
3065 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
3066 pAdapter->CommonCfg.CentralChannel = 36;
3068 pAdapter->CommonCfg.CentralChannel = 6;
3071 N_ChannelCheck(pAdapter);
3073 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
3074 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
3075 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
3077 // 40MHz ,control channel at lower
3078 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
3079 bbpValue &= (~0x18);
3081 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
3082 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
3083 // RX : control channel at lower
3084 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
3085 bbpValue &= (~0x20);
3086 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
3088 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
3089 Value &= 0xfffffffe;
3090 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
3091 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
3092 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
3093 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
3094 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
3095 pAdapter->CommonCfg.Channel,
3096 pAdapter->CommonCfg.CentralChannel));
3098 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
3099 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
3100 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
3102 // 40MHz ,control channel at upper
3103 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
3104 bbpValue &= (~0x18);
3106 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
3107 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
3108 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
3110 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
3112 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
3114 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
3115 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
3116 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
3117 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
3118 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
3119 pAdapter->CommonCfg.Channel,
3120 pAdapter->CommonCfg.CentralChannel));
3125 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
3126 bbpValue &= (~0x18);
3127 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
3128 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
3129 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
3130 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
3131 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
3133 // Enable Rx with promiscuous reception
3134 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
3135 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
3136 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
3138 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
3140 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
3141 csr.field.bBeaconGen = 0;
3142 csr.field.bTBTTEnable = 0;
3143 csr.field.TsfSyncMode = 0;
3144 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
3146 pAdapter->StaCfg.BssType = BSS_MONITOR;
3147 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
3148 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
3151 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
3152 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3154 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
3160 ==========================================================================
3162 Set Authentication mode
3164 TRUE if all parameters are OK, FALSE otherwise
3165 ==========================================================================
3167 INT Set_AuthMode_Proc(
3168 IN PRTMP_ADAPTER pAdapter,
3171 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
3172 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
3173 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
3174 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
3175 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
3176 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
3177 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
3178 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
3179 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
3180 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
3181 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
3182 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
3183 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
3184 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
3185 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
3186 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
3190 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3192 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
3198 ==========================================================================
3202 TRUE if all parameters are OK, FALSE otherwise
3203 ==========================================================================
3205 INT Set_EncrypType_Proc(
3206 IN PRTMP_ADAPTER pAdapter,
3209 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
3211 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3212 return TRUE; // do nothing
3214 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
3215 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
3216 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
3218 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
3220 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3221 return TRUE; // do nothing
3223 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
3224 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
3225 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
3227 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
3229 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
3230 return TRUE; // do nothing
3232 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
3233 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
3234 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
3236 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
3238 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
3239 return TRUE; // do nothing
3241 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
3242 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
3243 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
3248 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
3250 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
3256 ==========================================================================
3260 TRUE if all parameters are OK, FALSE otherwise
3261 ==========================================================================
3263 INT Set_DefaultKeyID_Proc(
3264 IN PRTMP_ADAPTER pAdapter,
3269 KeyIdx = simple_strtol(arg, 0, 10);
3270 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
3271 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
3273 return FALSE; //Invalid argument
3275 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
3281 ==========================================================================
3285 TRUE if all parameters are OK, FALSE otherwise
3286 ==========================================================================
3289 IN PRTMP_ADAPTER pAdapter,
3294 UCHAR CipherAlg=CIPHER_WEP64;
3296 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3297 return TRUE; // do nothing
3299 KeyLen = strlen(arg);
3303 case 5: //wep 40 Ascii type
3304 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
3305 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
3306 CipherAlg = CIPHER_WEP64;
3307 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
3309 case 10: //wep 40 Hex type
3310 for(i=0; i < KeyLen; i++)
3312 if( !isxdigit(*(arg+i)) )
3313 return FALSE; //Not Hex value;
3315 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
3316 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
3317 CipherAlg = CIPHER_WEP64;
3318 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
3320 case 13: //wep 104 Ascii type
3321 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
3322 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
3323 CipherAlg = CIPHER_WEP128;
3324 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
3326 case 26: //wep 104 Hex type
3327 for(i=0; i < KeyLen; i++)
3329 if( !isxdigit(*(arg+i)) )
3330 return FALSE; //Not Hex value;
3332 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
3333 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
3334 CipherAlg = CIPHER_WEP128;
3335 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
3337 default: //Invalid argument
3338 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
3342 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
3344 // Set keys (into ASIC)
3345 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3347 else // Old WEP stuff
3349 AsicAddSharedKeyEntry(pAdapter,
3352 pAdapter->SharedKey[BSS0][0].CipherAlg,
3353 pAdapter->SharedKey[BSS0][0].Key,
3361 ==========================================================================
3366 TRUE if all parameters are OK, FALSE otherwise
3367 ==========================================================================
3370 IN PRTMP_ADAPTER pAdapter,
3375 UCHAR CipherAlg=CIPHER_WEP64;
3377 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3378 return TRUE; // do nothing
3380 KeyLen = strlen(arg);
3384 case 5: //wep 40 Ascii type
3385 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
3386 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
3387 CipherAlg = CIPHER_WEP64;
3388 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
3390 case 10: //wep 40 Hex type
3391 for(i=0; i < KeyLen; i++)
3393 if( !isxdigit(*(arg+i)) )
3394 return FALSE; //Not Hex value;
3396 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
3397 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
3398 CipherAlg = CIPHER_WEP64;
3399 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
3401 case 13: //wep 104 Ascii type
3402 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
3403 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
3404 CipherAlg = CIPHER_WEP128;
3405 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
3407 case 26: //wep 104 Hex type
3408 for(i=0; i < KeyLen; i++)
3410 if( !isxdigit(*(arg+i)) )
3411 return FALSE; //Not Hex value;
3413 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
3414 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
3415 CipherAlg = CIPHER_WEP128;
3416 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
3418 default: //Invalid argument
3419 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
3422 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
3424 // Set keys (into ASIC)
3425 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3427 else // Old WEP stuff
3429 AsicAddSharedKeyEntry(pAdapter,
3432 pAdapter->SharedKey[BSS0][1].CipherAlg,
3433 pAdapter->SharedKey[BSS0][1].Key,
3441 ==========================================================================
3445 TRUE if all parameters are OK, FALSE otherwise
3446 ==========================================================================
3449 IN PRTMP_ADAPTER pAdapter,
3454 UCHAR CipherAlg=CIPHER_WEP64;
3456 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3457 return TRUE; // do nothing
3459 KeyLen = strlen(arg);
3463 case 5: //wep 40 Ascii type
3464 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
3465 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
3466 CipherAlg = CIPHER_WEP64;
3467 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
3469 case 10: //wep 40 Hex type
3470 for(i=0; i < KeyLen; i++)
3472 if( !isxdigit(*(arg+i)) )
3473 return FALSE; //Not Hex value;
3475 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
3476 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
3477 CipherAlg = CIPHER_WEP64;
3478 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
3480 case 13: //wep 104 Ascii type
3481 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
3482 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
3483 CipherAlg = CIPHER_WEP128;
3484 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
3486 case 26: //wep 104 Hex type
3487 for(i=0; i < KeyLen; i++)
3489 if( !isxdigit(*(arg+i)) )
3490 return FALSE; //Not Hex value;
3492 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
3493 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
3494 CipherAlg = CIPHER_WEP128;
3495 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
3497 default: //Invalid argument
3498 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
3501 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
3503 // Set keys (into ASIC)
3504 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3506 else // Old WEP stuff
3508 AsicAddSharedKeyEntry(pAdapter,
3511 pAdapter->SharedKey[BSS0][2].CipherAlg,
3512 pAdapter->SharedKey[BSS0][2].Key,
3520 ==========================================================================
3524 TRUE if all parameters are OK, FALSE otherwise
3525 ==========================================================================
3528 IN PRTMP_ADAPTER pAdapter,
3533 UCHAR CipherAlg=CIPHER_WEP64;
3535 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3536 return TRUE; // do nothing
3538 KeyLen = strlen(arg);
3542 case 5: //wep 40 Ascii type
3543 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
3544 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
3545 CipherAlg = CIPHER_WEP64;
3546 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
3548 case 10: //wep 40 Hex type
3549 for(i=0; i < KeyLen; i++)
3551 if( !isxdigit(*(arg+i)) )
3552 return FALSE; //Not Hex value;
3554 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
3555 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
3556 CipherAlg = CIPHER_WEP64;
3557 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
3559 case 13: //wep 104 Ascii type
3560 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
3561 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
3562 CipherAlg = CIPHER_WEP128;
3563 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
3565 case 26: //wep 104 Hex type
3566 for(i=0; i < KeyLen; i++)
3568 if( !isxdigit(*(arg+i)) )
3569 return FALSE; //Not Hex value;
3571 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
3572 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
3573 CipherAlg = CIPHER_WEP128;
3574 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
3576 default: //Invalid argument
3577 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
3580 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
3582 // Set keys (into ASIC)
3583 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3585 else // Old WEP stuff
3587 AsicAddSharedKeyEntry(pAdapter,
3590 pAdapter->SharedKey[BSS0][3].CipherAlg,
3591 pAdapter->SharedKey[BSS0][3].Key,
3600 ==========================================================================
3604 TRUE if all parameters are OK, FALSE otherwise
3605 ==========================================================================
3607 INT Set_WPAPSK_Proc(
3608 IN PRTMP_ADAPTER pAdapter,
3611 UCHAR keyMaterial[40];
3613 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3614 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3615 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3617 return TRUE; // do nothing
3619 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
3621 NdisZeroMemory(keyMaterial, 40);
3623 if ((strlen(arg) < 8) || (strlen(arg) > 64))
3625 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
3629 if (strlen(arg) == 64)
3631 AtoH(arg, keyMaterial, 32);
3632 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
3637 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
3638 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
3643 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
3644 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
3646 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3650 // Start STA supplicant state machine
3651 pAdapter->StaCfg.WpaState = SS_START;
3658 ==========================================================================
3660 Set Power Saving mode
3662 TRUE if all parameters are OK, FALSE otherwise
3663 ==========================================================================
3665 INT Set_PSMode_Proc(
3666 IN PRTMP_ADAPTER pAdapter,
3669 if (pAdapter->StaCfg.BssType == BSS_INFRA)
3671 if ((strcmp(arg, "Max_PSP") == 0) ||
3672 (strcmp(arg, "max_psp") == 0) ||
3673 (strcmp(arg, "MAX_PSP") == 0))
3675 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
3676 // to exclude certain situations.
3677 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
3678 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
3679 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
3680 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
3681 pAdapter->StaCfg.DefaultListenCount = 5;
3684 else if ((strcmp(arg, "Fast_PSP") == 0) ||
3685 (strcmp(arg, "fast_psp") == 0) ||
3686 (strcmp(arg, "FAST_PSP") == 0))
3688 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
3689 // to exclude certain situations.
3690 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
3691 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
3692 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
3693 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
3694 pAdapter->StaCfg.DefaultListenCount = 3;
3696 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
3697 (strcmp(arg, "legacy_psp") == 0) ||
3698 (strcmp(arg, "LEGACY_PSP") == 0))
3700 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
3701 // to exclude certain situations.
3702 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
3703 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
3704 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
3705 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
3706 pAdapter->StaCfg.DefaultListenCount = 3;
3710 //Default Ndis802_11PowerModeCAM
3711 // clear PSM bit immediately
3712 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
3713 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
3714 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
3715 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
3716 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
3719 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
3729 ==========================================================================
3731 Set WpaSupport flag.
3733 0: Driver ignore wpa_supplicant.
3734 1: wpa_supplicant initiates scanning and AP selection.
3735 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
3737 TRUE if all parameters are OK, FALSE otherwise
3738 ==========================================================================
3740 INT Set_Wpa_Support(
3741 IN PRTMP_ADAPTER pAd,
3745 if ( simple_strtol(arg, 0, 10) == 0)
3746 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
3747 else if ( simple_strtol(arg, 0, 10) == 1)
3748 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
3749 else if ( simple_strtol(arg, 0, 10) == 2)
3750 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
3752 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
3754 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
3759 INT Set_TGnWifiTest_Proc(
3760 IN PRTMP_ADAPTER pAd,
3763 if (simple_strtol(arg, 0, 10) == 0)
3764 pAd->StaCfg.bTGnWifiTest = FALSE;
3766 pAd->StaCfg.bTGnWifiTest = TRUE;
3768 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
3772 INT Set_LongRetryLimit_Proc(
3773 IN PRTMP_ADAPTER pAdapter,
3776 TX_RTY_CFG_STRUC tx_rty_cfg;
3777 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
3779 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
3780 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
3781 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
3782 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
3786 INT Set_ShortRetryLimit_Proc(
3787 IN PRTMP_ADAPTER pAdapter,
3790 TX_RTY_CFG_STRUC tx_rty_cfg;
3791 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
3793 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
3794 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
3795 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
3796 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));