npkt_t
![]() |
![]() |
![]() |
![]() |
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:

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>. - _NPKT_NOT_TXED -- if the driver couldn't transmit a packet, for whatever reason, it should set this flag before calling tx_done to indicate the packet is known to have been dropped.
- _NPKT_UP -- should be set for packets originating from the driver.
- _NPKT_MSG -- indicates that the packet doesn't contain data, but rather contains a message. A driver will set this flag when it sends a capabilities message upstream.
- _NPKT_PROMISC -- the upper 12 bits of the flags
field are reserved for the driver's internal purposes.
The driver can use the eight most significant bits while it's processing a packet. The driver shouldn't make assumptions about the state of these bits when it receives a packet from the upper layers.
The next four most significant bits are for the use of the originator of a packet. The driver can use these flags for packets being sent upstream. If a packet didn't originate with the driver, the driver must not alter these flags.
- 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]](prev.gif)
![[Contents]](contents.gif)
![[Index]](keyword_index.gif)
![[Next]](next.gif)