|
1 /* |
|
2 * Copyright (c) 2008-2009 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 the WlanLightPsModePowerModeMgr class |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 3 % |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "umaclightpsmodepowermodemgr.h" |
|
24 #include "UmacContextImpl.h" |
|
25 #include "802dot11.h" |
|
26 |
|
27 // Default Rx/Tx frame count threshold for considering change to Active mode. |
|
28 // This value is used if another value hasn't been provided |
|
29 const TUint KDefaultToActivePacketThreshold = 4; |
|
30 |
|
31 // Default Rx/Tx frame count threshold for considering change to Deep PS mode. |
|
32 // This value is used if another value hasn't been provided |
|
33 const TUint KDefaultToDeepPsPacketThreshold = 1; |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 WlanLightPsModePowerModeMgr::WlanLightPsModePowerModeMgr() : |
|
42 iToActiveFrameCount( 0 ), |
|
43 iToActiveFrameThreshold( KDefaultToActivePacketThreshold ), |
|
44 iToDeepPsFrameCount( 0 ), |
|
45 iToDeepPsFrameThreshold( KDefaultToDeepPsPacketThreshold ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 WlanLightPsModePowerModeMgr::~WlanLightPsModePowerModeMgr() |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 TPowerMgmtModeChange WlanLightPsModePowerModeMgr::OnFrameTx( |
|
62 WlanContextImpl& /*aCtxImpl*/, |
|
63 WHA::TQueueId /*aQueueId*/, |
|
64 TUint16 aEtherType, |
|
65 TBool aIgnoreThisFrame ) |
|
66 { |
|
67 TPowerMgmtModeChange powerMgmtModeChange( ENoChange ); |
|
68 |
|
69 if ( aEtherType == KEapolType || |
|
70 aEtherType == KWaiType ) |
|
71 { |
|
72 powerMgmtModeChange = EToActive; |
|
73 |
|
74 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
75 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameTx: EAPOL or WAI frame; change to Active") ); |
|
76 } |
|
77 else |
|
78 { |
|
79 if ( !aIgnoreThisFrame ) |
|
80 { |
|
81 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
82 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameTx: count this frame") ); |
|
83 |
|
84 ++iToActiveFrameCount; |
|
85 ++iToDeepPsFrameCount; |
|
86 |
|
87 if ( iToActiveFrameCount >= iToActiveFrameThreshold ) |
|
88 { |
|
89 powerMgmtModeChange = EToActive; |
|
90 |
|
91 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
92 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameTx: threshold exceeded; change to Active") ); |
|
93 } |
|
94 } |
|
95 else |
|
96 { |
|
97 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
98 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameTx: do no count this frame") ); |
|
99 |
|
100 // no further action needed |
|
101 } |
|
102 } |
|
103 |
|
104 return powerMgmtModeChange; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TPowerMgmtModeChange WlanLightPsModePowerModeMgr::OnFrameRx( |
|
112 WlanContextImpl& aCtxImpl, |
|
113 WHA::TQueueId aAccessCategory, |
|
114 TUint16 aEtherType, |
|
115 TBool aIgnoreThisFrame, |
|
116 TUint aPayloadLength, |
|
117 TDaType aDaType ) |
|
118 { |
|
119 TPowerMgmtModeChange powerMgmtModeChange( ENoChange ); |
|
120 |
|
121 if ( aEtherType == KEapolType || |
|
122 aEtherType == KWaiType ) |
|
123 { |
|
124 powerMgmtModeChange = EToActive; |
|
125 |
|
126 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
127 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameRx: EAPOL or WAI frame; change to Active") ); |
|
128 } |
|
129 else |
|
130 { |
|
131 if ( CountThisFrame( |
|
132 aCtxImpl, |
|
133 aAccessCategory, |
|
134 aEtherType, |
|
135 aIgnoreThisFrame, |
|
136 aPayloadLength, |
|
137 iUapsdRxFrameLengthThreshold, |
|
138 aDaType ) ) |
|
139 { |
|
140 ++iToActiveFrameCount; |
|
141 ++iToDeepPsFrameCount; |
|
142 |
|
143 if ( iToActiveFrameCount >= iToActiveFrameThreshold ) |
|
144 { |
|
145 powerMgmtModeChange = EToActive; |
|
146 |
|
147 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
148 ("UMAC: WlanLightPsModePowerModeMgr::OnFrameRx: threshold exceeded; change to Active") ); |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 return powerMgmtModeChange; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 TBool WlanLightPsModePowerModeMgr::OnLightPsToActiveTimerTimeout( |
|
161 WlanContextImpl& aCtxImpl ) |
|
162 { |
|
163 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
164 ("UMAC: WlanLightPsModePowerModeMgr::OnLightPsToActiveTimerTimeout: ToActiveFrameCount: %d"), |
|
165 iToActiveFrameCount ); |
|
166 |
|
167 iToActiveFrameCount = 0; |
|
168 |
|
169 if ( // we are seeking for the opportunity to perform tests on the |
|
170 // current AP |
|
171 aCtxImpl.ApTestOpportunitySeekStarted() && |
|
172 // we have not yet indicated to WLAN Mgmt Client the opportunity |
|
173 // to perform tests on the current AP |
|
174 !aCtxImpl.ApTestOpportunityIndicated() ) |
|
175 { |
|
176 // Inform WLAN Mgmt Client that this would be the time to start |
|
177 // the testing |
|
178 aCtxImpl.iUmac.OnInDicationEvent( EApTestOpportunity ); |
|
179 // make a note that AP test opportunity has been indicated to |
|
180 // WLAN Mgmt Client |
|
181 aCtxImpl.ApTestOpportunityIndicated( ETrue ); |
|
182 } |
|
183 |
|
184 return EFalse; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 TBool WlanLightPsModePowerModeMgr::OnLightPsToDeepPsTimerTimeout() |
|
192 { |
|
193 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
194 ("UMAC: WlanLightPsModePowerModeMgr::OnLightPsToDeepPsTimerTimeout: ToDeepPsFrameCount: %d"), |
|
195 iToDeepPsFrameCount ); |
|
196 |
|
197 if ( iToDeepPsFrameCount < iToDeepPsFrameThreshold ) |
|
198 { |
|
199 return ETrue; |
|
200 } |
|
201 else |
|
202 { |
|
203 iToDeepPsFrameCount = 0; |
|
204 return EFalse; |
|
205 } |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void WlanLightPsModePowerModeMgr::DoReset() |
|
213 { |
|
214 OsTracePrint( KPwrStateTransition, (TUint8*) |
|
215 ("UMAC: WlanLightPsModePowerModeMgr::DoReset()") ); |
|
216 |
|
217 iToActiveFrameCount = 0; |
|
218 iToDeepPsFrameCount = 0; |
|
219 } |