STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
Data Structures
Chapter 4
63
The qinit Structure
The qinit structure is as follows:
int (*qi_putp) __((queue_t *, mblk_t *)); /* put procedure */
int (*qi_srvp) __((queue_t *)); /* service procedure */
int (*qi_qopen)(); /* open procedure */
int (*qi_qclose)(); /* close procedure */
int (*qi_qadmin) __((void)); /* qadmin routine */
struct module_info * qi_minfo; /* module info */
struct module_stat * qi_mstat; /* module stat */
The qinit structure defines the queue procedures; put(), service(), open(), close(), and admin(). The qinit data
structure also contains pointers to module_info and an optional module_stat structure.
NOTE The qi_mstat functionality is not supported by the STREAMS subsystem. This should be set to
NULL. Drivers or modules must not modify the contents of this structure.
Contents of the qinit structure can be shared between the read and write queues. However, modules or
drivers must define qi_open, qi_qclose, and qi_minfo in the read side qinit structure. Each queue must
define a put procedure in its qinit structure. For a driver, the read side put procedure can be set to NULL.
The streamtab structure is as follows:
struct qinit * st_rdinit; /* read side of a module/non-mux driver */
struct qinit * st_wrinit; /* write side of a module/non-mux driver */
struct qinit * st_muxrinit; /* lower read side of a mux driver */
struct qinit * st_muxwinit; /* lower write side of a mux driver */
For modules and non-multiplexing drivers, only the first two fields are valid and set the remaining two fields
to NULL. The first two fields represent the qinit structures of the read and write queues.
For multiplexing drivers, the first two fields contain the address of the read-side or write-side qinit
structures of an upper multiplexor. The next two entries contain the address of the read-side or write-side
qinit structures of a lower multiplexor.
The streamtab structure must be a globally accessible and should not be defined with a static type qualifier.
The modules or driver must not modify the contents of this structure at run time.
The module_stat Structure
The module_stat structure is optional and it can be used to hold statistics about a driver or module. The
STREAMS subsystem does not provide services to set or access the information in the module_stat structure
as follows:
long ms_pcnt; /* count of calls to put proc */
long ms_scnt; /* count of calls to service proc */
long ms_ocnt; /* count of calls to open proc */
long ms_ccnt; /* count of calls to close proc */
long ms_acnt; /* count of calls to admin proc */
char * ms_xptr; /* pointer to private statistics */
short ms_xsize; /* length of private statistics buffer */