![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Functions in io-net that your driver can call
typedef struct _io_net_self { int *(reg); int *(dereg) (...); void (*alloc) (...); npkt_t *(alloc_up_npkt) (...); int (*free) (...); paddr_t (*mphys) (...); npkt_t (*tx_up_start) (...); int (*tx_done) (...); int (*devctl) (...); } io_net_self_t;
![]() |
The driver should always use the function table to call these functions. In addition, the driver should use a pointer to the function table that was passed to its primary entry point rather than copying the table or caching individual function pointers. The function pointers can change during the interface's lifetime. |
The io_net_self_t structure points to functions that allow your driver to call back into the networking framework.
The functions are described below.
This function registers an interface with io-net. It should be called once for each NIC interface that the driver wishes to instantiate.
![]() |
This function must be called before any of the other functions in the io_net_self_t structure. |
The prototype is:
int (*reg) (void *dll_hdl, io_net_registrant_t *registrant, int *reg_hdlp, uint16_t *cell, uint16_t *endpoint)
The arguments are:
This function returns:
The prototype is:
int (*dereg) (int registrant_hdl)
Deregister an interface from io-net. Typically, this function is called only if the driver encounters an error after registering with io-net and wishes to undo the registration.
The registrant_hdl argument is the registrant handle that was filled in via the reg_hdlp parameter when your driver registered by calling the reg() callback.
This function returns EOK on success, or an error code.
The prototype is:
void *(*alloc) (size_t size, int flags)
This function allocates a buffer of the given size that's safe to pass to any other module. It's typically used to allocate buffers to store data that's received from the medium.
The size parameter specifies the amount of memory, in bytes, that's to be allocated.
There are currently no flags defined.
This function returns a pointer to the allocated memory, or NULL if an error occurred.
The prototype is:
npkt_t *(*alloc_up_npkt) (size_t size, void **data)
Allocates an npkt_t structure suitable to deliver packet data upstream. This function allocates only the structures that describe the packet data, and not the packet data itself.
The arguments are:
The additional allocated data can be used to hold buffer descriptor (net_buf_t()) structures, and iov_t() structures, that point to the packet data. Note that the memory for the npkt_t() structure and the additional data will be allocated as a contiguous block of memory, and should be freed with a single call (as opposed to being freed piecemeal.)
This function returns a pointer to the allocated structure, or NULL if an error occurred.
The prototype is:
int (*free) (void *ptr)
This function frees a buffer, pointed to by ptr, that was allocated by the alloc() or alloc_up_npkt() callbacks.
This function returns:
The prototype is:
paddr_t (*mphys) (void *ptr)
This function does a quick lookup of the physical address of the memory, pointed to by ptr, that was allocated by either alloc(), or alloc_up_npkt().
This function returns the physical address of the buffer on success, or -1 if an error occurred (errno is set).
The prototype is:
npkt_t *(*tx_up_start) (int registrant_hdl, nptk_t *npkt, int off, int framelen_sub, uint16_t cell, uint16_t endpoint, uint16_t iface, void *tx_done_hdl)
A function used to send data packet and advertisement messages upstream. This function can be called from the driver's receive event-handler. Note that the thread that calls this function could re-enter the driver through one of its entry points. Be careful not to hold locks when calling this function; one of the driver's entry points could attempt to reacquire them. Note that for all packets sent upstream, the data must be contained in a single fragment.
The arguments are:
This function returns NULL upon success. If this is non-NULL, errno is set, and a linked list of npkt structures for which a tx_done() callback couldn't be registered (i.e. for which reg_tx_done() failed) is returned. The driver should immediately release (or reuse) any packets that are returned in this way.
The prototype is:
int (*tx_done) (int registrant_hdl, npkt_t *npkt)
Notifies the packet's originator that the packet is ready for release or reuse. When the packet data has been copied or transmitted, the driver's transmit routine calls this function. This function should also be called if your driver decides to discard the packet rather than attempt to transmit it.
The registrant_hdl argument is the registrant handle that was filled in when your driver registered by calling io-net's reg() callback. The npkt argument points to a linked list of packets that the driver has finished processing.
This function returns:
The prototype is:
int (*devctl) (int registrant_hdl, int dcmd, void *data, size_t size, int *ret)
Send a devctl() (device control) command to io-net.
The arguments are:
This function returns EOK on success, or an error code.
QNX Neutrino
![]() |
![]() |
![]() |
![]() |