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