1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * The full GNU General Public License is included in this distribution in the
10 * file called LICENSE.
12 * Contact Information:
13 * wlanfae <wlanfae@realtek.com>
14 ******************************************************************************/
22 static struct channel_list ChannelPlan
[] = {
23 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64,
24 149, 153, 157, 161, 165}, 24},
25 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
26 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56,
28 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
29 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
30 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
32 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
34 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
35 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
37 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
39 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14},
40 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
41 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52,
45 void dot11d_init(struct rtllib_device
*ieee
)
47 struct rt_dot11d_info
*pDot11dInfo
= GET_DOT11D_INFO(ieee
);
49 pDot11dInfo
->bEnabled
= false;
51 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
52 pDot11dInfo
->CountryIeLen
= 0;
53 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
54 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+ 1);
55 RESET_CIE_WATCHDOG(ieee
);
57 EXPORT_SYMBOL(dot11d_init
);
59 void Dot11d_Channelmap(u8 channel_plan
, struct rtllib_device
*ieee
)
61 int i
, max_chan
= 14, min_chan
= 1;
63 ieee
->bGlobalDomain
= false;
65 if (ChannelPlan
[channel_plan
].Len
!= 0) {
66 memset(GET_DOT11D_INFO(ieee
)->channel_map
, 0,
67 sizeof(GET_DOT11D_INFO(ieee
)->channel_map
));
68 for (i
= 0; i
< ChannelPlan
[channel_plan
].Len
; i
++) {
69 if (ChannelPlan
[channel_plan
].Channel
[i
] < min_chan
||
70 ChannelPlan
[channel_plan
].Channel
[i
] > max_chan
)
72 GET_DOT11D_INFO(ieee
)->channel_map
[ChannelPlan
73 [channel_plan
].Channel
[i
]] = 1;
77 switch (channel_plan
) {
78 case COUNTRY_CODE_GLOBAL_DOMAIN
:
79 ieee
->bGlobalDomain
= true;
80 for (i
= 12; i
<= 14; i
++)
81 GET_DOT11D_INFO(ieee
)->channel_map
[i
] = 2;
82 ieee
->IbssStartChnl
= 10;
83 ieee
->ibss_maxjoin_chal
= 11;
86 case COUNTRY_CODE_WORLD_WIDE_13
:
87 for (i
= 12; i
<= 13; i
++)
88 GET_DOT11D_INFO(ieee
)->channel_map
[i
] = 2;
89 ieee
->IbssStartChnl
= 10;
90 ieee
->ibss_maxjoin_chal
= 11;
94 ieee
->IbssStartChnl
= 1;
95 ieee
->ibss_maxjoin_chal
= 14;
99 EXPORT_SYMBOL(Dot11d_Channelmap
);
101 void Dot11d_Reset(struct rtllib_device
*ieee
)
103 struct rt_dot11d_info
*pDot11dInfo
= GET_DOT11D_INFO(ieee
);
106 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+ 1);
107 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+ 1);
108 for (i
= 1; i
<= 11; i
++)
109 (pDot11dInfo
->channel_map
)[i
] = 1;
110 for (i
= 12; i
<= 14; i
++)
111 (pDot11dInfo
->channel_map
)[i
] = 2;
112 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
113 pDot11dInfo
->CountryIeLen
= 0;
114 RESET_CIE_WATCHDOG(ieee
);
117 void Dot11d_UpdateCountryIe(struct rtllib_device
*dev
, u8
*pTaddr
,
118 u16 CoutryIeLen
, u8
*pCoutryIe
)
120 struct rt_dot11d_info
*pDot11dInfo
= GET_DOT11D_INFO(dev
);
121 u8 i
, j
, NumTriples
, MaxChnlNum
;
122 struct chnl_txpow_triple
*pTriple
;
124 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+ 1);
125 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+ 1);
127 NumTriples
= (CoutryIeLen
- 3) / 3;
128 pTriple
= (struct chnl_txpow_triple
*)(pCoutryIe
+ 3);
129 for (i
= 0; i
< NumTriples
; i
++) {
130 if (MaxChnlNum
>= pTriple
->FirstChnl
) {
131 netdev_info(dev
->dev
,
132 "%s: Invalid country IE, skip it......1\n",
136 if (MAX_CHANNEL_NUMBER
< (pTriple
->FirstChnl
+
137 pTriple
->NumChnls
)) {
138 netdev_info(dev
->dev
,
139 "%s: Invalid country IE, skip it......2\n",
144 for (j
= 0; j
< pTriple
->NumChnls
; j
++) {
145 pDot11dInfo
->channel_map
[pTriple
->FirstChnl
+ j
] = 1;
146 pDot11dInfo
->MaxTxPwrDbmList
[pTriple
->FirstChnl
+ j
] =
147 pTriple
->MaxTxPowerInDbm
;
148 MaxChnlNum
= pTriple
->FirstChnl
+ j
;
151 pTriple
= (struct chnl_txpow_triple
*)((u8
*)pTriple
+ 3);
154 UPDATE_CIE_SRC(dev
, pTaddr
);
156 pDot11dInfo
->CountryIeLen
= CoutryIeLen
;
157 memcpy(pDot11dInfo
->CountryIeBuf
, pCoutryIe
, CoutryIeLen
);
158 pDot11dInfo
->State
= DOT11D_STATE_LEARNED
;
161 void DOT11D_ScanComplete(struct rtllib_device
*dev
)
163 struct rt_dot11d_info
*pDot11dInfo
= GET_DOT11D_INFO(dev
);
165 switch (pDot11dInfo
->State
) {
166 case DOT11D_STATE_LEARNED
:
167 pDot11dInfo
->State
= DOT11D_STATE_DONE
;
169 case DOT11D_STATE_DONE
:
172 case DOT11D_STATE_NONE
: