|
1 /* |
|
2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Event dispatcher that is used to serialize MAC prototocl |
|
15 * statemachine access |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 27 % |
|
21 */ |
|
22 |
|
23 #include "config.h" |
|
24 #include "umaceventdispatcher.h" |
|
25 |
|
26 #include "umaceventdispatcherclient.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 WlanEventDispatcher::WlanEventDispatcher( |
|
35 MWlanEventDispatcherClient& aEventDispatcherClient ) |
|
36 : iEventDispatcherClient( aEventDispatcherClient ), |
|
37 iCommandCompletionRegistered ( EFalse ), iDisableChannelMask( 0 ), |
|
38 iOid( NULL ), iInternalEvents( 0 ) |
|
39 { |
|
40 }; |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 TBool WlanEventDispatcher::Dispatch() |
|
47 { |
|
48 TBool state_transition_event( EFalse ); |
|
49 |
|
50 if ( iInternalEvents ) |
|
51 { |
|
52 OsTracePrint( KEventDispatcher, (TUint8*) |
|
53 ("UMAC: WlanEventDispatcher::Dispatch(): dispatch internal event") ); |
|
54 |
|
55 state_transition_event = DispatchInternalEvent(); |
|
56 } |
|
57 if ( !state_transition_event ) |
|
58 { |
|
59 if ( iCommandCompletionRegistered ) |
|
60 { |
|
61 OsTracePrint( KEventDispatcher, (TUint8*) |
|
62 ("UMAC: WlanEventDispatcher::Dispatch(): dispatch WHA command completion") ); |
|
63 |
|
64 state_transition_event = DispatchCommandCompletionEvent(); |
|
65 } |
|
66 if ( !state_transition_event ) |
|
67 { |
|
68 if (// oid exists |
|
69 iOid |
|
70 // AND channel is NOT disabled |
|
71 && (!(iDisableChannelMask & KOidChannel)) ) |
|
72 { |
|
73 OsTracePrint( KEventDispatcher, (TUint8*) |
|
74 ("UMAC: WlanEventDispatcher::Dispatch(): dispatch OID") ); |
|
75 |
|
76 state_transition_event = DispatchOidEvent(); |
|
77 } |
|
78 } |
|
79 } |
|
80 return state_transition_event; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void WlanEventDispatcher::Register( |
|
88 WHA::TCompleteCommandId aCompleteCommandId, |
|
89 WHA::TStatus aStatus, |
|
90 const WHA::UCommandCompletionParams& aCommandCompletionParams ) |
|
91 { |
|
92 if ( iCommandCompletionRegistered ) |
|
93 { |
|
94 OsTracePrint( KEventDispatcher, (TUint8*) |
|
95 ("UMAC: WlanEventDispatcher::Register(): register cmd completion when one is already registered") ); |
|
96 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
97 } |
|
98 |
|
99 iWhaCommandCompletionParams.iId = aCompleteCommandId; |
|
100 iWhaCommandCompletionParams.iStatus = aStatus; |
|
101 iWhaCommandCompletionParams.iParams = aCommandCompletionParams; |
|
102 |
|
103 iCommandCompletionRegistered = ETrue; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 TBool WlanEventDispatcher::DispatchInternalEvent() |
|
111 { |
|
112 TBool ret ( EFalse ); |
|
113 |
|
114 if ( iInternalEvents & KAcParamUpdate ) |
|
115 { |
|
116 iInternalEvents &= ~KAcParamUpdate; |
|
117 ret = iEventDispatcherClient.OnInternalEvent( KAcParamUpdate ); |
|
118 } |
|
119 else if ( iInternalEvents & KPowerMgmtTransition ) |
|
120 { |
|
121 iInternalEvents &= ~KPowerMgmtTransition; |
|
122 ret = iEventDispatcherClient.OnInternalEvent( KPowerMgmtTransition ); |
|
123 } |
|
124 else if ( iInternalEvents & KTimeout) |
|
125 { |
|
126 iInternalEvents &= ~KTimeout; |
|
127 ret = iEventDispatcherClient.OnInternalEvent( KTimeout ); |
|
128 } |
|
129 else if ( iInternalEvents & KVoiceCallEntryTimerTimeout) |
|
130 { |
|
131 iInternalEvents &= ~KVoiceCallEntryTimerTimeout; |
|
132 ret = iEventDispatcherClient.OnInternalEvent( |
|
133 KVoiceCallEntryTimerTimeout ); |
|
134 } |
|
135 else if ( iInternalEvents & KNullTimerTimeout) |
|
136 { |
|
137 iInternalEvents &= ~KNullTimerTimeout; |
|
138 ret = iEventDispatcherClient.OnInternalEvent( KNullTimerTimeout ); |
|
139 } |
|
140 else if ( iInternalEvents & KNoVoiceTimerTimeout) |
|
141 { |
|
142 iInternalEvents &= ~KNoVoiceTimerTimeout; |
|
143 ret = iEventDispatcherClient.OnInternalEvent( KNoVoiceTimerTimeout ); |
|
144 } |
|
145 else if ( iInternalEvents & KKeepAliveTimerTimeout) |
|
146 { |
|
147 iInternalEvents &= ~KKeepAliveTimerTimeout; |
|
148 ret = iEventDispatcherClient.OnInternalEvent( KKeepAliveTimerTimeout ); |
|
149 } |
|
150 else if ( iInternalEvents & KActiveToLightPsTimerTimeout) |
|
151 { |
|
152 iInternalEvents &= ~KActiveToLightPsTimerTimeout; |
|
153 ret = iEventDispatcherClient.OnInternalEvent( |
|
154 KActiveToLightPsTimerTimeout ); |
|
155 } |
|
156 else if ( iInternalEvents & KLightPsToActiveTimerTimeout) |
|
157 { |
|
158 iInternalEvents &= ~KLightPsToActiveTimerTimeout; |
|
159 ret = iEventDispatcherClient.OnInternalEvent( |
|
160 KLightPsToActiveTimerTimeout ); |
|
161 } |
|
162 else if ( iInternalEvents & KLightPsToDeepPsTimerTimeout) |
|
163 { |
|
164 iInternalEvents &= ~KLightPsToDeepPsTimerTimeout; |
|
165 ret = iEventDispatcherClient.OnInternalEvent( |
|
166 KLightPsToDeepPsTimerTimeout ); |
|
167 } |
|
168 else if ( iInternalEvents & KSetCtsToSelf) |
|
169 { |
|
170 iInternalEvents &= ~KSetCtsToSelf; |
|
171 ret = iEventDispatcherClient.OnInternalEvent( KSetCtsToSelf ); |
|
172 } |
|
173 else if ( iInternalEvents & KSetRcpiTriggerLevel ) |
|
174 { |
|
175 iInternalEvents &= ~KSetRcpiTriggerLevel; |
|
176 ret = iEventDispatcherClient.OnInternalEvent( KSetRcpiTriggerLevel ); |
|
177 } |
|
178 else if ( iInternalEvents & KSetHtBssOperation ) |
|
179 { |
|
180 iInternalEvents &= ~KSetHtBssOperation; |
|
181 ret = iEventDispatcherClient.OnInternalEvent( KSetHtBssOperation ); |
|
182 } |
|
183 else |
|
184 { |
|
185 // programming error |
|
186 OsTracePrint( KErrorLevel, |
|
187 (TUint8*)("UMAC: iInternalEvents"), iInternalEvents ); |
|
188 OsAssert((TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
189 } |
|
190 |
|
191 return ret; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 TBool WlanEventDispatcher::DispatchCommandCompletionEvent() |
|
199 { |
|
200 // make a local copy of the completion parameters |
|
201 const TCommandResp resp ( iWhaCommandCompletionParams ); |
|
202 // clear the event flag |
|
203 iCommandCompletionRegistered = EFalse; |
|
204 |
|
205 // handle the event |
|
206 return ( iEventDispatcherClient.OnWhaCommandComplete( |
|
207 resp.iId, |
|
208 resp.iStatus, |
|
209 resp.iParams )); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 TBool WlanEventDispatcher::DispatchOidEvent() |
|
217 { |
|
218 TBool ret ( EFalse ); |
|
219 switch ( iOid->oid_id ) |
|
220 { |
|
221 case E802_11_CONFIGURE: |
|
222 ret = iEventDispatcherClient.HandleConfigure( iOid ); |
|
223 break; |
|
224 case E802_11_CONNECT: |
|
225 ret = iEventDispatcherClient.HandleConnect( iOid ); |
|
226 break; |
|
227 case E802_11_START_IBSS: |
|
228 ret = iEventDispatcherClient.HandleStartIBSS( iOid ); |
|
229 break; |
|
230 case E802_11_SCAN: |
|
231 ret = iEventDispatcherClient.HandleScan( iOid ); |
|
232 break; |
|
233 case E802_11_STOP_SCAN: |
|
234 ret = iEventDispatcherClient.HandleStopScan(); |
|
235 break; |
|
236 case E802_11_DISCONNECT: |
|
237 ret = iEventDispatcherClient.HandleDisconnect(); |
|
238 break; |
|
239 case E802_11_SET_POWER_MODE: |
|
240 ret = iEventDispatcherClient.HandleSetPowerMode( iOid ); |
|
241 break; |
|
242 case E802_11_SET_RCPI_TRIGGER_LEVEL: |
|
243 ret = iEventDispatcherClient.HandleSetRcpiTriggerLevel( iOid ); |
|
244 break; |
|
245 case E802_11_SET_TX_POWER_LEVEL: |
|
246 ret = iEventDispatcherClient.HandleSetTxPowerLevel( iOid ); |
|
247 break; |
|
248 case E802_11_GET_LAST_RCPI: |
|
249 ret = iEventDispatcherClient.HandleGetLastRcpi(); |
|
250 break; |
|
251 case E802_11_DISABLE_USER_DATA: |
|
252 ret = iEventDispatcherClient.HandleDisableUserData(); |
|
253 break; |
|
254 case E802_11_ENABLE_USER_DATA: |
|
255 ret = iEventDispatcherClient.HandleEnableUserData(); |
|
256 break; |
|
257 case E802_11_ADD_CIPHER_KEY: |
|
258 ret = iEventDispatcherClient.HandleAddCipherKey( iOid ); |
|
259 break; |
|
260 case E802_11_ADD_MULTICAST_ADDR: |
|
261 ret = iEventDispatcherClient.HandleAddMulticastAddr( iOid ); |
|
262 break; |
|
263 case E802_11_REMOVE_MULTICAST_ADDR: |
|
264 ret = iEventDispatcherClient.HandleRemoveMulticastAddr( iOid ); |
|
265 break; |
|
266 case E802_11_CONFIGURE_BSS_LOST: |
|
267 ret = iEventDispatcherClient.HandleConfigureBssLost( iOid ); |
|
268 break; |
|
269 case E802_11_SET_TX_RATE_ADAPT_PARAMS: |
|
270 ret = iEventDispatcherClient.HandleSetTxRateAdaptParams( iOid ); |
|
271 break; |
|
272 case E802_11_CONFIGURE_TX_RATE_POLICIES: |
|
273 ret = iEventDispatcherClient.HandleConfigureTxRatePolicies( iOid ); |
|
274 break; |
|
275 case E802_11_SET_POWER_MODE_MGMT_PARAMS: |
|
276 ret = iEventDispatcherClient.HandleSetPowerModeMgmtParams( iOid ); |
|
277 break; |
|
278 case E802_11_CONFIGURE_PWR_MODE_MGMT_TRAFFIC_OVERRIDE: |
|
279 ret = iEventDispatcherClient.HandleConfigurePwrModeMgmtTrafficOverride( iOid ); |
|
280 break; |
|
281 case E802_11_GET_FRAME_STATISTICS: |
|
282 ret = iEventDispatcherClient.HandleGetFrameStatistics(); |
|
283 break; |
|
284 case E802_11_CONFIGURE_UAPSD: |
|
285 ret = iEventDispatcherClient.HandleConfigureUapsd( iOid ); |
|
286 break; |
|
287 case E802_11_CONFIGURE_TX_QUEUE: |
|
288 ret = iEventDispatcherClient.HandleConfigureTxQueue( iOid ); |
|
289 break; |
|
290 case E802_11_GET_MAC_ADDRESS: |
|
291 ret = iEventDispatcherClient.HandleGetMacAddress(); |
|
292 break; |
|
293 case E802_11_CONFIGURE_ARP_IP_ADDRESS_FILTERING: |
|
294 ret = iEventDispatcherClient.HandleConfigureArpIpAddressFiltering( iOid ); |
|
295 break; |
|
296 case E802_11_CONFIGURE_HT_BLOCK_ACK: |
|
297 ret = iEventDispatcherClient.HandleConfigureHtBlockAck( iOid ); |
|
298 break; |
|
299 case E802_11_CONFIGURE_PROPRIETARY_SNAP_HDR: |
|
300 ret = iEventDispatcherClient.HandleConfigureProprietarySnapHdr( |
|
301 iOid ); |
|
302 break; |
|
303 default: |
|
304 // catch programming error |
|
305 OsTracePrint( KErrorLevel, (TUint8*) |
|
306 ("UMAC: OID: 0x%08x"), iOid->oid_id ); |
|
307 OsAssert((TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
308 break; |
|
309 } |
|
310 |
|
311 // mark as used |
|
312 iOid = NULL; |
|
313 return ret; |
|
314 } |