Home | History | Annotate | Line # | Download | only in dev
biovar.h revision 1.5
      1 /*	$NetBSD: biovar.h,v 1.5 2007/12/07 11:51:21 xtraeme 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 #include <sys/types.h>
     37 
     38 struct bio_common {
     39 	void		*bc_cookie;
     40 };
     41 
     42 /* convert name to a cookie */
     43 #define BIOCLOCATE _IOWR('B', 0, struct bio_locate)
     44 struct bio_locate {
     45 	void		*bl_cookie;
     46 	char		*bl_name;
     47 };
     48 
     49 #ifdef _KERNEL
     50 int	bio_register(struct device *, int (*)(struct device *, u_long, void *));
     51 void	bio_unregister(struct device *);
     52 #endif
     53 
     54 #define BIOCINQ _IOWR('B', 32, struct bioc_inq)
     55 struct bioc_inq {
     56 	void		*bi_cookie;
     57 
     58 	char		bi_dev[16];	/* controller device */
     59 	int		bi_novol;	/* nr of volumes */
     60 	int		bi_nodisk;	/* nr of total disks */
     61 };
     62 
     63 #define BIOCDISK _IOWR('B', 33, struct bioc_disk)
     64 /* structure that represents a disk in a RAID volume */
     65 struct bioc_disk {
     66 	void		*bd_cookie;
     67 
     68 	uint16_t	bd_channel;
     69 	uint16_t	bd_target;
     70 	uint16_t	bd_lun;
     71 	uint16_t	bd_other_id;	/* unused for now  */
     72 
     73 	int		bd_volid;	/* associate with volume */
     74 	int		bd_diskid;	/* virtual disk */
     75 	int		bd_status;	/* current status */
     76 #define BIOC_SDONLINE		0x00
     77 #define BIOC_SDONLINE_S		"Online"
     78 #define BIOC_SDOFFLINE		0x01
     79 #define BIOC_SDOFFLINE_S	"Offline"
     80 #define BIOC_SDFAILED		0x02
     81 #define BIOC_SDFAILED_S 	"Failed"
     82 #define BIOC_SDREBUILD		0x03
     83 #define BIOC_SDREBUILD_S	"Rebuild"
     84 #define BIOC_SDHOTSPARE		0x04
     85 #define BIOC_SDHOTSPARE_S	"Hot spare"
     86 #define BIOC_SDUNUSED		0x05
     87 #define BIOC_SDUNUSED_S		"Unused"
     88 #define BIOC_SDSCRUB		0x06
     89 #define BIOC_SDSCRUB_S		"Scrubbing"
     90 #define BIOC_SDINVALID		0xff
     91 #define BIOC_SDINVALID_S	"Invalid"
     92 	uint64_t	bd_size;	/* size of the disk */
     93 
     94 	char		bd_vendor[32];	/* scsi string */
     95 	char		bd_serial[32];	/* serial number */
     96 	char		bd_procdev[16];	/* processor device */
     97 };
     98 
     99 #define BIOCVOL _IOWR('B', 34, struct bioc_vol)
    100 /* structure that represents a RAID volume */
    101 struct bioc_vol {
    102 	void		*bv_cookie;
    103 	int		bv_volid;	/* volume id */
    104 
    105 	int16_t		bv_percent;	/* percent done operation */
    106 	uint16_t	bv_seconds;	/* seconds of progress so far */
    107 
    108 	int		bv_status;	/* current status */
    109 #define BIOC_SVONLINE		0x00
    110 #define BIOC_SVONLINE_S		"Online"
    111 #define BIOC_SVOFFLINE		0x01
    112 #define BIOC_SVOFFLINE_S	"Offline"
    113 #define BIOC_SVDEGRADED		0x02
    114 #define BIOC_SVDEGRADED_S	"Degraded"
    115 #define BIOC_SVBUILDING		0x03
    116 #define BIOC_SVBUILDING_S	"Building"
    117 #define BIOC_SVSCRUB		0x04
    118 #define BIOC_SVSCRUB_S		"Scrubbing"
    119 #define BIOC_SVREBUILD		0x05
    120 #define BIOC_SVREBUILD_S	"Rebuild"
    121 #define BIOC_SVMIGRATING	0x06
    122 #define BIOC_SVMIGRATING_S	"Migrating"
    123 #define BIOC_SVINVALID		0xff
    124 #define BIOC_SVINVALID_S	"Invalid"
    125 	uint64_t	bv_size;	/* size of the disk */
    126 	int		bv_level;	/* raid level */
    127 	int		bv_nodisk;	/* nr of drives */
    128 
    129 	char		bv_dev[16];	/* device */
    130 	char		bv_vendor[32];	/* scsi string */
    131 };
    132 
    133 #define BIOCALARM _IOWR('B', 35, struct bioc_alarm)
    134 struct bioc_alarm {
    135 	void		*ba_cookie;
    136 	int		ba_opcode;
    137 
    138 	int		ba_status;	/* only used with get state */
    139 #define BIOC_SADISABLE		0x00	/* disable alarm */
    140 #define BIOC_SAENABLE		0x01	/* enable alarm */
    141 #define BIOC_SASILENCE		0x02	/* silence alarm */
    142 #define BIOC_GASTATUS		0x03	/* get status */
    143 #define BIOC_SATEST		0x04	/* test alarm */
    144 };
    145 
    146 #define BIOCBLINK _IOWR('B', 36, struct bioc_blink)
    147 struct bioc_blink {
    148 	void		*bb_cookie;
    149 	uint16_t	bb_channel;
    150 	uint16_t	bb_target;
    151 
    152 	int		bb_status;	/* current status */
    153 #define BIOC_SBUNBLINK		0x00	/* disable blinking */
    154 #define BIOC_SBBLINK		0x01	/* enable blink */
    155 #define BIOC_SBALARM		0x02	/* enable alarm blink */
    156 };
    157 
    158 #define BIOCSETSTATE _IOWR('B', 37, struct bioc_setstate)
    159 struct bioc_setstate {
    160 	void		*bs_cookie;
    161 	uint16_t	bs_channel;
    162 	uint16_t	bs_target;
    163 	uint16_t	bs_lun;
    164 	uint16_t	bs_other_id;	/* unused for now  */
    165 
    166 	int		bs_status;	/* change to this status */
    167 #define BIOC_SSONLINE		0x00	/* online disk */
    168 #define BIOC_SSOFFLINE		0x01	/* offline disk */
    169 #define BIOC_SSHOTSPARE		0x02	/* mark as hotspare */
    170 #define BIOC_SSREBUILD		0x03	/* rebuild on this disk */
    171 	int		bs_volid;	/* volume id for rebuild */
    172 };
    173 
    174 #define BIOCCREATERAID _IOWR('B', 38, struct bioc_createraid)
    175 struct bioc_createraid {
    176 	void		*bc_cookie;
    177 	char		*bc_dev_list;
    178 	uint16_t	bc_dev_list_len;
    179 	uint16_t	bc_level;
    180 };
    181 
    182 /* kernel and userspace defines */
    183 #define BIOC_INQ		0x0001
    184 #define BIOC_DISK		0x0002
    185 #define BIOC_VOL		0x0004
    186 #define BIOC_ALARM		0x0008
    187 #define BIOC_BLINK		0x0010
    188 #define BIOC_SETSTATE		0x0020
    189 #define BIOC_CREATERAID		0x0040
    190 
    191 /* user space defines */
    192 #define BIOC_DEVLIST		0x10000
    193