xref: /netbsd/sys/dev/ic/icp_ioctl.h (revision 40de80e3)
1 /*	$NetBSD: icp_ioctl.h,v 1.7 2017/10/28 06:27:32 riastradh Exp $	*/
2 
3 /*
4  *       Copyright (c) 2000-03 Intel Corporation
5  *       All Rights Reserved
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions, and the following disclaimer,
12  *    without modification, immediately at the beginning of the file.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 /*
33  * ioctl interface to ICP-Vortex RAID controllers.  Facilitates use of
34  * ICP's configuration tools.
35  */
36 
37 #ifndef _DEV_IC_ICP_IOCTL_H_
38 #define	_DEV_IC_ICP_IOCTL_H_
39 
40 #include <sys/cdefs.h>
41 #include <sys/types.h>
42 #include <sys/ioccom.h>
43 
44 #include <dev/ic/icpreg.h>
45 
46 #define	GDT_SCRATCH_SZ	3072	/* 3KB scratch buffer */
47 
48 /* general ioctl */
49 typedef struct gdt_ucmd {
50 	u_int16_t	io_node;
51 	u_int16_t	service;
52 	u_int32_t	timeout;
53 	u_int16_t	status;
54 	u_int32_t	info;
55 
56 	struct {
57 		u_int32_t	cmd_boardnode;
58 		u_int32_t	cmd_cmdindex;
59 		u_int16_t	cmd_opcode;
60 
61 		union {
62 			struct icp_rawcmd rc;
63 			struct icp_ioctlcmd ic;
64 			struct icp_cachecmd cc;
65 		} cmd_packet;
66 	} __packed command;
67 
68 	u_int8_t	data[GDT_SCRATCH_SZ];
69 } __packed gdt_ucmd_t;
70 #define	GDT_IOCTL_GENERAL	_IOWR('J', 0, gdt_ucmd_t)
71 
72 /* get driver version */
73 #define	GDT_IOCTL_DRVERS	_IOR('J', 1, int)
74 
75 /* get controller type */
76 typedef struct gdt_ctrt {
77 	u_int16_t	io_node;
78 	u_int16_t	oem_id;
79 	u_int16_t	type;
80 	u_int32_t	info;
81 	u_int8_t	access;
82 	u_int8_t	remote;
83 	u_int16_t	ext_type;
84 	u_int16_t	device_id;
85 	u_int16_t	sub_device_id;
86 } __packed gdt_ctrt_t;
87 #define	GDT_IOCTL_CTRTYPE	_IOWR('J', 2, gdt_ctrt_t)
88 
89 /* get OS version */
90 typedef struct gdt_osv {
91 	u_int8_t	oscode;
92 	u_int8_t	version;
93 	u_int8_t	subversion;
94 	u_int16_t	revision;
95 	char		name[64];
96 } __packed gdt_osv_t;
97 #define	GDT_IOCTL_OSVERS	_IOR('J', 3, gdt_osv_t)
98 
99 /* get controller count */
100 #define	GDT_IOCTL_CTRCNT	_IOR('J', 5, int)
101 
102 /* 6 -- lock host drive? */
103 /* 7 -- lock channel? */
104 
105 /* get event */
106 #define	GDT_ES_ASYNC		1
107 #define	GDT_ES_DRIVER		2
108 #define	GDT_ES_TEST		3
109 #define	GDT_ES_SYNC		4
110 typedef struct {
111 	u_int16_t	size;		/* size of structure */
112 	union {
113 		char		stream[16];
114 		struct {
115 			u_int16_t	ionode;
116 			u_int16_t	service;
117 			u_int32_t	index;
118 		} __packed driver;
119 		struct {
120 			u_int16_t	ionode;
121 			u_int16_t	service;
122 			u_int16_t	status;
123 			u_int32_t	info;
124 			u_int8_t	scsi_coord[3];
125 		} __packed async;
126 		struct {
127 			u_int16_t	ionode;
128 			u_int16_t	service;
129 			u_int16_t	status;
130 			u_int32_t	info;
131 			u_int16_t	hostdrive;
132 			u_int8_t	scsi_coord[3];
133 			u_int8_t	sense_key;
134 		} __packed sync;
135 		struct {
136 			u_int32_t	l1;
137 			u_int32_t	l2;
138 			u_int32_t	l3;
139 			u_int32_t	l4;
140 		} __packed test;
141 	} eu;
142 	u_int32_t	severity;
143 	u_int8_t	event_string[256];
144 } __packed gdt_evt_data;
145 
146 typedef struct {
147 	u_int32_t	first_stamp;
148 	u_int32_t	last_stamp;
149 	u_int16_t	same_count;
150 	u_int16_t	event_source;
151 	u_int16_t	event_idx;
152 	u_int8_t	application;
153 	u_int8_t	reserved;
154 	gdt_evt_data	event_data;
155 } __packed gdt_evt_str;
156 
157 typedef struct gdt_event {
158 	int		erase;
159 	int		handle;
160 	gdt_evt_str	dvr;
161 } __packed gdt_event_t;
162 #define	GDT_IOCTL_EVENT		_IOWR('J', 7, gdt_event_t)
163 
164 /* get statistics */
165 typedef struct gdt_statist {
166 	u_int16_t	io_count_act;
167 	u_int16_t	io_count_max;
168 	u_int16_t	req_queue_act;
169 	u_int16_t	req_queue_max;
170 	u_int16_t	cmd_index_act;
171 	u_int16_t	cmd_index_max;
172 	u_int16_t	sg_count_act;
173 	u_int16_t	sg_count_max;
174 } __packed gdt_statist_t;
175 #define	GDT_IOCTL_STATIST	_IOR('J', 9, gdt_statist_t)
176 
177 /* rescan host drives */
178 typedef struct gdt_rescan {
179 	u_int16_t	io_node;
180 	u_int8_t	flag;
181 	u_int16_t	hdr_no;
182 	struct {
183 		u_int8_t	bus;
184 		u_int8_t	target;
185 		u_int8_t	lun;
186 		u_int8_t	cluster_type;
187 	} __packed hdr_list[ICP_MAX_HDRIVES];
188 } __packed gdt_rescan_t;
189 #define	GDT_IOCTL_RESCAN	_IOWR('J', 11, gdt_rescan_t)
190 
191 #endif /* _DEV_IC_ICP_IOCTL_H_ */
192