MC_IOCTL(9E) Driver Entry Points MC_IOCTL(9E)

NAME


mc_ioctl - device specific I/O control operation

SYNOPSIS


#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

void
prefix_m_ioctl(void *driver, queue_t *wq, mblk_t *mp);

INTERFACE LEVEL


illumos DDI Specific

PARAMETERS


driver A pointer to the driver's private data that was passed in via
the m_pdata member of the mac_register(9S) structure to the
mac_register(9F) function.

wq A pointer to a STREAMS write-side queue that the ioctl request
was received upon.

mp A pointer to a message block structure that contains the I/O
control request.

DESCRIPTION


The mc_ioctl() entry point is an optional GLDv3 entry point. It
provides a means for device-specific I/O control operations to be
initiated. In general, this entry point is not recommended for most
devices and is unimplemented.

The I/O control interface is not like a traditional character or block
device's ioctl(9E) entry point, rather it is a STREAMS-based I/O
control operation. The data pointer of the mp argument is a iocblk(9S)
structure. After handling the message, the driver will need to reply
to the message, which is usually done by using the miocack(9F) and
miocnak(9F) functions to prepare mp.

The device driver can access its soft state by casting the value
pointed to in driver. The driver should be careful and ensure that it
performs any necessary locking to access members of that structure
while processing the I/O control operation.

RETURN VALUES


Return information is not conveyed by the return value of this
function, rather it is encoded in the iocblk(9S) structure in the mp
argument.

EXAMPLES


The following example shows how a device driver might structure its
mc_ioctl() entry point.

#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

/*
* Note, this example merely shows the structure of this function. It does not
* actively handle any device-specific ioctls and instead returns failure for
* every one. This is the most common case. Note, miocnak(9F) takes care of
* calling putnext(9F) for us.
*/
static void
example_m_ioctl(void *arg, queue_t *wq, mblk_t *mp)
{
miocnak(wq, mp, 0, EINVAL);
}

SEE ALSO


ioctl(9E), mac(9E), put(9E), mac_register(9F), miocack(9F),
miocnak(9F), putnext(9F), iocblk(9S), mac_register(9S)

Writing Device Drivers.

STREAMS Programming Guide.

illumos May 31, 2016 illumos

tribblix@gmail.com :: GitHub :: Privacy