]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/network/IOOutputQueue.h
3c685f3e0367d4e3a86a7ca36c1edb81d7dc3139
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
28 * 2-Feb-1999 Joe Liu (jliu) created.
32 #ifndef _IOOUTPUTQUEUE_H
33 #define _IOOUTPUTQUEUE_H
35 #include <IOKit/network/IONetworkInterface.h>
37 // Forward declarations.
42 // FIXME - We do not want the enqueue/dequeue macros defined in queue.h.
44 #undef enqueue(queue,elt)
47 // FIXME - Belongs in IOBasicOutputQueue.h
49 /*! @enum The status of the packet sent to the target.
50 @constant kIOOutputStatusMask Define the status field in the return code.
51 @constant kIOOutputStatusAccept Packet was accepted by the target.
52 @constant kIOOutputStatusDropped Packet accepted, but was also dropped.
53 @constant kIOOutputStatusRetry Target ran out of resources, and is unable
54 to accept the packet. The ownership of the packet reverts back to the
58 kIOOutputStatusMask
= 0x00ff,
59 kIOOutputStatusAccepted
= 0x0000,
60 kIOOutputStatusDropped
= 0x0001,
61 kIOOutputStatusRetry
= 0x0002
64 /*! @enum A command requested by the target.
65 @constant kIOOutputCommandMask Define the command field in the return code.
66 @constant kIOOutputCommandNone No command.
67 @constant kIOOutputCommandStall A command to stall the queue. */
70 kIOOutputCommandMask
= 0xff00,
71 kIOOutputCommandNone
= 0x0000,
72 kIOOutputCommandStall
= 0x0100
75 /*! @enum Definition of common return codes returned by the target's
77 @constant kIOReturnOutputSuccess Packet was accepted.
78 @constant kIOReturnOutputDropped Packet was dropped.
79 @constant kIOReturnOutputStall Stall the queue and retry the same packet
80 when the queue is restarted. */
83 kIOReturnOutputSuccess
= (kIOOutputStatusAccepted
| kIOOutputCommandNone
),
84 kIOReturnOutputDropped
= (kIOOutputStatusDropped
| kIOOutputCommandNone
),
85 kIOReturnOutputStall
= (kIOOutputStatusRetry
| kIOOutputCommandStall
)
88 /*! @class IOOutputQueue : public OSObject
89 @abstract A packet queue that supports multiple producers, and a single
90 consumer. Each producer, or a client thread, will deliver a chain of packets
91 to the queue. A single consumer will remove packets from the queue one at a
92 time and forward it to the registered target/action. This object may be used
93 by an IONetworkController on the output (transmit) side to handle the output
94 packet flow downstream from an IONetworkInterface, and then call the driver's
95 output function. IOOutputQueue is an abstract class that provides an interface
96 for its subclasses. Concrete subclasses will complete the implementation, and
97 specify the context that the target is called for packets removed from
100 class IOOutputQueue
: public OSObject
102 OSDeclareAbstractStructors( IOOutputQueue
)
106 static void runServiceThread(thread_call_param_t
, thread_call_param_t
);
110 thread_call_t _callEntry
; // callout entry structure.
112 struct ExpansionData
{ };
114 Reserved for future use. (Internal use only) */
115 ExpansionData
*_reserved
;
119 @abstract Initialize an IOOutputQueue object.
120 @result true if initialized successfully, false otherwise. */
125 @abstract Free the IOOutputQueue object.
126 @discussion Release allocated resources, then call super::free(). */
130 /*! @function scheduleServiceThread
131 @abstract Schedule a service thread callout.
132 @discussion This method can be called by service() to schedule
133 a thread that will call serviceThread() when it starts running.
134 @param param A parameter to pass to the serviceThread() method.
135 @result true if a thread callout was scheduled, false otherwise. */
137 virtual bool scheduleServiceThread(void * param
);
139 /*! @function cancelServiceThread
140 @abstract Cancel any pending service thread callout.
141 @result true if a previously scheduled thread callout was canceled,
144 virtual bool cancelServiceThread();
146 /*! @function serviceThread
147 @abstract Method called by the scheduled service thread when it
149 @discussion Must be implemented by a subclass that calls
150 scheduleServiceThread(). The default implementation does nothing.
151 @param param A parameter that was given to scheduleServiceThread()
152 when the service thread was scheduled. */
154 virtual void serviceThread(void * param
);
159 @abstract Start up the queue.
160 @discussion Called by the target to start the queue. This will allow
161 packets to be removed from the queue, then delivered to the target.
162 @result true if the queue was started successfully, false otherwise. */
164 virtual bool start() = 0;
167 @abstract Stop the queue.
168 @discussion Stop the queue and prevent it from sending packets to its
170 @result Returns the previous running state of the queue,
171 true if the queue was running, false if the queue was already stopped. */
173 virtual bool stop() = 0;
175 /*! @function service
176 @abstract Service the queue.
177 @discussion Manage the queue after it has been started.
178 @param options Options for the service request.
179 @result A return value to indicate the service result. */
181 virtual bool service(IOOptionBits options
= 0) = 0;
184 @abstract Drop and free all packets currently held by the queue.
185 @result The number of packets that were dropped and freed. */
187 virtual UInt32
flush() = 0;
189 /*! @function setCapacity
190 @abstract Change the number of packets that the queue can hold
191 before it begins to drop excess packets.
192 @param capacity The new desired capacity.
193 @result true if the new capacity was accepted, false otherwise. */
195 virtual bool setCapacity(UInt32 capacity
) = 0;
197 /*! @function getCapacity
198 @abstract Get the number of packets that the queue can hold.
199 @discussion The queue will begin to drop incoming packets when the
200 size of queue reaches its capacity.
201 @result The current queue capacity. */
203 virtual UInt32
getCapacity() const = 0;
205 /*! @function getSize
206 @abstract Get the number of packets currently held in the queue.
207 @result The size of the queue. */
209 virtual UInt32
getSize() const = 0;
211 /*! @function enqueue
212 @abstract Called by a client to add a packet, or a chain of packets,
214 @discussion A packet is described by a mbuf chain, while a chain
215 of packets is constructed by linking multiple mbuf chains via the
217 @param m A single packet, or a chain of packets.
218 @param param A parameter provided by the caller.
219 @result A return code. */
221 virtual UInt32
enqueue(struct mbuf
* m
, void * param
) = 0;
223 /*! @function getOutputHandler
224 @abstract Return the address of a function that is designated to handle
225 incoming packets sent to the queue object.
226 @result The address of the enqueue() method is returned. */
228 virtual IOOutputAction
getOutputHandler() const;
230 /*! @function getStatisticsData
231 @abstract Return an IONetworkData object containing statistics counters
232 updated by the queue.
233 @result An IONetworkData object. This implementation will always return
236 virtual IONetworkData
* getStatisticsData() const;
238 // Virtual function padding
239 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 0);
240 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 1);
241 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 2);
242 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 3);
243 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 4);
244 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 5);
245 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 6);
246 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 7);
247 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 8);
248 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 9);
249 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 10);
250 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 11);
251 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 12);
252 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 13);
253 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 14);
254 OSMetaClassDeclareReservedUnused( IOOutputQueue
, 15);
257 #endif /* !_IOOUTPUTQUEUE_H */