xref: /netbsd-src/sys/dev/biovar.h (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1 /*	$NetBSD: biovar.h,v 1.8 2009/05/07 12:15:33 cegger Exp $ */
2 /*	$OpenBSD: biovar.h,v 1.26 2007/03/19 03:02:08 marco Exp $	*/
3 
4 /*
5  * Copyright (c) 2002 Niklas Hallqvist.  All rights reserved.
6  * Copyright (c) 2005 Marco Peereboom.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
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  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /*
30  * Devices getting ioctls through this interface should use ioctl class 'B'
31  * and command numbers starting from 32, lower ones are reserved for generic
32  * ioctls.  All ioctl data must be structures which start with a void *
33  * cookie.
34  */
35 
36 #ifndef _DEV_BIOVAR_H_
37 #define _DEV_BIOVAR_H_
38 
39 #include <sys/types.h>
40 #include <sys/device.h>
41 
42 #ifndef _KERNEL
43 #include <stdbool.h>
44 #endif
45 
46 struct bio_common {
47 	void		*bc_cookie;
48 };
49 
50 /* convert name to a cookie */
51 #define BIOCLOCATE _IOWR('B', 0, struct bio_locate)
52 struct bio_locate {
53 	void		*bl_cookie;
54 	char		*bl_name;
55 };
56 
57 #ifdef _KERNEL
58 int	bio_register(device_t, int (*)(device_t, u_long, void *));
59 void	bio_unregister(device_t);
60 #endif
61 
62 #define BIOCINQ _IOWR('B', 32, struct bioc_inq)
63 struct bioc_inq {
64 	void		*bi_cookie;
65 
66 	char		bi_dev[16];	/* controller device */
67 	int		bi_novol;	/* nr of volumes */
68 	int		bi_nodisk;	/* nr of total disks */
69 };
70 
71 #define BIOCDISK_NOVOL 	_IOWR('b', 38, struct bioc_disk)
72 #define BIOCDISK 	_IOWR('B', 33, struct bioc_disk)
73 /* structure that represents a disk in a RAID volume */
74 struct bioc_disk {
75 	void		*bd_cookie;
76 
77 	uint16_t	bd_channel;
78 	uint16_t	bd_target;
79 	uint16_t	bd_lun;
80 	uint16_t	bd_other_id;	/* unused for now  */
81 
82 	int		bd_volid;	/* associate with volume */
83 	int		bd_diskid;	/* virtual disk */
84 	int		bd_status;	/* current status */
85 #define BIOC_SDONLINE		0x00
86 #define BIOC_SDONLINE_S		"Online"
87 #define BIOC_SDOFFLINE		0x01
88 #define BIOC_SDOFFLINE_S	"Offline"
89 #define BIOC_SDFAILED		0x02
90 #define BIOC_SDFAILED_S 	"Failed"
91 #define BIOC_SDREBUILD		0x03
92 #define BIOC_SDREBUILD_S	"Rebuild"
93 #define BIOC_SDHOTSPARE		0x04
94 #define BIOC_SDHOTSPARE_S	"Hot spare"
95 #define BIOC_SDUNUSED		0x05
96 #define BIOC_SDUNUSED_S		"Unused"
97 #define BIOC_SDSCRUB		0x06
98 #define BIOC_SDSCRUB_S		"Scrubbing"
99 #define BIOC_SDPASSTHRU 	0x07
100 #define BIOC_SDPASSTHRU_S 	"Pass through"
101 #define BIOC_SDINVALID		0xff
102 #define BIOC_SDINVALID_S	"Invalid"
103 	uint64_t	bd_size;	/* size of the disk */
104 
105 	char		bd_vendor[32];	/* scsi string */
106 	char		bd_serial[32];	/* serial number */
107 	char		bd_procdev[16];	/* processor device */
108 
109 	bool		bd_disknovol;	/* disk not associated with volumes */
110 };
111 
112 /* COMPATIBILITY */
113 #ifdef _KERNEL
114 #define OBIOCDISK	_IOWR('B', 33, struct obioc_disk)
115 /* structure that represents a disk in a RAID volume (compat) */
116 struct obioc_disk {
117 	void 		*bd_cookie;
118 	uint16_t	bd_channel;
119 	uint16_t 	bd_target;
120 	uint16_t 	bd_lun;
121 	uint16_t 	bd_other_id;
122 	int 		bd_volid;
123 	int 		bd_diskid;
124 	int 		bd_status;
125 	uint64_t 	bd_size;
126 	char 		bd_vendor[32];
127 	char 		bd_serial[32];
128 	char 		bd_procdev[16];
129 };
130 #endif
131 
132 #define BIOCVOL _IOWR('B', 34, struct bioc_vol)
133 /* structure that represents a RAID volume */
134 struct bioc_vol {
135 	void		*bv_cookie;
136 	int		bv_volid;	/* volume id */
137 
138 	int16_t		bv_percent;	/* percent done operation */
139 	uint16_t	bv_seconds;	/* seconds of progress so far */
140 
141 	int		bv_status;	/* current status */
142 #define BIOC_SVONLINE		0x00
143 #define BIOC_SVONLINE_S		"Online"
144 #define BIOC_SVOFFLINE		0x01
145 #define BIOC_SVOFFLINE_S	"Offline"
146 #define BIOC_SVDEGRADED		0x02
147 #define BIOC_SVDEGRADED_S	"Degraded"
148 #define BIOC_SVBUILDING		0x03
149 #define BIOC_SVBUILDING_S	"Building"
150 #define BIOC_SVSCRUB		0x04
151 #define BIOC_SVSCRUB_S		"Scrubbing"
152 #define BIOC_SVREBUILD		0x05
153 #define BIOC_SVREBUILD_S	"Rebuild"
154 #define BIOC_SVMIGRATING	0x06
155 #define BIOC_SVMIGRATING_S	"Migrating"
156 #define BIOC_SVCHECKING 	0x07
157 #define BIOC_SVCHECKING_S	"Checking"
158 #define BIOC_SVINVALID		0xff
159 #define BIOC_SVINVALID_S	"Invalid"
160 	uint64_t	bv_size;	/* size of the disk */
161 	int		bv_level;	/* raid level */
162 #define BIOC_SVOL_RAID01	0x0e
163 #define BIOC_SVOL_RAID10	0x1e
164 #define BIOC_SVOL_UNUSED	0xaa
165 #define BIOC_SVOL_HOTSPARE	0xbb
166 #define BIOC_SVOL_PASSTHRU	0xcc
167 
168 	int		bv_nodisk;	/* nr of drives */
169 
170 	char		bv_dev[16];	/* device */
171 	char		bv_vendor[32];	/* scsi string */
172 
173 	uint16_t	bv_stripe_size;	/* stripe size */
174 };
175 
176 /* COMPATIBILITY */
177 #ifdef _KERNEL
178 #define OBIOCVOL _IOWR('B', 34, struct obioc_vol)
179 /* structure that represents a RAID volume */
180 struct obioc_vol {
181 	void 		*bv_cookie;
182 	int 		bv_volid;
183 	int16_t 	bv_percent;
184 	uint16_t 	bv_seconds;
185 	int 		bv_status;
186 	uint64_t 	bv_size;
187 	int 		bv_level;
188 	int 		bv_nodisk;
189 	char 		bv_dev[16];
190 	char 		bv_vendor[32];
191 };
192 #endif
193 
194 #define BIOCALARM _IOWR('B', 35, struct bioc_alarm)
195 struct bioc_alarm {
196 	void		*ba_cookie;
197 	int		ba_opcode;
198 
199 	int		ba_status;	/* only used with get state */
200 #define BIOC_SADISABLE		0x00	/* disable alarm */
201 #define BIOC_SAENABLE		0x01	/* enable alarm */
202 #define BIOC_SASILENCE		0x02	/* silence alarm */
203 #define BIOC_GASTATUS		0x03	/* get status */
204 #define BIOC_SATEST		0x04	/* test alarm */
205 };
206 
207 #define BIOCBLINK _IOWR('B', 36, struct bioc_blink)
208 struct bioc_blink {
209 	void		*bb_cookie;
210 	uint16_t	bb_channel;
211 	uint16_t	bb_target;
212 
213 	int		bb_status;	/* current status */
214 #define BIOC_SBUNBLINK		0x00	/* disable blinking */
215 #define BIOC_SBBLINK		0x01	/* enable blink */
216 #define BIOC_SBALARM		0x02	/* enable alarm blink */
217 };
218 
219 #define BIOCSETSTATE _IOWR('B', 37, struct bioc_setstate)
220 struct bioc_setstate {
221 	void		*bs_cookie;
222 	uint16_t	bs_channel;
223 	uint16_t	bs_target;
224 	uint16_t	bs_lun;
225 	uint16_t	bs_other_id;	/* unused for now  */
226 
227 	int		bs_status;	/* change to this status */
228 #define BIOC_SSONLINE		0x00	/* online disk */
229 #define BIOC_SSOFFLINE		0x01	/* offline disk */
230 #define BIOC_SSHOTSPARE		0x02	/* mark as hotspare */
231 #define BIOC_SSREBUILD		0x03	/* rebuild on this disk */
232 #define BIOC_SSDELHOTSPARE	0x04	/* unmark as hotspare */
233 #define BIOC_SSPASSTHRU 	0x05	/* mark as pass-through */
234 #define BIOC_SSDELPASSTHRU	0x06	/* unmark as pass-through */
235 #define BIOC_SSCHECKSTART_VOL	0x07	/* start consistency check in vol# */
236 #define BIOC_SSCHECKSTOP_VOL	0x08	/* stop consistency check in vol# */
237 	int		bs_volid;	/* volume id for rebuild */
238 };
239 
240 #define BIOCVOLOPS _IOWR('B', 39, struct bioc_volops)
241 struct bioc_volops {
242 	void		*bc_cookie;
243 	uint64_t	bc_size;	/* size of the volume set */
244 	uint64_t	bc_other_id;	/* unused for now */
245 	uint32_t	bc_devmask;	/* device mask for the volume set */
246 
247 	uint16_t	bc_channel;
248 	uint16_t	bc_target;
249 	uint16_t	bc_lun;
250 	uint16_t 	bc_stripe;	/* stripe size */
251 	uint16_t	bc_level;	/* RAID level requested */
252 
253 	int 		bc_opcode;
254 #define BIOC_VCREATE_VOLUME	0x00	/* create new volume */
255 #define BIOC_VREMOVE_VOLUME	0x01	/* remove volume */
256 	int 		bc_volid;	/* volume id to be created/removed */
257 };
258 
259 #endif /* ! _DEV_BIOVAR_H_ */
260