FreeNOS
|
Networking packet queue implementation. More...
#include <NetworkQueue.h>
Data Structures | |
struct | Packet |
Represents a network packet. More... | |
Public Types | |
typedef struct NetworkQueue::Packet | Packet |
Represents a network packet. More... | |
Public Member Functions | |
NetworkQueue (const Size packetSize, const Size queueSize=MaxPackets) | |
Constructor. More... | |
virtual | ~NetworkQueue () |
Destructor. More... | |
Packet * | get () |
Get unused packet. More... | |
void | release (Packet *packet) |
Put unused packet back. More... | |
void | push (Packet *packet) |
Enqueue packet with data. More... | |
Packet * | pop () |
Retrieve packet with data. More... | |
bool | hasData () const |
Check if data packets are available. More... | |
Static Public Attributes | |
static const Size | PayloadBufferSize = 2048 |
Size of payload memory buffer. More... | |
static const Size | MaxPackets = 64u |
Maximum number of packets available. More... | |
Private Attributes | |
Index< Packet, MaxPackets > | m_free |
Contains unused packets. More... | |
Index< Packet, MaxPackets > | m_data |
Contains packets with data. More... | |
Memory::Range | m_payloadRange |
Defines the memory range of mapped payload data. More... | |
Networking packet queue implementation.
Definition at line 37 of file NetworkQueue.h.
typedef struct NetworkQueue::Packet NetworkQueue::Packet |
Represents a network packet.
NetworkQueue::NetworkQueue | ( | const Size | packetSize, |
const Size | queueSize = MaxPackets |
||
) |
Constructor.
packetSize | The size of each packet in bytes |
queueSize | The size of the queue in number of packets |
Definition at line 23 of file NetworkQueue.cpp.
References Memory::Range::access, assert, NetworkQueue::Packet::data, ERROR, m_free, m_payloadRange, MapContiguous, MaxPackets, PAGESIZE, PayloadBufferSize, Memory::Range::phys, Memory::Readable, SELF, NetworkQueue::Packet::size, Memory::Range::size, API::Success, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.
|
virtual |
Destructor.
Definition at line 58 of file NetworkQueue.cpp.
References m_free, m_payloadRange, Release, SELF, and VMCtl().
NetworkQueue::Packet * NetworkQueue::get | ( | ) |
Get unused packet.
Definition at line 72 of file NetworkQueue.cpp.
References m_free, NetworkQueue::Packet::size, and ZERO.
Referenced by Ethernet::getTransmitPacket(), UDPSocket::process(), and Sun8iEmac::resetReceive().
bool NetworkQueue::hasData | ( | ) | const |
Check if data packets are available.
Definition at line 112 of file NetworkQueue.cpp.
References m_data.
Referenced by UDPSocket::canRead().
NetworkQueue::Packet * NetworkQueue::pop | ( | ) |
Retrieve packet with data.
Definition at line 98 of file NetworkQueue.cpp.
Referenced by UDPSocket::read().
void NetworkQueue::push | ( | NetworkQueue::Packet * | packet | ) |
Enqueue packet with data.
Definition at line 93 of file NetworkQueue.cpp.
References m_data.
Referenced by UDPSocket::process().
void NetworkQueue::release | ( | NetworkQueue::Packet * | packet | ) |
Put unused packet back.
Definition at line 87 of file NetworkQueue.cpp.
References m_free, and NetworkQueue::Packet::size.
Referenced by Sun8iEmac::interrupt(), UDPSocket::read(), and Loopback::transmit().
|
private |
Contains packets with data.
Definition at line 106 of file NetworkQueue.h.
|
private |
Contains unused packets.
Definition at line 103 of file NetworkQueue.h.
Referenced by get(), NetworkQueue(), release(), and ~NetworkQueue().
|
private |
Defines the memory range of mapped payload data.
Definition at line 109 of file NetworkQueue.h.
Referenced by NetworkQueue(), and ~NetworkQueue().
|
static |
Maximum number of packets available.
Definition at line 45 of file NetworkQueue.h.
Referenced by NetSend::exec(), Sun8iEmac::initialize(), NetworkQueue(), MpiProxy::processRecv(), Sun8iEmac::receive(), Sun8iEmac::resetReceive(), Sun8iEmac::resetTransmit(), Sun8iEmac::startDMA(), Sun8iEmac::transmit(), and UDPSocket::write().
|
static |
Size of payload memory buffer.
Definition at line 42 of file NetworkQueue.h.
Referenced by NetSend::exec(), NetworkQueue(), MpiProxy::processRecv(), and UDPSocket::write().