]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
24 | * | |
25 | * IOGatedOutputQueue.h | |
26 | * | |
27 | * HISTORY | |
28 | * | |
29 | */ | |
30 | ||
31 | #ifndef _IOGATEDOUTPUTQUEUE_H | |
32 | #define _IOGATEDOUTPUTQUEUE_H | |
33 | ||
34 | #include <IOKit/IOWorkLoop.h> | |
35 | #include <IOKit/IOCommandGate.h> | |
36 | #include <IOKit/IOInterruptEventSource.h> | |
37 | #include <IOKit/network/IOBasicOutputQueue.h> | |
38 | ||
39 | /*! @class IOGatedOutputQueue : public IOBasicOutputQueue | |
40 | @abstract An extension of an IOBasicOutputQueue. An IOCommandGate | |
41 | object is created by this queue and added to a work loop as an | |
42 | event source. All calls to the target by the consumer thread must | |
43 | occur with the gate closed. Therefore, all calls to the target of | |
44 | this type of queue will be serialized with any other thread that | |
45 | runs on the same work loop context. This is useful for network | |
46 | drivers that have a tight hardware coupling between the transmit | |
47 | and receive engines, and a single-threaded hardware access model | |
48 | is desirable. */ | |
49 | ||
50 | class IOGatedOutputQueue : public IOBasicOutputQueue | |
51 | { | |
52 | OSDeclareDefaultStructors( IOGatedOutputQueue ) | |
53 | ||
54 | private: | |
55 | static void gatedOutput(OSObject * owner, | |
56 | IOGatedOutputQueue * self, | |
57 | IOMbufQueue * queue, | |
58 | UInt32 * state); | |
59 | ||
60 | static void restartDeferredOutput(OSObject * owner, | |
61 | IOInterruptEventSource * sender, | |
62 | int count); | |
63 | ||
64 | protected: | |
65 | IOCommandGate * _gate; | |
66 | IOInterruptEventSource * _interruptSrc; | |
67 | ||
68 | /*! @function output | |
69 | @abstract Transfer all packets in the mbuf queue to the target. | |
70 | @param queue A queue of output packets. | |
71 | @param state Return a state bit defined by IOBasicOutputQueue that | |
72 | declares the new state of the queue following this method call. | |
73 | A kStateStalled is returned if the queue should stall, otherwise 0 | |
74 | is returned. */ | |
75 | ||
76 | virtual void output(IOMbufQueue * queue, UInt32 * state); | |
77 | ||
78 | /*! @function free | |
79 | @abstract Free the IOGatedOutputQueue object. | |
80 | @discussion Release allocated resources, then call super::free(). */ | |
81 | ||
82 | virtual void free(); | |
83 | ||
84 | /*! @function output | |
85 | @abstract Override the method inherited from IOOutputQueue. | |
86 | @result true if a thread was successfully scheduled to service | |
87 | the queue. */ | |
88 | ||
89 | virtual bool scheduleServiceThread(void * param); | |
90 | ||
91 | public: | |
92 | ||
93 | /*! @function init | |
94 | @abstract Initialize an IOGatedOutputQueue object. | |
95 | @param target The object that will handle packets removed from the | |
96 | queue, and is usually a subclass of IONetworkController. | |
97 | @param action The function that will handle packets removed from the | |
98 | queue. | |
99 | @param workloop A workloop object. An IOCommandGate object is created | |
100 | and added to this workloop as an event source. | |
101 | @param capacity The initial capacity of the output queue. | |
102 | @result true if initialized successfully, false otherwise. */ | |
103 | ||
104 | virtual bool init(OSObject * target, | |
105 | IOOutputAction action, | |
106 | IOWorkLoop * workloop, | |
107 | UInt32 capacity = 0); | |
108 | ||
109 | /*! @function withTarget | |
110 | @abstract Factory method that will construct and initialize an | |
111 | IOGatedOutputQueue object. | |
112 | @param target An IONetworkController object that will handle packets | |
113 | removed from the queue. | |
114 | @param workloop A workloop object. An IOCommandGate object is created | |
115 | and added to this workloop as an event source. | |
116 | @param capacity The initial capacity of the output queue. | |
117 | @result An IOGatedOutputQueue object on success, or 0 otherwise. */ | |
118 | ||
119 | static IOGatedOutputQueue * withTarget(IONetworkController * target, | |
120 | IOWorkLoop * workloop, | |
121 | UInt32 capacity = 0); | |
122 | ||
123 | /*! @function withTarget | |
124 | @abstract Factory method that will construct and initialize an | |
125 | IOGatedOutputQueue object. | |
126 | @param target The object that will handle packets removed from the | |
127 | queue. | |
128 | @param action The function that will handle packets removed from the | |
129 | queue. | |
130 | @param workloop A workloop object. An IOCommandGate object is created | |
131 | and added to this workloop as an event source. | |
132 | @param capacity The initial capacity of the output queue. | |
133 | @result An IOGatedOutputQueue object on success, or 0 otherwise. */ | |
134 | ||
135 | static IOGatedOutputQueue * withTarget(OSObject * target, | |
136 | IOOutputAction action, | |
137 | IOWorkLoop * workloop, | |
138 | UInt32 capacity = 0); | |
139 | }; | |
140 | ||
141 | #endif /* !_IOGATEDOUTPUTQUEUE_H */ |