[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

npkt_t

Data structure describing a packet

Synopsis:

typedef struct _npkt {
    net_buf      buffers;
    npkt_t       *next;
    void         *org_data;
    uint32_t     flags;
    uint32_t     framelen;
    uint32_t     tot_iov;
    uint32_t     csum_flags;
    uint32_t     ref_cnt;
    uint16_t     req_complete;
    union {
        void     *p;
        unsigned char c [16];
    } inter_module;
} npkt_t;

Description:

A packet consists of an npkt_t structure, which has data buffers associated with it. If the driver wants to create a packet to send upstream, it should call alloc_up_npkt().

A data buffer is described by a structure of type net_buf_t, as defined in <sys/io-net.h>. The data in a buffer is comprised of one or more contiguous fragments. Each fragment is described by a net_iov_t structure (also defined in <sys/io-net.h>) that contains a pointer to the fragment's data, the size of the fragment, and the physical address of the fragment. Note that packets being sent upstream must consist of a single fragment.

The npkt_t structure is defined in <sys/io-net.h>.

The npkt_t structure is the main data structure for a packet. The following fields of the npkt_t structure are of importance to the network driver:

buffers
Points to a queue of data buffers. The buffer queues can be manipulated and traversed by a set of macros defined in <sys/queue.h>. See the examples below for the kind of operations a driver would need to perform on buffer queues.
next
Used for chaining packets into a linked list. The last item in the list is set to NULL.
org_data
For the sole use of the originator of the packet. The driver should only modify or interpret this field if the driver was the originator of the packet.
flags
The logical OR of zero or more of the following:
Note: If you're using the new lightweight Qnet, a network driver developed with releases prior to 6.3 could malfunction because the assignment of the bits in the flags field of the npkt_t structure has changed. See _NPKT_ORG_MASK and _NPKT_SCRATCH_MASK in <sys/io-net.h>.

framelen
The total size of the packet data, in bytes, including the Ethernet header.
tot_iov
The total number of fragments that comprise the packet data. This number must be one for packets being sent upstream.
csum_flags
Used for hardware checksum offloading. See the "Hardware checksum offloading" section in the Writing a Network Driver chapter for more details.
ref_cnt
For packets originating from the driver, this should be set to one.
req_complete
For packets originating from the driver, this should be set to zero.

net_buf_t

A queue of structures of type net_buf_t is used to describe the data fragments that are associated with the packet.

typedef struct _net_buf {
    TAILQ_ENTRY (_net_buf)  ptrs;
    int        niov;
    net_iov_t  *net_iov;
} ;

The members of this structure are as follows:

ptrs
Used by the queue manipulation macros to create queues of buffers.
niov
The number of data fragments associated with the buffer.
net_iov
Points to an array of data structure descriptors.

net_iov_t

The net_iov_t structure is used to describe the data fragment descriptors associated with the packet.

typedef struct _net_iovec {
    void   *iov_base;
    paddr_t iov_phys;
    size_t  iov_len;
} ;

The members of this structure are as follows:

iov_base
Points to the data fragment.
iov_phy
The physical address of the data fragment.
iov_len
The size of the data fragment, in bytes.

Classification:

QNX Neutrino


[Previous] [Contents] [Index] [Next]