2 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
14 Dot11d_Init(struct ieee80211_device
*ieee
)
16 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(ieee
);
18 pDot11dInfo
->bEnabled
= 0;
20 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
21 pDot11dInfo
->CountryIeLen
= 0;
22 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
23 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
24 RESET_CIE_WATCHDOG(ieee
);
26 printk("Dot11d_Init()\n");
31 // Reset to the state as we are just entering a regulatory domain.
34 Dot11d_Reset(struct ieee80211_device
*ieee
)
37 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(ieee
);
39 if(!pDot11dInfo
->bEnabled
)
42 // Clear old channel map
43 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
44 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
45 // Set new channel map
46 for (i
=1; i
<=11; i
++) {
47 (pDot11dInfo
->channel_map
)[i
] = 1;
49 for (i
=12; i
<=14; i
++) {
50 (pDot11dInfo
->channel_map
)[i
] = 2;
53 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
54 pDot11dInfo
->CountryIeLen
= 0;
55 RESET_CIE_WATCHDOG(ieee
);
60 // Update country IE from Beacon or Probe Resopnse
61 // and configure PHY for operation in the regulatory domain.
64 // Configure Tx power.
67 // 1. IS_DOT11D_ENABLE() is TRUE.
68 // 2. Input IE is an valid one.
71 Dot11d_UpdateCountryIe(
72 struct ieee80211_device
*dev
,
78 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
79 u8 i
, j
, NumTriples
, MaxChnlNum
;
80 PCHNL_TXPOWER_TRIPLE pTriple
;
82 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
83 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
85 NumTriples
= (CoutryIeLen
- 3) / 3; // skip 3-byte country string.
86 pTriple
= (PCHNL_TXPOWER_TRIPLE
)(pCoutryIe
+ 3);
87 for(i
= 0; i
< NumTriples
; i
++)
89 if(MaxChnlNum
>= pTriple
->FirstChnl
)
90 { // It is not in a monotonically increasing order, so stop processing.
91 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
94 if(MAX_CHANNEL_NUMBER
< (pTriple
->FirstChnl
+ pTriple
->NumChnls
))
95 { // It is not a valid set of channel id, so stop processing.
96 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
100 for(j
= 0 ; j
< pTriple
->NumChnls
; j
++)
102 pDot11dInfo
->channel_map
[pTriple
->FirstChnl
+ j
] = 1;
103 pDot11dInfo
->MaxTxPwrDbmList
[pTriple
->FirstChnl
+ j
] = pTriple
->MaxTxPowerInDbm
;
104 MaxChnlNum
= pTriple
->FirstChnl
+ j
;
107 pTriple
= (PCHNL_TXPOWER_TRIPLE
)((u8
*)pTriple
+ 3);
110 printk("Channel List:");
111 for(i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
112 if(pDot11dInfo
->channel_map
[i
] > 0)
117 UPDATE_CIE_SRC(dev
, pTaddr
);
119 pDot11dInfo
->CountryIeLen
= CoutryIeLen
;
120 memcpy(pDot11dInfo
->CountryIeBuf
, pCoutryIe
,CoutryIeLen
);
121 pDot11dInfo
->State
= DOT11D_STATE_LEARNED
;
126 DOT11D_GetMaxTxPwrInDbm(
127 struct ieee80211_device
*dev
,
131 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
132 u8 MaxTxPwrInDbm
= 255;
134 if(MAX_CHANNEL_NUMBER
< Channel
)
136 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
137 return MaxTxPwrInDbm
;
139 if(pDot11dInfo
->channel_map
[Channel
])
141 MaxTxPwrInDbm
= pDot11dInfo
->MaxTxPwrDbmList
[Channel
];
144 return MaxTxPwrInDbm
;
150 struct ieee80211_device
* dev
153 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
155 switch(pDot11dInfo
->State
)
157 case DOT11D_STATE_LEARNED
:
158 pDot11dInfo
->State
= DOT11D_STATE_DONE
;
161 case DOT11D_STATE_DONE
:
162 if( GET_CIE_WATCHDOG(dev
) == 0 )
163 { // Reset country IE if previous one is gone.
167 case DOT11D_STATE_NONE
:
173 struct ieee80211_device
* dev
,
177 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
179 if(MAX_CHANNEL_NUMBER
< channel
)
181 printk("IsLegalChannel(): Invalid Channel\n");
184 if(pDot11dInfo
->channel_map
[channel
] > 0)
190 struct ieee80211_device
* dev
,
194 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
198 for (i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
200 if(pDot11dInfo
->channel_map
[i
] > 0)
207 if(MAX_CHANNEL_NUMBER
< channel
)
209 printk("IsLegalChannel(): Invalid Channel\n");
213 if(pDot11dInfo
->channel_map
[channel
] > 0)