Main data structure for a packet
typedef struct _npkt {
TAILQ_HEAD(, _net_buf) buffers;
npkt_t *next;
void *io_net0;
void *org_data;
uint32_t flags;
uint32_t framelen;
uint32_t tot_iov;
uint32_t io_net1;
uint32_t ref_cnt;
uint16_t num_complete;
uint16_t req_complete;
uint16_t cell;
uint16_t endpoint;
uint16_t iface;
uint16_t skip;
union {
void *p;
unsigned char c [16];
} inter_module;
} npkt_t;
// This field follows the structure implicitly:
npkt_done_t c [];
The npkt_t structure is the main data structure for a packet.
The fields include:
- buffers
- A queue of buffers, managed using the TAILQ*() macros from
<sys/queue.h>.
- next
- A pointer to the next npkt_t.
Modules can use this pointer to queue packets.
- io_net0, io_net1, ref_cnt
- Internal to io-net, don't examine or modify.
- org_data
- For the exclusive use of the originator of this npkt_t.
No one else should touch this member.
- flags
- The status of the buffer.
This is a combination of the following bits:
- _NPKT_NOT_TXED -- the packet hasn't actually
been transmitted.
- _NPKT_NO_RES -- the up producer that originated
the packet wants its buffer back right away.
If the up producer that originates the packet sets this flag, the
up producer's
tx_done()
function is guaranteed to be called by the time io-net's
tx_done()
has returned.
The implication is that the up producer can reuse the buffer right away.
It's more efficient not to set this flag.
- _NPKT_UP -- the npkt_t is headed in
the up direction; down if this bit isn't set.
- _NPKT_MSG -- this message is intended for a
different layer, rather than actually containing packet data.
- _NPKT_MSG_DYING -- when a driver is unmounted,
io-net synthesizes a npkt_t structure with
the flags set to _NPKT_MSG | _NPKT_MSG_DYING, and
sends it up as though it came from the driver.
It has no data in it.
It means this cell, endpoint, and all
ifaces are gone.
- _NPKT_BCAST -- a broadcast packet.
- _NPKT_MCAST -- a multicast packet.
- _NPKT_INTERNAL -- internal to io-net.
The originator of the packet can use the top 12 bits as it sees fit.
_NPKT_ORG_MASK is a mask that you can use to get just these
bits.
- framelen
- The total length of the entire packet.
- tot_iov
- The total number of iovs in the packet.
- num_complete
- The number of elements in the npkt_done_t array that
implicitly immediately follows this structure.
- req_complete
- The required number of npkt_done_t elements this
downward-headed packet required before it reached its final destination.
This member is for information purposes only (read-only) in the
originator's tx_done() function if the originator isn't using
io-net's alloc_down_pkt() function.
- cell
- The cell to or from which the npkt_t is headed.
- endpoint
- The endpoint within the cell.
- iface
- The interface within the endpoint.
- skip
- For use by _REG_FILTER_BELOW types of modules.
The idea is that they can receive a packet from above, modify it somehow,
stuff their reg_hdl in the skip
member, and return TX_DOWN_AGAIN (from
<sys/io-net.h>) from their rx_down() function.
The down producer sees TX_DOWN_AGAIN and resends it
down (after recalculating the checksum, rerouting, etc.), but this
time, the _REG_FILTER_BELOW is skipped by
io-net.
The down producer has to support the TX_DOWN_AGAIN
return code.
- inter_module.p, inter_module.c
- A data area that can be used by any module to pass information to the
module above or below it.
The npkt_t is implicitly followed immediately by an
array, c, of npkt_done_t structures.
On a downward-headed transmission, this array is num_complete
elements long, whereas on an upward-headed transmission, it's always 1
element long.
QNX