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 * You should have received a copy of the GNU General Public License along with
10 * this program; if not, write to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
23 Dot11d_Init(struct ieee80211_device
*ieee
)
25 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(ieee
);
27 pDot11dInfo
->bEnabled
= 0;
29 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
30 pDot11dInfo
->CountryIeLen
= 0;
31 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
32 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
33 RESET_CIE_WATCHDOG(ieee
);
35 printk("Dot11d_Init()\n");
40 // Reset to the state as we are just entering a regulatory domain.
43 Dot11d_Reset(struct ieee80211_device
*ieee
)
46 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(ieee
);
48 // Clear old channel map
49 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
50 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
51 // Set new channel map
52 for (i
=1; i
<=11; i
++) {
53 (pDot11dInfo
->channel_map
)[i
] = 1;
55 for (i
=12; i
<=14; i
++) {
56 (pDot11dInfo
->channel_map
)[i
] = 2;
59 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
60 pDot11dInfo
->CountryIeLen
= 0;
61 RESET_CIE_WATCHDOG(ieee
);
67 // Update country IE from Beacon or Probe Resopnse
68 // and configure PHY for operation in the regulatory domain.
71 // Configure Tx power.
74 // 1. IS_DOT11D_ENABLE() is TRUE.
75 // 2. Input IE is an valid one.
78 Dot11d_UpdateCountryIe(
79 struct ieee80211_device
*dev
,
85 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
86 u8 i
, j
, NumTriples
, MaxChnlNum
;
87 PCHNL_TXPOWER_TRIPLE pTriple
;
89 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
90 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
92 NumTriples
= (CoutryIeLen
- 3) / 3; // skip 3-byte country string.
93 pTriple
= (PCHNL_TXPOWER_TRIPLE
)(pCoutryIe
+ 3);
94 for(i
= 0; i
< NumTriples
; i
++)
96 if(MaxChnlNum
>= pTriple
->FirstChnl
)
97 { // It is not in a monotonically increasing order, so stop processing.
98 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
101 if(MAX_CHANNEL_NUMBER
< (pTriple
->FirstChnl
+ pTriple
->NumChnls
))
102 { // It is not a valid set of channel id, so stop processing.
103 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
107 for(j
= 0 ; j
< pTriple
->NumChnls
; j
++)
109 pDot11dInfo
->channel_map
[pTriple
->FirstChnl
+ j
] = 1;
110 pDot11dInfo
->MaxTxPwrDbmList
[pTriple
->FirstChnl
+ j
] = pTriple
->MaxTxPowerInDbm
;
111 MaxChnlNum
= pTriple
->FirstChnl
+ j
;
114 pTriple
= (PCHNL_TXPOWER_TRIPLE
)((u8
*)pTriple
+ 3);
116 printk("Channel List:");
117 for(i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
118 if(pDot11dInfo
->channel_map
[i
] > 0)
122 UPDATE_CIE_SRC(dev
, pTaddr
);
124 pDot11dInfo
->CountryIeLen
= CoutryIeLen
;
125 memcpy(pDot11dInfo
->CountryIeBuf
, pCoutryIe
,CoutryIeLen
);
126 pDot11dInfo
->State
= DOT11D_STATE_LEARNED
;
131 DOT11D_GetMaxTxPwrInDbm(
132 struct ieee80211_device
*dev
,
136 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
137 u8 MaxTxPwrInDbm
= 255;
139 if(MAX_CHANNEL_NUMBER
< Channel
)
141 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
142 return MaxTxPwrInDbm
;
144 if(pDot11dInfo
->channel_map
[Channel
])
146 MaxTxPwrInDbm
= pDot11dInfo
->MaxTxPwrDbmList
[Channel
];
149 return MaxTxPwrInDbm
;
155 struct ieee80211_device
* dev
158 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
160 switch(pDot11dInfo
->State
)
162 case DOT11D_STATE_LEARNED
:
163 pDot11dInfo
->State
= DOT11D_STATE_DONE
;
166 case DOT11D_STATE_DONE
:
167 if( GET_CIE_WATCHDOG(dev
) == 0 )
168 { // Reset country IE if previous one is gone.
172 case DOT11D_STATE_NONE
:
178 struct ieee80211_device
* dev
,
182 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
184 if(MAX_CHANNEL_NUMBER
< channel
)
186 printk("IsLegalChannel(): Invalid Channel\n");
189 if(pDot11dInfo
->channel_map
[channel
] > 0)
195 struct ieee80211_device
* dev
,
199 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
203 for (i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
205 if(pDot11dInfo
->channel_map
[i
] > 0)
212 if(MAX_CHANNEL_NUMBER
< channel
)
214 printk("IsLegalChannel(): Invalid Channel\n");
218 if(pDot11dInfo
->channel_map
[channel
] > 0)