ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IOBasicOutputQueue |
Inherits from: | |
Declared In: |
A concrete implementation of an IOOutputQueue.
This object uses a spinlock to protect the packet queue from multiple producers. A single producer is promoted to become a consumer when the queue is not active. Otherwise, the producer will simply queue the packet and return without blocking.
The flow of packets from the queue to its target can be controlled by calling methods such as start(), stop(), or service(). The target is expected to call those methods from a single threaded context, i.e. the work loop context in a network driver. In addition, the target must also return a status for every packet delivered by the consumer thread. This return value is the only mechanism that the target can use to manage the queue when it is running on the consumer thread.
Adds a packet, or a chain of packets, to the queue.
Drops and frees all packets currently held by the queue.
Frees the IOBasicOutputQueue object.
Gets the number of packets that the queue can hold.
Gets the number of packets dropped by the queue.
Gets the number of packets accepted by the target.
Gets the number of instances when the target has refused to accept the packet provided.
Gets the number of packets currently held in the queue.
Gets the number of instances when the target has stalled the queue.
Gets the state of the queue object.
Returns an IONetworkData object containing statistics counters updated by the queue.
Handles an external access to the IONetworkData object returned by getStatisticsData().
Initializes an IOBasicOutputQueue object.
Transfers all packets in the mbuf queue to the target.
Services a queue that was stalled by the target.
Provides an implementation for the serviceThread() method defined in IOOutputQueue.
Changes the number of packets that the queue can hold before it begins to drop excess packets.
Starts up the packet flow between the queue and its target.
Stops the packet flow between the queue and its target.
Factory method that constructs and initializes an IOBasicOutputQueue object.
Factory method that constructs and initializes an IOBasicOutputQueue object.
enqueue |
Adds a packet, or a chain of packets, to the queue.
public
virtual UInt32 enqueue( mbuf_t m, void *param);
m
A single packet, or a chain of packets.
param
A parameter provided by the caller.
Always returns 0.
This method is called by a client to add a packet, or a chain of packets, to the queue. A packet is described by an mbuf chain, while a chain of packets is constructed by linking multiple mbuf chains via the m_nextpkt field. This method can be called by multiple client threads.
flush |
Drops and frees all packets currently held by the queue.
public
virtual UInt32 flush();
Returns the number of packets that were dropped and freed.
To ensure that all packets are removed from the queue, stop() should be called prior to flush(), to make sure there are no packets in-flight and being delivered to the target.
free |
Frees the IOBasicOutputQueue object.
protected
virtual void free();
This function releases allocated resources, then call super::free().
getCapacity |
Gets the number of packets that the queue can hold.
public
virtual UInt32 getCapacity() const;
Returns the current queue capacity.
The queue will begin to drop incoming packets when the size of the queue reaches its capacity.
getDropCount |
Gets the number of packets dropped by the queue.
public
virtual UInt32 getDropCount();
Returns the number of packets dropped due to over-capacity, or by external calls to the flush() method.
getOutputCount |
Gets the number of packets accepted by the target.
public
virtual UInt32 getOutputCount();
Returns the number of times that kIOOutputStatusAccepted is returned by the target.
getRetryCount |
Gets the number of instances when the target has refused to accept the packet provided.
public
virtual UInt32 getRetryCount();
Returns the number of times that kIOOutputStatusRetry is returned by the target.
getSize |
Gets the number of packets currently held in the queue.
public
virtual UInt32 getSize() const;
Returns the size of the queue.
getStallCount |
Gets the number of instances when the target has stalled the queue.
public
virtual UInt32 getStallCount();
Returns the number of times that kIOOutputCommandStall is returned by the target.
getState |
Gets the state of the queue object.
public
virtual UInt32 getState() const;
Returns the current state of the queue object.
getStatisticsData |
Returns an IONetworkData object containing statistics counters updated by the queue.
public
virtual IONetworkData * getStatisticsData() const;
Returns an IONetworkData object.
handleNetworkDataAccess |
Handles an external access to the IONetworkData object returned by getStatisticsData().
protected
virtual IOReturn handleNetworkDataAccess( IONetworkData *data, UInt32 type, void *param);
data
The IONetworkData object being accessed.
type
Description of the type of access being performed.
param
An optional parameter for the handler.
Returns kIOReturnSuccess on success, or an error code otherwise.
init |
Initializes an IOBasicOutputQueue object.
public
virtual bool init( OSObject *target, IOOutputAction action, UInt32 capacity = 0);
target
The object that will handle packets removed from the queue, which is usually a subclass of IONetworkController.
action
The function that will handle packets removed from the queue.
capacity
The initial capacity of the output queue.
Returns true if initialized successfully, false otherwise.
output |
Transfers all packets in the mbuf queue to the target.
protected
virtual void output( IOMbufQueue *queue, UInt32 *state);
queue
A queue of output packets.
state
Returns a state bit defined by IOBasicOutputQueue that declares the new state of the queue following this method call. A kStateStalled is returned if the queue should stall, otherwise 0 is returned.
service |
Services a queue that was stalled by the target.
public
virtual bool service( IOOptionBits options = 0);
Returns true if the queue was stalled and there were packets sitting in the queue awaiting delivery, false otherwise.
A target that stalls the queue must call service() when it becomes ready to accept more packets. Calling this method when the queue is not stalled is harmless.
serviceThread |
Provides an implementation for the serviceThread() method defined in IOOutputQueue.
protected
virtual void serviceThread( void *param);
param
A parameter that was given to scheduleServiceThread(). This parameter is not used.
This method is called by the scheduled service thread when it starts to run. The service thread is scheduled by service() to restart a stalled queue when the kServiceAsync option is given.
setCapacity |
Changes the number of packets that the queue can hold before it begins to drop excess packets.
public
virtual bool setCapacity( UInt32 capacity);
capacity
The new desired capacity.
Returns true if the new capacity was accepted, false otherwise.
start |
Starts up the packet flow between the queue and its target.
public
virtual bool start();
Returns true if the queue was started successfully, false otherwise.
Called by the target to start the queue. This will allow packets to be removed from the queue, and then delivered to the target.
stop |
Stops the packet flow between the queue and its target.
public
virtual bool stop();
Returns the previous running state of the queue, true if the queue was running, false if the queue was already stopped.
This method stops the queue and prevents it from sending packets to its target. This call is synchronous and it may block. After this method returns, the queue will no longer call the registered target/action, even as new packets are added to the queue. The queue will continue to absorb new packets until the size of the queue reaches its capacity. The registered action must never call stop(), or a deadlock will occur.
withTarget(IONetworkController *, UInt32) |
Factory method that constructs and initializes an IOBasicOutputQueue object.
public
static IOBasicOutputQueue * withTarget( IONetworkController *target, UInt32 capacity = 0);
target
An IONetworkController object that will handle packets removed from the queue.
capacity
The initial capacity of the output queue.
Returns an IOBasicOutputQueue object on success, or 0 otherwise.
withTarget(OSObject *, IOOutputAction, UInt32) |
Factory method that constructs and initializes an IOBasicOutputQueue object.
public
static IOBasicOutputQueue * withTarget( OSObject *target, IOOutputAction action, UInt32 capacity = 0);
target
The object that will handle packets removed from the queue.
action
The function that will handle packets removed from the queue.
capacity
The initial capacity of the output queue.
Returns an IOBasicOutputQueue object on success, or 0 otherwise.
GetStateBits |
The bits in the value returned by getState().
public
enum { kStateRunning = 0x1, kStateOutputStalled = 0x2, kStateOutputActive = 0x4, kStateOutputServiceMask = 0xff00 };
kStateRunning
Set when the queue is running. Calling start() and stop() will set or clear this bit.
kStateStalled
Set when the queue is stalled by the target.
kStateActive
Set when a consumer thread is actively removing packets from the queue and passing them to the target.
ServiceAsync |
The option bits recognized by service().
public
enum { kServiceAsync = 0x1 };
kServiceAsync
Set this option to service the queue in an asynchronous manner. The service() call will not block, but a scheduling latency will be introduced before the queue is serviced.
|
Last Updated: 2008-12-19