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 *************************************************************************
28 #include "rt_config.h"
30 static void HTParametersHook(
35 #define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
37 // We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
38 BOOLEAN rtstrmactohex(char *s1, char *s2)
41 char *ptokS = s1, *ptokE = s1;
43 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
46 while((*ptokS) != '\0')
48 if((ptokE = strchr(ptokS, ':')) != NULL)
50 if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
52 AtoH(ptokS, &s2[i++], 1);
55 break; // parsing finished
58 return ( i == 6 ? TRUE : FALSE);
63 // we assume the s1 and s2 both are strings.
64 BOOLEAN rtstrcasecmp(char *s1, char *s2)
66 char *p1 = s1, *p2 = s2;
68 if (strlen(s1) != strlen(s2))
73 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
82 // we assume the s1 (buffer) and s2 (key) both are strings.
83 char * rtstrstruncasecmp(char * s1, char * s2)
103 if (('a' <= temp1) && (temp1 <= 'z'))
104 temp1 = 'A'+(temp1-'a');
105 if (('a' <= temp2) && (temp2 <= 'z'))
106 temp2 = 'A'+(temp2-'a');
118 return NULL; // not found
124 * strstr - Find the first substring in a %NUL terminated string
125 * @s1: The string to be searched
126 * @s2: The string to search for
128 char * rtstrstr(const char * s1,const char * s2)
141 if (!memcmp(s1,s2,l2))
150 * rstrtok - Split a string into tokens
151 * @s: The string to be searched
152 * @ct: The characters to search for
153 * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
156 char * rstrtok(char * s,const char * ct)
160 sbegin = s ? s : __rstrtok;
166 sbegin += strspn(sbegin,ct);
173 send = strpbrk( sbegin, ct);
174 if (send && *send != '\0')
183 * delimitcnt - return the count of a given delimiter in a given string.
184 * @s: The string to be searched.
185 * @ct: The delimiter to search for.
186 * Notice : We suppose the delimiter is a single-char string(for example : ";").
188 INT delimitcnt(char * s,const char * ct)
191 /* point to the beginning of the line */
192 const char *token = s;
196 token = strpbrk(token, ct); /* search for delimiters */
200 /* advanced to the terminating null character */
203 /* skip the delimiter */
207 * Print the found text: use len with %.*s to specify field width.
210 /* accumulate delimiter count */
217 * converts the Internet host address from the standard numbers-and-dots notation
219 * returns nonzero if the address is valid, zero if not.
221 int rtinet_aton(const char *cp, unsigned int *addr)
226 unsigned int parts[4];
227 unsigned int *pp = parts;
232 * Collect number up to ``.''.
233 * Values are specified as for C:
234 * 0x=hex, 0=octal, other=decimal.
240 if (*++cp == 'x' || *cp == 'X')
245 while ((c = *cp) != '\0')
247 if (isdigit((unsigned char) c))
249 val = (val * base) + (c - '0');
253 if (base == 16 && isxdigit((unsigned char) c))
256 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
265 * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
266 * a.b (with b treated as 24 bits)
268 if (pp >= parts + 3 || val > 0xff)
277 * Check for trailing junk.
280 if (!isspace((unsigned char) *cp++))
284 * Concoct the address according to the number of parts specified.
290 case 1: /* a -- 32 bits */
293 case 2: /* a.b -- 8.24 bits */
296 val |= parts[0] << 24;
299 case 3: /* a.b.c -- 8.8.16 bits */
302 val |= (parts[0] << 24) | (parts[1] << 16);
305 case 4: /* a.b.c.d -- 8.8.8.8 bits */
308 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
318 ========================================================================
321 Find key section for Get key parameter.
324 buffer Pointer to the buffer to start find the key section
325 section the key of the secion to be find
330 ========================================================================
332 PUCHAR RTMPFindSection(
338 strcpy(temp_buf, "Default");
340 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
341 return (ptr+strlen("\n"));
347 ========================================================================
353 key Pointer to key string
354 dest Pointer to destination
355 destsize The datasize of the destination
356 buffer Pointer to the buffer to start find the key
363 This routine get the value with the matched key (case case-sensitive)
364 ========================================================================
366 INT RTMPGetKeyParameter(
372 UCHAR *temp_buf1 = NULL;
373 UCHAR *temp_buf2 = NULL;
380 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
381 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
383 if(temp_buf1 == NULL)
386 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
387 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
388 if(temp_buf2 == NULL)
390 os_free_mem(NULL, temp_buf1);
395 if((offset = RTMPFindSection(buffer)) == NULL)
397 os_free_mem(NULL, temp_buf1);
398 os_free_mem(NULL, temp_buf2);
402 strcpy(temp_buf1, "\n");
403 strcat(temp_buf1, key);
404 strcat(temp_buf1, "=");
407 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
409 os_free_mem(NULL, temp_buf1);
410 os_free_mem(NULL, temp_buf2);
414 start_ptr+=strlen("\n");
415 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
416 end_ptr=start_ptr+strlen(start_ptr);
418 if (end_ptr<start_ptr)
420 os_free_mem(NULL, temp_buf1);
421 os_free_mem(NULL, temp_buf2);
425 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
426 temp_buf2[end_ptr-start_ptr]='\0';
427 len = strlen(temp_buf2);
428 strcpy(temp_buf1, temp_buf2);
429 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
431 os_free_mem(NULL, temp_buf1);
432 os_free_mem(NULL, temp_buf2);
436 strcpy(temp_buf2, start_ptr+1);
441 if( (*ptr == ' ') || (*ptr == '\t') )
448 memset(dest, 0x00, destsize);
449 strncpy(dest, ptr, len >= destsize ? destsize: len);
451 os_free_mem(NULL, temp_buf1);
452 os_free_mem(NULL, temp_buf2);
457 ========================================================================
463 key Pointer to key string
464 dest Pointer to destination
465 destsize The datasize of the destination
466 buffer Pointer to the buffer to start find the key
473 This routine get the value with the matched key (case case-sensitive).
474 It is called for parsing SSID and any key string.
475 ========================================================================
477 INT RTMPGetCriticalParameter(
483 UCHAR *temp_buf1 = NULL;
484 UCHAR *temp_buf2 = NULL;
491 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
492 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
494 if(temp_buf1 == NULL)
497 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
498 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
499 if(temp_buf2 == NULL)
501 os_free_mem(NULL, temp_buf1);
506 if((offset = RTMPFindSection(buffer)) == NULL)
508 os_free_mem(NULL, temp_buf1);
509 os_free_mem(NULL, temp_buf2);
513 strcpy(temp_buf1, "\n");
514 strcat(temp_buf1, key);
515 strcat(temp_buf1, "=");
518 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
520 os_free_mem(NULL, temp_buf1);
521 os_free_mem(NULL, temp_buf2);
525 start_ptr+=strlen("\n");
526 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
527 end_ptr=start_ptr+strlen(start_ptr);
529 if (end_ptr<start_ptr)
531 os_free_mem(NULL, temp_buf1);
532 os_free_mem(NULL, temp_buf2);
536 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
537 temp_buf2[end_ptr-start_ptr]='\0';
538 len = strlen(temp_buf2);
539 strcpy(temp_buf1, temp_buf2);
540 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
542 os_free_mem(NULL, temp_buf1);
543 os_free_mem(NULL, temp_buf2);
547 strcpy(temp_buf2, start_ptr+1);
551 /* We cannot trim space(' ') for SSID and key string. */
554 //if( (*ptr == ' ') || (*ptr == '\t') )
562 memset(dest, 0x00, destsize);
563 strncpy(dest, ptr, len >= destsize ? destsize: len);
565 os_free_mem(NULL, temp_buf1);
566 os_free_mem(NULL, temp_buf2);
571 ========================================================================
574 Get multiple key parameter.
577 key Pointer to key string
578 dest Pointer to destination
579 destsize The datasize of the destination
580 buffer Pointer to the buffer to start find the key
587 This routine get the value with the matched key (case case-sensitive)
588 ========================================================================
590 INT RTMPGetKeyParameterWithOffset(
593 OUT USHORT *end_offset,
596 IN BOOLEAN bTrimSpace)
598 UCHAR *temp_buf1 = NULL;
599 UCHAR *temp_buf2 = NULL;
606 if (*end_offset >= MAX_INI_BUFFER_SIZE)
609 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
611 if(temp_buf1 == NULL)
614 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
615 if(temp_buf2 == NULL)
617 os_free_mem(NULL, temp_buf1);
624 if ((offset = RTMPFindSection(buffer)) == NULL)
626 os_free_mem(NULL, temp_buf1);
627 os_free_mem(NULL, temp_buf2);
632 offset = buffer + (*end_offset);
634 strcpy(temp_buf1, "\n");
635 strcat(temp_buf1, key);
636 strcat(temp_buf1, "=");
639 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
641 os_free_mem(NULL, temp_buf1);
642 os_free_mem(NULL, temp_buf2);
646 start_ptr+=strlen("\n");
647 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
648 end_ptr=start_ptr+strlen(start_ptr);
650 if (end_ptr<start_ptr)
652 os_free_mem(NULL, temp_buf1);
653 os_free_mem(NULL, temp_buf2);
657 *end_offset = end_ptr - buffer;
659 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
660 temp_buf2[end_ptr-start_ptr]='\0';
661 len = strlen(temp_buf2);
662 strcpy(temp_buf1, temp_buf2);
663 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
665 os_free_mem(NULL, temp_buf1);
666 os_free_mem(NULL, temp_buf2);
670 strcpy(temp_buf2, start_ptr+1);
675 if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
682 memset(dest, 0x00, destsize);
683 strncpy(dest, ptr, len >= destsize ? destsize: len);
685 os_free_mem(NULL, temp_buf1);
686 os_free_mem(NULL, temp_buf2);
691 static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
694 INT i = BSSIdx, idx = KeyIdx;
696 UCHAR CipherAlg = CIPHER_WEP64;
699 KeyLen = strlen(keybuff);
703 if( (KeyLen == 5) || (KeyLen == 13))
705 pAd->SharedKey[i][idx].KeyLen = KeyLen;
706 NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
708 CipherAlg = CIPHER_WEP64;
710 CipherAlg = CIPHER_WEP128;
711 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
713 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
717 {//Invalid key length
718 DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
724 if( (KeyLen == 10) || (KeyLen == 26))
726 pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
727 AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
729 CipherAlg = CIPHER_WEP64;
731 CipherAlg = CIPHER_WEP128;
732 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
734 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
738 {//Invalid key length
739 DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
744 static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
749 ULONG KeyType[MAX_MBSSID_NUM];
752 NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
755 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
758 KeyIdx = simple_strtol(tmpbuf, 0, 10);
759 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
760 pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
762 pAd->StaCfg.DefaultKeyId = 0;
764 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
769 for (idx = 0; idx < 4; idx++)
771 sprintf(tok_str, "Key%dType", idx + 1);
773 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
775 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
777 KeyType[i] = simple_strtol(macptr, 0, 10);
781 sprintf(tok_str, "Key%dStr", idx + 1);
782 if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
784 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
791 static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
795 BOOLEAN bWmmEnable = FALSE;
798 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
800 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
802 pAd->CommonCfg.bWmmCapable = TRUE;
807 pAd->CommonCfg.bWmmCapable = FALSE;
810 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
813 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
814 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
816 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
818 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
820 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
827 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
829 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
830 pAd->CommonCfg.bAPSDCapable = TRUE;
832 pAd->CommonCfg.bAPSDCapable = FALSE;
834 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
837 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
838 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
842 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
844 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
846 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
849 pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
850 pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
851 pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
852 pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
858 NDIS_STATUS RTMPReadParametersHook(
859 IN PRTMP_ADAPTER pAd)
863 INT retval, orgfsuid, orgfsgid;
869 UCHAR keyMaterial[40];
874 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
876 return NDIS_STATUS_FAILURE;
878 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
882 return NDIS_STATUS_FAILURE;
885 src = STA_PROFILE_PATH;
887 // Save uid and gid used for filesystem access.
888 // Set user and group to 0 (root)
889 orgfsuid = current_fsuid();
890 orgfsgid = current_fsgid();
891 /* Hm, can't really do this nicely anymore, so rely on these files
892 * being set to the proper permission to read them... */
893 /* current->cred->fsuid = current->cred->fsgid = 0; */
899 srcf = filp_open(src, O_RDONLY, 0);
902 DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
906 // The object must have a read method
907 if (srcf->f_op && srcf->f_op->read)
909 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
910 retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
913 DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
917 // set file parameter to portcfg
919 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
921 pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
922 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
925 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
927 pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
928 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
931 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
933 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
935 if (strlen(pAd->CommonCfg.CountryCode) != 0)
937 pAd->CommonCfg.bCountryFlag = TRUE;
939 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
942 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
944 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
945 if (Geography <= BOTH)
947 pAd->CommonCfg.Geography = Geography;
948 pAd->CommonCfg.CountryCode[2] =
949 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
950 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
955 pAd->CommonCfg.Geography = BOTH;
956 pAd->CommonCfg.CountryCode[2] = ' ';
961 if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
963 if (strlen(tmpbuf) <= 32)
965 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
966 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
967 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
968 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
969 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
970 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
971 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
972 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
973 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
974 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
981 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
983 pAd->bConfigChanged = TRUE;
984 if (strcmp(tmpbuf, "Adhoc") == 0)
985 pAd->StaCfg.BssType = BSS_ADHOC;
986 else //Default Infrastructure mode
987 pAd->StaCfg.BssType = BSS_INFRA;
988 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
989 pAd->StaCfg.WpaState = SS_NOTUSE;
990 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
995 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
997 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
998 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1001 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
1003 int value = 0, maxPhyMode = PHY_11G;
1005 maxPhyMode = PHY_11N_5G;
1007 value = simple_strtol(tmpbuf, 0, 10);
1009 if (value <= maxPhyMode)
1011 pAd->CommonCfg.PhyMode = value;
1013 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1016 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
1018 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1019 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1022 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
1024 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1025 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1028 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
1030 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1032 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1034 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1037 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
1039 switch (simple_strtol(tmpbuf, 0, 10))
1042 pAd->CommonCfg.UseBGProtection = 1;
1044 case 2: //Always OFF
1045 pAd->CommonCfg.UseBGProtection = 2;
1049 pAd->CommonCfg.UseBGProtection = 0;
1052 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1055 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
1057 switch (simple_strtol(tmpbuf, 0, 10))
1059 case 1: //disable OLBC Detection
1060 pAd->CommonCfg.DisableOLBCDetect = 1;
1062 case 0: //enable OLBC Detection
1063 pAd->CommonCfg.DisableOLBCDetect = 0;
1066 pAd->CommonCfg.DisableOLBCDetect= 0;
1069 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1072 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
1074 switch (simple_strtol(tmpbuf, 0, 10))
1076 case Rt802_11PreambleShort:
1077 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1079 case Rt802_11PreambleLong:
1081 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1084 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1087 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
1089 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1090 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1091 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1093 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1095 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1098 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
1100 FragThresh = simple_strtol(tmpbuf, 0, 10);
1101 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1103 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1104 { //illegal FragThresh so we set it to default
1105 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1106 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1108 else if (FragThresh % 2 == 1)
1110 // The length of each fragment shall always be an even number of octets, except for the last fragment
1111 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1112 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1116 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1118 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1119 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1122 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
1125 // pAd->CommonCfg.bEnableTxBurst = FALSE;
1127 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1128 pAd->CommonCfg.bEnableTxBurst = TRUE;
1130 pAd->CommonCfg.bEnableTxBurst = FALSE;
1132 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1135 #ifdef AGGREGATION_SUPPORT
1137 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
1139 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1140 pAd->CommonCfg.bAggregationCapable = TRUE;
1142 pAd->CommonCfg.bAggregationCapable = FALSE;
1143 #ifdef PIGGYBACK_SUPPORT
1144 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1145 #endif // PIGGYBACK_SUPPORT //
1146 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1149 pAd->CommonCfg.bAggregationCapable = FALSE;
1150 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1151 #endif // AGGREGATION_SUPPORT //
1154 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
1157 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
1159 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1160 pAd->CommonCfg.bUseShortSlotTime = TRUE;
1162 pAd->CommonCfg.bUseShortSlotTime = FALSE;
1164 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1167 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
1169 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1171 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1172 pAd->CommonCfg.bIEEE80211H = TRUE;
1174 pAd->CommonCfg.bIEEE80211H = FALSE;
1176 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1180 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
1182 if(simple_strtol(tmpbuf, 0, 10) != 0)
1183 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1185 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1187 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1191 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
1193 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1195 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
1196 pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
1198 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1200 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
1201 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1203 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1205 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
1206 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1208 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1210 pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
1211 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1213 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1215 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1216 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1220 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1221 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1224 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
1228 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1229 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1233 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
1235 #if WIRELESS_EXT >= 15
1236 if(simple_strtol(tmpbuf, 0, 10) != 0)
1237 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1239 pAd->CommonCfg.bWirelessEvent = 0; // disable
1241 pAd->CommonCfg.bWirelessEvent = 0; // disable
1243 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1245 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
1247 if(simple_strtol(tmpbuf, 0, 10) != 0)
1248 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1250 pAd->CommonCfg.bWiFiTest = 0; // disable
1252 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1255 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
1258 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1259 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1260 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1261 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1262 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1263 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1264 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1265 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1266 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1267 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1268 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1269 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1270 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1271 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1273 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1275 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1277 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1281 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
1284 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1285 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1286 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1287 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1288 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1289 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1291 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1293 // Update all wepstatus related
1294 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1295 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1296 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1297 pAd->StaCfg.bMixCipher = FALSE;
1299 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1300 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1305 if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
1309 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1311 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1312 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1313 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1318 else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
1320 PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
1321 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1324 else if (strlen(tmpbuf) == 64)
1326 AtoH(tmpbuf, keyMaterial, 32);
1327 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1332 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
1337 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1338 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1340 // Start STA supplicant state machine
1341 pAd->StaCfg.WpaState = SS_START;
1343 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1346 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
1347 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
1348 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
1349 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
1350 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
1352 // Decide its ChiperAlg
1353 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
1354 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
1355 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
1356 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
1358 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
1360 pAd->StaCfg.WpaState = SS_NOTUSE;
1363 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1368 //DefaultKeyID, KeyType, KeyStr
1369 rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
1373 /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, buffer))
1375 switch (simple_strtol(tmpbuf, 0, 10))
1378 pAd->CommonCfg.bEnableHSCounter = TRUE;
1382 pAd->CommonCfg.bEnableHSCounter = FALSE;
1385 DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
1388 HTParametersHook(pAd, tmpbuf, buffer);
1392 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
1394 if (pAd->StaCfg.BssType == BSS_INFRA)
1396 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1398 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1399 // to exclude certain situations.
1400 // MlmeSetPsm(pAd, PWR_SAVE);
1401 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1402 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1403 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1404 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1405 pAd->StaCfg.DefaultListenCount = 5;
1407 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1408 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1410 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1411 // to exclude certain situations.
1412 // MlmeSetPsmBit(pAd, PWR_SAVE);
1413 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1414 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1415 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1416 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1417 pAd->StaCfg.DefaultListenCount = 3;
1419 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1420 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1422 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1423 // to exclude certain situations.
1424 // MlmeSetPsmBit(pAd, PWR_SAVE);
1425 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1426 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1427 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1428 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1429 pAd->StaCfg.DefaultListenCount = 3;
1432 { //Default Ndis802_11PowerModeCAM
1433 // clear PSM bit immediately
1434 MlmeSetPsmBit(pAd, PWR_ACTIVE);
1435 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1436 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1437 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1438 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1440 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1444 if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
1446 if (simple_strtol(tmpbuf, 0, 10) == 0)
1447 pAd->StaCfg.bFastRoaming = FALSE;
1449 pAd->StaCfg.bFastRoaming = TRUE;
1451 DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
1454 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
1456 long lInfo = simple_strtol(tmpbuf, 0, 10);
1458 if (lInfo > 90 || lInfo < 60)
1459 pAd->StaCfg.dBmToRoam = -70;
1461 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1463 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1466 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
1468 if(simple_strtol(tmpbuf, 0, 10) == 0)
1469 pAd->StaCfg.bTGnWifiTest = FALSE;
1471 pAd->StaCfg.bTGnWifiTest = TRUE;
1472 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1479 DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
1482 retval=filp_close(srcf,NULL);
1486 DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
1493 current->fsuid = orgfsuid;
1494 current->fsgid = orgfsgid;
1500 return (NDIS_STATUS_SUCCESS);
1503 static void HTParametersHook(
1504 IN PRTMP_ADAPTER pAd,
1511 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
1513 Value = simple_strtol(pValueStr, 0, 10);
1516 pAd->CommonCfg.bHTProtect = FALSE;
1520 pAd->CommonCfg.bHTProtect = TRUE;
1522 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
1525 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
1527 Value = simple_strtol(pValueStr, 0, 10);
1530 pAd->CommonCfg.bMIMOPSEnable = FALSE;
1534 pAd->CommonCfg.bMIMOPSEnable = TRUE;
1536 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
1540 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
1542 Value = simple_strtol(pValueStr, 0, 10);
1543 if (Value > MMPS_ENABLE)
1545 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1549 //TODO: add mimo power saving mechanism
1550 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1551 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
1553 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
1556 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
1558 Value = simple_strtol(pValueStr, 0, 10);
1561 pAd->CommonCfg.bBADecline = FALSE;
1565 pAd->CommonCfg.bBADecline = TRUE;
1567 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
1571 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
1573 Value = simple_strtol(pValueStr, 0, 10);
1576 pAd->CommonCfg.bDisableReordering = FALSE;
1580 pAd->CommonCfg.bDisableReordering = TRUE;
1582 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
1585 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
1587 Value = simple_strtol(pValueStr, 0, 10);
1590 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
1594 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
1596 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
1597 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
1601 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
1603 Value = simple_strtol(pValueStr, 0, 10);
1606 pAd->HTCEnable = FALSE;
1610 pAd->HTCEnable = TRUE;
1612 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
1615 // Enable HT Link Adaptation Control
1616 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
1618 Value = simple_strtol(pValueStr, 0, 10);
1621 pAd->bLinkAdapt = FALSE;
1625 pAd->HTCEnable = TRUE;
1626 pAd->bLinkAdapt = TRUE;
1628 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1631 // Reverse Direction Mechanism
1632 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
1634 Value = simple_strtol(pValueStr, 0, 10);
1637 pAd->CommonCfg.bRdg = FALSE;
1641 pAd->HTCEnable = TRUE;
1642 pAd->CommonCfg.bRdg = TRUE;
1644 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1651 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
1653 Value = simple_strtol(pValueStr, 0, 10);
1656 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
1660 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
1662 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
1666 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
1668 Value = simple_strtol(pValueStr, 0, 10);
1669 if (Value <=7 && Value >= 0)
1671 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
1672 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
1676 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
1677 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
1681 // Max Rx BA Window Size
1682 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
1684 Value = simple_strtol(pValueStr, 0, 10);
1686 if (Value >=1 && Value <= 64)
1688 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
1689 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
1690 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
1694 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
1695 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
1696 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
1702 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
1704 Value = simple_strtol(pValueStr, 0, 10);
1706 if (Value == GI_400)
1708 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
1712 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
1715 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
1718 // HT Operation Mode : Mixed Mode , Green Field
1719 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
1721 Value = simple_strtol(pValueStr, 0, 10);
1723 if (Value == HTMODE_GF)
1726 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
1730 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
1733 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
1736 // Fixed Tx mode : CCK, OFDM
1737 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
1742 fix_tx_mode = FIXED_TXMODE_HT;
1744 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
1746 fix_tx_mode = FIXED_TXMODE_OFDM;
1748 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
1750 fix_tx_mode = FIXED_TXMODE_CCK;
1752 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
1754 fix_tx_mode = FIXED_TXMODE_HT;
1758 Value = simple_strtol(pValueStr, 0, 10);
1762 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
1763 fix_tx_mode = Value;
1765 fix_tx_mode = FIXED_TXMODE_HT;
1768 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
1769 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1776 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
1778 Value = simple_strtol(pValueStr, 0, 10);
1782 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1786 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1789 #ifdef MCAST_RATE_SPECIFIC
1790 pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
1791 #endif // MCAST_RATE_SPECIFIC //
1793 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1796 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
1798 Value = simple_strtol(pValueStr, 0, 10);
1803 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1807 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1810 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1814 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
1817 Value = simple_strtol(pValueStr, 0, 10);
1819 // if ((Value >= 0 && Value <= 15) || (Value == 32))
1820 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1822 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1823 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1824 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1828 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1829 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1830 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1836 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
1838 Value = simple_strtol(pValueStr, 0, 10);
1839 if (Value == STBC_USE)
1841 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1845 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1847 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1850 // 40_Mhz_Intolerant
1851 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
1853 Value = simple_strtol(pValueStr, 0, 10);
1856 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1860 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1862 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1865 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
1867 switch (simple_strtol(pValueStr, 0, 10))
1870 pAd->CommonCfg.TxStream = 1;
1873 pAd->CommonCfg.TxStream = 2;
1877 pAd->CommonCfg.TxStream = 3;
1879 if (pAd->MACVersion < RALINK_2883_VERSION)
1880 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1883 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1886 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
1888 switch (simple_strtol(pValueStr, 0, 10))
1891 pAd->CommonCfg.RxStream = 1;
1894 pAd->CommonCfg.RxStream = 2;
1898 pAd->CommonCfg.RxStream = 3;
1900 if (pAd->MACVersion < RALINK_2883_VERSION)
1901 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
1904 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));