xref: /reactos/sdk/include/ddk/rxworkq.h (revision c2c66aff)
1 #ifndef _RXWORKQ_H_
2 #define _RXWORKQ_H_
3 
4 typedef
5 VOID
6 (NTAPI *PRX_WORKERTHREAD_ROUTINE) (
7     _In_ PVOID Context);
8 
9 typedef struct _RX_WORK_QUEUE_ITEM_
10 {
11      WORK_QUEUE_ITEM;
12      PRDBSS_DEVICE_OBJECT pDeviceObject;
13 } RX_WORK_QUEUE_ITEM, *PRX_WORK_QUEUE_ITEM;
14 
15 typedef struct _RX_WORK_DISPATCH_ITEM_
16 {
17    RX_WORK_QUEUE_ITEM WorkQueueItem;
18    PRX_WORKERTHREAD_ROUTINE DispatchRoutine;
19    PVOID DispatchRoutineParameter;
20 } RX_WORK_DISPATCH_ITEM, *PRX_WORK_DISPATCH_ITEM;
21 
22 typedef enum _RX_WORK_QUEUE_STATE_
23 {
24    RxWorkQueueActive,
25    RxWorkQueueInactive,
26    RxWorkQueueRundownInProgress
27 } RX_WORK_QUEUE_STATE, *PRX_WORK_QUEUE_STATE;
28 
29 typedef struct _RX_WORK_QUEUE_RUNDOWN_CONTEXT_
30 {
31    KEVENT RundownCompletionEvent;
32    LONG NumberOfThreadsSpunDown;
33    PETHREAD *ThreadPointers;
34 } RX_WORK_QUEUE_RUNDOWN_CONTEXT, *PRX_WORK_QUEUE_RUNDOWN_CONTEXT;
35 
36 typedef struct _RX_WORK_QUEUE_
37 {
38    USHORT State;
39    BOOLEAN SpinUpRequestPending;
40    UCHAR Type;
41    KSPIN_LOCK SpinLock;
42    PRX_WORK_QUEUE_RUNDOWN_CONTEXT pRundownContext;
43    volatile LONG NumberOfWorkItemsDispatched;
44    volatile LONG NumberOfWorkItemsToBeDispatched;
45    LONG CumulativeQueueLength;
46    LONG NumberOfSpinUpRequests;
47    LONG MaximumNumberOfWorkerThreads;
48    LONG MinimumNumberOfWorkerThreads;
49    volatile LONG NumberOfActiveWorkerThreads;
50    volatile LONG NumberOfIdleWorkerThreads;
51    LONG NumberOfFailedSpinUpRequests;
52    volatile LONG WorkQueueItemForSpinUpWorkerThreadInUse;
53    RX_WORK_QUEUE_ITEM WorkQueueItemForTearDownWorkQueue;
54    RX_WORK_QUEUE_ITEM WorkQueueItemForSpinUpWorkerThread;
55    RX_WORK_QUEUE_ITEM WorkQueueItemForSpinDownWorkerThread;
56    KQUEUE Queue;
57    PETHREAD *ThreadPointers;
58 } RX_WORK_QUEUE, *PRX_WORK_QUEUE;
59 
60 typedef struct _RX_WORK_QUEUE_DISPATCHER_
61 {
62    RX_WORK_QUEUE WorkQueue[RxMaximumWorkQueue];
63 } RX_WORK_QUEUE_DISPATCHER, *PRX_WORK_QUEUE_DISPATCHER;
64 
65 typedef enum _RX_DISPATCHER_STATE_
66 {
67    RxDispatcherActive,
68    RxDispatcherInactive
69 } RX_DISPATCHER_STATE, *PRX_DISPATCHER_STATE;
70 
71 typedef struct _RX_DISPATCHER_
72 {
73    LONG NumberOfProcessors;
74    PEPROCESS OwnerProcess;
75    PRX_WORK_QUEUE_DISPATCHER pWorkQueueDispatcher;
76    RX_DISPATCHER_STATE State;
77    LIST_ENTRY SpinUpRequests;
78    KSPIN_LOCK SpinUpRequestsLock;
79    KEVENT SpinUpRequestsEvent;
80    KEVENT SpinUpRequestsTearDownEvent;
81 } RX_DISPATCHER, *PRX_DISPATCHER;
82 
83 NTSTATUS
84 NTAPI
85 RxPostToWorkerThread(
86     _In_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject,
87     _In_ WORK_QUEUE_TYPE WorkQueueType,
88     _In_ PRX_WORK_QUEUE_ITEM pWorkQueueItem,
89     _In_ PRX_WORKERTHREAD_ROUTINE Routine,
90     _In_ PVOID pContext);
91 
92 NTSTATUS
93 NTAPI
94 RxDispatchToWorkerThread(
95     _In_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject,
96     _In_ WORK_QUEUE_TYPE WorkQueueType,
97     _In_ PRX_WORKERTHREAD_ROUTINE Routine,
98     _In_ PVOID pContext);
99 
100 NTSTATUS
101 NTAPI
102 RxInitializeDispatcher(
103     VOID);
104 
105 NTSTATUS
106 RxInitializeMRxDispatcher(
107      _Inout_ PRDBSS_DEVICE_OBJECT pMRxDeviceObject);
108 
109 #endif
110