Home | History | Annotate | Line # | Download | only in dev
biovar.h revision 1.1.18.6
      1 /*	$NetBSD: biovar.h,v 1.1.18.6 2008/03/17 09:14:37 yamt 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 
     41 #ifndef _KERNEL
     42 #include <stdbool.h>
     43 #endif
     44 
     45 struct bio_common {
     46 	void		*bc_cookie;
     47 };
     48 
     49 /* convert name to a cookie */
     50 #define BIOCLOCATE _IOWR('B', 0, struct bio_locate)
     51 struct bio_locate {
     52 	void		*bl_cookie;
     53 	char		*bl_name;
     54 };
     55 
     56 #ifdef _KERNEL
     57 int	bio_register(struct device *, int (*)(struct device *, u_long, void *));
     58 void	bio_unregister(struct device *);
     59 #endif
     60 
     61 #define BIOCINQ _IOWR('B', 32, struct bioc_inq)
     62 struct bioc_inq {
     63 	void		*bi_cookie;
     64 
     65 	char		bi_dev[16];	/* controller device */
     66 	int		bi_novol;	/* nr of volumes */
     67 	int		bi_nodisk;	/* nr of total disks */
     68 };
     69 
     70 #define BIOCDISK_NOVOL 	_IOWR('b', 38, struct bioc_disk)
     71 #define BIOCDISK 	_IOWR('B', 33, struct bioc_disk)
     72 /* structure that represents a disk in a RAID volume */
     73 struct bioc_disk {
     74 	void		*bd_cookie;
     75 
     76 	uint16_t	bd_channel;
     77 	uint16_t	bd_target;
     78 	uint16_t	bd_lun;
     79 	uint16_t	bd_other_id;	/* unused for now  */
     80 
     81 	int		bd_volid;	/* associate with volume */
     82 	int		bd_diskid;	/* virtual disk */
     83 	int		bd_status;	/* current status */
     84 #define BIOC_SDONLINE		0x00
     85 #define BIOC_SDONLINE_S		"Online"
     86 #define BIOC_SDOFFLINE		0x01
     87 #define BIOC_SDOFFLINE_S	"Offline"
     88 #define BIOC_SDFAILED		0x02
     89 #define BIOC_SDFAILED_S 	"Failed"
     90 #define BIOC_SDREBUILD		0x03
     91 #define BIOC_SDREBUILD_S	"Rebuild"
     92 #define BIOC_SDHOTSPARE		0x04
     93 #define BIOC_SDHOTSPARE_S	"Hot spare"
     94 #define BIOC_SDUNUSED		0x05
     95 #define BIOC_SDUNUSED_S		"Unused"
     96 #define BIOC_SDSCRUB		0x06
     97 #define BIOC_SDSCRUB_S		"Scrubbing"
     98 #define BIOC_SDPASSTHRU 	0x07
     99 #define BIOC_SDPASSTHRU_S 	"Pass through"
    100 #define BIOC_SDINVALID		0xff
    101 #define BIOC_SDINVALID_S	"Invalid"
    102 	uint64_t	bd_size;	/* size of the disk */
    103 
    104 	char		bd_vendor[32];	/* scsi string */
    105 	char		bd_serial[32];	/* serial number */
    106 	char		bd_procdev[16];	/* processor device */
    107 
    108 	bool		bd_disknovol;	/* disk not associated with volumes */
    109 };
    110 
    111 /* COMPATIBILITY */
    112 #ifdef _KERNEL
    113 #define OBIOCDISK	_IOWR('B', 33, struct obioc_disk)
    114 /* structure that represents a disk in a RAID volume (compat) */
    115 struct obioc_disk {
    116 	void 		*bd_cookie;
    117 	uint16_t	bd_channel;
    118 	uint16_t 	bd_target;
    119 	uint16_t 	bd_lun;
    120 	uint16_t 	bd_other_id;
    121 	int 		bd_volid;
    122 	int 		bd_diskid;
    123 	int 		bd_status;
    124 	uint64_t 	bd_size;
    125 	char 		bd_vendor[32];
    126 	char 		bd_serial[32];
    127 	char 		bd_procdev[16];
    128 };
    129 #endif
    130 
    131 #define BIOCVOL _IOWR('B', 34, struct bioc_vol)
    132 /* structure that represents a RAID volume */
    133 struct bioc_vol {
    134 	void		*bv_cookie;
    135 	int		bv_volid;	/* volume id */
    136 
    137 	int16_t		bv_percent;	/* percent done operation */
    138 	uint16_t	bv_seconds;	/* seconds of progress so far */
    139 
    140 	int		bv_status;	/* current status */
    141 #define BIOC_SVONLINE		0x00
    142 #define BIOC_SVONLINE_S		"Online"
    143 #define BIOC_SVOFFLINE		0x01
    144 #define BIOC_SVOFFLINE_S	"Offline"
    145 #define BIOC_SVDEGRADED		0x02
    146 #define BIOC_SVDEGRADED_S	"Degraded"
    147 #define BIOC_SVBUILDING		0x03
    148 #define BIOC_SVBUILDING_S	"Building"
    149 #define BIOC_SVSCRUB		0x04
    150 #define BIOC_SVSCRUB_S		"Scrubbing"
    151 #define BIOC_SVREBUILD		0x05
    152 #define BIOC_SVREBUILD_S	"Rebuild"
    153 #define BIOC_SVMIGRATING	0x06
    154 #define BIOC_SVMIGRATING_S	"Migrating"
    155 #define BIOC_SVCHECKING 	0x07
    156 #define BIOC_SVCHECKING_S	"Checking"
    157 #define BIOC_SVINVALID		0xff
    158 #define BIOC_SVINVALID_S	"Invalid"
    159 	uint64_t	bv_size;	/* size of the disk */
    160 	int		bv_level;	/* raid level */
    161 #define BIOC_SVOL_RAID01	0x0e
    162 #define BIOC_SVOL_RAID10	0x1e
    163 #define BIOC_SVOL_UNUSED	0xaa
    164 #define BIOC_SVOL_HOTSPARE	0xbb
    165 #define BIOC_SVOL_PASSTHRU	0xcc
    166 
    167 	int		bv_nodisk;	/* nr of drives */
    168 
    169 	char		bv_dev[16];	/* device */
    170 	char		bv_vendor[32];	/* scsi string */
    171 
    172 	uint16_t	bv_stripe_size;	/* stripe size */
    173 };
    174 
    175 /* COMPATIBILITY */
    176 #ifdef _KERNEL
    177 #define OBIOCVOL _IOWR('B', 34, struct obioc_vol)
    178 /* structure that represents a RAID volume */
    179 struct obioc_vol {
    180 	void 		*bv_cookie;
    181 	int 		bv_volid;
    182 	int16_t 	bv_percent;
    183 	uint16_t 	bv_seconds;
    184 	int 		bv_status;
    185 	uint64_t 	bv_size;
    186 	int 		bv_level;
    187 	int 		bv_nodisk;
    188 	char 		bv_dev[16];
    189 	char 		bv_vendor[32];
    190 };
    191 #endif
    192 
    193 #define BIOCALARM _IOWR('B', 35, struct bioc_alarm)
    194 struct bioc_alarm {
    195 	void		*ba_cookie;
    196 	int		ba_opcode;
    197 
    198 	int		ba_status;	/* only used with get state */
    199 #define BIOC_SADISABLE		0x00	/* disable alarm */
    200 #define BIOC_SAENABLE		0x01	/* enable alarm */
    201 #define BIOC_SASILENCE		0x02	/* silence alarm */
    202 #define BIOC_GASTATUS		0x03	/* get status */
    203 #define BIOC_SATEST		0x04	/* test alarm */
    204 };
    205 
    206 #define BIOCBLINK _IOWR('B', 36, struct bioc_blink)
    207 struct bioc_blink {
    208 	void		*bb_cookie;
    209 	uint16_t	bb_channel;
    210 	uint16_t	bb_target;
    211 
    212 	int		bb_status;	/* current status */
    213 #define BIOC_SBUNBLINK		0x00	/* disable blinking */
    214 #define BIOC_SBBLINK		0x01	/* enable blink */
    215 #define BIOC_SBALARM		0x02	/* enable alarm blink */
    216 };
    217 
    218 #define BIOCSETSTATE _IOWR('B', 37, struct bioc_setstate)
    219 struct bioc_setstate {
    220 	void		*bs_cookie;
    221 	uint16_t	bs_channel;
    222 	uint16_t	bs_target;
    223 	uint16_t	bs_lun;
    224 	uint16_t	bs_other_id;	/* unused for now  */
    225 
    226 	int		bs_status;	/* change to this status */
    227 #define BIOC_SSONLINE		0x00	/* online disk */
    228 #define BIOC_SSOFFLINE		0x01	/* offline disk */
    229 #define BIOC_SSHOTSPARE		0x02	/* mark as hotspare */
    230 #define BIOC_SSREBUILD		0x03	/* rebuild on this disk */
    231 #define BIOC_SSDELHOTSPARE	0x04	/* unmark as hotspare */
    232 #define BIOC_SSPASSTHRU 	0x05	/* mark as pass-through */
    233 #define BIOC_SSDELPASSTHRU	0x06	/* unmark as pass-through */
    234 #define BIOC_SSCHECKSTART_VOL	0x07	/* start consistency check in vol# */
    235 #define BIOC_SSCHECKSTOP_VOL	0x08	/* stop consistency check in vol# */
    236 	int		bs_volid;	/* volume id for rebuild */
    237 };
    238 
    239 #define BIOCVOLOPS _IOWR('B', 39, struct bioc_volops)
    240 struct bioc_volops {
    241 	void		*bc_cookie;
    242 	uint64_t	bc_size;	/* size of the volume set */
    243 	uint64_t	bc_other_id;	/* unused for now */
    244 	uint32_t	bc_devmask;	/* device mask for the volume set */
    245 
    246 	uint16_t	bc_channel;
    247 	uint16_t	bc_target;
    248 	uint16_t	bc_lun;
    249 	uint16_t 	bc_stripe;	/* stripe size */
    250 	uint16_t	bc_level;	/* RAID level requested */
    251 
    252 	int 		bc_opcode;
    253 #define BIOC_VCREATE_VOLUME	0x00	/* create new volume */
    254 #define BIOC_VREMOVE_VOLUME	0x01	/* remove volume */
    255 	int 		bc_volid;	/* volume id to be created/removed */
    256 };
    257 
    258 #endif /* ! _DEV_BIOVAR_H_ */
    259