PCI: fix rom.c kernel-doc warning
[linux-2.6/libata-dev.git] / drivers / staging / rt2870 / rt_profile.c
blob467fea35e4a95cac52b4b6ad67502bf422086c65
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
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. *
14 * *
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. *
19 * *
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. *
24 * *
25 *************************************************************************
28 #include "rt_config.h"
30 #ifdef DOT11_N_SUPPORT
31 static void HTParametersHook(
32 IN PRTMP_ADAPTER pAd,
33 IN CHAR *pValueStr,
34 IN CHAR *pInput);
35 #endif // DOT11_N_SUPPORT //
37 #define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
39 // We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
40 BOOLEAN rtstrmactohex(char *s1, char *s2)
42 int i = 0;
43 char *ptokS = s1, *ptokE = s1;
45 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
46 return FALSE;
48 while((*ptokS) != '\0')
50 if((ptokE = strchr(ptokS, ':')) != NULL)
51 *ptokE++ = '\0';
52 if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
53 break; // fail
54 AtoH(ptokS, &s2[i++], 1);
55 ptokS = ptokE;
56 if (i == 6)
57 break; // parsing finished
60 return ( i == 6 ? TRUE : FALSE);
65 // we assume the s1 and s2 both are strings.
66 BOOLEAN rtstrcasecmp(char *s1, char *s2)
68 char *p1 = s1, *p2 = s2;
70 if (strlen(s1) != strlen(s2))
71 return FALSE;
73 while(*p1 != '\0')
75 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
76 return FALSE;
77 p1++;
78 p2++;
81 return TRUE;
84 // we assume the s1 (buffer) and s2 (key) both are strings.
85 char * rtstrstruncasecmp(char * s1, char * s2)
87 INT l1, l2, i;
88 char temp1, temp2;
90 l2 = strlen(s2);
91 if (!l2)
92 return (char *) s1;
94 l1 = strlen(s1);
96 while (l1 >= l2)
98 l1--;
100 for(i=0; i<l2; i++)
102 temp1 = *(s1+i);
103 temp2 = *(s2+i);
105 if (('a' <= temp1) && (temp1 <= 'z'))
106 temp1 = 'A'+(temp1-'a');
107 if (('a' <= temp2) && (temp2 <= 'z'))
108 temp2 = 'A'+(temp2-'a');
110 if (temp1 != temp2)
111 break;
114 if (i == l2)
115 return (char *) s1;
117 s1++;
120 return NULL; // not found
123 //add by kathy
126 * strstr - Find the first substring in a %NUL terminated string
127 * @s1: The string to be searched
128 * @s2: The string to search for
130 char * rtstrstr(const char * s1,const char * s2)
132 INT l1, l2;
134 l2 = strlen(s2);
135 if (!l2)
136 return (char *) s1;
138 l1 = strlen(s1);
140 while (l1 >= l2)
142 l1--;
143 if (!memcmp(s1,s2,l2))
144 return (char *) s1;
145 s1++;
148 return NULL;
152 * rstrtok - Split a string into tokens
153 * @s: The string to be searched
154 * @ct: The characters to search for
155 * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
157 char * __rstrtok;
158 char * rstrtok(char * s,const char * ct)
160 char *sbegin, *send;
162 sbegin = s ? s : __rstrtok;
163 if (!sbegin)
165 return NULL;
168 sbegin += strspn(sbegin,ct);
169 if (*sbegin == '\0')
171 __rstrtok = NULL;
172 return( NULL );
175 send = strpbrk( sbegin, ct);
176 if (send && *send != '\0')
177 *send++ = '\0';
179 __rstrtok = send;
181 return (sbegin);
185 * delimitcnt - return the count of a given delimiter in a given string.
186 * @s: The string to be searched.
187 * @ct: The delimiter to search for.
188 * Notice : We suppose the delimiter is a single-char string(for example : ";").
190 INT delimitcnt(char * s,const char * ct)
192 INT count = 0;
193 /* point to the beginning of the line */
194 const char *token = s;
196 for ( ;; )
198 token = strpbrk(token, ct); /* search for delimiters */
200 if ( token == NULL )
202 /* advanced to the terminating null character */
203 break;
205 /* skip the delimiter */
206 ++token;
209 * Print the found text: use len with %.*s to specify field width.
212 /* accumulate delimiter count */
213 ++count;
215 return count;
219 * converts the Internet host address from the standard numbers-and-dots notation
220 * into binary data.
221 * returns nonzero if the address is valid, zero if not.
223 int rtinet_aton(const char *cp, unsigned int *addr)
225 unsigned int val;
226 int base, n;
227 char c;
228 unsigned int parts[4];
229 unsigned int *pp = parts;
231 for (;;)
234 * Collect number up to ``.''.
235 * Values are specified as for C:
236 * 0x=hex, 0=octal, other=decimal.
238 val = 0;
239 base = 10;
240 if (*cp == '0')
242 if (*++cp == 'x' || *cp == 'X')
243 base = 16, cp++;
244 else
245 base = 8;
247 while ((c = *cp) != '\0')
249 if (isdigit((unsigned char) c))
251 val = (val * base) + (c - '0');
252 cp++;
253 continue;
255 if (base == 16 && isxdigit((unsigned char) c))
257 val = (val << 4) +
258 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
259 cp++;
260 continue;
262 break;
264 if (*cp == '.')
267 * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
268 * a.b (with b treated as 24 bits)
270 if (pp >= parts + 3 || val > 0xff)
271 return 0;
272 *pp++ = val, cp++;
274 else
275 break;
279 * Check for trailing junk.
281 while (*cp)
282 if (!isspace((unsigned char) *cp++))
283 return 0;
286 * Concoct the address according to the number of parts specified.
288 n = pp - parts + 1;
289 switch (n)
292 case 1: /* a -- 32 bits */
293 break;
295 case 2: /* a.b -- 8.24 bits */
296 if (val > 0xffffff)
297 return 0;
298 val |= parts[0] << 24;
299 break;
301 case 3: /* a.b.c -- 8.8.16 bits */
302 if (val > 0xffff)
303 return 0;
304 val |= (parts[0] << 24) | (parts[1] << 16);
305 break;
307 case 4: /* a.b.c.d -- 8.8.8.8 bits */
308 if (val > 0xff)
309 return 0;
310 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
311 break;
314 *addr = htonl(val);
315 return 1;
320 ========================================================================
322 Routine Description:
323 Find key section for Get key parameter.
325 Arguments:
326 buffer Pointer to the buffer to start find the key section
327 section the key of the secion to be find
329 Return Value:
330 NULL Fail
331 Others Success
332 ========================================================================
334 PUCHAR RTMPFindSection(
335 IN PCHAR buffer)
337 CHAR temp_buf[32];
338 PUCHAR ptr;
340 strcpy(temp_buf, "Default");
342 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
343 return (ptr+strlen("\n"));
344 else
345 return NULL;
349 ========================================================================
351 Routine Description:
352 Get key parameter.
354 Arguments:
355 key Pointer to key string
356 dest Pointer to destination
357 destsize The datasize of the destination
358 buffer Pointer to the buffer to start find the key
360 Return Value:
361 TRUE Success
362 FALSE Fail
364 Note:
365 This routine get the value with the matched key (case case-sensitive)
366 ========================================================================
368 INT RTMPGetKeyParameter(
369 IN PCHAR key,
370 OUT PCHAR dest,
371 IN INT destsize,
372 IN PCHAR buffer)
374 UCHAR *temp_buf1 = NULL;
375 UCHAR *temp_buf2 = NULL;
376 CHAR *start_ptr;
377 CHAR *end_ptr;
378 CHAR *ptr;
379 CHAR *offset = 0;
380 INT len;
382 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
383 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
385 if(temp_buf1 == NULL)
386 return (FALSE);
388 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
389 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
390 if(temp_buf2 == NULL)
392 os_free_mem(NULL, temp_buf1);
393 return (FALSE);
396 //find section
397 if((offset = RTMPFindSection(buffer)) == NULL)
399 os_free_mem(NULL, temp_buf1);
400 os_free_mem(NULL, temp_buf2);
401 return (FALSE);
404 strcpy(temp_buf1, "\n");
405 strcat(temp_buf1, key);
406 strcat(temp_buf1, "=");
408 //search key
409 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
411 os_free_mem(NULL, temp_buf1);
412 os_free_mem(NULL, temp_buf2);
413 return (FALSE);
416 start_ptr+=strlen("\n");
417 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
418 end_ptr=start_ptr+strlen(start_ptr);
420 if (end_ptr<start_ptr)
422 os_free_mem(NULL, temp_buf1);
423 os_free_mem(NULL, temp_buf2);
424 return (FALSE);
427 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
428 temp_buf2[end_ptr-start_ptr]='\0';
429 len = strlen(temp_buf2);
430 strcpy(temp_buf1, temp_buf2);
431 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
433 os_free_mem(NULL, temp_buf1);
434 os_free_mem(NULL, temp_buf2);
435 return (FALSE);
438 strcpy(temp_buf2, start_ptr+1);
439 ptr = temp_buf2;
440 //trim space or tab
441 while(*ptr != 0x00)
443 if( (*ptr == ' ') || (*ptr == '\t') )
444 ptr++;
445 else
446 break;
449 len = strlen(ptr);
450 memset(dest, 0x00, destsize);
451 strncpy(dest, ptr, len >= destsize ? destsize: len);
453 os_free_mem(NULL, temp_buf1);
454 os_free_mem(NULL, temp_buf2);
455 return TRUE;
459 ========================================================================
461 Routine Description:
462 Get key parameter.
464 Arguments:
465 key Pointer to key string
466 dest Pointer to destination
467 destsize The datasize of the destination
468 buffer Pointer to the buffer to start find the key
470 Return Value:
471 TRUE Success
472 FALSE Fail
474 Note:
475 This routine get the value with the matched key (case case-sensitive).
476 It is called for parsing SSID and any key string.
477 ========================================================================
479 INT RTMPGetCriticalParameter(
480 IN PCHAR key,
481 OUT PCHAR dest,
482 IN INT destsize,
483 IN PCHAR buffer)
485 UCHAR *temp_buf1 = NULL;
486 UCHAR *temp_buf2 = NULL;
487 CHAR *start_ptr;
488 CHAR *end_ptr;
489 CHAR *ptr;
490 CHAR *offset = 0;
491 INT len;
493 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
494 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
496 if(temp_buf1 == NULL)
497 return (FALSE);
499 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
500 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
501 if(temp_buf2 == NULL)
503 os_free_mem(NULL, temp_buf1);
504 return (FALSE);
507 //find section
508 if((offset = RTMPFindSection(buffer)) == NULL)
510 os_free_mem(NULL, temp_buf1);
511 os_free_mem(NULL, temp_buf2);
512 return (FALSE);
515 strcpy(temp_buf1, "\n");
516 strcat(temp_buf1, key);
517 strcat(temp_buf1, "=");
519 //search key
520 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
522 os_free_mem(NULL, temp_buf1);
523 os_free_mem(NULL, temp_buf2);
524 return (FALSE);
527 start_ptr+=strlen("\n");
528 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
529 end_ptr=start_ptr+strlen(start_ptr);
531 if (end_ptr<start_ptr)
533 os_free_mem(NULL, temp_buf1);
534 os_free_mem(NULL, temp_buf2);
535 return (FALSE);
538 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
539 temp_buf2[end_ptr-start_ptr]='\0';
540 len = strlen(temp_buf2);
541 strcpy(temp_buf1, temp_buf2);
542 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
544 os_free_mem(NULL, temp_buf1);
545 os_free_mem(NULL, temp_buf2);
546 return (FALSE);
549 strcpy(temp_buf2, start_ptr+1);
550 ptr = temp_buf2;
552 //trim tab
553 /* We cannot trim space(' ') for SSID and key string. */
554 while(*ptr != 0x00)
556 //if( (*ptr == ' ') || (*ptr == '\t') )
557 if( (*ptr == '\t') )
558 ptr++;
559 else
560 break;
563 len = strlen(ptr);
564 memset(dest, 0x00, destsize);
565 strncpy(dest, ptr, len >= destsize ? destsize: len);
567 os_free_mem(NULL, temp_buf1);
568 os_free_mem(NULL, temp_buf2);
569 return TRUE;
573 ========================================================================
575 Routine Description:
576 Get multiple key parameter.
578 Arguments:
579 key Pointer to key string
580 dest Pointer to destination
581 destsize The datasize of the destination
582 buffer Pointer to the buffer to start find the key
584 Return Value:
585 TRUE Success
586 FALSE Fail
588 Note:
589 This routine get the value with the matched key (case case-sensitive)
590 ========================================================================
592 INT RTMPGetKeyParameterWithOffset(
593 IN PCHAR key,
594 OUT PCHAR dest,
595 OUT USHORT *end_offset,
596 IN INT destsize,
597 IN PCHAR buffer,
598 IN BOOLEAN bTrimSpace)
600 UCHAR *temp_buf1 = NULL;
601 UCHAR *temp_buf2 = NULL;
602 CHAR *start_ptr;
603 CHAR *end_ptr;
604 CHAR *ptr;
605 CHAR *offset = 0;
606 INT len;
608 if (*end_offset >= MAX_INI_BUFFER_SIZE)
609 return (FALSE);
611 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
613 if(temp_buf1 == NULL)
614 return (FALSE);
616 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
617 if(temp_buf2 == NULL)
619 os_free_mem(NULL, temp_buf1);
620 return (FALSE);
623 //find section
624 if(*end_offset == 0)
626 if ((offset = RTMPFindSection(buffer)) == NULL)
628 os_free_mem(NULL, temp_buf1);
629 os_free_mem(NULL, temp_buf2);
630 return (FALSE);
633 else
634 offset = buffer + (*end_offset);
636 strcpy(temp_buf1, "\n");
637 strcat(temp_buf1, key);
638 strcat(temp_buf1, "=");
640 //search key
641 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
643 os_free_mem(NULL, temp_buf1);
644 os_free_mem(NULL, temp_buf2);
645 return (FALSE);
648 start_ptr+=strlen("\n");
649 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
650 end_ptr=start_ptr+strlen(start_ptr);
652 if (end_ptr<start_ptr)
654 os_free_mem(NULL, temp_buf1);
655 os_free_mem(NULL, temp_buf2);
656 return (FALSE);
659 *end_offset = end_ptr - buffer;
661 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
662 temp_buf2[end_ptr-start_ptr]='\0';
663 len = strlen(temp_buf2);
664 strcpy(temp_buf1, temp_buf2);
665 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
667 os_free_mem(NULL, temp_buf1);
668 os_free_mem(NULL, temp_buf2);
669 return (FALSE);
672 strcpy(temp_buf2, start_ptr+1);
673 ptr = temp_buf2;
674 //trim space or tab
675 while(*ptr != 0x00)
677 if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
678 ptr++;
679 else
680 break;
683 len = strlen(ptr);
684 memset(dest, 0x00, destsize);
685 strncpy(dest, ptr, len >= destsize ? destsize: len);
687 os_free_mem(NULL, temp_buf1);
688 os_free_mem(NULL, temp_buf2);
689 return TRUE;
693 static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
695 PUCHAR keybuff;
696 INT i = BSSIdx, idx = KeyIdx;
697 ULONG KeyLen;
698 UCHAR CipherAlg = CIPHER_WEP64;
700 keybuff = buffer;
701 KeyLen = strlen(keybuff);
703 if (KeyType == 1)
704 {//Ascii
705 if( (KeyLen == 5) || (KeyLen == 13))
707 pAd->SharedKey[i][idx].KeyLen = KeyLen;
708 NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
709 if (KeyLen == 5)
710 CipherAlg = CIPHER_WEP64;
711 else
712 CipherAlg = CIPHER_WEP128;
713 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
715 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
716 return 1;
718 else
719 {//Invalid key length
720 DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
721 return 0;
724 else
725 {//Hex type
726 if( (KeyLen == 10) || (KeyLen == 26))
728 pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
729 AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
730 if (KeyLen == 10)
731 CipherAlg = CIPHER_WEP64;
732 else
733 CipherAlg = CIPHER_WEP128;
734 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
736 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
737 return 1;
739 else
740 {//Invalid key length
741 DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
742 return 0;
746 static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
748 char tok_str[16];
749 PUCHAR macptr;
750 INT i = 0, idx;
751 ULONG KeyType[MAX_MBSSID_NUM];
752 ULONG KeyIdx;
754 NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
756 //DefaultKeyID
757 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
760 #ifdef CONFIG_STA_SUPPORT
761 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
763 KeyIdx = simple_strtol(tmpbuf, 0, 10);
764 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
765 pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
766 else
767 pAd->StaCfg.DefaultKeyId = 0;
769 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
771 #endif // CONFIG_STA_SUPPORT //
775 for (idx = 0; idx < 4; idx++)
777 sprintf(tok_str, "Key%dType", idx + 1);
778 //Key1Type
779 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
781 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
783 KeyType[i] = simple_strtol(macptr, 0, 10);
786 #ifdef CONFIG_STA_SUPPORT
787 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
789 sprintf(tok_str, "Key%dStr", idx + 1);
790 if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
792 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
795 #endif // CONFIG_STA_SUPPORT //
801 #ifdef CONFIG_STA_SUPPORT
802 static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
804 PUCHAR macptr;
805 INT i=0;
806 BOOLEAN bWmmEnable = FALSE;
808 //WmmCapable
809 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
811 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
813 pAd->CommonCfg.bWmmCapable = TRUE;
814 bWmmEnable = TRUE;
816 else //Disable
818 pAd->CommonCfg.bWmmCapable = FALSE;
821 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
824 #ifdef QOS_DLS_SUPPORT
825 //DLSCapable
826 if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
828 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
830 pAd->CommonCfg.bDLSCapable = TRUE;
832 else //Disable
834 pAd->CommonCfg.bDLSCapable = FALSE;
837 DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
839 #endif // QOS_DLS_SUPPORT //
841 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
842 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
844 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
846 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
848 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
852 if (bWmmEnable)
854 //APSDCapable
855 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
857 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
858 pAd->CommonCfg.bAPSDCapable = TRUE;
859 else
860 pAd->CommonCfg.bAPSDCapable = FALSE;
862 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
865 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
866 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
868 BOOLEAN apsd_ac[4];
870 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
872 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
874 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
877 pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
878 pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
879 pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
880 pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
885 #endif // CONFIG_STA_SUPPORT //
888 NDIS_STATUS RTMPReadParametersHook(
889 IN PRTMP_ADAPTER pAd)
891 PUCHAR src = NULL;
892 struct file *srcf;
893 INT retval, orgfsuid, orgfsgid;
894 mm_segment_t orgfs;
895 CHAR *buffer;
896 CHAR *tmpbuf;
897 ULONG RtsThresh;
898 ULONG FragThresh;
899 #ifdef CONFIG_STA_SUPPORT
900 UCHAR keyMaterial[40];
901 #endif // CONFIG_STA_SUPPORT //
904 PUCHAR macptr;
905 INT i = 0;
907 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
908 if(buffer == NULL)
909 return NDIS_STATUS_FAILURE;
911 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
912 if(tmpbuf == NULL)
914 kfree(buffer);
915 return NDIS_STATUS_FAILURE;
918 #ifdef CONFIG_STA_SUPPORT
919 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
920 src = STA_PROFILE_PATH;
921 #endif // CONFIG_STA_SUPPORT //
922 #ifdef MULTIPLE_CARD_SUPPORT
923 src = pAd->MC_FileName;
924 #endif // MULTIPLE_CARD_SUPPORT //
926 // Save uid and gid used for filesystem access.
927 // Set user and group to 0 (root)
928 orgfsuid = current_fsuid();
929 orgfsgid = current_fsgid();
930 /* Hm, can't really do this nicely anymore, so rely on these files
931 * being set to the proper permission to read them... */
932 /* current->cred->fsuid = current->cred->fsgid = 0; */
933 orgfs = get_fs();
934 set_fs(KERNEL_DS);
936 if (src && *src)
938 srcf = filp_open(src, O_RDONLY, 0);
939 if (IS_ERR(srcf))
941 DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
943 else
945 // The object must have a read method
946 if (srcf->f_op && srcf->f_op->read)
948 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
949 retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
950 if (retval < 0)
952 DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
954 else
956 // set file parameter to portcfg
957 //CountryRegion
958 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
960 pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
961 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
963 //CountryRegionABand
964 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
966 pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
967 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
969 //CountryCode
970 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
972 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
973 #ifdef CONFIG_STA_SUPPORT
974 #ifdef EXT_BUILD_CHANNEL_LIST
975 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
976 NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
977 #endif // EXT_BUILD_CHANNEL_LIST //
978 #endif // CONFIG_STA_SUPPORT //
979 if (strlen(pAd->CommonCfg.CountryCode) != 0)
981 pAd->CommonCfg.bCountryFlag = TRUE;
983 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
985 //ChannelGeography
986 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
988 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
989 if (Geography <= BOTH)
991 pAd->CommonCfg.Geography = Geography;
992 pAd->CommonCfg.CountryCode[2] =
993 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
994 #ifdef CONFIG_STA_SUPPORT
995 #ifdef EXT_BUILD_CHANNEL_LIST
996 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
997 pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
998 #endif // EXT_BUILD_CHANNEL_LIST //
999 #endif // CONFIG_STA_SUPPORT //
1000 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
1003 else
1005 pAd->CommonCfg.Geography = BOTH;
1006 pAd->CommonCfg.CountryCode[2] = ' ';
1010 #ifdef CONFIG_STA_SUPPORT
1011 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1013 //SSID
1014 if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
1016 if (strlen(tmpbuf) <= 32)
1018 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
1019 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
1020 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
1021 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
1022 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
1023 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
1024 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1025 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1026 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1027 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
1031 #endif // CONFIG_STA_SUPPORT //
1033 #ifdef CONFIG_STA_SUPPORT
1034 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1036 //NetworkType
1037 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
1039 pAd->bConfigChanged = TRUE;
1040 if (strcmp(tmpbuf, "Adhoc") == 0)
1041 pAd->StaCfg.BssType = BSS_ADHOC;
1042 else //Default Infrastructure mode
1043 pAd->StaCfg.BssType = BSS_INFRA;
1044 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1045 pAd->StaCfg.WpaState = SS_NOTUSE;
1046 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
1049 #endif // CONFIG_STA_SUPPORT //
1050 //Channel
1051 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
1053 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1054 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1056 //WirelessMode
1057 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
1059 int value = 0, maxPhyMode = PHY_11G;
1061 #ifdef DOT11_N_SUPPORT
1062 maxPhyMode = PHY_11N_5G;
1063 #endif // DOT11_N_SUPPORT //
1065 value = simple_strtol(tmpbuf, 0, 10);
1067 if (value <= maxPhyMode)
1069 pAd->CommonCfg.PhyMode = value;
1071 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1073 //BasicRate
1074 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
1076 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1077 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1079 //BeaconPeriod
1080 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
1082 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1083 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1085 //TxPower
1086 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
1088 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1089 #ifdef CONFIG_STA_SUPPORT
1090 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1091 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1092 #endif // CONFIG_STA_SUPPORT //
1093 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1095 //BGProtection
1096 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
1098 switch (simple_strtol(tmpbuf, 0, 10))
1100 case 1: //Always On
1101 pAd->CommonCfg.UseBGProtection = 1;
1102 break;
1103 case 2: //Always OFF
1104 pAd->CommonCfg.UseBGProtection = 2;
1105 break;
1106 case 0: //AUTO
1107 default:
1108 pAd->CommonCfg.UseBGProtection = 0;
1109 break;
1111 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1113 //OLBCDetection
1114 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
1116 switch (simple_strtol(tmpbuf, 0, 10))
1118 case 1: //disable OLBC Detection
1119 pAd->CommonCfg.DisableOLBCDetect = 1;
1120 break;
1121 case 0: //enable OLBC Detection
1122 pAd->CommonCfg.DisableOLBCDetect = 0;
1123 break;
1124 default:
1125 pAd->CommonCfg.DisableOLBCDetect= 0;
1126 break;
1128 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1130 //TxPreamble
1131 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
1133 switch (simple_strtol(tmpbuf, 0, 10))
1135 case Rt802_11PreambleShort:
1136 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1137 break;
1138 case Rt802_11PreambleLong:
1139 default:
1140 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1141 break;
1143 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1145 //RTSThreshold
1146 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
1148 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1149 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1150 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1151 else
1152 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1154 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1156 //FragThreshold
1157 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
1159 FragThresh = simple_strtol(tmpbuf, 0, 10);
1160 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1162 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1163 { //illegal FragThresh so we set it to default
1164 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1165 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1167 else if (FragThresh % 2 == 1)
1169 // The length of each fragment shall always be an even number of octets, except for the last fragment
1170 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1171 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1173 else
1175 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1177 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1178 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1180 //TxBurst
1181 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
1183 //#ifdef WIFI_TEST
1184 // pAd->CommonCfg.bEnableTxBurst = FALSE;
1185 //#else
1186 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1187 pAd->CommonCfg.bEnableTxBurst = TRUE;
1188 else //Disable
1189 pAd->CommonCfg.bEnableTxBurst = FALSE;
1190 //#endif
1191 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1194 #ifdef AGGREGATION_SUPPORT
1195 //PktAggregate
1196 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
1198 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1199 pAd->CommonCfg.bAggregationCapable = TRUE;
1200 else //Disable
1201 pAd->CommonCfg.bAggregationCapable = FALSE;
1202 #ifdef PIGGYBACK_SUPPORT
1203 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1204 #endif // PIGGYBACK_SUPPORT //
1205 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1207 #else
1208 pAd->CommonCfg.bAggregationCapable = FALSE;
1209 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1210 #endif // AGGREGATION_SUPPORT //
1212 // WmmCapable
1214 #ifdef CONFIG_STA_SUPPORT
1215 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1216 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
1217 #endif // CONFIG_STA_SUPPORT //
1219 //ShortSlot
1220 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
1222 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1223 pAd->CommonCfg.bUseShortSlotTime = TRUE;
1224 else //Disable
1225 pAd->CommonCfg.bUseShortSlotTime = FALSE;
1227 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1229 //IEEE80211H
1230 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
1232 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1234 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1235 pAd->CommonCfg.bIEEE80211H = TRUE;
1236 else //Disable
1237 pAd->CommonCfg.bIEEE80211H = FALSE;
1239 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1242 //CSPeriod
1243 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
1245 if(simple_strtol(tmpbuf, 0, 10) != 0)
1246 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1247 else
1248 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1250 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1253 //RDRegion
1254 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
1256 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1258 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
1259 pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
1261 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1263 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
1264 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1266 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1268 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
1269 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1271 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1273 pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
1274 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1276 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1278 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1279 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1281 else
1283 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1284 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1287 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
1289 else
1291 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1292 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1295 //WirelessEvent
1296 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
1298 #if WIRELESS_EXT >= 15
1299 if(simple_strtol(tmpbuf, 0, 10) != 0)
1300 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1301 else
1302 pAd->CommonCfg.bWirelessEvent = 0; // disable
1303 #else
1304 pAd->CommonCfg.bWirelessEvent = 0; // disable
1305 #endif
1306 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1308 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
1310 if(simple_strtol(tmpbuf, 0, 10) != 0)
1311 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1312 else
1313 pAd->CommonCfg.bWiFiTest = 0; // disable
1315 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1317 //AuthMode
1318 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
1320 #ifdef CONFIG_STA_SUPPORT
1321 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1323 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1324 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1325 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1326 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1327 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1328 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1329 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1330 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1331 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1332 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1333 #ifdef WPA_SUPPLICANT_SUPPORT
1334 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1335 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1336 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1337 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1338 #endif // WPA_SUPPLICANT_SUPPORT //
1339 else
1340 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1342 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1344 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1346 #endif // CONFIG_STA_SUPPORT //
1348 //EncrypType
1349 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
1352 #ifdef CONFIG_STA_SUPPORT
1353 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1355 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1356 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1357 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1358 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1359 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1360 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1361 else
1362 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1364 // Update all wepstatus related
1365 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1366 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1367 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1368 pAd->StaCfg.bMixCipher = FALSE;
1370 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1371 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1373 #endif // CONFIG_STA_SUPPORT //
1378 #ifdef CONFIG_STA_SUPPORT
1379 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1381 if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
1383 int err=0;
1385 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1387 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1388 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1389 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1392 err = 1;
1394 else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
1396 PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
1397 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1400 else if (strlen(tmpbuf) == 64)
1402 AtoH(tmpbuf, keyMaterial, 32);
1403 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1405 else
1407 err = 1;
1408 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
1411 if (err == 0)
1413 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1414 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1416 // Start STA supplicant state machine
1417 pAd->StaCfg.WpaState = SS_START;
1419 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1422 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
1423 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
1424 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
1425 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
1426 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
1428 // Decide its ChiperAlg
1429 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
1430 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
1431 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
1432 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
1433 else
1434 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
1436 pAd->StaCfg.WpaState = SS_NOTUSE;
1439 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1443 #endif // CONFIG_STA_SUPPORT //
1445 //DefaultKeyID, KeyType, KeyStr
1446 rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
1449 //HSCounter
1450 /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, buffer))
1452 switch (simple_strtol(tmpbuf, 0, 10))
1454 case 1: //Enable
1455 pAd->CommonCfg.bEnableHSCounter = TRUE;
1456 break;
1457 case 0: //Disable
1458 default:
1459 pAd->CommonCfg.bEnableHSCounter = FALSE;
1460 break;
1462 DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
1465 #ifdef DOT11_N_SUPPORT
1466 HTParametersHook(pAd, tmpbuf, buffer);
1467 #endif // DOT11_N_SUPPORT //
1470 #ifdef CARRIER_DETECTION_SUPPORT
1471 //CarrierDetect
1472 if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, buffer))
1474 if ((strncmp(tmpbuf, "0", 1) == 0))
1475 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1476 else if ((strncmp(tmpbuf, "1", 1) == 0))
1477 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
1478 else
1479 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1481 DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
1483 else
1484 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1485 #endif // CARRIER_DETECTION_SUPPORT //
1487 #ifdef CONFIG_STA_SUPPORT
1488 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1490 //PSMode
1491 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
1493 if (pAd->StaCfg.BssType == BSS_INFRA)
1495 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1497 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1498 // to exclude certain situations.
1499 // MlmeSetPsm(pAd, PWR_SAVE);
1500 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1501 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1502 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1503 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1504 pAd->StaCfg.DefaultListenCount = 5;
1506 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1507 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1509 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1510 // to exclude certain situations.
1511 // MlmeSetPsmBit(pAd, PWR_SAVE);
1512 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1513 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1514 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1515 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1516 pAd->StaCfg.DefaultListenCount = 3;
1518 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1519 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1521 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1522 // to exclude certain situations.
1523 // MlmeSetPsmBit(pAd, PWR_SAVE);
1524 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1525 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1526 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1527 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1528 pAd->StaCfg.DefaultListenCount = 3;
1530 else
1531 { //Default Ndis802_11PowerModeCAM
1532 // clear PSM bit immediately
1533 MlmeSetPsmBit(pAd, PWR_ACTIVE);
1534 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1535 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1536 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1537 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1539 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1542 // FastRoaming
1543 if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
1545 if (simple_strtol(tmpbuf, 0, 10) == 0)
1546 pAd->StaCfg.bFastRoaming = FALSE;
1547 else
1548 pAd->StaCfg.bFastRoaming = TRUE;
1550 DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
1552 // RoamThreshold
1553 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
1555 long lInfo = simple_strtol(tmpbuf, 0, 10);
1557 if (lInfo > 90 || lInfo < 60)
1558 pAd->StaCfg.dBmToRoam = -70;
1559 else
1560 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1562 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1565 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
1567 if(simple_strtol(tmpbuf, 0, 10) == 0)
1568 pAd->StaCfg.bTGnWifiTest = FALSE;
1569 else
1570 pAd->StaCfg.bTGnWifiTest = TRUE;
1571 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1574 #endif // CONFIG_STA_SUPPORT //
1580 else
1582 DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
1585 retval=filp_close(srcf,NULL);
1587 if (retval)
1589 DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
1594 set_fs(orgfs);
1595 #if 0
1596 current->fsuid = orgfsuid;
1597 current->fsgid = orgfsgid;
1598 #endif
1600 kfree(buffer);
1601 kfree(tmpbuf);
1603 return (NDIS_STATUS_SUCCESS);
1606 #ifdef DOT11_N_SUPPORT
1607 static void HTParametersHook(
1608 IN PRTMP_ADAPTER pAd,
1609 IN CHAR *pValueStr,
1610 IN CHAR *pInput)
1613 INT Value;
1615 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
1617 Value = simple_strtol(pValueStr, 0, 10);
1618 if (Value == 0)
1620 pAd->CommonCfg.bHTProtect = FALSE;
1622 else
1624 pAd->CommonCfg.bHTProtect = TRUE;
1626 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
1629 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
1631 Value = simple_strtol(pValueStr, 0, 10);
1632 if (Value == 0)
1634 pAd->CommonCfg.bMIMOPSEnable = FALSE;
1636 else
1638 pAd->CommonCfg.bMIMOPSEnable = TRUE;
1640 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
1644 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
1646 Value = simple_strtol(pValueStr, 0, 10);
1647 if (Value > MMPS_ENABLE)
1649 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1651 else
1653 //TODO: add mimo power saving mechanism
1654 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1655 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
1657 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
1660 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
1662 Value = simple_strtol(pValueStr, 0, 10);
1663 if (Value == 0)
1665 pAd->CommonCfg.bBADecline = FALSE;
1667 else
1669 pAd->CommonCfg.bBADecline = TRUE;
1671 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
1675 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
1677 Value = simple_strtol(pValueStr, 0, 10);
1678 if (Value == 0)
1680 pAd->CommonCfg.bDisableReordering = FALSE;
1682 else
1684 pAd->CommonCfg.bDisableReordering = TRUE;
1686 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
1689 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
1691 Value = simple_strtol(pValueStr, 0, 10);
1692 if (Value == 0)
1694 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
1696 else
1698 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
1700 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
1701 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
1704 // Tx_+HTC frame
1705 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
1707 Value = simple_strtol(pValueStr, 0, 10);
1708 if (Value == 0)
1710 pAd->HTCEnable = FALSE;
1712 else
1714 pAd->HTCEnable = TRUE;
1716 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
1719 // Enable HT Link Adaptation Control
1720 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
1722 Value = simple_strtol(pValueStr, 0, 10);
1723 if (Value == 0)
1725 pAd->bLinkAdapt = FALSE;
1727 else
1729 pAd->HTCEnable = TRUE;
1730 pAd->bLinkAdapt = TRUE;
1732 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1735 // Reverse Direction Mechanism
1736 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
1738 Value = simple_strtol(pValueStr, 0, 10);
1739 if (Value == 0)
1741 pAd->CommonCfg.bRdg = FALSE;
1743 else
1745 pAd->HTCEnable = TRUE;
1746 pAd->CommonCfg.bRdg = TRUE;
1748 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1754 // Tx A-MSUD ?
1755 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
1757 Value = simple_strtol(pValueStr, 0, 10);
1758 if (Value == 0)
1760 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
1762 else
1764 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
1766 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
1769 // MPDU Density
1770 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
1772 Value = simple_strtol(pValueStr, 0, 10);
1773 if (Value <=7 && Value >= 0)
1775 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
1776 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
1778 else
1780 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
1781 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
1785 // Max Rx BA Window Size
1786 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
1788 Value = simple_strtol(pValueStr, 0, 10);
1790 if (Value >=1 && Value <= 64)
1792 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
1793 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
1794 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
1796 else
1798 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
1799 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
1800 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
1805 // Guard Interval
1806 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
1808 Value = simple_strtol(pValueStr, 0, 10);
1810 if (Value == GI_400)
1812 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
1814 else
1816 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
1819 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
1822 // HT Operation Mode : Mixed Mode , Green Field
1823 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
1825 Value = simple_strtol(pValueStr, 0, 10);
1827 if (Value == HTMODE_GF)
1830 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
1832 else
1834 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
1837 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
1840 // Fixed Tx mode : CCK, OFDM
1841 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
1843 UCHAR fix_tx_mode;
1845 #ifdef CONFIG_STA_SUPPORT
1846 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1848 fix_tx_mode = FIXED_TXMODE_HT;
1850 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
1852 fix_tx_mode = FIXED_TXMODE_OFDM;
1854 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
1856 fix_tx_mode = FIXED_TXMODE_CCK;
1858 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
1860 fix_tx_mode = FIXED_TXMODE_HT;
1862 else
1864 Value = simple_strtol(pValueStr, 0, 10);
1865 // 1 : CCK
1866 // 2 : OFDM
1867 // otherwise : HT
1868 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
1869 fix_tx_mode = Value;
1870 else
1871 fix_tx_mode = FIXED_TXMODE_HT;
1874 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
1875 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1878 #endif // CONFIG_STA_SUPPORT //
1882 // Channel Width
1883 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
1885 Value = simple_strtol(pValueStr, 0, 10);
1887 if (Value == BW_40)
1889 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1891 else
1893 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1896 #ifdef MCAST_RATE_SPECIFIC
1897 pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
1898 #endif // MCAST_RATE_SPECIFIC //
1900 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1903 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
1905 Value = simple_strtol(pValueStr, 0, 10);
1907 if (Value == 0)
1910 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1912 else
1914 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1917 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1920 // MSC
1921 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
1924 #ifdef CONFIG_STA_SUPPORT
1925 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1927 Value = simple_strtol(pValueStr, 0, 10);
1929 // if ((Value >= 0 && Value <= 15) || (Value == 32))
1930 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1932 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1933 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1934 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1936 else
1938 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1939 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1940 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1943 #endif // CONFIG_STA_SUPPORT //
1946 // STBC
1947 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
1949 Value = simple_strtol(pValueStr, 0, 10);
1950 if (Value == STBC_USE)
1952 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1954 else
1956 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1958 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1961 // 40_Mhz_Intolerant
1962 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
1964 Value = simple_strtol(pValueStr, 0, 10);
1965 if (Value == 0)
1967 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1969 else
1971 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1973 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1975 //HT_TxStream
1976 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
1978 switch (simple_strtol(pValueStr, 0, 10))
1980 case 1:
1981 pAd->CommonCfg.TxStream = 1;
1982 break;
1983 case 2:
1984 pAd->CommonCfg.TxStream = 2;
1985 break;
1986 case 3: // 3*3
1987 default:
1988 pAd->CommonCfg.TxStream = 3;
1990 if (pAd->MACVersion < RALINK_2883_VERSION)
1991 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1992 break;
1994 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1996 //HT_RxStream
1997 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
1999 switch (simple_strtol(pValueStr, 0, 10))
2001 case 1:
2002 pAd->CommonCfg.RxStream = 1;
2003 break;
2004 case 2:
2005 pAd->CommonCfg.RxStream = 2;
2006 break;
2007 case 3:
2008 default:
2009 pAd->CommonCfg.RxStream = 3;
2011 if (pAd->MACVersion < RALINK_2883_VERSION)
2012 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
2013 break;
2015 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
2019 #endif // DOT11_N_SUPPORT //