author | mikaruus <mika.a.ruuskanen@nokia.com> |
Wed, 17 Feb 2010 13:58:55 +0200 | |
changeset 7 | fa67e03b87df |
parent 5 | 8ccc39f9d787 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2007-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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include "dpdef.h" // dataport definitions |
|
22 |
#include "dpdataport.h" // dataport main and c32 interface |
|
23 |
#include "dpflowctrl.h" // flow control handling |
|
24 |
#include "dppif.h" // dcs pipe interface |
|
25 |
#include <iscdefinitions.h> |
|
26 |
#include "dplog.h" // dataport logging |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
27 |
#include "OstTraceDefinitions.h" |
0 | 28 |
#ifdef OST_TRACE_COMPILER_IN_USE |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
29 |
#include "dpflowctrlTraces.h" |
0 | 30 |
#endif |
31 |
||
32 |
// EXTERNAL DATA STRUCTURES |
|
33 |
// none |
|
34 |
||
35 |
// EXTERNAL FUNCTION PROTOTYPES |
|
36 |
// none |
|
37 |
||
38 |
// CONSTANTS |
|
39 |
// none |
|
40 |
||
41 |
// MACROS |
|
42 |
// none |
|
43 |
||
44 |
// LOCAL CONSTANTS AND MACROS |
|
45 |
// none |
|
46 |
||
47 |
// MODULE DATA STRUCTURES |
|
48 |
// none |
|
49 |
||
50 |
// LOCAL FUNCTION PROTOTYPES |
|
51 |
// none |
|
52 |
||
53 |
// FORWARD DECLARATIONS |
|
54 |
// none |
|
55 |
||
56 |
// ============================= LOCAL FUNCTIONS =============================== |
|
57 |
// none |
|
58 |
||
59 |
// ============================ MEMBER FUNCTIONS =============================== |
|
60 |
||
61 |
// ----------------------------------------------------------------------------- |
|
62 |
// CDpFlowCtrl::CDpFlowCtrl |
|
63 |
// C++ default constructor can NOT contain any code, that |
|
64 |
// might leave. |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
CDpFlowCtrl::CDpFlowCtrl( |
|
68 |
CDpDataPort& aDataPort ) : |
|
69 |
CActive( KDpFlowCtrlPriority ), |
|
70 |
iDataPort( aDataPort ), |
|
71 |
iPifDcs( iDataPort.Pif() ), |
|
72 |
iFlowCtrlDp2Dcs( EFlowControlOn ), |
|
73 |
iFlowCtrlDcs2Dp( EFlowControlOff ), |
|
74 |
iLastFlowControlSentToClient( EFlowControlOn ), |
|
75 |
iIsDataportReadyforDteFlow( EFalse ) |
|
76 |
{ |
|
77 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_CDPFLOWCTRL, "CDpFlowCtrl::CDpFlowCtrl" ); |
|
78 |
LOGM(" CDpFlowCtrl::CDpFlowCtrl"); |
|
79 |
||
80 |
iIscFlowCtrlStatus = EIscFlowControlOn; |
|
81 |
||
82 |
CActiveScheduler::Add( this ); |
|
83 |
} |
|
84 |
||
85 |
// ----------------------------------------------------------------------------- |
|
86 |
// CDpFlowCtrl::~CDpFlowCtrl |
|
87 |
// Destructor |
|
88 |
// ----------------------------------------------------------------------------- |
|
89 |
CDpFlowCtrl::~CDpFlowCtrl() |
|
90 |
{ |
|
91 |
OstTrace0( TRACE_NORMAL, DUP1_CDPFLOWCTRL_CDPFLOWCTRL, "CDpFlowCtrl::~CDpFlowCtrl" ); |
|
92 |
LOGM(" CDpFlowCtrl::~CDpFlowCtrl"); |
|
93 |
} |
|
94 |
||
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// CDpFlowCtrl::RunL |
|
97 |
// This method sets water mark according Isc Api' proxy's flow |
|
98 |
// control status, if Dcs2Dp flow control status is not already set. |
|
99 |
// Isc Api pipe data message buffer request is renewed. |
|
100 |
// ----------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
void CDpFlowCtrl::RunL() |
|
103 |
{ |
|
104 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_RUNL, "CDpFlowCtrl::RunL" ); |
|
105 |
OstTrace1( TRACE_NORMAL, DUP1_CDPFLOWCTRL_RUNL, "CDpFlowCtrl:: Port: %u", iDataPort.PortUnit() ); |
|
106 |
||
107 |
LOGM1("CDpFlowCtrl::RunL - Port %d", iDataPort.PortUnit() ); |
|
108 |
||
109 |
switch ( iIscFlowCtrlStatus ) |
|
110 |
{ |
|
111 |
// Dataport's Proxy's pipe data message buffer has reached HighWaterMark |
|
112 |
case EIscFlowControlOn: |
|
113 |
{ |
|
114 |
LOG(" CDpFlowCtrl::RunL, Proxy's High WaterMarkReached"); |
|
115 |
OstTrace0( TRACE_NORMAL, DUP2_CDPFLOWCTRL_RUNL, "CDpFlowCtrl:: Proxy's High WaterMarkReached" ); |
|
116 |
||
117 |
iFlowCtrlDp2Dcs = EFlowControlOn; |
|
118 |
break; |
|
119 |
} |
|
120 |
// Dataport's Proxy's pipe data message buffer has reached LowWaterMark |
|
121 |
case EIscFlowControlOff: |
|
122 |
{ |
|
123 |
LOG(" CDpFlowCtrl::RunL, Proxy's Low WaterMarkReached"); |
|
124 |
OstTrace0( TRACE_NORMAL, DUP3_CDPFLOWCTRL_RUNL, "CDpFlowCtrl:: Proxy's Low WaterMarkReached" ); |
|
125 |
||
126 |
iFlowCtrlDp2Dcs = EFlowControlOff; |
|
127 |
iPifDcs.SetPipeState( CDpPif::EDpPipeEnabled ); |
|
128 |
break; |
|
129 |
} |
|
130 |
// Connection closed, data transmission ended |
|
131 |
case EIscTransmissionEnd: |
|
132 |
{ |
|
133 |
LOG(" CDpFlowCtrl::RunL, Transmission End"); |
|
134 |
OstTrace0( TRACE_NORMAL, DUP4_CDPFLOWCTRL_RUNL, "CDpFlowCtrl:: Transmission End" ); |
|
135 |
||
136 |
// set flow control on |
|
137 |
iFlowCtrlDp2Dcs = EFlowControlOn; |
|
138 |
iFlowCtrlDcs2Dp = EFlowControlOn; |
|
139 |
iPifDcs.SetPipeState( CDpPif::EDpPipeDisconnected ); |
|
7
fa67e03b87df
New release based on our 2010wk08 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
5
diff
changeset
|
140 |
iDataPort.ISAHandle().ResetBuffers(); |
0 | 141 |
break; |
142 |
} |
|
143 |
default: |
|
144 |
{ |
|
145 |
// This should newer happen, No actions needed. |
|
146 |
LOG(" CDpFlowCtrl::RunL, Proxy buffer reached HWM or LWM, but no action needed"); |
|
147 |
OstTrace0( TRACE_NORMAL, DUP5_CDPFLOWCTRL_RUNL, "CDpFlowCtrl:: Proxy buffer reached HWM or LWM, but no action needed" ); |
|
148 |
||
149 |
} |
|
150 |
} |
|
151 |
||
152 |
// inform client |
|
153 |
if ( iFlowControlNotify ) |
|
154 |
{ |
|
155 |
InformFlowControlToClient(); |
|
156 |
} |
|
157 |
// no else |
|
158 |
||
159 |
// inform other modules |
|
160 |
Notify(); |
|
161 |
||
162 |
if ( EIscTransmissionEnd != iIscFlowCtrlStatus ) |
|
163 |
{ |
|
164 |
// renew flow control request |
|
165 |
RequestIscFlowControlNotification(); |
|
166 |
} |
|
167 |
else |
|
168 |
{ |
|
169 |
// Check if DataPort is ready to be deleted |
|
170 |
if ( iDataPort.IsReadyToDestruct() ) |
|
171 |
{ |
|
172 |
iDataPort.DeleteDataPort(); |
|
173 |
} |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
174 |
else |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
175 |
{ |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
176 |
RequestIscFlowControlNotification(); |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
177 |
} |
0 | 178 |
//no else |
179 |
} |
|
180 |
} |
|
181 |
||
182 |
// ----------------------------------------------------------------------------- |
|
183 |
// CDpFlowCtrl::RunError |
|
184 |
// Leave in RunL() is handled here. Error code is returned, |
|
185 |
// when internal error has occured. |
|
186 |
// ----------------------------------------------------------------------------- |
|
187 |
// |
|
188 |
TInt CDpFlowCtrl::RunError( |
|
189 |
TInt aError ) |
|
190 |
{ |
|
191 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_RUNERROR, "CDpFlowCtrl::RunError" ); |
|
192 |
OstTraceExt2( TRACE_NORMAL, DUP1_CDPFLOWCTRL_RUNERROR, "CDpFlowCtrl:: Port: %u, error code: %d", iDataPort.PortUnit(), aError ); |
|
193 |
||
194 |
LOGM2("CDpFlowCtrl::RunError - Port %d, error code: %d", |
|
195 |
iDataPort.PortUnit(), aError ); |
|
196 |
||
197 |
return aError; |
|
198 |
} |
|
199 |
||
200 |
// ----------------------------------------------------------------------------- |
|
201 |
// CDpFlowCtrl::RequestIscFlowControlNotification |
|
202 |
// This method requests Isc Api pipe data message buffer status. |
|
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
||
206 |
void CDpFlowCtrl::RequestIscFlowControlNotification() |
|
207 |
{ |
|
208 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_REQUESTISCFLOWCONTROLNOTIFICATION, "CDpFlowCtrl::RequestIscFlowControlNotification" ); |
|
209 |
OstTrace1( TRACE_NORMAL, DUP1_CDPFLOWCTRL_REQUESTISCFLOWCONTROLNOTIFICATION, "CDpFlowCtrl:: Port: %u", iDataPort.PortUnit() ); |
|
210 |
||
211 |
LOGM1(" CDpFlowCtrl::RequestIscFlowControlNotification - Port %d", |
|
212 |
iDataPort.PortUnit() ); |
|
213 |
||
214 |
if ( !IsActive() ) |
|
215 |
{ |
|
216 |
iDataPort.ISAHandle().NotifyFlowControl( |
|
217 |
iStatus, iIscFlowCtrlStatus ); |
|
218 |
SetActive(); |
|
219 |
} |
|
220 |
// no else |
|
221 |
} |
|
222 |
||
223 |
// ----------------------------------------------------------------------------- |
|
224 |
// CDpFlowCtrl::DoCancel |
|
225 |
// This method cancels this active object by RequestComplete(). |
|
226 |
// Must be called directly (not through Cancel()), when RunL() |
|
227 |
// should be completed with KErrCancel. |
|
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
void CDpFlowCtrl::DoCancel() |
|
231 |
{ |
|
232 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_DOCANCEL, "CDpFlowCtrl::DoCancel" ); |
|
233 |
LOG(" CDpFlowCtrl::DoCancel"); |
|
234 |
||
235 |
// do the required signaling |
|
236 |
iDataPort.ISAHandle().NotifyFlowControlCancel(); |
|
237 |
} |
|
238 |
||
239 |
// ----------------------------------------------------------------------------- |
|
240 |
// CDpFlowCtrl::GetDp2DcsFlowControlStatus |
|
241 |
// Gets flowcontrol status of DP-->DCS |
|
242 |
// ----------------------------------------------------------------------------- |
|
243 |
// |
|
244 |
void CDpFlowCtrl::GetDp2DcsFlowControlStatus( |
|
245 |
TFlowControl& aFlowControl ) |
|
246 |
{ |
|
247 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_GETDP2DCSFLOWCONTROLSTATUS, "CDpFlowCtrl::GetDp2DcsFlowControlStatus" ); |
|
248 |
LOGM(" CDpFlowCtrl::GetDp2DcsFlowControlStatus"); |
|
249 |
||
250 |
aFlowControl = iFlowCtrlDp2Dcs; |
|
251 |
} |
|
252 |
||
253 |
// ----------------------------------------------------------------------------- |
|
254 |
// CDpFlowCtrl::SetFlowControlNotify |
|
255 |
// Set the flow control notify enabled/disabled. |
|
256 |
// ----------------------------------------------------------------------------- |
|
257 |
// |
|
258 |
void CDpFlowCtrl::SetFlowControlNotify( |
|
259 |
const TBool aEnableNotify ) |
|
260 |
{ |
|
261 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_SETFLOWCONTROLNOTIFY, "CDpFlowCtrl::SetFlowControlNotify" ); |
|
262 |
LOGM(" CDpFlowCtrl::SetFlowControlNotify"); |
|
263 |
||
264 |
iFlowControlNotify = aEnableNotify; |
|
265 |
// new flow control message is received while notification was not active. |
|
266 |
if ( aEnableNotify && ( iLastFlowControlSentToClient != iFlowCtrlDp2Dcs ) ) |
|
267 |
{ |
|
268 |
InformFlowControlToClient(); |
|
269 |
} |
|
270 |
// no else |
|
271 |
} |
|
272 |
||
273 |
// ----------------------------------------------------------------------------- |
|
274 |
// CDpFlowCtrl::WaterMarkLowReached |
|
275 |
// RX buffer or Isc Api's proxy has reached low water mark. |
|
276 |
// Sets the local FlowCtrlDcs2Dp flow OFF and sends flow |
|
277 |
// change to DCS, if needed. Notify flow control users |
|
278 |
// (flow control observers). |
|
279 |
// ----------------------------------------------------------------------------- |
|
280 |
// |
|
281 |
void CDpFlowCtrl::WaterMarkLowReached() |
|
282 |
{ |
|
283 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_WATERMARKLOWREACHED, "CDpFlowCtrl::WaterMarkLowReached" ); |
|
284 |
OstTrace1( TRACE_NORMAL, DUP1_CDPFLOWCTRL_WATERMARKLOWREACHED, "CDpFlowCtrl:: Port: %u", iDataPort.PortUnit() ); |
|
285 |
OstTrace0( TRACE_NORMAL, DUP2_CDPFLOWCTRL_WATERMARKLOWREACHED, "CDpFlowCtrl:: LOW WATER MARK" ); |
|
286 |
||
287 |
LOGM1(" CDpFlowCtrl::WaterMarkLowReached - Port %d", |
|
288 |
iDataPort.PortUnit() ); |
|
289 |
LOG(" CDpFlowCtrl - LOW WATER MARK"); |
|
290 |
||
291 |
// flow control is set OFF, i.e. data is being transmitted |
|
292 |
iFlowCtrlDcs2Dp = EFlowControlOff; |
|
293 |
// inform flow control users |
|
294 |
Notify(); |
|
295 |
} |
|
296 |
||
297 |
// ----------------------------------------------------------------------------- |
|
298 |
// CDpFlowCtrl::WaterMarkHighReached |
|
299 |
// RX buffer or Isc Api's proxy has reached high water mark. |
|
300 |
// Sets the local RX flow ON. Sends flow change to DCS if needed. |
|
301 |
// Notify flow control users (flow control observers). |
|
302 |
// ----------------------------------------------------------------------------- |
|
303 |
// |
|
304 |
void CDpFlowCtrl::WaterMarkHighReached() |
|
305 |
{ |
|
306 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_WATERMARKHIGHREACHED, "CDpFlowCtrl::WaterMarkHighReached" ); |
|
307 |
OstTrace1( TRACE_NORMAL, DUP1_CDPFLOWCTRL_WATERMARKHIGHREACHED, "CDpFlowCtrl:: Port: %u", iDataPort.PortUnit() ); |
|
308 |
OstTrace0( TRACE_NORMAL, DUP2_CDPFLOWCTRL_WATERMARKHIGHREACHED, "CDpFlowCtrl:: HIGH WATER MARK" ); |
|
309 |
||
310 |
LOGM1(" CDpFlowCtrl::WaterMarkHighReachedL - Port %d", |
|
311 |
iDataPort.PortUnit() ); |
|
312 |
LOG(" CDpFlowCtrl - HIGH WATER MARK"); |
|
313 |
||
314 |
// flow control is set ON, ie data is inhibited |
|
315 |
iFlowCtrlDcs2Dp = EFlowControlOn; |
|
316 |
// inform flow control users |
|
317 |
Notify(); |
|
318 |
} |
|
319 |
||
320 |
// ----------------------------------------------------------------------------- |
|
321 |
// CDpFlowCtrl::NotifyClientDatapotReadyforDteFlow |
|
322 |
// Notifies client about flow control change when starting DataPort. |
|
323 |
// ----------------------------------------------------------------------------- |
|
324 |
// |
|
325 |
void CDpFlowCtrl::NotifyClientDatapotReadyforDteFlow() |
|
326 |
{ |
|
327 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_NOTIFYCLIENTDATAPOTREADYFORDTEFLOW, "CDpFlowCtrl::NotifyClientDatapotReadyforDteFlow" ); |
|
328 |
LOGM(" CDpFlowCtrl::NotifyClientDatapotReadyforDteFlow"); |
|
329 |
||
330 |
if ( ( !iIsDataportReadyforDteFlow ) && iFlowCtrlDp2Dcs ) |
|
331 |
{ |
|
332 |
InformFlowControlToClient(); |
|
333 |
} |
|
334 |
// no else |
|
335 |
} |
|
336 |
||
337 |
// ----------------------------------------------------------------------------- |
|
338 |
// CDpFlowCtrl::InformFlowControlToClient |
|
339 |
// Informs client about the flow control change. |
|
340 |
// ----------------------------------------------------------------------------- |
|
341 |
// |
|
342 |
void CDpFlowCtrl::InformFlowControlToClient() |
|
343 |
{ |
|
344 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_INFORMFLOWCONTROLTOCLIENT, "CDpFlowCtrl::InformFlowControlToClient" ); |
|
345 |
LOGM(" CDpFlowCtrl::InformFlowControlToClient"); |
|
346 |
||
347 |
if ( EFlowControlOn == iFlowCtrlDp2Dcs ) |
|
348 |
{ |
|
349 |
LOG(" CDpFlowCtrl::InformFlowControlToClient, EFlowControlOn (completed)"); |
|
350 |
OstTrace0( TRACE_NORMAL, DUP1_CDPFLOWCTRL_INFORMFLOWCONTROLTOCLIENT, "CDpFlowCtrl:: EFlowControlOn (completed)" ); |
|
351 |
} |
|
352 |
else |
|
353 |
{ |
|
354 |
LOG(" CDpFlowCtrl::InformFlowControlToClient, EFlowControlOff (completed)"); |
|
355 |
OstTrace0( TRACE_NORMAL, DUP2_CDPFLOWCTRL_INFORMFLOWCONTROLTOCLIENT, "CDpFlowCtrl:: EFlowControlOff (completed)" ); |
|
356 |
} |
|
357 |
||
358 |
iDataPort.FlowControlChangeCompleted( iFlowCtrlDp2Dcs, KErrNone ); |
|
359 |
iLastFlowControlSentToClient = iFlowCtrlDp2Dcs; |
|
360 |
||
361 |
iIsDataportReadyforDteFlow = ETrue; |
|
362 |
} |
|
363 |
||
364 |
// ----------------------------------------------------------------------------- |
|
365 |
// CDpFlowCtrl::Attach |
|
366 |
// Attach observer to CDpSubject. |
|
367 |
// ----------------------------------------------------------------------------- |
|
368 |
// |
|
369 |
void CDpFlowCtrl::Attach( CDpObserver& aObserver ) |
|
370 |
{ |
|
371 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_ATTACH, "CDpFlowCtrl::Attach" ); |
|
372 |
iDpSubject.Attach( aObserver ); |
|
373 |
} |
|
374 |
||
375 |
// ----------------------------------------------------------------------------- |
|
376 |
// CDpFlowCtrl::Detach |
|
377 |
// Detach observer from CDpSubject. |
|
378 |
// ----------------------------------------------------------------------------- |
|
379 |
// |
|
380 |
void CDpFlowCtrl::Detach( CDpObserver& aObserver ) |
|
381 |
{ |
|
382 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_DETACH, "CDpFlowCtrl::Detach" ); |
|
383 |
iDpSubject.Detach( aObserver ); |
|
384 |
} |
|
385 |
||
386 |
// ----------------------------------------------------------------------------- |
|
387 |
// CDpFlowCtrl::Notify |
|
388 |
// Notify all observers of CDpSubject object. |
|
389 |
// ----------------------------------------------------------------------------- |
|
390 |
// |
|
391 |
void CDpFlowCtrl::Notify() |
|
392 |
{ |
|
393 |
OstTrace0( TRACE_NORMAL, CDPFLOWCTRL_NOTIFY, "CDpFlowCtrl::Notify" ); |
|
394 |
iDpSubject.Notify(); |
|
395 |
} |
|
396 |
||
397 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
398 |
// none |
|
399 |
||
400 |
// End of File |