STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
Data Structures
Chapter 4
62
Data Structures
A STREAMS module or driver must define and initialize three data structures — module_info, qinit, and
streamtab. An optional module_stat structure can also be defined and initialized. In addition to these data
structures, HP-UX requires all modules and drivers to define streams_info_t. Drivers must define
drv_info_t and drv_ops_t.
DLKM modules require additional data structures to be defined. These are described in the “DLKM
STREAMS” section.
The module_info Structure
The module_info structure provides the information about a module or driver. The information in this
structure is shared between both the read and write queues:
unsigned short mi_idnum; /* module ID number */
char * mi_idname; /* module name */
long mi_minpsz; /* min packet size use */
long mi_maxpsz; /* max packet size use */
ulong mi_hiwat; /* high water mark, for flow control */
ulong mi_lowat; /* low water mark, for flow control */
mi_idnum
Represents a number used to identify the module or driver. When this field is set to zero,
STREAMS assigns a unique number. If it is set by the driver or module, case, STREAMS
cannot ensure a unique number. The mi_idnum can be used by user processes and the
STREAMS driver or modules in tracing events and logging errors as specified in strlog (7).
See Appendix B, “STREAMS Utilities Supported by HP-UX.
mi_idname
Is a pointer to an array of characters representing a unique name. The name identifies the
module or driver. This parameter is set by the module or driver developer. STREAMS
truncates the extra characters if the name exceeds FMNAMESZ.
mi_minpsz and mi_maxpsz
The minimum and maximum packet size of an M_DATA message that are accepted by a
module or driver. These values are copied onto q_minpsz and q_maxpsz during open (), for a
driver or the push () for a module.
These limits are used by the stream head when sending messages downstream. The stream
head uses q_maxpsz of the top most module to fragment the data, if required, for large
writes. These are advisory limits between modules and drivers.
mi_hiwat and mi_lowat
The values represent the flow control parameters for a queue. These values represent the
maximum and minimum number of bytes that can be put onto the message queues. They
are copied onto q_hiwat and q_lowat, respectively.