aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rt2870/rt_profile.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-12-17 20:04:23 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-06 16:52:35 -0500
commitc55519ff75224222f4668c92ae3733059269f575 (patch)
treecf7871a28ee226e274763608f215c171d54cd33e /drivers/staging/rt2870/rt_profile.c
parent6e16aee60c815dac2d6c3b875769a79d09df6f91 (diff)
Staging: add rt2870 wireless driver
This is the Ralink RT2870 driver from the company that does horrible things like reading a config file from /etc. However, the driver that is currently under development from the wireless development community is not working at all yet, so distros and users are using this version instead (quite common hardware on a lot of netbook machines). So here is this driver, for now, until the wireless developers get a "clean" version into the main tree, or until this version is cleaned up sufficiently to move out of the staging tree. Ported to the Linux build system and cleaned up a bit already by me. Cc: Linux wireless <linux-wireless@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rt2870/rt_profile.c')
-rw-r--r--drivers/staging/rt2870/rt_profile.c2016
1 files changed, 2016 insertions, 0 deletions
diff --git a/drivers/staging/rt2870/rt_profile.c b/drivers/staging/rt2870/rt_profile.c
new file mode 100644
index 00000000000..3e360c66158
--- /dev/null
+++ b/drivers/staging/rt2870/rt_profile.c
@@ -0,0 +1,2016 @@
1/*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
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 *************************************************************************
26 */
27
28#include "rt_config.h"
29
30#ifdef DOT11_N_SUPPORT
31static void HTParametersHook(
32 IN PRTMP_ADAPTER pAd,
33 IN CHAR *pValueStr,
34 IN CHAR *pInput);
35#endif // DOT11_N_SUPPORT //
36
37#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
38
39// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
40BOOLEAN rtstrmactohex(char *s1, char *s2)
41{
42 int i = 0;
43 char *ptokS = s1, *ptokE = s1;
44
45 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
46 return FALSE;
47
48 while((*ptokS) != '\0')
49 {
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
58 }
59
60 return ( i == 6 ? TRUE : FALSE);
61
62}
63
64
65// we assume the s1 and s2 both are strings.
66BOOLEAN rtstrcasecmp(char *s1, char *s2)
67{
68 char *p1 = s1, *p2 = s2;
69
70 if (strlen(s1) != strlen(s2))
71 return FALSE;
72
73 while(*p1 != '\0')
74 {
75 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
76 return FALSE;
77 p1++;
78 p2++;
79 }
80
81 return TRUE;
82}
83
84// we assume the s1 (buffer) and s2 (key) both are strings.
85char * rtstrstruncasecmp(char * s1, char * s2)
86{
87 INT l1, l2, i;
88 char temp1, temp2;
89
90 l2 = strlen(s2);
91 if (!l2)
92 return (char *) s1;
93
94 l1 = strlen(s1);
95
96 while (l1 >= l2)
97 {
98 l1--;
99
100 for(i=0; i<l2; i++)
101 {
102 temp1 = *(s1+i);
103 temp2 = *(s2+i);
104
105 if (('a' <= temp1) && (temp1 <= 'z'))
106 temp1 = 'A'+(temp1-'a');
107 if (('a' <= temp2) && (temp2 <= 'z'))
108 temp2 = 'A'+(temp2-'a');
109
110 if (temp1 != temp2)
111 break;
112 }
113
114 if (i == l2)
115 return (char *) s1;
116
117 s1++;
118 }
119
120 return NULL; // not found
121}
122
123//add by kathy
124
125 /**
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
129 */
130char * rtstrstr(const char * s1,const char * s2)
131{
132 INT l1, l2;
133
134 l2 = strlen(s2);
135 if (!l2)
136 return (char *) s1;
137
138 l1 = strlen(s1);
139
140 while (l1 >= l2)
141 {
142 l1--;
143 if (!memcmp(s1,s2,l2))
144 return (char *) s1;
145 s1++;
146 }
147
148 return NULL;
149}
150
151/**
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.
156 */
157char * __rstrtok;
158char * rstrtok(char * s,const char * ct)
159{
160 char *sbegin, *send;
161
162 sbegin = s ? s : __rstrtok;
163 if (!sbegin)
164 {
165 return NULL;
166 }
167
168 sbegin += strspn(sbegin,ct);
169 if (*sbegin == '\0')
170 {
171 __rstrtok = NULL;
172 return( NULL );
173 }
174
175 send = strpbrk( sbegin, ct);
176 if (send && *send != '\0')
177 *send++ = '\0';
178
179 __rstrtok = send;
180
181 return (sbegin);
182}
183
184/**
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 : ";").
189 */
190INT delimitcnt(char * s,const char * ct)
191{
192 INT count = 0;
193 /* point to the beginning of the line */
194 const char *token = s;
195
196 for ( ;; )
197 {
198 token = strpbrk(token, ct); /* search for delimiters */
199
200 if ( token == NULL )
201 {
202 /* advanced to the terminating null character */
203 break;
204 }
205 /* skip the delimiter */
206 ++token;
207
208 /*
209 * Print the found text: use len with %.*s to specify field width.
210 */
211
212 /* accumulate delimiter count */
213 ++count;
214 }
215 return count;
216}
217
218/*
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.
222 */
223int rtinet_aton(const char *cp, unsigned int *addr)
224{
225 unsigned int val;
226 int base, n;
227 char c;
228 unsigned int parts[4];
229 unsigned int *pp = parts;
230
231 for (;;)
232 {
233 /*
234 * Collect number up to ``.''.
235 * Values are specified as for C:
236 * 0x=hex, 0=octal, other=decimal.
237 */
238 val = 0;
239 base = 10;
240 if (*cp == '0')
241 {
242 if (*++cp == 'x' || *cp == 'X')
243 base = 16, cp++;
244 else
245 base = 8;
246 }
247 while ((c = *cp) != '\0')
248 {
249 if (isdigit((unsigned char) c))
250 {
251 val = (val * base) + (c - '0');
252 cp++;
253 continue;
254 }
255 if (base == 16 && isxdigit((unsigned char) c))
256 {
257 val = (val << 4) +
258 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
259 cp++;
260 continue;
261 }
262 break;
263 }
264 if (*cp == '.')
265 {
266 /*
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)
269 */
270 if (pp >= parts + 3 || val > 0xff)
271 return 0;
272 *pp++ = val, cp++;
273 }
274 else
275 break;
276 }
277
278 /*
279 * Check for trailing junk.
280 */
281 while (*cp)
282 if (!isspace((unsigned char) *cp++))
283 return 0;
284
285 /*
286 * Concoct the address according to the number of parts specified.
287 */
288 n = pp - parts + 1;
289 switch (n)
290 {
291
292 case 1: /* a -- 32 bits */
293 break;
294
295 case 2: /* a.b -- 8.24 bits */
296 if (val > 0xffffff)
297 return 0;
298 val |= parts[0] << 24;
299 break;
300
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;
306
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;
312 }
313
314 *addr = htonl(val);
315 return 1;
316
317}
318
319/*
320 ========================================================================
321
322 Routine Description:
323 Find key section for Get key parameter.
324
325 Arguments:
326 buffer Pointer to the buffer to start find the key section
327 section the key of the secion to be find
328
329 Return Value:
330 NULL Fail
331 Others Success
332 ========================================================================
333*/
334PUCHAR RTMPFindSection(
335 IN PCHAR buffer)
336{
337 CHAR temp_buf[32];
338 PUCHAR ptr;
339
340 strcpy(temp_buf, "Default");
341
342 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
343 return (ptr+strlen("\n"));
344 else
345 return NULL;
346}
347
348/*
349 ========================================================================
350
351 Routine Description:
352 Get key parameter.
353
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
359
360 Return Value:
361 TRUE Success
362 FALSE Fail
363
364 Note:
365 This routine get the value with the matched key (case case-sensitive)
366 ========================================================================
367*/
368INT RTMPGetKeyParameter(
369 IN PCHAR key,
370 OUT PCHAR dest,
371 IN INT destsize,
372 IN PCHAR buffer)
373{
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;
381
382 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
383 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
384
385 if(temp_buf1 == NULL)
386 return (FALSE);
387
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)
391 {
392 os_free_mem(NULL, temp_buf1);
393 return (FALSE);
394 }
395
396 //find section
397 if((offset = RTMPFindSection(buffer)) == NULL)
398 {
399 os_free_mem(NULL, temp_buf1);
400 os_free_mem(NULL, temp_buf2);
401 return (FALSE);
402 }
403
404 strcpy(temp_buf1, "\n");
405 strcat(temp_buf1, key);
406 strcat(temp_buf1, "=");
407
408 //search key
409 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
410 {
411 os_free_mem(NULL, temp_buf1);
412 os_free_mem(NULL, temp_buf2);
413 return (FALSE);
414 }
415
416 start_ptr+=strlen("\n");
417 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
418 end_ptr=start_ptr+strlen(start_ptr);
419
420 if (end_ptr<start_ptr)
421 {
422 os_free_mem(NULL, temp_buf1);
423 os_free_mem(NULL, temp_buf2);
424 return (FALSE);
425 }
426
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)
432 {
433 os_free_mem(NULL, temp_buf1);
434 os_free_mem(NULL, temp_buf2);
435 return (FALSE);
436 }
437
438 strcpy(temp_buf2, start_ptr+1);
439 ptr = temp_buf2;
440 //trim space or tab
441 while(*ptr != 0x00)
442 {
443 if( (*ptr == ' ') || (*ptr == '\t') )
444 ptr++;
445 else
446 break;
447 }
448
449 len = strlen(ptr);
450 memset(dest, 0x00, destsize);
451 strncpy(dest, ptr, len >= destsize ? destsize: len);
452
453 os_free_mem(NULL, temp_buf1);
454 os_free_mem(NULL, temp_buf2);
455 return TRUE;
456}
457
458/*
459 ========================================================================
460
461 Routine Description:
462 Get key parameter.
463
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
469
470 Return Value:
471 TRUE Success
472 FALSE Fail
473
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 ========================================================================
478*/
479INT RTMPGetCriticalParameter(
480 IN PCHAR key,
481 OUT PCHAR dest,
482 IN INT destsize,
483 IN PCHAR buffer)
484{
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;
492
493 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
494 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
495
496 if(temp_buf1 == NULL)
497 return (FALSE);
498
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)
502 {
503 os_free_mem(NULL, temp_buf1);
504 return (FALSE);
505 }
506
507 //find section
508 if((offset = RTMPFindSection(buffer)) == NULL)
509 {
510 os_free_mem(NULL, temp_buf1);
511 os_free_mem(NULL, temp_buf2);
512 return (FALSE);
513 }
514
515 strcpy(temp_buf1, "\n");
516 strcat(temp_buf1, key);
517 strcat(temp_buf1, "=");
518
519 //search key
520 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
521 {
522 os_free_mem(NULL, temp_buf1);
523 os_free_mem(NULL, temp_buf2);
524 return (FALSE);
525 }
526
527 start_ptr+=strlen("\n");
528 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
529 end_ptr=start_ptr+strlen(start_ptr);
530
531 if (end_ptr<start_ptr)
532 {
533 os_free_mem(NULL, temp_buf1);
534 os_free_mem(NULL, temp_buf2);
535 return (FALSE);
536 }
537
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)
543 {
544 os_free_mem(NULL, temp_buf1);
545 os_free_mem(NULL, temp_buf2);
546 return (FALSE);
547 }
548
549 strcpy(temp_buf2, start_ptr+1);
550 ptr = temp_buf2;
551
552 //trim tab
553 /* We cannot trim space(' ') for SSID and key string. */
554 while(*ptr != 0x00)
555 {
556 //if( (*ptr == ' ') || (*ptr == '\t') )
557 if( (*ptr == '\t') )
558 ptr++;
559 else
560 break;
561 }
562
563 len = strlen(ptr);
564 memset(dest, 0x00, destsize);
565 strncpy(dest, ptr, len >= destsize ? destsize: len);
566
567 os_free_mem(NULL, temp_buf1);
568 os_free_mem(NULL, temp_buf2);
569 return TRUE;
570}
571
572/*
573 ========================================================================
574
575 Routine Description:
576 Get multiple key parameter.
577
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
583
584 Return Value:
585 TRUE Success
586 FALSE Fail
587
588 Note:
589 This routine get the value with the matched key (case case-sensitive)
590 ========================================================================
591*/
592INT 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)
599{
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;
607
608 if (*end_offset >= MAX_INI_BUFFER_SIZE)
609 return (FALSE);
610
611 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
612
613 if(temp_buf1 == NULL)
614 return (FALSE);
615
616 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
617 if(temp_buf2 == NULL)
618 {
619 os_free_mem(NULL, temp_buf1);
620 return (FALSE);
621 }
622
623 //find section
624 if(*end_offset == 0)
625 {
626 if ((offset = RTMPFindSection(buffer)) == NULL)
627 {
628 os_free_mem(NULL, temp_buf1);
629 os_free_mem(NULL, temp_buf2);
630 return (FALSE);
631 }
632 }
633 else
634 offset = buffer + (*end_offset);
635
636 strcpy(temp_buf1, "\n");
637 strcat(temp_buf1, key);
638 strcat(temp_buf1, "=");
639
640 //search key
641 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
642 {
643 os_free_mem(NULL, temp_buf1);
644 os_free_mem(NULL, temp_buf2);
645 return (FALSE);
646 }
647
648 start_ptr+=strlen("\n");
649 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
650 end_ptr=start_ptr+strlen(start_ptr);
651
652 if (end_ptr<start_ptr)
653 {
654 os_free_mem(NULL, temp_buf1);
655 os_free_mem(NULL, temp_buf2);
656 return (FALSE);
657 }
658
659 *end_offset = end_ptr - buffer;
660
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)
666 {
667 os_free_mem(NULL, temp_buf1);
668 os_free_mem(NULL, temp_buf2);
669 return (FALSE);
670 }
671
672 strcpy(temp_buf2, start_ptr+1);
673 ptr = temp_buf2;
674 //trim space or tab
675 while(*ptr != 0x00)
676 {
677 if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
678 ptr++;
679 else
680 break;
681 }
682
683 len = strlen(ptr);
684 memset(dest, 0x00, destsize);
685 strncpy(dest, ptr, len >= destsize ? destsize: len);
686
687 os_free_mem(NULL, temp_buf1);
688 os_free_mem(NULL, temp_buf2);
689 return TRUE;
690}
691
692
693static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
694{
695 PUCHAR keybuff;
696 INT i = BSSIdx, idx = KeyIdx;
697 ULONG KeyLen;
698 UCHAR CipherAlg = CIPHER_WEP64;
699
700 keybuff = buffer;
701 KeyLen = strlen(keybuff);
702
703 if (KeyType == 1)
704 {//Ascii
705 if( (KeyLen == 5) || (KeyLen == 13))
706 {
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;
714
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;
717 }
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;
722 }
723 }
724 else
725 {//Hex type
726 if( (KeyLen == 10) || (KeyLen == 26))
727 {
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;
735
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;
738 }
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;
743 }
744 }
745}
746static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
747{
748 char tok_str[16];
749 PUCHAR macptr;
750 INT i = 0, idx;
751 ULONG KeyType[MAX_MBSSID_NUM];
752 ULONG KeyIdx;
753
754 NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
755
756 //DefaultKeyID
757 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
758 {
759
760#ifdef CONFIG_STA_SUPPORT
761 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
762 {
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;
768
769 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
770 }
771#endif // CONFIG_STA_SUPPORT //
772 }
773
774
775 for (idx = 0; idx < 4; idx++)
776 {
777 sprintf(tok_str, "Key%dType", idx + 1);
778 //Key1Type
779 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
780 {
781 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
782 {
783 KeyType[i] = simple_strtol(macptr, 0, 10);
784 }
785
786#ifdef CONFIG_STA_SUPPORT
787 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
788 {
789 sprintf(tok_str, "Key%dStr", idx + 1);
790 if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
791 {
792 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
793 }
794 }
795#endif // CONFIG_STA_SUPPORT //
796 }
797 }
798}
799
800
801#ifdef CONFIG_STA_SUPPORT
802static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
803{
804 PUCHAR macptr;
805 INT i=0;
806 BOOLEAN bWmmEnable = FALSE;
807
808 //WmmCapable
809 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
810 {
811 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
812 {
813 pAd->CommonCfg.bWmmCapable = TRUE;
814 bWmmEnable = TRUE;
815 }
816 else //Disable
817 {
818 pAd->CommonCfg.bWmmCapable = FALSE;
819 }
820
821 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
822 }
823
824#ifdef QOS_DLS_SUPPORT
825 //DLSCapable
826 if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
827 {
828 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
829 {
830 pAd->CommonCfg.bDLSCapable = TRUE;
831 }
832 else //Disable
833 {
834 pAd->CommonCfg.bDLSCapable = FALSE;
835 }
836
837 DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
838 }
839#endif // QOS_DLS_SUPPORT //
840
841 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
842 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
843 {
844 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
845 {
846 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
847
848 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
849 }
850 }
851
852 if (bWmmEnable)
853 {
854 //APSDCapable
855 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
856 {
857 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
858 pAd->CommonCfg.bAPSDCapable = TRUE;
859 else
860 pAd->CommonCfg.bAPSDCapable = FALSE;
861
862 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
863 }
864
865 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
866 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
867 {
868 BOOLEAN apsd_ac[4];
869
870 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
871 {
872 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
873
874 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
875 }
876
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];
881 }
882 }
883
884}
885#endif // CONFIG_STA_SUPPORT //
886
887
888NDIS_STATUS RTMPReadParametersHook(
889 IN PRTMP_ADAPTER pAd)
890{
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 //
902
903
904 PUCHAR macptr;
905 INT i = 0;
906
907 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
908 if(buffer == NULL)
909 return NDIS_STATUS_FAILURE;
910
911 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
912 if(tmpbuf == NULL)
913 {
914 kfree(buffer);
915 return NDIS_STATUS_FAILURE;
916 }
917
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 //
925
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 current->fsuid=current->fsgid = 0;
931 orgfs = get_fs();
932 set_fs(KERNEL_DS);
933
934 if (src && *src)
935 {
936 srcf = filp_open(src, O_RDONLY, 0);
937 if (IS_ERR(srcf))
938 {
939 DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
940 }
941 else
942 {
943 // The object must have a read method
944 if (srcf->f_op && srcf->f_op->read)
945 {
946 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
947 retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
948 if (retval < 0)
949 {
950 DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
951 }
952 else
953 {
954 // set file parameter to portcfg
955 //CountryRegion
956 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
957 {
958 pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
959 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
960 }
961 //CountryRegionABand
962 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
963 {
964 pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
965 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
966 }
967 //CountryCode
968 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
969 {
970 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
971#ifdef CONFIG_STA_SUPPORT
972#ifdef EXT_BUILD_CHANNEL_LIST
973 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
974 NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
975#endif // EXT_BUILD_CHANNEL_LIST //
976#endif // CONFIG_STA_SUPPORT //
977 if (strlen(pAd->CommonCfg.CountryCode) != 0)
978 {
979 pAd->CommonCfg.bCountryFlag = TRUE;
980 }
981 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
982 }
983 //ChannelGeography
984 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
985 {
986 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
987 if (Geography <= BOTH)
988 {
989 pAd->CommonCfg.Geography = Geography;
990 pAd->CommonCfg.CountryCode[2] =
991 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
992#ifdef CONFIG_STA_SUPPORT
993#ifdef EXT_BUILD_CHANNEL_LIST
994 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
995 pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
996#endif // EXT_BUILD_CHANNEL_LIST //
997#endif // CONFIG_STA_SUPPORT //
998 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
999 }
1000 }
1001 else
1002 {
1003 pAd->CommonCfg.Geography = BOTH;
1004 pAd->CommonCfg.CountryCode[2] = ' ';
1005 }
1006
1007
1008#ifdef CONFIG_STA_SUPPORT
1009 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1010 {
1011 //SSID
1012 if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
1013 {
1014 if (strlen(tmpbuf) <= 32)
1015 {
1016 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
1017 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
1018 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
1019 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
1020 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
1021 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
1022 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1023 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1024 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1025 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf));
1026 }
1027 }
1028 }
1029#endif // CONFIG_STA_SUPPORT //
1030
1031#ifdef CONFIG_STA_SUPPORT
1032 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1033 {
1034 //NetworkType
1035 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
1036 {
1037 pAd->bConfigChanged = TRUE;
1038 if (strcmp(tmpbuf, "Adhoc") == 0)
1039 pAd->StaCfg.BssType = BSS_ADHOC;
1040 else //Default Infrastructure mode
1041 pAd->StaCfg.BssType = BSS_INFRA;
1042 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1043 pAd->StaCfg.WpaState = SS_NOTUSE;
1044 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType));
1045 }
1046 }
1047#endif // CONFIG_STA_SUPPORT //
1048 //Channel
1049 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
1050 {
1051 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1052 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1053 }
1054 //WirelessMode
1055 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
1056 {
1057 int value = 0, maxPhyMode = PHY_11G;
1058
1059#ifdef DOT11_N_SUPPORT
1060 maxPhyMode = PHY_11N_5G;
1061#endif // DOT11_N_SUPPORT //
1062
1063 value = simple_strtol(tmpbuf, 0, 10);
1064
1065 if (value <= maxPhyMode)
1066 {
1067 pAd->CommonCfg.PhyMode = value;
1068 }
1069 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1070 }
1071 //BasicRate
1072 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
1073 {
1074 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1075 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1076 }
1077 //BeaconPeriod
1078 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
1079 {
1080 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1081 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1082 }
1083 //TxPower
1084 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
1085 {
1086 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1087#ifdef CONFIG_STA_SUPPORT
1088 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1089 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1090#endif // CONFIG_STA_SUPPORT //
1091 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1092 }
1093 //BGProtection
1094 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
1095 {
1096 switch (simple_strtol(tmpbuf, 0, 10))
1097 {
1098 case 1: //Always On
1099 pAd->CommonCfg.UseBGProtection = 1;
1100 break;
1101 case 2: //Always OFF
1102 pAd->CommonCfg.UseBGProtection = 2;
1103 break;
1104 case 0: //AUTO
1105 default:
1106 pAd->CommonCfg.UseBGProtection = 0;
1107 break;
1108 }
1109 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1110 }
1111 //OLBCDetection
1112 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
1113 {
1114 switch (simple_strtol(tmpbuf, 0, 10))
1115 {
1116 case 1: //disable OLBC Detection
1117 pAd->CommonCfg.DisableOLBCDetect = 1;
1118 break;
1119 case 0: //enable OLBC Detection
1120 pAd->CommonCfg.DisableOLBCDetect = 0;
1121 break;
1122 default:
1123 pAd->CommonCfg.DisableOLBCDetect= 0;
1124 break;
1125 }
1126 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1127 }
1128 //TxPreamble
1129 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
1130 {
1131 switch (simple_strtol(tmpbuf, 0, 10))
1132 {
1133 case Rt802_11PreambleShort:
1134 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1135 break;
1136 case Rt802_11PreambleLong:
1137 default:
1138 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1139 break;
1140 }
1141 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1142 }
1143 //RTSThreshold
1144 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
1145 {
1146 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1147 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1148 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1149 else
1150 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1151
1152 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1153 }
1154 //FragThreshold
1155 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
1156 {
1157 FragThresh = simple_strtol(tmpbuf, 0, 10);
1158 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1159
1160 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1161 { //illegal FragThresh so we set it to default
1162 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1163 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1164 }
1165 else if (FragThresh % 2 == 1)
1166 {
1167 // The length of each fragment shall always be an even number of octets, except for the last fragment
1168 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1169 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1170 }
1171 else
1172 {
1173 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1174 }
1175 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1176 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1177 }
1178 //TxBurst
1179 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
1180 {
1181//#ifdef WIFI_TEST
1182// pAd->CommonCfg.bEnableTxBurst = FALSE;
1183//#else
1184 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1185 pAd->CommonCfg.bEnableTxBurst = TRUE;
1186 else //Disable
1187 pAd->CommonCfg.bEnableTxBurst = FALSE;
1188//#endif
1189 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1190 }
1191
1192#ifdef AGGREGATION_SUPPORT
1193 //PktAggregate
1194 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
1195 {
1196 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1197 pAd->CommonCfg.bAggregationCapable = TRUE;
1198 else //Disable
1199 pAd->CommonCfg.bAggregationCapable = FALSE;
1200#ifdef PIGGYBACK_SUPPORT
1201 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1202#endif // PIGGYBACK_SUPPORT //
1203 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1204 }
1205#else
1206 pAd->CommonCfg.bAggregationCapable = FALSE;
1207 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1208#endif // AGGREGATION_SUPPORT //
1209
1210 // WmmCapable
1211
1212#ifdef CONFIG_STA_SUPPORT
1213 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1214 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
1215#endif // CONFIG_STA_SUPPORT //
1216
1217 //ShortSlot
1218 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
1219 {
1220 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1221 pAd->CommonCfg.bUseShortSlotTime = TRUE;
1222 else //Disable
1223 pAd->CommonCfg.bUseShortSlotTime = FALSE;
1224
1225 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1226 }
1227 //IEEE80211H
1228 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
1229 {
1230 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1231 {
1232 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1233 pAd->CommonCfg.bIEEE80211H = TRUE;
1234 else //Disable
1235 pAd->CommonCfg.bIEEE80211H = FALSE;
1236
1237 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1238 }
1239 }
1240 //CSPeriod
1241 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
1242 {
1243 if(simple_strtol(tmpbuf, 0, 10) != 0)
1244 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1245 else
1246 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1247
1248 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1249 }
1250
1251 //RDRegion
1252 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
1253 {
1254 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1255 {
1256 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
1257 pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
1258 }
1259 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1260 {
1261 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
1262 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1263 }
1264 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1265 {
1266 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
1267 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1268 }
1269 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1270 {
1271 pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
1272 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1273 }
1274 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1275 {
1276 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1277 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1278 }
1279 else
1280 {
1281 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1282 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1283 }
1284
1285 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
1286 }
1287 else
1288 {
1289 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1290 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1291 }
1292
1293 //WirelessEvent
1294 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
1295 {
1296#if WIRELESS_EXT >= 15
1297 if(simple_strtol(tmpbuf, 0, 10) != 0)
1298 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1299 else
1300 pAd->CommonCfg.bWirelessEvent = 0; // disable
1301#else
1302 pAd->CommonCfg.bWirelessEvent = 0; // disable
1303#endif
1304 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1305 }
1306 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
1307 {
1308 if(simple_strtol(tmpbuf, 0, 10) != 0)
1309 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1310 else
1311 pAd->CommonCfg.bWiFiTest = 0; // disable
1312
1313 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1314 }
1315 //AuthMode
1316 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
1317 {
1318#ifdef CONFIG_STA_SUPPORT
1319 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1320 {
1321 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1322 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1323 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1324 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1325 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1326 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1327 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1328 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1329 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1330 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1331#ifdef WPA_SUPPLICANT_SUPPORT
1332 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1333 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1334 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1335 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1336#endif // WPA_SUPPLICANT_SUPPORT //
1337 else
1338 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1339
1340 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1341
1342 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
1343 }
1344#endif // CONFIG_STA_SUPPORT //
1345 }
1346 //EncrypType
1347 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
1348 {
1349
1350#ifdef CONFIG_STA_SUPPORT
1351 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1352 {
1353 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1354 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1355 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1356 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1357 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1358 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1359 else
1360 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1361
1362 // Update all wepstatus related
1363 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1364 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1365 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1366 pAd->StaCfg.bMixCipher = FALSE;
1367
1368 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1369 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
1370 }
1371#endif // CONFIG_STA_SUPPORT //
1372 }
1373
1374
1375
1376#ifdef CONFIG_STA_SUPPORT
1377 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1378 {
1379 if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
1380 {
1381 int err=0;
1382
1383 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1384
1385 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1386 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1387 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1388 )
1389 {
1390 err = 1;
1391 }
1392 else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
1393 {
1394 PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
1395 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1396
1397 }
1398 else if (strlen(tmpbuf) == 64)
1399 {
1400 AtoH(tmpbuf, keyMaterial, 32);
1401 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1402 }
1403 else
1404 {
1405 err = 1;
1406 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__));
1407 }
1408
1409 if (err == 0)
1410 {
1411 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1412 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1413 {
1414 // Start STA supplicant state machine
1415 pAd->StaCfg.WpaState = SS_START;
1416 }
1417 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1418 {
1419 /*
1420 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
1421 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
1422 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
1423 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
1424 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
1425
1426 // Decide its ChiperAlg
1427 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
1428 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
1429 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
1430 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
1431 else
1432 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
1433 */
1434 pAd->StaCfg.WpaState = SS_NOTUSE;
1435 }
1436
1437 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf));
1438 }
1439 }
1440 }
1441#endif // CONFIG_STA_SUPPORT //
1442
1443 //DefaultKeyID, KeyType, KeyStr
1444 rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
1445
1446
1447 //HSCounter
1448 /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, buffer))
1449 {
1450 switch (simple_strtol(tmpbuf, 0, 10))
1451 {
1452 case 1: //Enable
1453 pAd->CommonCfg.bEnableHSCounter = TRUE;
1454 break;
1455 case 0: //Disable
1456 default:
1457 pAd->CommonCfg.bEnableHSCounter = FALSE;
1458 break;
1459 }
1460 DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
1461 }*/
1462
1463#ifdef DOT11_N_SUPPORT
1464 HTParametersHook(pAd, tmpbuf, buffer);
1465#endif // DOT11_N_SUPPORT //
1466
1467
1468#ifdef CARRIER_DETECTION_SUPPORT
1469 //CarrierDetect
1470 if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, buffer))
1471 {
1472 if ((strncmp(tmpbuf, "0", 1) == 0))
1473 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1474 else if ((strncmp(tmpbuf, "1", 1) == 0))
1475 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
1476 else
1477 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1478
1479 DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
1480 }
1481 else
1482 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1483#endif // CARRIER_DETECTION_SUPPORT //
1484
1485#ifdef CONFIG_STA_SUPPORT
1486 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1487 {
1488 //PSMode
1489 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
1490 {
1491 if (pAd->StaCfg.BssType == BSS_INFRA)
1492 {
1493 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1494 {
1495 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1496 // to exclude certain situations.
1497 // MlmeSetPsm(pAd, PWR_SAVE);
1498 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1499 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1500 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1501 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1502 pAd->StaCfg.DefaultListenCount = 5;
1503 }
1504 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1505 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1506 {
1507 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1508 // to exclude certain situations.
1509 // MlmeSetPsmBit(pAd, PWR_SAVE);
1510 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1511 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1512 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1513 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1514 pAd->StaCfg.DefaultListenCount = 3;
1515 }
1516 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1517 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1518 {
1519 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1520 // to exclude certain situations.
1521 // MlmeSetPsmBit(pAd, PWR_SAVE);
1522 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1523 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1524 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1525 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1526 pAd->StaCfg.DefaultListenCount = 3;
1527 }
1528 else
1529 { //Default Ndis802_11PowerModeCAM
1530 // clear PSM bit immediately
1531 MlmeSetPsmBit(pAd, PWR_ACTIVE);
1532 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1533 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1534 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1535 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1536 }
1537 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1538 }
1539 }
1540 // FastRoaming
1541 if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
1542 {
1543 if (simple_strtol(tmpbuf, 0, 10) == 0)
1544 pAd->StaCfg.bFastRoaming = FALSE;
1545 else
1546 pAd->StaCfg.bFastRoaming = TRUE;
1547
1548 DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
1549 }
1550 // RoamThreshold
1551 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
1552 {
1553 long lInfo = simple_strtol(tmpbuf, 0, 10);
1554
1555 if (lInfo > 90 || lInfo < 60)
1556 pAd->StaCfg.dBmToRoam = -70;
1557 else
1558 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1559
1560 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1561 }
1562
1563 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
1564 {
1565 if(simple_strtol(tmpbuf, 0, 10) == 0)
1566 pAd->StaCfg.bTGnWifiTest = FALSE;
1567 else
1568 pAd->StaCfg.bTGnWifiTest = TRUE;
1569 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1570 }
1571 }
1572#endif // CONFIG_STA_SUPPORT //
1573
1574
1575
1576 }
1577 }
1578 else
1579 {
1580 DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
1581 }
1582
1583 retval=filp_close(srcf,NULL);
1584
1585 if (retval)
1586 {
1587 DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
1588 }
1589 }
1590 }
1591
1592 set_fs(orgfs);
1593 current->fsuid = orgfsuid;
1594 current->fsgid = orgfsgid;
1595
1596 kfree(buffer);
1597 kfree(tmpbuf);
1598
1599 return (NDIS_STATUS_SUCCESS);
1600}
1601
1602#ifdef DOT11_N_SUPPORT
1603static void HTParametersHook(
1604 IN PRTMP_ADAPTER pAd,
1605 IN CHAR *pValueStr,
1606 IN CHAR *pInput)
1607{
1608
1609 INT Value;
1610
1611 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
1612 {
1613 Value = simple_strtol(pValueStr, 0, 10);
1614 if (Value == 0)
1615 {
1616 pAd->CommonCfg.bHTProtect = FALSE;
1617 }
1618 else
1619 {
1620 pAd->CommonCfg.bHTProtect = TRUE;
1621 }
1622 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
1623 }
1624
1625 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
1626 {
1627 Value = simple_strtol(pValueStr, 0, 10);
1628 if (Value == 0)
1629 {
1630 pAd->CommonCfg.bMIMOPSEnable = FALSE;
1631 }
1632 else
1633 {
1634 pAd->CommonCfg.bMIMOPSEnable = TRUE;
1635 }
1636 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
1637 }
1638
1639
1640 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
1641 {
1642 Value = simple_strtol(pValueStr, 0, 10);
1643 if (Value > MMPS_ENABLE)
1644 {
1645 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1646 }
1647 else
1648 {
1649 //TODO: add mimo power saving mechanism
1650 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1651 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
1652 }
1653 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
1654 }
1655
1656 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
1657 {
1658 Value = simple_strtol(pValueStr, 0, 10);
1659 if (Value == 0)
1660 {
1661 pAd->CommonCfg.bBADecline = FALSE;
1662 }
1663 else
1664 {
1665 pAd->CommonCfg.bBADecline = TRUE;
1666 }
1667 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
1668 }
1669
1670
1671 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
1672 {
1673 Value = simple_strtol(pValueStr, 0, 10);
1674 if (Value == 0)
1675 {
1676 pAd->CommonCfg.bDisableReordering = FALSE;
1677 }
1678 else
1679 {
1680 pAd->CommonCfg.bDisableReordering = TRUE;
1681 }
1682 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
1683 }
1684
1685 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
1686 {
1687 Value = simple_strtol(pValueStr, 0, 10);
1688 if (Value == 0)
1689 {
1690 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
1691 }
1692 else
1693 {
1694 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
1695 }
1696 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
1697 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
1698 }
1699
1700 // Tx_+HTC frame
1701 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
1702 {
1703 Value = simple_strtol(pValueStr, 0, 10);
1704 if (Value == 0)
1705 {
1706 pAd->HTCEnable = FALSE;
1707 }
1708 else
1709 {
1710 pAd->HTCEnable = TRUE;
1711 }
1712 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
1713 }
1714
1715 // Enable HT Link Adaptation Control
1716 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
1717 {
1718 Value = simple_strtol(pValueStr, 0, 10);
1719 if (Value == 0)
1720 {
1721 pAd->bLinkAdapt = FALSE;
1722 }
1723 else
1724 {
1725 pAd->HTCEnable = TRUE;
1726 pAd->bLinkAdapt = TRUE;
1727 }
1728 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1729 }
1730
1731 // Reverse Direction Mechanism
1732 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
1733 {
1734 Value = simple_strtol(pValueStr, 0, 10);
1735 if (Value == 0)
1736 {
1737 pAd->CommonCfg.bRdg = FALSE;
1738 }
1739 else
1740 {
1741 pAd->HTCEnable = TRUE;
1742 pAd->CommonCfg.bRdg = TRUE;
1743 }
1744 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1745 }
1746
1747
1748
1749
1750 // Tx A-MSUD ?
1751 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
1752 {
1753 Value = simple_strtol(pValueStr, 0, 10);
1754 if (Value == 0)
1755 {
1756 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
1757 }
1758 else
1759 {
1760 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
1761 }
1762 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
1763 }
1764
1765 // MPDU Density
1766 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
1767 {
1768 Value = simple_strtol(pValueStr, 0, 10);
1769 if (Value <=7 && Value >= 0)
1770 {
1771 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
1772 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
1773 }
1774 else
1775 {
1776 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
1777 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
1778 }
1779 }
1780
1781 // Max Rx BA Window Size
1782 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
1783 {
1784 Value = simple_strtol(pValueStr, 0, 10);
1785
1786 if (Value >=1 && Value <= 64)
1787 {
1788 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
1789 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
1790 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
1791 }
1792 else
1793 {
1794 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
1795 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
1796 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
1797 }
1798
1799 }
1800
1801 // Guard Interval
1802 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
1803 {
1804 Value = simple_strtol(pValueStr, 0, 10);
1805
1806 if (Value == GI_400)
1807 {
1808 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
1809 }
1810 else
1811 {
1812 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
1813 }
1814
1815 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
1816 }
1817
1818 // HT Operation Mode : Mixed Mode , Green Field
1819 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
1820 {
1821 Value = simple_strtol(pValueStr, 0, 10);
1822
1823 if (Value == HTMODE_GF)
1824 {
1825
1826 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
1827 }
1828 else
1829 {
1830 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
1831 }
1832
1833 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
1834 }
1835
1836 // Fixed Tx mode : CCK, OFDM
1837 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
1838 {
1839 UCHAR fix_tx_mode;
1840
1841#ifdef CONFIG_STA_SUPPORT
1842 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1843 {
1844 fix_tx_mode = FIXED_TXMODE_HT;
1845
1846 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
1847 {
1848 fix_tx_mode = FIXED_TXMODE_OFDM;
1849 }
1850 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
1851 {
1852 fix_tx_mode = FIXED_TXMODE_CCK;
1853 }
1854 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
1855 {
1856 fix_tx_mode = FIXED_TXMODE_HT;
1857 }
1858 else
1859 {
1860 Value = simple_strtol(pValueStr, 0, 10);
1861 // 1 : CCK
1862 // 2 : OFDM
1863 // otherwise : HT
1864 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
1865 fix_tx_mode = Value;
1866 else
1867 fix_tx_mode = FIXED_TXMODE_HT;
1868 }
1869
1870 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
1871 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1872
1873 }
1874#endif // CONFIG_STA_SUPPORT //
1875 }
1876
1877
1878 // Channel Width
1879 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
1880 {
1881 Value = simple_strtol(pValueStr, 0, 10);
1882
1883 if (Value == BW_40)
1884 {
1885 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1886 }
1887 else
1888 {
1889 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1890 }
1891
1892#ifdef MCAST_RATE_SPECIFIC
1893 pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
1894#endif // MCAST_RATE_SPECIFIC //
1895
1896 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1897 }
1898
1899 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
1900 {
1901 Value = simple_strtol(pValueStr, 0, 10);
1902
1903 if (Value == 0)
1904 {
1905
1906 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1907 }
1908 else
1909 {
1910 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1911 }
1912
1913 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1914 }
1915
1916 // MSC
1917 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
1918 {
1919
1920#ifdef CONFIG_STA_SUPPORT
1921 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1922 {
1923 Value = simple_strtol(pValueStr, 0, 10);
1924
1925// if ((Value >= 0 && Value <= 15) || (Value == 32))
1926 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1927 {
1928 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1929 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1930 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1931 }
1932 else
1933 {
1934 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1935 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1936 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1937 }
1938 }
1939#endif // CONFIG_STA_SUPPORT //
1940 }
1941
1942 // STBC
1943 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
1944 {
1945 Value = simple_strtol(pValueStr, 0, 10);
1946 if (Value == STBC_USE)
1947 {
1948 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1949 }
1950 else
1951 {
1952 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1953 }
1954 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1955 }
1956
1957 // 40_Mhz_Intolerant
1958 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
1959 {
1960 Value = simple_strtol(pValueStr, 0, 10);
1961 if (Value == 0)
1962 {
1963 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1964 }
1965 else
1966 {
1967 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1968 }
1969 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1970 }
1971 //HT_TxStream
1972 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
1973 {
1974 switch (simple_strtol(pValueStr, 0, 10))
1975 {
1976 case 1:
1977 pAd->CommonCfg.TxStream = 1;
1978 break;
1979 case 2:
1980 pAd->CommonCfg.TxStream = 2;
1981 break;
1982 case 3: // 3*3
1983 default:
1984 pAd->CommonCfg.TxStream = 3;
1985
1986 if (pAd->MACVersion < RALINK_2883_VERSION)
1987 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1988 break;
1989 }
1990 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1991 }
1992 //HT_RxStream
1993 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
1994 {
1995 switch (simple_strtol(pValueStr, 0, 10))
1996 {
1997 case 1:
1998 pAd->CommonCfg.RxStream = 1;
1999 break;
2000 case 2:
2001 pAd->CommonCfg.RxStream = 2;
2002 break;
2003 case 3:
2004 default:
2005 pAd->CommonCfg.RxStream = 3;
2006
2007 if (pAd->MACVersion < RALINK_2883_VERSION)
2008 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
2009 break;
2010 }
2011 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
2012 }
2013
2014}
2015#endif // DOT11_N_SUPPORT //
2016