]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/staging/rt3090/common/cmm_profile.c
Staging: rt2860: add RT3090 chipset support
[net-next-2.6.git] / drivers / staging / rt3090 / common / cmm_profile.c
CommitLineData
36c7928c
BZ
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 Module Name:
28 cmm_profile.c
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 --------- ---------- ----------------------------------------------
35 */
36
37#include "../rt_config.h"
38
39
40#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
41
42// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
43BOOLEAN rtstrmactohex(PSTRING s1, PSTRING s2)
44{
45 int i = 0;
46 PSTRING ptokS = s1, ptokE = s1;
47
48 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
49 return FALSE;
50
51 while((*ptokS) != '\0')
52 {
53 if((ptokE = strchr(ptokS, ':')) != NULL)
54 *ptokE++ = '\0';
55 if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
56 break; // fail
57 AtoH(ptokS, (PUCHAR)&s2[i++], 1);
58 ptokS = ptokE;
59 if (i == 6)
60 break; // parsing finished
61 }
62
63 return ( i == 6 ? TRUE : FALSE);
64
65}
66
67
68// we assume the s1 and s2 both are strings.
69BOOLEAN rtstrcasecmp(PSTRING s1, PSTRING s2)
70{
71 PSTRING p1 = s1, p2 = s2;
72
73 if (strlen(s1) != strlen(s2))
74 return FALSE;
75
76 while(*p1 != '\0')
77 {
78 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
79 return FALSE;
80 p1++;
81 p2++;
82 }
83
84 return TRUE;
85}
86
87// we assume the s1 (buffer) and s2 (key) both are strings.
88PSTRING rtstrstruncasecmp(PSTRING s1, PSTRING s2)
89{
90 INT l1, l2, i;
91 char temp1, temp2;
92
93 l2 = strlen(s2);
94 if (!l2)
95 return (char *) s1;
96
97 l1 = strlen(s1);
98
99 while (l1 >= l2)
100 {
101 l1--;
102
103 for(i=0; i<l2; i++)
104 {
105 temp1 = *(s1+i);
106 temp2 = *(s2+i);
107
108 if (('a' <= temp1) && (temp1 <= 'z'))
109 temp1 = 'A'+(temp1-'a');
110 if (('a' <= temp2) && (temp2 <= 'z'))
111 temp2 = 'A'+(temp2-'a');
112
113 if (temp1 != temp2)
114 break;
115 }
116
117 if (i == l2)
118 return (char *) s1;
119
120 s1++;
121 }
122
123 return NULL; // not found
124}
125
126//add by kathy
127
128 /**
129 * strstr - Find the first substring in a %NUL terminated string
130 * @s1: The string to be searched
131 * @s2: The string to search for
132 */
133PSTRING rtstrstr(PSTRING s1,const PSTRING s2)
134{
135 INT l1, l2;
136
137 l2 = strlen(s2);
138 if (!l2)
139 return s1;
140
141 l1 = strlen(s1);
142
143 while (l1 >= l2)
144 {
145 l1--;
146 if (!memcmp(s1,s2,l2))
147 return s1;
148 s1++;
149 }
150
151 return NULL;
152}
153
154/**
155 * rstrtok - Split a string into tokens
156 * @s: The string to be searched
157 * @ct: The characters to search for
158 * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
159 */
160PSTRING __rstrtok;
161PSTRING rstrtok(PSTRING s,const PSTRING ct)
162{
163 PSTRING sbegin, send;
164
165 sbegin = s ? s : __rstrtok;
166 if (!sbegin)
167 {
168 return NULL;
169 }
170
171 sbegin += strspn(sbegin,ct);
172 if (*sbegin == '\0')
173 {
174 __rstrtok = NULL;
175 return( NULL );
176 }
177
178 send = strpbrk( sbegin, ct);
179 if (send && *send != '\0')
180 *send++ = '\0';
181
182 __rstrtok = send;
183
184 return (sbegin);
185}
186
187/**
188 * delimitcnt - return the count of a given delimiter in a given string.
189 * @s: The string to be searched.
190 * @ct: The delimiter to search for.
191 * Notice : We suppose the delimiter is a single-char string(for example : ";").
192 */
193INT delimitcnt(PSTRING s,PSTRING ct)
194{
195 INT count = 0;
196 /* point to the beginning of the line */
197 PSTRING token = s;
198
199 for ( ;; )
200 {
201 token = strpbrk(token, ct); /* search for delimiters */
202
203 if ( token == NULL )
204 {
205 /* advanced to the terminating null character */
206 break;
207 }
208 /* skip the delimiter */
209 ++token;
210
211 /*
212 * Print the found text: use len with %.*s to specify field width.
213 */
214
215 /* accumulate delimiter count */
216 ++count;
217 }
218 return count;
219}
220
221/*
222 * converts the Internet host address from the standard numbers-and-dots notation
223 * into binary data.
224 * returns nonzero if the address is valid, zero if not.
225 */
226int rtinet_aton(PSTRING cp, unsigned int *addr)
227{
228 unsigned int val;
229 int base, n;
230 STRING c;
231 unsigned int parts[4];
232 unsigned int *pp = parts;
233
234 for (;;)
235 {
236 /*
237 * Collect number up to ``.''.
238 * Values are specified as for C:
239 * 0x=hex, 0=octal, other=decimal.
240 */
241 val = 0;
242 base = 10;
243 if (*cp == '0')
244 {
245 if (*++cp == 'x' || *cp == 'X')
246 base = 16, cp++;
247 else
248 base = 8;
249 }
250 while ((c = *cp) != '\0')
251 {
252 if (isdigit((unsigned char) c))
253 {
254 val = (val * base) + (c - '0');
255 cp++;
256 continue;
257 }
258 if (base == 16 && isxdigit((unsigned char) c))
259 {
260 val = (val << 4) +
261 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
262 cp++;
263 continue;
264 }
265 break;
266 }
267 if (*cp == '.')
268 {
269 /*
270 * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
271 * a.b (with b treated as 24 bits)
272 */
273 if (pp >= parts + 3 || val > 0xff)
274 return 0;
275 *pp++ = val, cp++;
276 }
277 else
278 break;
279 }
280
281 /*
282 * Check for trailing junk.
283 */
284 while (*cp)
285 if (!isspace((unsigned char) *cp++))
286 return 0;
287
288 /*
289 * Concoct the address according to the number of parts specified.
290 */
291 n = pp - parts + 1;
292 switch (n)
293 {
294
295 case 1: /* a -- 32 bits */
296 break;
297
298 case 2: /* a.b -- 8.24 bits */
299 if (val > 0xffffff)
300 return 0;
301 val |= parts[0] << 24;
302 break;
303
304 case 3: /* a.b.c -- 8.8.16 bits */
305 if (val > 0xffff)
306 return 0;
307 val |= (parts[0] << 24) | (parts[1] << 16);
308 break;
309
310 case 4: /* a.b.c.d -- 8.8.8.8 bits */
311 if (val > 0xff)
312 return 0;
313 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
314 break;
315 }
316
317 *addr = htonl(val);
318 return 1;
319
320}
321
322/*
323 ========================================================================
324
325 Routine Description:
326 Find key section for Get key parameter.
327
328 Arguments:
329 buffer Pointer to the buffer to start find the key section
330 section the key of the secion to be find
331
332 Return Value:
333 NULL Fail
334 Others Success
335 ========================================================================
336*/
337PSTRING RTMPFindSection(
338 IN PSTRING buffer)
339{
340 STRING temp_buf[32];
341 PSTRING ptr;
342
343 strcpy(temp_buf, "Default");
344
345 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
346 return (ptr+strlen("\n"));
347 else
348 return NULL;
349}
350
351/*
352 ========================================================================
353
354 Routine Description:
355 Get key parameter.
356
357 Arguments:
358 key Pointer to key string
359 dest Pointer to destination
360 destsize The datasize of the destination
361 buffer Pointer to the buffer to start find the key
362 bTrimSpace Set true if you want to strip the space character of the result pattern
363
364 Return Value:
365 TRUE Success
366 FALSE Fail
367
368 Note:
369 This routine get the value with the matched key (case case-sensitive)
370 For SSID and security key related parameters, we SHALL NOT trim the space(' ') character.
371 ========================================================================
372*/
373INT RTMPGetKeyParameter(
374 IN PSTRING key,
375 OUT PSTRING dest,
376 IN INT destsize,
377 IN PSTRING buffer,
378 IN BOOLEAN bTrimSpace)
379{
380 PSTRING pMemBuf, temp_buf1 = NULL, temp_buf2 = NULL;
381 PSTRING start_ptr, end_ptr;
382 PSTRING ptr;
383 PSTRING offset = NULL;
384 INT len, keyLen;
385
386
387 keyLen = strlen(key);
388 os_alloc_mem(NULL, (PUCHAR *)&pMemBuf, MAX_PARAM_BUFFER_SIZE * 2);
389 if (pMemBuf == NULL)
390 return (FALSE);
391
392 memset(pMemBuf, 0, MAX_PARAM_BUFFER_SIZE * 2);
393 temp_buf1 = pMemBuf;
394 temp_buf2 = (PSTRING)(pMemBuf + MAX_PARAM_BUFFER_SIZE);
395
396
397 //find section
398 if((offset = RTMPFindSection(buffer)) == NULL)
399 {
400 os_free_mem(NULL, (PUCHAR)pMemBuf);
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, (PUCHAR)pMemBuf);
412 return (FALSE);
413 }
414
415 start_ptr += strlen("\n");
416 if((end_ptr = rtstrstr(start_ptr, "\n"))==NULL)
417 end_ptr = start_ptr+strlen(start_ptr);
418
419 if (end_ptr<start_ptr)
420 {
421 os_free_mem(NULL, (PUCHAR)pMemBuf);
422 return (FALSE);
423 }
424
425 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
426 temp_buf2[end_ptr-start_ptr]='\0';
427 if((start_ptr=rtstrstr(temp_buf2, "=")) == NULL)
428 {
429 os_free_mem(NULL, (PUCHAR)pMemBuf);
430 return (FALSE);
431 }
432 ptr = (start_ptr +1);
433 //trim special characters, i.e., TAB or space
434 while(*start_ptr != 0x00)
435 {
436 if( ((*ptr == ' ') && bTrimSpace) || (*ptr == '\t') )
437 ptr++;
438 else
439 break;
440 }
441 len = strlen(start_ptr);
442
443 memset(dest, 0x00, destsize);
444 strncpy(dest, ptr, ((len >= destsize) ? destsize: len));
445
446 os_free_mem(NULL, (PUCHAR)pMemBuf);
447
448 return TRUE;
449}
450
451
452/*
453 ========================================================================
454
455 Routine Description:
456 Get multiple key parameter.
457
458 Arguments:
459 key Pointer to key string
460 dest Pointer to destination
461 destsize The datasize of the destination
462 buffer Pointer to the buffer to start find the key
463
464 Return Value:
465 TRUE Success
466 FALSE Fail
467
468 Note:
469 This routine get the value with the matched key (case case-sensitive)
470 ========================================================================
471*/
472INT RTMPGetKeyParameterWithOffset(
473 IN PSTRING key,
474 OUT PSTRING dest,
475 OUT USHORT *end_offset,
476 IN INT destsize,
477 IN PSTRING buffer,
478 IN BOOLEAN bTrimSpace)
479{
480 PSTRING temp_buf1 = NULL;
481 PSTRING temp_buf2 = NULL;
482 PSTRING start_ptr;
483 PSTRING end_ptr;
484 PSTRING ptr;
485 PSTRING offset = 0;
486 INT len;
487
488 if (*end_offset >= MAX_INI_BUFFER_SIZE)
489 return (FALSE);
490
491 os_alloc_mem(NULL, (PUCHAR *)&temp_buf1, MAX_PARAM_BUFFER_SIZE);
492
493 if(temp_buf1 == NULL)
494 return (FALSE);
495
496 os_alloc_mem(NULL, (PUCHAR *)&temp_buf2, MAX_PARAM_BUFFER_SIZE);
497 if(temp_buf2 == NULL)
498 {
499 os_free_mem(NULL, (PUCHAR)temp_buf1);
500 return (FALSE);
501 }
502
503 //find section
504 if(*end_offset == 0)
505 {
506 if ((offset = RTMPFindSection(buffer)) == NULL)
507 {
508 os_free_mem(NULL, (PUCHAR)temp_buf1);
509 os_free_mem(NULL, (PUCHAR)temp_buf2);
510 return (FALSE);
511 }
512 }
513 else
514 offset = buffer + (*end_offset);
515
516 strcpy(temp_buf1, "\n");
517 strcat(temp_buf1, key);
518 strcat(temp_buf1, "=");
519
520 //search key
521 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
522 {
523 os_free_mem(NULL, (PUCHAR)temp_buf1);
524 os_free_mem(NULL, (PUCHAR)temp_buf2);
525 return (FALSE);
526 }
527
528 start_ptr+=strlen("\n");
529 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
530 end_ptr=start_ptr+strlen(start_ptr);
531
532 if (end_ptr<start_ptr)
533 {
534 os_free_mem(NULL, (PUCHAR)temp_buf1);
535 os_free_mem(NULL, (PUCHAR)temp_buf2);
536 return (FALSE);
537 }
538
539 *end_offset = end_ptr - buffer;
540
541 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
542 temp_buf2[end_ptr-start_ptr]='\0';
543 len = strlen(temp_buf2);
544 strcpy(temp_buf1, temp_buf2);
545 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
546 {
547 os_free_mem(NULL, (PUCHAR)temp_buf1);
548 os_free_mem(NULL, (PUCHAR)temp_buf2);
549 return (FALSE);
550 }
551
552 strcpy(temp_buf2, start_ptr+1);
553 ptr = temp_buf2;
554 //trim space or tab
555 while(*ptr != 0x00)
556 {
557 if((bTrimSpace && (*ptr == ' ')) || (*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, (PUCHAR)temp_buf1);
568 os_free_mem(NULL, (PUCHAR)temp_buf2);
569 return TRUE;
570}
571
572
573static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN PSTRING buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
574{
575 PSTRING keybuff;
576 //INT i = BSSIdx, idx = KeyIdx, retVal;
577 ULONG KeyLen;
578 //UCHAR CipherAlg = CIPHER_WEP64;
579 CIPHER_KEY *pSharedKey;
580
581 keybuff = buffer;
582 KeyLen = strlen(keybuff);
583 pSharedKey = &pAd->SharedKey[BSSIdx][KeyIdx];
584
585 if(((KeyType != 0) && (KeyType != 1)) ||
586 ((KeyType == 0) && (KeyLen != 10) && (KeyLen != 26)) ||
587 ((KeyType== 1) && (KeyLen != 5) && (KeyLen != 13)))
588 {
589 DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length(%ld) or Type(%ld)\n",
590 KeyIdx+1, KeyLen, KeyType));
591 return FALSE;
592 }
593 else
594 {
595 return RT_CfgSetWepKey(pAd, buffer, pSharedKey, KeyIdx);
596 }
597
598}
599
600
601static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer)
602{
603 STRING tok_str[16];
604 PSTRING macptr;
605 INT i = 0, idx;
606 ULONG KeyType[MAX_MBSSID_NUM];
607 ULONG KeyIdx;
608
609 NdisZeroMemory(KeyType, sizeof(KeyType));
610
611 //DefaultKeyID
612 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer, TRUE))
613 {
614
615#ifdef CONFIG_STA_SUPPORT
616 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
617 {
618 KeyIdx = simple_strtol(tmpbuf, 0, 10);
619 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
620 pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
621 else
622 pAd->StaCfg.DefaultKeyId = 0;
623
624 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
625 }
626#endif // CONFIG_STA_SUPPORT //
627 }
628
629
630 for (idx = 0; idx < 4; idx++)
631 {
632 sprintf(tok_str, "Key%dType", idx + 1);
633 //Key1Type
634 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, TRUE))
635 {
636 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
637 {
638 /*
639 do sanity check for KeyType length;
640 or in station mode, the KeyType length > 1,
641 the code will overwrite the stack of caller
642 (RTMPSetProfileParameters) and cause srcbuf = NULL
643 */
644 if (i < MAX_MBSSID_NUM)
645 KeyType[i] = simple_strtol(macptr, 0, 10);
646 }
647
648#ifdef CONFIG_STA_SUPPORT
649 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
650 {
651 sprintf(tok_str, "Key%dStr", idx + 1);
652 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE))
653 {
654 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
655 }
656 }
657#endif // CONFIG_STA_SUPPORT //
658 }
659 }
660}
661
662
663
664#ifdef CONFIG_STA_SUPPORT
665static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
666{
667 PSTRING macptr;
668 INT i=0;
669 BOOLEAN bWmmEnable = FALSE;
670
671 //WmmCapable
672 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer, TRUE))
673 {
674 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
675 {
676 pAd->CommonCfg.bWmmCapable = TRUE;
677 bWmmEnable = TRUE;
678 }
679 else //Disable
680 {
681 pAd->CommonCfg.bWmmCapable = FALSE;
682 }
683
684 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
685 }
686
687#ifdef QOS_DLS_SUPPORT
688 //DLSCapable
689 if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer, TRUE))
690 {
691 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
692 {
693 pAd->CommonCfg.bDLSCapable = TRUE;
694 }
695 else //Disable
696 {
697 pAd->CommonCfg.bDLSCapable = FALSE;
698 }
699
700 DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
701 }
702#endif // QOS_DLS_SUPPORT //
703
704 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
705 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer, TRUE))
706 {
707 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
708 {
709 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
710
711 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
712 }
713 }
714
715 if (bWmmEnable)
716 {
717 //APSDCapable
718 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer, TRUE))
719 {
720 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
721 pAd->CommonCfg.bAPSDCapable = TRUE;
722 else
723 pAd->CommonCfg.bAPSDCapable = FALSE;
724
725 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
726 }
727
728 //MaxSPLength
729 if(RTMPGetKeyParameter("MaxSPLength", tmpbuf, 10, buffer, TRUE))
730 {
731 pAd->CommonCfg.MaxSPLength = simple_strtol(tmpbuf, 0, 10);
732
733 DBGPRINT(RT_DEBUG_TRACE, ("MaxSPLength=%d\n", pAd->CommonCfg.MaxSPLength));
734 }
735
736 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
737 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer, TRUE))
738 {
739 BOOLEAN apsd_ac[4];
740
741 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
742 {
743 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
744
745 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
746 }
747
748 pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
749 pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
750 pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
751 pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
752
753 pAd->CommonCfg.bACMAPSDTr[0] = apsd_ac[0];
754 pAd->CommonCfg.bACMAPSDTr[1] = apsd_ac[1];
755 pAd->CommonCfg.bACMAPSDTr[2] = apsd_ac[2];
756 pAd->CommonCfg.bACMAPSDTr[3] = apsd_ac[3];
757 }
758 }
759
760}
761#endif // CONFIG_STA_SUPPORT //
762
763
764#ifdef DOT11_N_SUPPORT
765static void HTParametersHook(
766 IN PRTMP_ADAPTER pAd,
767 IN PSTRING pValueStr,
768 IN PSTRING pInput)
769{
770
771 long Value;
772
773 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput, TRUE))
774 {
775 Value = simple_strtol(pValueStr, 0, 10);
776 if (Value == 0)
777 {
778 pAd->CommonCfg.bHTProtect = FALSE;
779 }
780 else
781 {
782 pAd->CommonCfg.bHTProtect = TRUE;
783 }
784 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
785 }
786
787 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput, TRUE))
788 {
789 Value = simple_strtol(pValueStr, 0, 10);
790 if (Value == 0)
791 {
792 pAd->CommonCfg.bMIMOPSEnable = FALSE;
793 }
794 else
795 {
796 pAd->CommonCfg.bMIMOPSEnable = TRUE;
797 }
798 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
799 }
800
801
802 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput, TRUE))
803 {
804 Value = simple_strtol(pValueStr, 0, 10);
805 if (Value > MMPS_ENABLE)
806 {
807 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
808 }
809 else
810 {
811 //TODO: add mimo power saving mechanism
812 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
813 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
814 }
815 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", (INT) Value));
816 }
817
818 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput, TRUE))
819 {
820 Value = simple_strtol(pValueStr, 0, 10);
821 if (Value == 0)
822 {
823 pAd->CommonCfg.bBADecline = FALSE;
824 }
825 else
826 {
827 pAd->CommonCfg.bBADecline = TRUE;
828 }
829 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
830 }
831
832
833 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput, TRUE))
834 {
835 Value = simple_strtol(pValueStr, 0, 10);
836 if (Value == 0)
837 {
838 pAd->CommonCfg.bDisableReordering = FALSE;
839 }
840 else
841 {
842 pAd->CommonCfg.bDisableReordering = TRUE;
843 }
844 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
845 }
846
847 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput, TRUE))
848 {
849 Value = simple_strtol(pValueStr, 0, 10);
850 if (Value == 0)
851 {
852 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
853 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
854 }
855 else
856 {
857 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
858 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
859 }
860 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
861 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
862 }
863
864 // Tx_+HTC frame
865 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput, TRUE))
866 {
867 Value = simple_strtol(pValueStr, 0, 10);
868 if (Value == 0)
869 {
870 pAd->HTCEnable = FALSE;
871 }
872 else
873 {
874 pAd->HTCEnable = TRUE;
875 }
876 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
877 }
878
879 // Enable HT Link Adaptation Control
880 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput, TRUE))
881 {
882 Value = simple_strtol(pValueStr, 0, 10);
883 if (Value == 0)
884 {
885 pAd->bLinkAdapt = FALSE;
886 }
887 else
888 {
889 pAd->HTCEnable = TRUE;
890 pAd->bLinkAdapt = TRUE;
891 }
892 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
893 }
894
895 // Reverse Direction Mechanism
896 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput, TRUE))
897 {
898 Value = simple_strtol(pValueStr, 0, 10);
899 if (Value == 0)
900 {
901 pAd->CommonCfg.bRdg = FALSE;
902 }
903 else
904 {
905 pAd->HTCEnable = TRUE;
906 pAd->CommonCfg.bRdg = TRUE;
907 }
908 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
909 }
910
911
912
913
914 // Tx A-MSUD ?
915 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput, TRUE))
916 {
917 Value = simple_strtol(pValueStr, 0, 10);
918 if (Value == 0)
919 {
920 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
921 }
922 else
923 {
924 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
925 }
926 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
927 }
928
929 // MPDU Density
930 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput, TRUE))
931 {
932 Value = simple_strtol(pValueStr, 0, 10);
933 if (Value <=7 && Value >= 0)
934 {
935 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
936 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", (INT) Value));
937 }
938 else
939 {
940 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
941 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
942 }
943 }
944
945 // Max Rx BA Window Size
946 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput, TRUE))
947 {
948 Value = simple_strtol(pValueStr, 0, 10);
949
950 if (Value >=1 && Value <= 64)
951 {
952 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
953 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
954 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", (INT) Value));
955 }
956 else
957 {
958 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
959 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
960 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
961 }
962
963 }
964
965 // Guard Interval
966 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput, TRUE))
967 {
968 Value = simple_strtol(pValueStr, 0, 10);
969
970 if (Value == GI_400)
971 {
972 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
973 }
974 else
975 {
976 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
977 }
978
979 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
980 }
981
982 // HT Operation Mode : Mixed Mode , Green Field
983 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput, TRUE))
984 {
985 Value = simple_strtol(pValueStr, 0, 10);
986
987 if (Value == HTMODE_GF)
988 {
989
990 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
991 }
992 else
993 {
994 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
995 }
996
997 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
998 }
999
1000 // Fixed Tx mode : CCK, OFDM
1001 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput, TRUE))
1002 {
1003 UCHAR fix_tx_mode;
1004
1005#ifdef CONFIG_STA_SUPPORT
1006 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1007 {
1008 fix_tx_mode = FIXED_TXMODE_HT;
1009
1010 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
1011 {
1012 fix_tx_mode = FIXED_TXMODE_OFDM;
1013 }
1014 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
1015 {
1016 fix_tx_mode = FIXED_TXMODE_CCK;
1017 }
1018 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
1019 {
1020 fix_tx_mode = FIXED_TXMODE_HT;
1021 }
1022 else
1023 {
1024 Value = simple_strtol(pValueStr, 0, 10);
1025 // 1 : CCK
1026 // 2 : OFDM
1027 // otherwise : HT
1028 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
1029 fix_tx_mode = Value;
1030 else
1031 fix_tx_mode = FIXED_TXMODE_HT;
1032 }
1033
1034 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
1035 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1036
1037 }
1038#endif // CONFIG_STA_SUPPORT //
1039 }
1040
1041
1042 // Channel Width
1043 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput, TRUE))
1044 {
1045 Value = simple_strtol(pValueStr, 0, 10);
1046
1047 if (Value == BW_40)
1048 {
1049 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1050 }
1051 else
1052 {
1053 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1054 }
1055
1056#ifdef MCAST_RATE_SPECIFIC
1057 pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
1058#endif // MCAST_RATE_SPECIFIC //
1059
1060 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1061 }
1062
1063 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput, TRUE))
1064 {
1065 Value = simple_strtol(pValueStr, 0, 10);
1066
1067 if (Value == 0)
1068 {
1069
1070 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1071 }
1072 else
1073 {
1074 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1075 }
1076
1077 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1078 }
1079
1080 // MSC
1081 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput, TRUE))
1082 {
1083
1084#ifdef CONFIG_STA_SUPPORT
1085 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1086 {
1087 Value = simple_strtol(pValueStr, 0, 10);
1088
1089// if ((Value >= 0 && Value <= 15) || (Value == 32))
1090 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1091 {
1092 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1093 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1094 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1095 }
1096 else
1097 {
1098 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1099 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1100 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1101 }
1102 }
1103#endif // CONFIG_STA_SUPPORT //
1104 }
1105
1106 // STBC
1107 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput, TRUE))
1108 {
1109 Value = simple_strtol(pValueStr, 0, 10);
1110 if (Value == STBC_USE)
1111 {
1112 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1113 }
1114 else
1115 {
1116 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1117 }
1118 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1119 }
1120
1121 // 40_Mhz_Intolerant
1122 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput, TRUE))
1123 {
1124 Value = simple_strtol(pValueStr, 0, 10);
1125 if (Value == 0)
1126 {
1127 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1128 }
1129 else
1130 {
1131 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1132 }
1133 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1134 }
1135 //HT_TxStream
1136 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput, TRUE))
1137 {
1138 switch (simple_strtol(pValueStr, 0, 10))
1139 {
1140 case 1:
1141 pAd->CommonCfg.TxStream = 1;
1142 break;
1143 case 2:
1144 pAd->CommonCfg.TxStream = 2;
1145 break;
1146 case 3: // 3*3
1147 default:
1148 pAd->CommonCfg.TxStream = 3;
1149
1150 if (pAd->MACVersion < RALINK_2883_VERSION)
1151 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1152 break;
1153 }
1154 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1155 }
1156 //HT_RxStream
1157 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput, TRUE))
1158 {
1159 switch (simple_strtol(pValueStr, 0, 10))
1160 {
1161 case 1:
1162 pAd->CommonCfg.RxStream = 1;
1163 break;
1164 case 2:
1165 pAd->CommonCfg.RxStream = 2;
1166 break;
1167 case 3:
1168 default:
1169 pAd->CommonCfg.RxStream = 3;
1170
1171 if (pAd->MACVersion < RALINK_2883_VERSION)
1172 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
1173 break;
1174 }
1175 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
1176 }
1177 //2008/11/05: KH add to support Antenna power-saving of AP<--
1178 //Green AP
1179 if(RTMPGetKeyParameter("GreenAP", pValueStr, 10, pInput, TRUE))
1180 {
1181 Value = simple_strtol(pValueStr, 0, 10);
1182 if (Value == 0)
1183 {
1184 pAd->CommonCfg.bGreenAPEnable = FALSE;
1185 }
1186 else
1187 {
1188 pAd->CommonCfg.bGreenAPEnable = TRUE;
1189 }
1190 DBGPRINT(RT_DEBUG_TRACE, ("HT: Green AP= %d\n", pAd->CommonCfg.bGreenAPEnable));
1191 }
1192
1193 // HT_DisallowTKIP
1194 if (RTMPGetKeyParameter("HT_DisallowTKIP", pValueStr, 25, pInput, TRUE))
1195 {
1196 Value = simple_strtol(pValueStr, 0, 10);
1197
1198 if (Value == 1)
1199 {
1200 pAd->CommonCfg.HT_DisallowTKIP = TRUE;
1201 }
1202 else
1203 {
1204 pAd->CommonCfg.HT_DisallowTKIP = FALSE;
1205 }
1206
1207 DBGPRINT(RT_DEBUG_TRACE, ("HT: Disallow TKIP mode = %s\n", (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "ON" : "OFF" ));
1208 }
1209
1210
1211 //2008/11/05:KH add to support Antenna power-saving of AP-->
1212}
1213#endif // DOT11_N_SUPPORT //
1214
1215
1216NDIS_STATUS RTMPSetProfileParameters(
1217 IN RTMP_ADAPTER *pAd,
1218 IN PSTRING pBuffer)
1219{
1220 PSTRING tmpbuf;
1221 ULONG RtsThresh;
1222 ULONG FragThresh;
1223 PSTRING macptr;
1224 INT i = 0, retval;
1225 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
1226 if(tmpbuf == NULL)
1227 return NDIS_STATUS_FAILURE;
1228
1229 do
1230 {
1231 // set file parameter to portcfg
1232 //CountryRegion
1233 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, pBuffer, TRUE))
1234 {
1235 retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_24G);
1236 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
1237 }
1238 //CountryRegionABand
1239 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, pBuffer, TRUE))
1240 {
1241 retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_5G);
1242 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
1243 }
1244#ifdef RTMP_EFUSE_SUPPORT
1245#ifdef RT30xx
1246 //EfuseBufferMode
1247 if(RTMPGetKeyParameter("EfuseBufferMode", tmpbuf, 25, pBuffer, TRUE))
1248 {
1249 pAd->bEEPROMFile = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1250 DBGPRINT(RT_DEBUG_TRACE, ("EfuseBufferMode=%d\n", pAd->bUseEfuse));
1251 }
1252#endif // RT30xx //
1253#endif // RTMP_EFUSE_SUPPORT //
1254 //CountryCode
1255 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, pBuffer, TRUE))
1256 {
1257 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
1258#ifdef CONFIG_STA_SUPPORT
1259#ifdef EXT_BUILD_CHANNEL_LIST
1260 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1261 NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
1262#endif // EXT_BUILD_CHANNEL_LIST //
1263#endif // CONFIG_STA_SUPPORT //
1264 if (strlen((PSTRING) pAd->CommonCfg.CountryCode) != 0)
1265 {
1266 pAd->CommonCfg.bCountryFlag = TRUE;
1267 }
1268 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
1269 }
1270 //ChannelGeography
1271 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, pBuffer, TRUE))
1272 {
1273 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1274 if (Geography <= BOTH)
1275 {
1276 pAd->CommonCfg.Geography = Geography;
1277 pAd->CommonCfg.CountryCode[2] =
1278 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
1279#ifdef CONFIG_STA_SUPPORT
1280#ifdef EXT_BUILD_CHANNEL_LIST
1281 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1282 pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
1283#endif // EXT_BUILD_CHANNEL_LIST //
1284#endif // CONFIG_STA_SUPPORT //
1285 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
1286 }
1287 }
1288 else
1289 {
1290 pAd->CommonCfg.Geography = BOTH;
1291 pAd->CommonCfg.CountryCode[2] = ' ';
1292 }
1293
1294
1295#ifdef CONFIG_STA_SUPPORT
1296 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1297 {
1298 //SSID
1299 if (RTMPGetKeyParameter("SSID", tmpbuf, 256, pBuffer, FALSE))
1300 {
1301 if (strlen(tmpbuf) <= 32)
1302 {
1303 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
1304 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
1305 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
1306 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
1307 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
1308 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
1309 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1310 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1311 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1312 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf));
1313 }
1314 }
1315 }
1316#endif // CONFIG_STA_SUPPORT //
1317
1318#ifdef CONFIG_STA_SUPPORT
1319 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1320 {
1321 //NetworkType
1322 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, pBuffer, TRUE))
1323 {
1324 pAd->bConfigChanged = TRUE;
1325 if (strcmp(tmpbuf, "Adhoc") == 0)
1326 pAd->StaCfg.BssType = BSS_ADHOC;
1327 else //Default Infrastructure mode
1328 pAd->StaCfg.BssType = BSS_INFRA;
1329 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1330 pAd->StaCfg.WpaState = SS_NOTUSE;
1331 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType));
1332 }
1333 }
1334#ifdef RTMP_MAC_PCI
1335 //NewPCIePS
1336 if(RTMPGetKeyParameter("NewPCIePS", tmpbuf, 10, pBuffer, TRUE))
1337 {
1338 UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1339 if(temp_buffer>0)
1340 pAd->StaCfg.PSControl.field.EnableNewPS=TRUE;
1341 else
1342 pAd->StaCfg.PSControl.field.EnableNewPS=FALSE;
1343 DBGPRINT(RT_DEBUG_TRACE, ("NewPCIePS=%d\n", pAd->StaCfg.PSControl.field.EnableNewPS));
1344 }
1345#endif // RTMP_MAC_PCI //
1346#ifdef RT3090
1347 //PCIePowerLevel
1348
1349 if(RTMPGetKeyParameter("PCIePowerLevel", tmpbuf, 10, pBuffer, TRUE))
1350 {
1351 pAd->StaCfg.PSControl.field.rt30xxPowerMode = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1352 DBGPRINT(RT_DEBUG_TRACE, ("PCIePowerLevel=%d\n", pAd->StaCfg.PSControl.field.rt30xxPowerMode));
1353 }
1354 //FollowHostASPM
1355 if(RTMPGetKeyParameter("FollowHostASPM", tmpbuf, 10, pBuffer, TRUE))
1356 {
1357 UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1358
1359 if(temp_buffer>0)
1360 pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM=TRUE;
1361 else
1362 pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM=FALSE;
1363 DBGPRINT(RT_DEBUG_TRACE, ("rt30xxFollowHostASPM=%d\n", pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM));
1364 }
1365 //ForceTestASPM
1366 if(RTMPGetKeyParameter("ForceTestASPM", tmpbuf, 10, pBuffer, TRUE))
1367 {
1368 UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1369
1370 if(temp_buffer>0)
1371 pAd->StaCfg.PSControl.field.rt30xxForceASPMTest=TRUE;
1372 else
1373 pAd->StaCfg.PSControl.field.rt30xxForceASPMTest=FALSE;
1374 DBGPRINT(RT_DEBUG_TRACE, ("rt30xxForceASPM=%d\n", pAd->StaCfg.PSControl.field.rt30xxForceASPMTest));
1375 }
1376#endif // RT3090 //
1377#endif // CONFIG_STA_SUPPORT //
1378 //Channel
1379 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, pBuffer, TRUE))
1380 {
1381 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1382 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1383 }
1384 //WirelessMode
1385 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, pBuffer, TRUE))
1386 {
1387 RT_CfgSetWirelessMode(pAd, tmpbuf);
1388 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1389 }
1390 //BasicRate
1391 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, pBuffer, TRUE))
1392 {
1393 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1394 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1395 }
1396 //BeaconPeriod
1397 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, pBuffer, TRUE))
1398 {
1399 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1400 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1401 }
1402 //TxPower
1403 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, pBuffer, TRUE))
1404 {
1405 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1406#ifdef CONFIG_STA_SUPPORT
1407 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1408 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1409#endif // CONFIG_STA_SUPPORT //
1410 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1411 }
1412 //BGProtection
1413 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, pBuffer, TRUE))
1414 {
1415 //#if 0 //#ifndef WIFI_TEST
1416 // pAd->CommonCfg.UseBGProtection = 2;// disable b/g protection for throughput test
1417 //#else
1418 switch (simple_strtol(tmpbuf, 0, 10))
1419 {
1420 case 1: //Always On
1421 pAd->CommonCfg.UseBGProtection = 1;
1422 break;
1423 case 2: //Always OFF
1424 pAd->CommonCfg.UseBGProtection = 2;
1425 break;
1426 case 0: //AUTO
1427 default:
1428 pAd->CommonCfg.UseBGProtection = 0;
1429 break;
1430 }
1431 //#endif
1432 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1433 }
1434 //OLBCDetection
1435 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, pBuffer, TRUE))
1436 {
1437 switch (simple_strtol(tmpbuf, 0, 10))
1438 {
1439 case 1: //disable OLBC Detection
1440 pAd->CommonCfg.DisableOLBCDetect = 1;
1441 break;
1442 case 0: //enable OLBC Detection
1443 pAd->CommonCfg.DisableOLBCDetect = 0;
1444 break;
1445 default:
1446 pAd->CommonCfg.DisableOLBCDetect= 0;
1447 break;
1448 }
1449 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1450 }
1451 //TxPreamble
1452 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, pBuffer, TRUE))
1453 {
1454 switch (simple_strtol(tmpbuf, 0, 10))
1455 {
1456 case Rt802_11PreambleShort:
1457 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1458 break;
1459 case Rt802_11PreambleLong:
1460 default:
1461 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1462 break;
1463 }
1464 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1465 }
1466 //RTSThreshold
1467 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, pBuffer, TRUE))
1468 {
1469 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1470 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1471 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1472 else
1473 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1474
1475 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1476 }
1477 //FragThreshold
1478 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, pBuffer, TRUE))
1479 {
1480 FragThresh = simple_strtol(tmpbuf, 0, 10);
1481 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1482
1483 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1484 { //illegal FragThresh so we set it to default
1485 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1486 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1487 }
1488 else if (FragThresh % 2 == 1)
1489 {
1490 // The length of each fragment shall always be an even number of octets, except for the last fragment
1491 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1492 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1493 }
1494 else
1495 {
1496 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1497 }
1498 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1499 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1500 }
1501 //TxBurst
1502 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, pBuffer, TRUE))
1503 {
1504 //#ifdef WIFI_TEST
1505 // pAd->CommonCfg.bEnableTxBurst = FALSE;
1506 //#else
1507 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1508 pAd->CommonCfg.bEnableTxBurst = TRUE;
1509 else //Disable
1510 pAd->CommonCfg.bEnableTxBurst = FALSE;
1511 //#endif
1512 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1513 }
1514
1515#ifdef AGGREGATION_SUPPORT
1516 //PktAggregate
1517 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, pBuffer, TRUE))
1518 {
1519 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1520 pAd->CommonCfg.bAggregationCapable = TRUE;
1521 else //Disable
1522 pAd->CommonCfg.bAggregationCapable = FALSE;
1523#ifdef PIGGYBACK_SUPPORT
1524 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1525#endif // PIGGYBACK_SUPPORT //
1526 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1527 }
1528#else
1529 pAd->CommonCfg.bAggregationCapable = FALSE;
1530 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1531#endif // AGGREGATION_SUPPORT //
1532
1533 // WmmCapable
1534
1535#ifdef CONFIG_STA_SUPPORT
1536 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1537 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, pBuffer);
1538#endif // CONFIG_STA_SUPPORT //
1539
1540 //ShortSlot
1541 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, pBuffer, TRUE))
1542 {
1543 RT_CfgSetShortSlot(pAd, tmpbuf);
1544 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1545 }
1546 //IEEE80211H
1547 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, pBuffer, TRUE))
1548 {
1549 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1550 {
1551 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1552 pAd->CommonCfg.bIEEE80211H = TRUE;
1553 else //Disable
1554 pAd->CommonCfg.bIEEE80211H = FALSE;
1555
1556 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1557 }
1558 }
1559 //CSPeriod
1560 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, pBuffer, TRUE))
1561 {
1562 if(simple_strtol(tmpbuf, 0, 10) != 0)
1563 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1564 else
1565 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1566
1567 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1568 }
1569
1570#ifdef MERGE_ARCH_TEAM
1571 // DfsLowerLimit
1572 if(RTMPGetKeyParameter("DfsLowerLimit", tmpbuf, 10, pBuffer, TRUE))
1573 {
1574 if(simple_strtol(tmpbuf, 0, 10) != 0)
1575 pAd->CommonCfg.RadarDetect.DfsLowerLimit = simple_strtol(tmpbuf, 0, 10);
1576
1577 DBGPRINT(RT_DEBUG_TRACE, ("DfsLowerLimit=%ld\n", pAd->CommonCfg.RadarDetect.DfsLowerLimit));
1578 }
1579
1580 // DfsUpperLimit
1581 if(RTMPGetKeyParameter("DfsUpperLimit", tmpbuf, 10, pBuffer, TRUE))
1582 {
1583 if(simple_strtol(tmpbuf, 0, 10) != 0)
1584 pAd->CommonCfg.RadarDetect.DfsUpperLimit = simple_strtol(tmpbuf, 0, 10);
1585
1586 DBGPRINT(RT_DEBUG_TRACE, ("DfsUpperLimit=%ld\n", pAd->CommonCfg.RadarDetect.DfsUpperLimit));
1587 }
1588
1589 // FixDfsLimit
1590 if(RTMPGetKeyParameter("FixDfsLimit", tmpbuf, 10, pBuffer, TRUE))
1591 {
1592 if(simple_strtol(tmpbuf, 0, 10) != 0)
1593 pAd->CommonCfg.RadarDetect.FixDfsLimit = TRUE;
1594 else
1595 pAd->CommonCfg.RadarDetect.FixDfsLimit = FALSE;
1596
1597 DBGPRINT(RT_DEBUG_TRACE, ("FixDfsLimit=%d\n", pAd->CommonCfg.RadarDetect.FixDfsLimit));
1598 }
1599
1600 // LongPulseRadarTh
1601 if(RTMPGetKeyParameter("LongPulseRadarTh", tmpbuf, 10, pBuffer, TRUE))
1602 {
1603 if(simple_strtol(tmpbuf, 0, 10) != 0)
1604 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = simple_strtol(tmpbuf, 0, 10);
1605
1606 DBGPRINT(RT_DEBUG_TRACE, ("LongPulseRadarTh=%d\n", pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
1607 }
1608
1609 // AvgRssiReq
1610 if(RTMPGetKeyParameter("AvgRssiReq", tmpbuf, 10, pBuffer, TRUE))
1611 {
1612 if(simple_strtol(tmpbuf, 0, 10) != 0)
1613 pAd->CommonCfg.RadarDetect.AvgRssiReq = simple_strtol(tmpbuf, 0, 10);
1614
1615 DBGPRINT(RT_DEBUG_TRACE, ("AvgRssiReq=%d\n", pAd->CommonCfg.RadarDetect.AvgRssiReq));
1616 }
1617
1618#endif // MERGE_ARCH_TEAM //
1619
1620 //RDRegion
1621 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, pBuffer, TRUE))
1622 {
1623 RADAR_DETECT_STRUCT *pRadarDetect = &pAd->CommonCfg.RadarDetect;
1624 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1625 {
1626 pRadarDetect->RDDurRegion = JAP_W53;
1627 pRadarDetect->DfsSessionTime = 15;
1628 }
1629 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1630 {
1631 pRadarDetect->RDDurRegion = JAP_W56;
1632 pRadarDetect->DfsSessionTime = 13;
1633 }
1634 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1635 {
1636 pRadarDetect->RDDurRegion = JAP;
1637 pRadarDetect->DfsSessionTime = 5;
1638 }
1639 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1640 {
1641 pRadarDetect->RDDurRegion = FCC;
1642 pRadarDetect->DfsSessionTime = 5;
1643#ifdef DFS_FCC_BW40_FIX
1644 pRadarDetect->DfsSessionFccOff = 0;
1645#endif // DFS_FCC_BW40_FIX //
1646 }
1647 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1648 {
1649 pRadarDetect->RDDurRegion = CE;
1650 pRadarDetect->DfsSessionTime = 13;
1651 }
1652 else
1653 {
1654 pRadarDetect->RDDurRegion = CE;
1655 pRadarDetect->DfsSessionTime = 13;
1656 }
1657
1658 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pRadarDetect->RDDurRegion));
1659 }
1660 else
1661 {
1662 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1663 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1664 }
1665
1666 //WirelessEvent
1667 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, pBuffer, TRUE))
1668 {
1669#if WIRELESS_EXT >= 15
1670 if(simple_strtol(tmpbuf, 0, 10) != 0)
1671 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1672 else
1673 pAd->CommonCfg.bWirelessEvent = 0; // disable
1674#else
1675 pAd->CommonCfg.bWirelessEvent = 0; // disable
1676#endif
1677 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1678 }
1679 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, pBuffer, TRUE))
1680 {
1681 if(simple_strtol(tmpbuf, 0, 10) != 0)
1682 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1683 else
1684 pAd->CommonCfg.bWiFiTest = 0; // disable
1685
1686 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1687 }
1688 //AuthMode
1689 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, pBuffer, TRUE))
1690 {
1691#ifdef CONFIG_STA_SUPPORT
1692 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1693 {
1694 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1695 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1696 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1697 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1698 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1699 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1700 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1701 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1702 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1703 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1704#ifdef WPA_SUPPLICANT_SUPPORT
1705 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1706 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1707 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1708 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1709#endif // WPA_SUPPLICANT_SUPPORT //
1710 else
1711 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1712
1713 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1714
1715 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
1716 }
1717#endif // CONFIG_STA_SUPPORT //
1718 }
1719 //EncrypType
1720 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, pBuffer, TRUE))
1721 {
1722
1723#ifdef CONFIG_STA_SUPPORT
1724 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1725 {
1726 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1727 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1728 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1729 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1730 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1731 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1732 else
1733 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1734
1735 // Update all wepstatus related
1736 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1737 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1738 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1739 pAd->StaCfg.bMixCipher = FALSE;
1740
1741 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1742 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
1743 }
1744#endif // CONFIG_STA_SUPPORT //
1745 }
1746
1747
1748#ifdef CONFIG_STA_SUPPORT
1749 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1750 {
1751 if(RTMPGetKeyParameter("WPAPSK", tmpbuf, 512, pBuffer, FALSE))
1752 {
1753 int ret = TRUE;
1754
1755 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1756
1757 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1758 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1759 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1760 )
1761 {
1762 ret = FALSE;
1763 }
1764 else
1765 {
1766 ret = RT_CfgSetWPAPSKKey(pAd, tmpbuf, (PUCHAR)pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->StaCfg.PMK);
1767 }
1768
1769 if (ret == TRUE)
1770 {
1771 RTMPZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
1772 RTMPMoveMemory(pAd->StaCfg.WpaPassPhrase, tmpbuf, strlen(tmpbuf));
1773 pAd->StaCfg.WpaPassPhraseLen= strlen(tmpbuf);
1774
1775 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1776 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1777 {
1778 // Start STA supplicant state machine
1779 pAd->StaCfg.WpaState = SS_START;
1780 }
1781 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1782 {
1783 pAd->StaCfg.WpaState = SS_NOTUSE;
1784 }
1785 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf));
1786 }
1787 }
1788 }
1789#endif // CONFIG_STA_SUPPORT //
1790
1791 //DefaultKeyID, KeyType, KeyStr
1792 rtmp_read_key_parms_from_file(pAd, tmpbuf, pBuffer);
1793
1794
1795 //HSCounter
1796 /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, pBuffer, TRUE))
1797 {
1798 switch (simple_strtol(tmpbuf, 0, 10))
1799 {
1800 case 1: //Enable
1801 pAd->CommonCfg.bEnableHSCounter = TRUE;
1802 break;
1803 case 0: //Disable
1804 default:
1805 pAd->CommonCfg.bEnableHSCounter = FALSE;
1806 break;
1807 }
1808 DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
1809 }*/
1810
1811#ifdef DOT11_N_SUPPORT
1812 HTParametersHook(pAd, tmpbuf, pBuffer);
1813#endif // DOT11_N_SUPPORT //
1814
1815
1816#ifdef CARRIER_DETECTION_SUPPORT
1817 //CarrierDetect
1818 if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, pBuffer, TRUE))
1819 {
1820 if ((strncmp(tmpbuf, "0", 1) == 0))
1821 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1822 else if ((strncmp(tmpbuf, "1", 1) == 0))
1823 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
1824 else
1825 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1826
1827 DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
1828 }
1829 else
1830 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
1831#endif // CARRIER_DETECTION_SUPPORT //
1832
1833#ifdef CONFIG_STA_SUPPORT
1834 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1835 {
1836 //PSMode
1837 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, pBuffer, TRUE))
1838 {
1839 if (pAd->StaCfg.BssType == BSS_INFRA)
1840 {
1841 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1842 {
1843 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1844 // to exclude certain situations.
1845 // MlmeSetPsm(pAd, PWR_SAVE);
1846 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1847 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1848 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1849 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1850 pAd->StaCfg.DefaultListenCount = 5;
1851 }
1852 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1853 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1854 {
1855 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1856 // to exclude certain situations.
1857 // MlmeSetPsmBit(pAd, PWR_SAVE);
1858 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1859 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1860 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1861 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1862 pAd->StaCfg.DefaultListenCount = 3;
1863 }
1864 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1865 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1866 {
1867 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1868 // to exclude certain situations.
1869 // MlmeSetPsmBit(pAd, PWR_SAVE);
1870 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1871 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1872 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1873 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1874 pAd->StaCfg.DefaultListenCount = 3;
1875 }
1876 else
1877 { //Default Ndis802_11PowerModeCAM
1878 // clear PSM bit immediately
1879 RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
1880 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1881 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1882 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1883 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1884 }
1885 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1886 }
1887 }
1888 // AutoRoaming by RSSI
1889 if (RTMPGetKeyParameter("AutoRoaming", tmpbuf, 32, pBuffer, TRUE))
1890 {
1891 if (simple_strtol(tmpbuf, 0, 10) == 0)
1892 pAd->StaCfg.bAutoRoaming = FALSE;
1893 else
1894 pAd->StaCfg.bAutoRoaming = TRUE;
1895
1896 DBGPRINT(RT_DEBUG_TRACE, ("AutoRoaming=%d\n", pAd->StaCfg.bAutoRoaming));
1897 }
1898 // RoamThreshold
1899 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, pBuffer, TRUE))
1900 {
1901 long lInfo = simple_strtol(tmpbuf, 0, 10);
1902
1903 if (lInfo > 90 || lInfo < 60)
1904 pAd->StaCfg.dBmToRoam = -70;
1905 else
1906 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1907
1908 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1909 }
1910
1911 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, pBuffer, TRUE))
1912 {
1913 if(simple_strtol(tmpbuf, 0, 10) == 0)
1914 pAd->StaCfg.bTGnWifiTest = FALSE;
1915 else
1916 pAd->StaCfg.bTGnWifiTest = TRUE;
1917 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1918 }
1919
1920 // Beacon Lost Time
1921 if (RTMPGetKeyParameter("BeaconLostTime", tmpbuf, 32, pBuffer, TRUE))
1922 {
1923 ULONG lInfo = (ULONG)simple_strtol(tmpbuf, 0, 10);
1924
1925 if ((lInfo != 0) && (lInfo <= 60))
1926 pAd->StaCfg.BeaconLostTime = (lInfo * OS_HZ);
1927 DBGPRINT(RT_DEBUG_TRACE, ("BeaconLostTime=%ld \n", pAd->StaCfg.BeaconLostTime));
1928 }
1929
1930
1931 }
1932#endif // CONFIG_STA_SUPPORT //
1933
1934
1935
1936#ifdef RT30xx
1937#ifdef ANT_DIVERSITY_SUPPORT
1938 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1939 {
1940 if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, pBuffer, TRUE))
1941 {
1942 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1943 {
1944 UCHAR Ant = simple_strtol(tmpbuf, 0, 10);
1945 if(Ant < 3)
1946 pAd->CommonCfg.bRxAntDiversity = Ant;
1947 else
1948 pAd->CommonCfg.bRxAntDiversity = ANT_DIVERSITY_DISABLE;
1949
1950 DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
1951 }
1952 }
1953 }
1954#endif // ANT_DIVERSITY_SUPPORT //
1955#endif // RT30xx //
1956
1957 }while(0);
1958
1959
1960 kfree(tmpbuf);
1961
1962 return NDIS_STATUS_SUCCESS;
1963
1964}
1965
1966
1967#ifdef MULTIPLE_CARD_SUPPORT
1968// record whether the card in the card list is used in the card file
1969UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
1970// record used card mac address in the card list
1971static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6];
1972
1973/*
1974========================================================================
1975Routine Description:
1976 Get card profile path.
1977
1978Arguments:
1979 pAd
1980
1981Return Value:
1982 TRUE - Find a card profile
1983 FALSE - use default profile
1984
1985Note:
1986========================================================================
1987*/
1988BOOLEAN RTMP_CardInfoRead(
1989 IN PRTMP_ADAPTER pAd)
1990{
1991#define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
1992#define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
1993#define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
1994
1995#define LETTER_CASE_TRANSLATE(txt_p, card_id) \
1996 { UINT32 _len; char _char; \
1997 for(_len=0; _len<strlen(card_id); _len++) { \
1998 _char = *(txt_p + _len); \
1999 if (('A' <= _char) && (_char <= 'Z')) \
2000 *(txt_p+_len) = 'a'+(_char-'A'); \
2001 } }
2002
2003 RTMP_OS_FD srcf;
2004 INT retval;
2005 PSTRING buffer, tmpbuf;
2006 STRING card_id_buf[30], RFIC_word[30];
2007 BOOLEAN flg_match_ok = FALSE;
2008 INT32 card_select_method;
2009 INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
2010 EEPROM_ANTENNA_STRUC antenna;
2011 USHORT addr01, addr23, addr45;
2012 UINT8 mac[6];
2013 UINT32 data, card_index;
2014 UCHAR *start_ptr;
2015 RTMP_OS_FS_INFO osFSInfo;
2016
2017 // init
2018 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
2019 if (buffer == NULL)
2020 return FALSE;
2021
2022 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
2023 if(tmpbuf == NULL)
2024 {
2025 kfree(buffer);
2026 return NDIS_STATUS_FAILURE;
2027 }
2028
2029 // get RF IC type
2030 RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
2031
2032 if ((data & 0x30) == 0)
2033 pAd->EEPROMAddressNum = 6; // 93C46
2034 else if ((data & 0x30) == 0x10)
2035 pAd->EEPROMAddressNum = 8; // 93C66
2036 else
2037 pAd->EEPROMAddressNum = 8; // 93C86
2038
2039 RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
2040
2041 if ((antenna.field.RfIcType == RFIC_2850) ||
2042 (antenna.field.RfIcType == RFIC_2750))
2043 {
2044 /* ABGN card */
2045 strcpy(RFIC_word, "abgn");
2046 }
2047 else
2048 {
2049 /* BGN card */
2050 strcpy(RFIC_word, "bgn");
2051 }
2052
2053 // get MAC address
2054 RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
2055 RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
2056 RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
2057
2058 mac[0] = (UCHAR)(addr01 & 0xff);
2059 mac[1] = (UCHAR)(addr01 >> 8);
2060 mac[2] = (UCHAR)(addr23 & 0xff);
2061 mac[3] = (UCHAR)(addr23 >> 8);
2062 mac[4] = (UCHAR)(addr45 & 0xff);
2063 mac[5] = (UCHAR)(addr45 >> 8);
2064
2065 DBGPRINT(RT_DEBUG_TRACE, ("mac addr=%02x:%02x:%02x:%02x:%02x:%02x!\n", PRINT_MAC(mac)));
2066
2067 RtmpOSFSInfoChange(&osFSInfo, TRUE);
2068 // open card information file
2069 srcf = RtmpOSFileOpen(CARD_INFO_PATH, O_RDONLY, 0);
2070 if (IS_FILE_OPEN_ERR(srcf))
2071 {
2072 /* card information file does not exist */
2073 DBGPRINT(RT_DEBUG_TRACE,
2074 ("--> Error opening %s\n", CARD_INFO_PATH));
2075 goto free_resource;
2076 }
2077
2078 /* card information file exists so reading the card information */
2079 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
2080 retval = RtmpOSFileRead(srcf, buffer, MAX_INI_BUFFER_SIZE);
2081 if (retval < 0)
2082 {
2083 /* read fail */
2084 DBGPRINT(RT_DEBUG_TRACE,
2085 ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
2086 }
2087 else
2088 {
2089 /* get card selection method */
2090 memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
2091 card_select_method = MC_SELECT_CARDTYPE; // default
2092
2093 if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer, TRUE))
2094 {
2095 if (strcmp(tmpbuf, "CARDID") == 0)
2096 card_select_method = MC_SELECT_CARDID;
2097 else if (strcmp(tmpbuf, "MAC") == 0)
2098 card_select_method = MC_SELECT_MAC;
2099 else if (strcmp(tmpbuf, "CARDTYPE") == 0)
2100 card_select_method = MC_SELECT_CARDTYPE;
2101 }
2102
2103 DBGPRINT(RT_DEBUG_TRACE,
2104 ("MC> Card Selection = %d\n", card_select_method));
2105
2106 // init
2107 card_free_id = -1;
2108 card_nouse_id = -1;
2109 card_same_mac_id = -1;
2110 card_match_id = -1;
2111
2112 // search current card information records
2113 for(card_index=0;
2114 card_index<MAX_NUM_OF_MULTIPLE_CARD;
2115 card_index++)
2116 {
2117 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
2118 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
2119 {
2120 // MAC is all-0 so the entry is available
2121 MC_CardUsed[card_index] = 0;
2122
2123 if (card_free_id < 0)
2124 card_free_id = card_index; // 1st free entry
2125 }
2126 else
2127 {
2128 if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
2129 {
2130 // we find the entry with same MAC
2131 if (card_same_mac_id < 0)
2132 card_same_mac_id = card_index; // 1st same entry
2133 }
2134 else
2135 {
2136 // MAC is not all-0 but used flag == 0
2137 if ((MC_CardUsed[card_index] == 0) &&
2138 (card_nouse_id < 0))
2139 {
2140 card_nouse_id = card_index; // 1st available entry
2141 }
2142 }
2143 }
2144 }
2145
2146 DBGPRINT(RT_DEBUG_TRACE,
2147 ("MC> Free = %d, Same = %d, NOUSE = %d\n",
2148 card_free_id, card_same_mac_id, card_nouse_id));
2149
2150 if ((card_same_mac_id >= 0) &&
2151 ((card_select_method == MC_SELECT_CARDID) ||
2152 (card_select_method == MC_SELECT_CARDTYPE)))
2153 {
2154 // same MAC entry is found
2155 card_match_id = card_same_mac_id;
2156
2157 if (card_select_method == MC_SELECT_CARDTYPE)
2158 {
2159 // for CARDTYPE
2160 sprintf(card_id_buf, "%02dCARDTYPE%s",
2161 card_match_id, RFIC_word);
2162
2163 if ((start_ptr = (PUCHAR)rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
2164 {
2165 // we found the card ID
2166 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
2167 }
2168 }
2169 }
2170 else
2171 {
2172 // the card is 1st plug-in, try to find the match card profile
2173 switch(card_select_method)
2174 {
2175 case MC_SELECT_CARDID: // CARDID
2176 default:
2177 if (card_free_id >= 0)
2178 card_match_id = card_free_id;
2179 else
2180 card_match_id = card_nouse_id;
2181 break;
2182
2183 case MC_SELECT_MAC: // MAC
2184 sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
2185 mac[0], mac[1], mac[2],
2186 mac[3], mac[4], mac[5]);
2187
2188 /* try to find the key word in the card file */
2189 if ((start_ptr = (PUCHAR)rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
2190 {
2191 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
2192
2193 /* get the row ID (2 ASCII characters) */
2194 start_ptr -= 2;
2195 card_id_buf[0] = *(start_ptr);
2196 card_id_buf[1] = *(start_ptr+1);
2197 card_id_buf[2] = 0x00;
2198
2199 card_match_id = simple_strtol(card_id_buf, 0, 10);
2200 }
2201 break;
2202
2203 case MC_SELECT_CARDTYPE: // CARDTYPE
2204 card_nouse_id = -1;
2205
2206 for(card_index=0;
2207 card_index<MAX_NUM_OF_MULTIPLE_CARD;
2208 card_index++)
2209 {
2210 sprintf(card_id_buf, "%02dCARDTYPE%s",
2211 card_index, RFIC_word);
2212
2213 if ((start_ptr = (PUCHAR)rtstrstruncasecmp(buffer,
2214 card_id_buf)) != NULL)
2215 {
2216 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
2217
2218 if (MC_CardUsed[card_index] == 0)
2219 {
2220 /* current the card profile is not used */
2221 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
2222 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
2223 {
2224 // find it and no previous card use it
2225 card_match_id = card_index;
2226 break;
2227 }
2228 else
2229 {
2230 // ever a card use it
2231 if (card_nouse_id < 0)
2232 card_nouse_id = card_index;
2233 }
2234 }
2235 }
2236 }
2237
2238 // if not find a free one, use the available one
2239 if (card_match_id < 0)
2240 card_match_id = card_nouse_id;
2241 break;
2242 }
2243 }
2244
2245 if (card_match_id >= 0)
2246 {
2247 // make up search keyword
2248 switch(card_select_method)
2249 {
2250 case MC_SELECT_CARDID: // CARDID
2251 sprintf(card_id_buf, "%02dCARDID", card_match_id);
2252 break;
2253
2254 case MC_SELECT_MAC: // MAC
2255 sprintf(card_id_buf,
2256 "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
2257 card_match_id,
2258 mac[0], mac[1], mac[2],
2259 mac[3], mac[4], mac[5]);
2260 break;
2261
2262 case MC_SELECT_CARDTYPE: // CARDTYPE
2263 default:
2264 sprintf(card_id_buf, "%02dcardtype%s",
2265 card_match_id, RFIC_word);
2266 break;
2267 }
2268
2269 DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
2270
2271 // read card file path
2272 if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer, TRUE))
2273 {
2274 if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
2275 {
2276 // backup card information
2277 pAd->MC_RowID = card_match_id; /* base 0 */
2278 MC_CardUsed[card_match_id] = 1;
2279 memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
2280
2281 // backup card file path
2282 NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
2283 pAd->MC_FileName[strlen(tmpbuf)] = '\0';
2284 flg_match_ok = TRUE;
2285
2286 DBGPRINT(RT_DEBUG_TRACE,
2287 ("Card Profile Name = %s\n", pAd->MC_FileName));
2288 }
2289 else
2290 {
2291 DBGPRINT(RT_DEBUG_ERROR,
2292 ("Card Profile Name length too large!\n"));
2293 }
2294 }
2295 else
2296 {
2297 DBGPRINT(RT_DEBUG_ERROR,
2298 ("Can not find search key word in card.dat!\n"));
2299 }
2300
2301 if ((flg_match_ok != TRUE) &&
2302 (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
2303 {
2304 MC_CardUsed[card_match_id] = 0;
2305 memset(MC_CardMac[card_match_id], 0, sizeof(mac));
2306 }
2307 } // if (card_match_id >= 0)
2308 }
2309
2310
2311 // close file
2312 retval = RtmpOSFileClose(srcf);
2313
2314free_resource:
2315 RtmpOSFSInfoChange(&osFSInfo, FALSE);
2316 kfree(buffer);
2317 kfree(tmpbuf);
2318
2319 return flg_match_ok;
2320}
2321#endif // MULTIPLE_CARD_SUPPORT //