1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright 2016 Joyent, Inc. 13.\" 14.Dd May 31, 2016 15.Dt MC_IOCTL 9E 16.Os 17.Sh NAME 18.Nm mc_ioctl 19.Nd device specific I/O control operation 20.Sh SYNOPSIS 21.In sys/types.h 22.In sys/stream.h 23.In sys/stropts.h 24.In sys/ddi.h 25.In sys/sunddi.h 26.Ft void 27.Fo prefix_m_ioctl 28.Fa "void *driver" 29.Fa "queue_t *wq" 30.Fa "mblk_t *mp" 31.Fc 32.Sh INTERFACE LEVEL 33illumos DDI Specific 34.Sh PARAMETERS 35.Bl -tag -width Ds 36.It Fa driver 37A pointer to the driver's private data that was passed in via the 38.Sy m_pdata 39member of the 40.Xr mac_register 9S 41structure to the 42.Xr mac_register 9F 43function. 44.It Fa wq 45A pointer to a STREAMS write-side queue that the ioctl request was 46received upon. 47.It Fa mp 48A pointer to a message block structure that contains the I/O control 49request. 50.El 51.Sh DESCRIPTION 52The 53.Fn mc_ioctl 54entry point is an optional GLDv3 entry point. It provides a means 55for device-specific I/O control operations to be initiated. In general, 56this entry point is not recommended for most devices and is 57unimplemented. 58.Pp 59The I/O control interface is not like a traditional character or block 60device's 61.Xr ioctl 9E 62entry point, rather it is a STREAMS-based I/O control operation. The 63data pointer of the 64.Fa mp 65argument is a 66.Xr iocblk 9S 67structure. After handling the message, the driver will need to reply to 68the message, which is usually done by using the 69.Xr miocack 9F 70and 71.Xr miocnak 9F 72functions to prepare 73.Fa mp . 74.Pp 75The device driver can access its soft state by casting the value pointed 76to in 77.Fa driver . 78The driver should be careful and ensure that it performs any necessary 79locking to access members of that structure while processing the I/O 80control operation. 81.Sh RETURN VALUES 82Return information is not conveyed by the return value of this function, rather 83it is encoded in the 84.Xr iocblk 9S 85structure in the 86.Fa mp 87argument. 88.Sh EXAMPLES 89The following example shows how a device driver might structure its 90.Fn mc_ioctl 91entry point. 92.Bd -literal 93#include <sys/types.h> 94#include <sys/stream.h> 95#include <sys/stropts.h> 96#include <sys/ddi.h> 97#include <sys/sunddi.h> 98 99/* 100 * Note, this example merely shows the structure of this function. It does not 101 * actively handle any device-specific ioctls and instead returns failure for 102 * every one. This is the most common case. Note, miocnak(9F) takes care of 103 * calling putnext(9F) for us. 104 */ 105static void 106example_m_ioctl(void *arg, queue_t *wq, mblk_t *mp) 107{ 108 miocnak(wq, mp, 0, EINVAL); 109} 110.Ed 111.Sh SEE ALSO 112.Xr ioctl 9E , 113.Xr mac 9E , 114.Xr put 9E , 115.Xr mac_register 9F , 116.Xr miocack 9F , 117.Xr miocnak 9F , 118.Xr putnext 9F , 119.Xr iocblk 9S , 120.Xr mac_register 9S 121.Rs 122.%T Writing Device Drivers 123.Re 124.Rs 125.%T STREAMS Programming Guide 126.Re 127