ReactOS  0.4.15-dev-1203-g0e5a4d5
clntirp.c File Reference
#include "classp.h"
#include "debug.h"
Include dependency graph for clntirp.c:

Go to the source code of this file.

Functions

VOID ClasspStartIdleTimer (IN PCLASS_PRIVATE_FDO_DATA FdoData)
 
VOID ClasspStopIdleTimer (PCLASS_PRIVATE_FDO_DATA FdoData)
 
VOID ClasspServiceIdleRequest (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN PostToDpc)
 
PIRP ClasspDequeueIdleRequest (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID EnqueueDeferredClientIrp (PDEVICE_OBJECT Fdo, PIRP Irp)
 
PIRP DequeueDeferredClientIrp (PDEVICE_OBJECT Fdo)
 
VOID ClasspInitializeIdleTimer (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
ULONGLONG ClasspGetIdleTime (IN PCLASS_PRIVATE_FDO_DATA FdoData, IN LARGE_INTEGER CurrentTime)
 
LOGICAL ClasspIdleDurationSufficient (IN PCLASS_PRIVATE_FDO_DATA FdoData, OUT LARGE_INTEGER **CurrentTimeIn)
 
VOID NTAPI ClasspIdleTimerDpc (IN PKDPC Dpc, IN PVOID Context, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
NTSTATUS ClasspEnqueueIdleRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID ClasspCompleteIdleRequest (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 

Variables

KDEFERRED_ROUTINE ClasspIdleTimerDpc
 

Function Documentation

◆ ClasspCompleteIdleRequest()

VOID ClasspCompleteIdleRequest ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 713 of file clntirp.c.

716 {
717  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
718 
719  //
720  // Issue the next idle request if there are any left in the queue, there are
721  // no non-idle requests outstanding, there are less than max idle requests
722  // outstanding, and it has been long enough since the completion of the last
723  // non-idle request.
724  //
725  if ((fdoData->IdleIoCount > 0) &&
726  (fdoData->ActiveIdleIoCount < fdoData->IdleActiveIoMax) &&
727  (fdoData->ActiveIoCount <= 0) &&
728  (ClasspIdleDurationSufficient(fdoData, NULL))) {
729  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspCompleteIdleRequest: Service next idle reqeusts\n"));
731  }
732 
733  return;
734 }
#define TRUE
Definition: types.h:120
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
smooth NULL
Definition: ftsmooth.c:416
LOGICAL ClasspIdleDurationSufficient(IN PCLASS_PRIVATE_FDO_DATA FdoData, OUT LARGE_INTEGER **CurrentTimeIn)
Definition: clntirp.c:406
VOID ClasspServiceIdleRequest(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN PostToDpc)
Definition: clntirp.c:757

Referenced by TransferPktComplete().

◆ ClasspDequeueIdleRequest()

PIRP ClasspDequeueIdleRequest ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 654 of file clntirp.c.

657 {
658  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
659  PLIST_ENTRY listEntry = NULL;
660  PIRP irp = NULL;
661  KIRQL oldIrql;
662 
663  KeAcquireSpinLock(&fdoData->IdleListLock, &oldIrql);
664 
665  if (fdoData->IdleIoCount > 0) {
666  listEntry = RemoveHeadList(&fdoData->IdleIrpList);
667  //
668  // Make sure we actaully removed a request from the list
669  //
670  NT_ASSERT(listEntry != &fdoData->IdleIrpList);
671  //
672  // Decrement the idle I/O count.
673  //
674  fdoData->IdleIoCount--;
675  //
676  // Stop the timer on last request
677  //
678  if (fdoData->IdleIoCount == 0) {
679  ClasspStopIdleTimer(fdoData);
680  }
681  irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);
682  NT_ASSERT(irp->Type == IO_TYPE_IRP);
683 
684 
685  InitializeListHead(&irp->Tail.Overlay.ListEntry);
686  }
687 
688  KeReleaseSpinLock(&fdoData->IdleListLock, oldIrql);
689 
690 
691  return irp;
692 }
VOID ClasspStopIdleTimer(PCLASS_PRIVATE_FDO_DATA FdoData)
Definition: clntirp.c:316
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY IdleIrpList
Definition: classp.h:882
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define IO_TYPE_IRP
Definition: typedefs.h:119
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK IdleListLock
Definition: classp.h:877
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClasspServiceIdleRequest().

◆ ClasspEnqueueIdleRequest()

NTSTATUS ClasspEnqueueIdleRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 576 of file clntirp.c.

580 {
581  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
582  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExtension->PrivateFdoData;
583  KIRQL oldIrql;
584  BOOLEAN issueRequest = TRUE;
585  LARGE_INTEGER currentTime;
586  LARGE_INTEGER* pCurrentTime;
587 
588  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspEnqueueIdleRequest: Queue idle request %p\n", Irp));
589 
591 
592  //
593  // Reset issueRequest if the idle duration is not sufficient.
594  //
595  pCurrentTime = &currentTime;
596  if (ClasspIdleDurationSufficient(fdoData, &pCurrentTime) == FALSE) {
597  issueRequest = FALSE;
598  }
599 
600  //
601  // If there are already max active idle requests in the port driver, then
602  // queue this idle request.
603  //
604  if (fdoData->ActiveIdleIoCount >= fdoData->IdleActiveIoMax) {
605  issueRequest = FALSE;
606  }
607 
608 
609  KeAcquireSpinLock(&fdoData->IdleListLock, &oldIrql);
610  if (IsListEmpty(&fdoData->IdleIrpList)) {
611  NT_ASSERT(fdoData->IdleIoCount == 0);
612  }
613  InsertTailList(&fdoData->IdleIrpList, &Irp->Tail.Overlay.ListEntry);
614 
615 
616  fdoData->IdleIoCount++;
617  if (!fdoData->IdleTimerStarted) {
618  ClasspStartIdleTimer(fdoData);
619  }
620 
621  if (fdoData->IdleIoCount != 1) {
622  issueRequest = FALSE;
623  }
624 
625 
626  KeReleaseSpinLock(&fdoData->IdleListLock, oldIrql);
627 
628  if (issueRequest) {
629  ClasspServiceIdleRequest(fdoExtension, FALSE);
630  }
631 
632  return STATUS_PENDING;
633 }
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define InsertTailList(ListHead, Entry)
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
LIST_ENTRY IdleIrpList
Definition: classp.h:882
#define STATUS_PENDING
Definition: ntstatus.h:82
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LOGICAL ClasspIdleDurationSufficient(IN PCLASS_PRIVATE_FDO_DATA FdoData, OUT LARGE_INTEGER **CurrentTimeIn)
Definition: clntirp.c:406
VOID ClasspStartIdleTimer(IN PCLASS_PRIVATE_FDO_DATA FdoData)
Definition: clntirp.c:261
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK IdleListLock
Definition: classp.h:877
IoMarkIrpPending(Irp)
VOID ClasspServiceIdleRequest(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN PostToDpc)
Definition: clntirp.c:757
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClassReadWrite().

◆ ClasspGetIdleTime()

ULONGLONG ClasspGetIdleTime ( IN PCLASS_PRIVATE_FDO_DATA  FdoData,
IN LARGE_INTEGER  CurrentTime 
)

Definition at line 351 of file clntirp.c.

355 {
356  ULONGLONG idleTime;
358 
359  //
360  // Get the time difference between current time and last I/O
361  // complete time.
362  //
363 
364  status = RtlULongLongSub((ULONGLONG)CurrentTime.QuadPart,
365  (ULONGLONG)FdoData->LastNonIdleIoTime.QuadPart,
366  &idleTime);
367 
368  if (NT_SUCCESS(status)) {
369  //
370  // Convert the time to milliseconds.
371  //
372  idleTime = ClasspTimeDiffToMs(idleTime);
373  } else {
374  //
375  // Failed to get time difference, assume enough time passed.
376  //
377  idleTime = FdoData->IdleInterval;
378  }
379 
380  return idleTime;
381 }
LONG NTSTATUS
Definition: precomp.h:26
__inline ULONGLONG ClasspTimeDiffToMs(ULONGLONG TimeDiff)
Definition: classp.h:1297
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClasspIdleDurationSufficient().

◆ ClasspIdleDurationSufficient()

LOGICAL ClasspIdleDurationSufficient ( IN PCLASS_PRIVATE_FDO_DATA  FdoData,
OUT LARGE_INTEGER **  CurrentTimeIn 
)

Definition at line 406 of file clntirp.c.

410 {
411  ULONGLONG idleInterval;
412  LARGE_INTEGER CurrentTime;
413 
414  //
415  // If there are any outstanding non-idle requests, then there has been no
416  // idle time.
417  //
418  if (FdoData->ActiveIoCount > 0) {
419  if (CurrentTimeIn != NULL) {
420  *CurrentTimeIn = NULL;
421  }
422  return FALSE;
423  }
424 
425  //
426  // Check whether an idle request should be issued now or on the next timer
427  // expiration.
428  //
429 
430  CurrentTime = ClasspGetCurrentTime();
431  idleInterval = ClasspGetIdleTime(FdoData, CurrentTime);
432 
433  if (CurrentTimeIn != NULL) {
434  **CurrentTimeIn = CurrentTime;
435  }
436 
437  if (idleInterval >= FdoData->IdleInterval) {
438  return TRUE;
439  }
440 
441  return FALSE;
442 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG ClasspGetIdleTime(IN PCLASS_PRIVATE_FDO_DATA FdoData, IN LARGE_INTEGER CurrentTime)
Definition: clntirp.c:351
__inline LARGE_INTEGER ClasspGetCurrentTime(VOID)
Definition: classp.h:1280

Referenced by ClasspCompleteIdleRequest(), ClasspEnqueueIdleRequest(), and ClasspIdleTimerDpc().

◆ ClasspIdleTimerDpc()

VOID NTAPI ClasspIdleTimerDpc ( IN PKDPC  Dpc,
IN PVOID  Context,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 468 of file clntirp.c.

474 {
475  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Context;
476  PCLASS_PRIVATE_FDO_DATA fdoData;
477  ULONGLONG idleTime;
479  LARGE_INTEGER currentTime;
480  LARGE_INTEGER* pCurrentTime;
481 
485 
486  if (fdoExtension == NULL) {
487  NT_ASSERT(fdoExtension != NULL);
488  return;
489  }
490 
491  fdoData = fdoExtension->PrivateFdoData;
492 
493  if (fdoData->ActiveIoCount <= 0) {
494 
495  //
496  // If there are max active idle requests, do not issue another one here.
497  //
498  if (fdoData->ActiveIdleIoCount >= fdoData->IdleActiveIoMax) {
499  return;
500  }
501 
502  //
503  // Check whether enough idle time has passed since the last non-idle
504  // request has completed.
505  //
506 
507  pCurrentTime = &currentTime;
508  if (ClasspIdleDurationSufficient(fdoData, &pCurrentTime)) {
509  //
510  // We are going to issue an idle request so reset the anti-starvation
511  // timer counter.
512  // If we are here (Idle duration is sufficient), pCurrentTime is
513  // expected to be set.
514  //
515  NT_ASSERT(pCurrentTime != NULL);
516  fdoData->AntiStarvationStartTime = *pCurrentTime;
517  ClasspServiceIdleRequest(fdoExtension, FALSE);
518  }
519  return;
520  }
521 
522  //
523  // Get the time difference between current time and last I/O
524  // complete time.
525  //
526 
527  currentTime = ClasspGetCurrentTime();
528  status = RtlULongLongSub((ULONGLONG)currentTime.QuadPart,
530  &idleTime);
531 
532  if (NT_SUCCESS(status)) {
533  //
534  // Convert the time to milliseconds.
535  //
536  idleTime = ClasspTimeDiffToMs(idleTime);
537  } else {
538  //
539  // Failed to get time difference, assume enough time passed.
540  //
541  idleTime = fdoData->StarvationDuration;
542  }
543 
544  //
545  // If the timer is running then there must be at least one idle priority I/O pending
546  //
547  if (idleTime >= fdoData->StarvationDuration) {
548  fdoData->AntiStarvationStartTime = currentTime;
549  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspIdleTimerDpc: Starvation timer. Send one idle request\n"));
550  ClasspServiceIdleRequest(fdoExtension, FALSE);
551  }
552  return;
553 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
__inline ULONGLONG ClasspTimeDiffToMs(ULONGLONG TimeDiff)
Definition: classp.h:1297
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:511
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
USHORT StarvationDuration
Definition: classp.h:915
__inline LARGE_INTEGER ClasspGetCurrentTime(VOID)
Definition: classp.h:1280
LOGICAL ClasspIdleDurationSufficient(IN PCLASS_PRIVATE_FDO_DATA FdoData, OUT LARGE_INTEGER **CurrentTimeIn)
Definition: clntirp.c:406
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
struct tagContext Context
Definition: acpixf.h:1034
LARGE_INTEGER AntiStarvationStartTime
Definition: classp.h:930
static SERVICE_STATUS status
Definition: service.c:31
VOID ClasspServiceIdleRequest(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN PostToDpc)
Definition: clntirp.c:757
LONGLONG QuadPart
Definition: typedefs.h:114
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

◆ ClasspInitializeIdleTimer()

VOID ClasspInitializeIdleTimer ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 175 of file clntirp.c.

178 {
179  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
180  ULONG idleInterval = CLASS_IDLE_INTERVAL;
181  ULONG idlePrioritySupported = TRUE;
182  ULONG activeIdleIoMax = 1;
183 
184  ClassGetDeviceParameter(FdoExtension,
187  &idlePrioritySupported);
188 
189 
190  if (idlePrioritySupported == FALSE) {
191  //
192  // User has set the registry to disable idle priority for this disk.
193  // No need to initialize any further.
194  // Always ensure that none of the other fields used for idle priority
195  // io are ever used without checking if it is supported.
196  //
197  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspInitializeIdleTimer: Idle priority not supported for disk %p\n", FdoExtension));
198  fdoData->IdlePrioritySupported = FALSE;
199  fdoData->IdleIoCount = 0;
200  fdoData->ActiveIoCount = 0;
201  return;
202  }
203 
204  ClassGetDeviceParameter(FdoExtension,
207  &idleInterval);
208 
209  if ((idleInterval < CLASS_IDLE_INTERVAL_MIN) || (idleInterval > USHORT_MAX)) {
210  //
211  // If the interval is too low or too high, reset it to the default value.
212  //
213  idleInterval = CLASS_IDLE_INTERVAL;
214  }
215 
216  fdoData->IdlePrioritySupported = TRUE;
218  KeInitializeTimer(&fdoData->IdleTimer);
220  InitializeListHead(&fdoData->IdleIrpList);
221  fdoData->IdleTimerStarted = FALSE;
223  fdoData->IdleInterval = (USHORT)(idleInterval);
224  fdoData->IdleIoCount = 0;
225  fdoData->ActiveIoCount = 0;
226  fdoData->ActiveIdleIoCount = 0;
227 
228  ClassGetDeviceParameter(FdoExtension,
231  &activeIdleIoMax);
232 
233  activeIdleIoMax = max(activeIdleIoMax, 1);
234  activeIdleIoMax = min(activeIdleIoMax, USHORT_MAX);
235 
236  fdoData->IdleActiveIoMax = (USHORT)activeIdleIoMax;
237 
238  return;
239 }
#define CLASS_STARVATION_INTERVAL
Definition: classp.h:1200
#define max(a, b)
Definition: svc.c:63
#define USHORT_MAX
Definition: intsafe.h:145
#define TRUE
Definition: types.h:120
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define CLASS_IDLE_INTERVAL_MIN
Definition: classp.h:1198
#define CLASSP_REG_SUBKEY_NAME
Definition: cdromp.h:120
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
LIST_ENTRY IdleIrpList
Definition: classp.h:882
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define CLASSP_REG_IDLE_INTERVAL_NAME
Definition: classp.h:119
USHORT StarvationDuration
Definition: classp.h:915
BOOLEAN IdlePrioritySupported
Definition: classp.h:808
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KDEFERRED_ROUTINE ClasspIdleTimerDpc
Definition: clntirp.c:42
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
KSPIN_LOCK IdleListLock
Definition: classp.h:877
#define CLASS_IDLE_INTERVAL
Definition: classp.h:1199
#define CLASSP_REG_IDLE_PRIORITY_SUPPORTED
Definition: classp.h:121
#define CLASSP_REG_IDLE_ACTIVE_MAX
Definition: classp.h:120

Referenced by ClassPnpStartDevice().

◆ ClasspServiceIdleRequest()

VOID ClasspServiceIdleRequest ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
BOOLEAN  PostToDpc 
)

Definition at line 757 of file clntirp.c.

761 {
762  PIRP irp;
763 
765  if (irp != NULL) {
766  ServiceTransferRequest(FdoExtension->DeviceObject, irp, PostToDpc);
767  }
768  return;
769 }
PIRP ClasspDequeueIdleRequest(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: clntirp.c:654
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS ServiceTransferRequest(PDEVICE_OBJECT Fdo, PIRP Irp, BOOLEAN PostToDpc)
Definition: class.c:3341

Referenced by ClasspCompleteIdleRequest(), ClasspEnqueueIdleRequest(), and ClasspIdleTimerDpc().

◆ ClasspStartIdleTimer()

VOID ClasspStartIdleTimer ( IN PCLASS_PRIVATE_FDO_DATA  FdoData)

Definition at line 261 of file clntirp.c.

264 {
265  LARGE_INTEGER dueTime;
266  LONG mstotimer;
267  LONG timerStarted;
268 
269  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspStartIdleTimer: Start idle timer\n"));
270 
271  timerStarted = InterlockedCompareExchange(&FdoData->IdleTimerStarted, 1, 0);
272 
273  if (!timerStarted) {
274 
275  //
276  // Reset the anti-starvation start time.
277  //
278  FdoData->AntiStarvationStartTime = ClasspGetCurrentTime();
279 
280  //
281  // convert milliseconds to a relative 100ns
282  //
283  mstotimer = (-10) * 1000;
284 
285  //
286  // multiply the period
287  //
288  dueTime.QuadPart = Int32x32To64(FdoData->IdleInterval, mstotimer);
289 
290  KeSetTimerEx(&FdoData->IdleTimer,
291  dueTime,
292  FdoData->IdleInterval,
293  &FdoData->IdleDpc);
294  }
295  return;
296 }
#define InterlockedCompareExchange
Definition: interlocked.h:104
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
long LONG
Definition: pedump.c:60
__inline LARGE_INTEGER ClasspGetCurrentTime(VOID)
Definition: classp.h:1280
#define Int32x32To64(a, b)
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by ClasspEnqueueIdleRequest().

◆ ClasspStopIdleTimer()

VOID ClasspStopIdleTimer ( PCLASS_PRIVATE_FDO_DATA  FdoData)

Definition at line 316 of file clntirp.c.

319 {
320  LONG timerStarted;
321 
322  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_TIMER, "ClasspStopIdleTimer: Stop idle timer\n"));
323 
324  timerStarted = InterlockedCompareExchange(&FdoData->IdleTimerStarted, 0, 1);
325 
326  if (timerStarted) {
327  (VOID)KeCancelTimer(&FdoData->IdleTimer);
328  }
329  return;
330 }
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
long LONG
Definition: pedump.c:60
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define VOID
Definition: acefi.h:82

Referenced by ClasspDequeueIdleRequest().

◆ DequeueDeferredClientIrp()

PIRP DequeueDeferredClientIrp ( PDEVICE_OBJECT  Fdo)

Definition at line 113 of file clntirp.c.

116 {
117  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
118  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExtension->PrivateFdoData;
119  PIRP irp;
120 
121  //
122  // The DeferredClientIrpList is almost always empty.
123  // We don't want to grab the spinlock every time we check it (which is on every xfer completion)
124  // so check once first before we grab the spinlock.
125  //
126  if (IsListEmpty(&fdoData->DeferredClientIrpList)){
127  irp = NULL;
128  }
129  else {
130  PLIST_ENTRY listEntry;
131  KIRQL oldIrql;
132 
133  KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
134  if (IsListEmpty(&fdoData->DeferredClientIrpList)){
135  listEntry = NULL;
136  }
137  else {
138  listEntry = RemoveHeadList(&fdoData->DeferredClientIrpList);
139  }
140  KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
141 
142  if (listEntry == NULL) {
143  irp = NULL;
144  }
145  else {
146  irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);
147  NT_ASSERT(irp->Type == IO_TYPE_IRP);
148 
149 
150  InitializeListHead(&irp->Tail.Overlay.ListEntry);
151  }
152  }
153 
154  return irp;
155 }
KSPIN_LOCK SpinLock
Definition: classp.h:795
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY DeferredClientIrpList
Definition: classp.h:777
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define IO_TYPE_IRP
Definition: typedefs.h:119
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by TransferPktComplete().

◆ EnqueueDeferredClientIrp()

VOID EnqueueDeferredClientIrp ( PDEVICE_OBJECT  Fdo,
PIRP  Irp 
)

Definition at line 78 of file clntirp.c.

82 {
84  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExtension->PrivateFdoData;
85  KIRQL oldIrql;
86 
87 
88  KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
89  InsertTailList(&fdoData->DeferredClientIrpList, &Irp->Tail.Overlay.ListEntry);
90 
91 
92  KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
93 }
_In_ PIRP Irp
Definition: csq.h:116
KSPIN_LOCK SpinLock
Definition: classp.h:795
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY DeferredClientIrpList
Definition: classp.h:777
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627

Referenced by ServiceTransferRequest().

Variable Documentation

◆ ClasspIdleTimerDpc

KDEFERRED_ROUTINE ClasspIdleTimerDpc

Definition at line 42 of file clntirp.c.

Referenced by ClasspInitializeIdleTimer().