|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Implementation of WlanConfigureTxQueueParams class |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 12 % |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "umacconfiguretxqueueparams.h" |
|
24 #include "UmacContextImpl.h" |
|
25 #include "umacwhaconfigurequeue.h" |
|
26 #include "umacwhaconfigureac.h" |
|
27 |
|
28 #ifndef NDEBUG |
|
29 const TInt8 WlanConfigureTxQueueParams::iName[] |
|
30 = "wsacomplex-configuretxqueueparams"; |
|
31 |
|
32 const TUint8 WlanConfigureTxQueueParams::iStateName |
|
33 [ESTATEMAX][KMaxStateStringLength] = |
|
34 { |
|
35 {"EINIT"}, |
|
36 {"ECONFIGUREBESTEFFORTQUEUE"}, |
|
37 {"ECONFIGUREVOICEQUEUE"}, |
|
38 {"ECONFIGUREVIDEOQUEUE"}, |
|
39 {"ECONFIGUREBACKGROUNDQUEUE"}, |
|
40 {"ECONFIGUREAC"}, |
|
41 {"EFINIT"} |
|
42 }; |
|
43 |
|
44 const TUint8 WlanConfigureTxQueueParams::iEventName |
|
45 [EEVENTMAX][KMaxEventStringLength] = |
|
46 { |
|
47 {"ESTATEENTRY"}, |
|
48 {"ETXCOMPLETE"} |
|
49 }; |
|
50 #endif // !NDEBUG |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void WlanConfigureTxQueueParams::Fsm( |
|
60 WlanContextImpl& aCtxImpl, |
|
61 TEvent aEvent ) |
|
62 { |
|
63 OsTracePrint( KUmacDetails, |
|
64 (TUint8*)("UMAC: WlanConfigureTxQueueParams::Fsm(): FSM EVENT") ); |
|
65 #ifndef NDEBUG |
|
66 OsTracePrint( |
|
67 KUmacDetails, |
|
68 (TUint8*)("UMAC: WlanConfigureTxQueueParams::Fsm(): event:")); |
|
69 OsTracePrint( KUmacDetails, iEventName[aEvent] ); |
|
70 OsTracePrint( |
|
71 KUmacDetails, |
|
72 (TUint8*)("UMAC: WlanConfigureTxQueueParams::Fsm(): state:")); |
|
73 OsTracePrint( KUmacDetails, iStateName[iState] ); |
|
74 #endif |
|
75 |
|
76 switch ( aEvent ) |
|
77 { |
|
78 case ESTATEENTRY: |
|
79 OnStateEntryEvent( aCtxImpl ); |
|
80 break; |
|
81 case ETXCOMPLETE: |
|
82 OnTxCompleteEvent( aCtxImpl ); |
|
83 break; |
|
84 default: |
|
85 // catch internal FSM programming error |
|
86 #ifndef NDEBUG |
|
87 OsTracePrint( KErrorLevel, (TUint8*)("UMAC: event:")); |
|
88 OsTracePrint( KErrorLevel, iEventName[aEvent] ); |
|
89 #endif |
|
90 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
91 } |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void WlanConfigureTxQueueParams::OnStateEntryEvent( |
|
99 WlanContextImpl& aCtxImpl ) |
|
100 { |
|
101 switch ( iState ) |
|
102 { |
|
103 case EINIT: |
|
104 ChangeInternalState( aCtxImpl, ECONFIGUREBESTEFFORTQUEUE ); |
|
105 break; |
|
106 case ECONFIGUREBESTEFFORTQUEUE: |
|
107 ConfigureQueue( aCtxImpl, WHA::ELegacy ); |
|
108 break; |
|
109 case ECONFIGUREVOICEQUEUE: |
|
110 ConfigureQueue( aCtxImpl, WHA::EVoice ); |
|
111 break; |
|
112 case ECONFIGUREVIDEOQUEUE: |
|
113 ConfigureQueue( aCtxImpl, WHA::EVideo ); |
|
114 break; |
|
115 case ECONFIGUREBACKGROUNDQUEUE: |
|
116 ConfigureQueue( aCtxImpl, WHA::EBackGround ); |
|
117 break; |
|
118 case ECONFIGUREAC: |
|
119 ConfigureAc( aCtxImpl ); |
|
120 break; |
|
121 case EFINIT: |
|
122 // fsm execution complete traverse back to history state |
|
123 TraverseToHistoryState( aCtxImpl ); |
|
124 break; |
|
125 default: |
|
126 // cath internal FSM programming error |
|
127 #ifndef NDEBUG |
|
128 OsTracePrint( KErrorLevel, (TUint8*)("UMAC: state:")); |
|
129 OsTracePrint( KErrorLevel, iStateName[iState] ); |
|
130 #endif |
|
131 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
132 } |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void WlanConfigureTxQueueParams::OnTxCompleteEvent( |
|
140 WlanContextImpl& aCtxImpl ) |
|
141 { |
|
142 switch ( iState ) |
|
143 { |
|
144 case ECONFIGUREBESTEFFORTQUEUE: |
|
145 // continue state traversal |
|
146 ChangeInternalState( aCtxImpl, ECONFIGUREVOICEQUEUE ); |
|
147 break; |
|
148 case ECONFIGUREVOICEQUEUE: |
|
149 // continue state traversal |
|
150 ChangeInternalState( aCtxImpl, ECONFIGUREVIDEOQUEUE ); |
|
151 break; |
|
152 case ECONFIGUREVIDEOQUEUE: |
|
153 // continue state traversal |
|
154 ChangeInternalState( aCtxImpl, ECONFIGUREBACKGROUNDQUEUE ); |
|
155 break; |
|
156 case ECONFIGUREBACKGROUNDQUEUE: |
|
157 // continue state traversal |
|
158 ChangeInternalState( aCtxImpl, ECONFIGUREAC ); |
|
159 break; |
|
160 case ECONFIGUREAC: |
|
161 // continue state traversal |
|
162 ChangeInternalState( aCtxImpl, EFINIT ); |
|
163 break; |
|
164 default: |
|
165 // cath internal FSM programming error |
|
166 #ifndef NDEBUG |
|
167 OsTracePrint( KErrorLevel, (TUint8*)("UMAC: state:")); |
|
168 OsTracePrint( KErrorLevel, iStateName[iState] ); |
|
169 #endif |
|
170 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
171 } |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void WlanConfigureTxQueueParams::ChangeInternalState( |
|
179 WlanContextImpl& aCtxImpl, |
|
180 TState aNewState ) |
|
181 { |
|
182 iState = aNewState; |
|
183 Fsm( aCtxImpl, ESTATEENTRY ); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void WlanConfigureTxQueueParams::ConfigureQueue( |
|
191 WlanContextImpl& aCtxImpl, |
|
192 WHA::TQueueId aQueueId ) |
|
193 { |
|
194 OsTracePrint( |
|
195 KUmacDetails, |
|
196 (TUint8*)("UMAC: WlanConfigureTxQueueParams::ConfigureQueue") ); |
|
197 |
|
198 WHA::TPsScheme psScheme( WHA::ERegularPs ); |
|
199 |
|
200 // enable U-APSD for the AC/Queue in question if necessary. |
|
201 // Otherwise stick to regular PS |
|
202 switch ( aQueueId ) |
|
203 { |
|
204 case WHA::ELegacy: |
|
205 if ( aCtxImpl.UapsdUsedForBestEffort() ) |
|
206 { |
|
207 psScheme = WHA::EUapsd; |
|
208 } |
|
209 break; |
|
210 case WHA::EBackGround: |
|
211 if ( aCtxImpl.UapsdUsedForBackground() ) |
|
212 { |
|
213 psScheme = WHA::EUapsd; |
|
214 } |
|
215 break; |
|
216 case WHA::EVideo: |
|
217 if ( aCtxImpl.UapsdUsedForVideo() ) |
|
218 { |
|
219 psScheme = WHA::EUapsd; |
|
220 } |
|
221 break; |
|
222 case WHA::EVoice: |
|
223 if ( aCtxImpl.UapsdUsedForVoice() ) |
|
224 { |
|
225 psScheme = WHA::EUapsd; |
|
226 } |
|
227 break; |
|
228 default: |
|
229 // catch programming error |
|
230 OsTracePrint( KErrorLevel, (TUint8*) |
|
231 ("UMAC: ERROR: non-supported queue, aQueueId: %d"), aQueueId ); |
|
232 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
233 } |
|
234 |
|
235 WlanWhaConfigureQueue& wha_command = aCtxImpl.WhaConfigureQueue(); |
|
236 |
|
237 wha_command.Set( |
|
238 aQueueId, |
|
239 aCtxImpl.iWlanMib.dot11MaxTransmitMSDULifetime[aQueueId], |
|
240 psScheme, |
|
241 WHA::ENormal, |
|
242 aCtxImpl.iWlanMib.iMediumTime[aQueueId] ); |
|
243 |
|
244 // change global state: entry procedure triggers action |
|
245 ChangeState( aCtxImpl, |
|
246 *this, // prev state |
|
247 wha_command // next state |
|
248 ); |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void WlanConfigureTxQueueParams::ConfigureAc( |
|
256 WlanContextImpl& aCtxImpl ) |
|
257 { |
|
258 OsTracePrint( |
|
259 KUmacDetails, |
|
260 (TUint8*)("UMAC: WlanConfigureTxQueueParams::ConfigureAc()") ); |
|
261 |
|
262 WlanWhaConfigureAc& wha_command = aCtxImpl.WhaConfigureAc(); |
|
263 |
|
264 wha_command.Set( |
|
265 aCtxImpl.CwMinVector(), |
|
266 aCtxImpl.CwMaxVector(), |
|
267 aCtxImpl.AifsVector(), |
|
268 aCtxImpl.TxOplimitVector() ); |
|
269 |
|
270 // change global state: entry procedure triggers action |
|
271 ChangeState( aCtxImpl, |
|
272 *this, // prev state |
|
273 wha_command // next state |
|
274 ); |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void WlanConfigureTxQueueParams::Entry( |
|
282 WlanContextImpl& aCtxImpl ) |
|
283 { |
|
284 if ( aCtxImpl.WsaCmdActive() ) |
|
285 { |
|
286 // sanity checking code |
|
287 OsAssert( (TUint8*)("UMAC * panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
288 } |
|
289 |
|
290 if ( iState != EINIT ) |
|
291 { |
|
292 // this is NOT the start of the the FSM actions |
|
293 // note that we send the ETXCOMPLETE event as the states |
|
294 // that wait for it are the only ones that can be interrupted |
|
295 // as they are asynchronous operations by nature |
|
296 // and wait for corresponding WHA completion method |
|
297 Fsm( aCtxImpl, ETXCOMPLETE ); |
|
298 } |
|
299 else |
|
300 { |
|
301 // this is the start of the the FSM actions |
|
302 Fsm( aCtxImpl, ESTATEENTRY ); |
|
303 } |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void WlanConfigureTxQueueParams::Exit( |
|
311 WlanContextImpl& /*aCtxImpl*/ ) |
|
312 { |
|
313 iState = EINIT; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 #ifndef NDEBUG |
|
321 const TInt8* WlanConfigureTxQueueParams::GetStateName( |
|
322 TUint8& aLength ) const |
|
323 { |
|
324 aLength = sizeof( iName ); |
|
325 return iName; |
|
326 } |
|
327 #endif |