1 /* $OpenBSD: safte.h,v 1.9 2020/09/12 15:54:51 krw Exp $ */ 2 3 /* 4 * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _SCSI_SAFTE_H 20 #define _SCSI_SAFTE_H 21 22 /* scsi_inquiry_data.extra */ 23 struct safte_inq { 24 u_int8_t uniqueid[7]; 25 u_int8_t chanid; 26 u_int8_t ident[6]; 27 #define SAFTE_IDENT "SAF-TE" 28 }; 29 30 struct safte_readbuf_cmd { 31 u_int8_t opcode; /* READ_BUFFER */ 32 u_int8_t flags; 33 #define SAFTE_RD_LUNMASK 0xe0 /* the lun should always be 0 */ 34 #define SAFTE_RD_MODEMASK 0x07 35 #define SAFTE_RD_MODE 0x01 /* 0x01 is the SAF-TE command mode */ 36 u_int8_t bufferid; 37 #define SAFTE_RD_CONFIG 0x00 /* enclosure configuration */ 38 #define SAFTE_RD_ENCSTAT 0x01 /* enclosure status */ 39 #define SAFTE_RD_USAGE 0x02 /* usage statistics */ 40 #define SAFTE_RD_INSERTS 0x03 /* device insertions */ 41 #define SAFTE_RD_SLOTSTAT 0x04 /* slot status */ 42 #define SAFTE_RD_GLOBALS 0x05 /* global flags */ 43 u_int32_t reserved1; 44 u_int16_t length; /* transfer length (big endian) */ 45 u_int8_t reserved2; 46 } __packed; 47 48 struct safte_writebuf_cmd { 49 u_int8_t opcode; /* WRITE_BUFFER */ 50 u_int8_t flags; 51 #define SAFTE_WR_LUNMASK 0xe0 /* the lun should always be 0 */ 52 #define SAFTE_WR_MODEMASK 0x07 53 #define SAFTE_WR_MODE 0x01 /* 0x01 is the SAF-TE command mode */ 54 u_int8_t reserved1[5]; 55 u_int16_t length; /* transfer length (big endian) */ 56 u_int8_t reserved2; 57 } __packed; 58 59 #define SAFTE_WRITE_SLOTSTAT 0x10 /* write device slot status */ 60 #define SAFTE_WRITE_SETID 0x11 /* set scsi id */ 61 #define SAFTE_WRITE_SLOTOP 0x12 /* perform slot operation */ 62 #define SAFTE_WRITE_FANSPEED 0x13 /* set fan speed */ 63 #define SAFTE_WRITE_PWRSUP 0x14 /* activate power supply */ 64 #define SAFTE_WRITE_GLOBALS 0x15 /* global flags */ 65 66 67 /* enclosure configuration */ 68 struct safte_config { 69 u_int8_t nfans; /* number of fans */ 70 u_int8_t npwrsup; /* number of power supplies */ 71 u_int8_t nslots; /* number of device slots */ 72 u_int8_t doorlock; /* door lock installed */ 73 u_int8_t ntemps; /* number of temp sensors */ 74 u_int8_t alarm; /* audible alarm installed */ 75 u_int8_t therm; /* temps in C and num of thermostats */ 76 #define SAFTE_CFG_CELSIUSMASK 0x80 77 #define SAFTE_CFG_CELSIUS(a) ((a) & SAFTE_CFG_CELSIUSMASK ? 1 : 0) 78 #define SAFTE_CFG_NTHERMMASK 0x0f 79 #define SAFTE_CFG_NTHERM(a) ((a) & SAFTE_CFG_NTHERMMASK) 80 u_int8_t reserved[56]; /* 7 to 62 */ 81 u_int8_t vendor_bytes; /* number of vendor specific bytes */ 82 } __packed; 83 #define SAFTE_CONFIG_LEN sizeof(struct safte_config) 84 85 /* enclosure status fields */ 86 /* fan status field */ 87 #define SAFTE_FAN_OP 0x00 /* operational */ 88 #define SAFTE_FAN_MF 0x01 /* malfunctioning */ 89 #define SAFTE_FAN_NOTINST 0x02 /* not installed */ 90 #define SAFTE_FAN_UNKNOWN 0x80 /* unknown status or unreportable */ 91 92 /* power supply status field */ 93 #define SAFTE_PWR_OP_ON 0x00 /* operational and on */ 94 #define SAFTE_PWR_OP_OFF 0x01 /* operational and off */ 95 #define SAFTE_PWR_MF_ON 0x10 /* malfunctioning and on */ 96 #define SAFTE_PWR_MF_OFF 0x11 /* malfunctioning and off */ 97 #define SAFTE_PWR_NOTINST 0x20 /* not present */ 98 #define SAFTE_PWR_PRESENT 0x21 /* present */ 99 #define SAFTE_PWR_UNKNOWN 0x80 /* unknown status or unreportable */ 100 101 /* scsi id fields */ 102 /* are integers, not bitfields */ 103 104 /* door lock status */ 105 #define SAFTE_DOOR_LOCKED 0x00 /* locked */ 106 #define SAFTE_DOOR_UNLOCKED 0x01 /* unlocked or uncontrollable */ 107 #define SAFTE_DOOR_UNKNOWN 0x80 /* unknown status or unreportable */ 108 109 /* speaker status */ 110 #define SAFTE_SPKR_OFF 0x00 /* off or not installed */ 111 #define SAFTE_SPKR_ON 0x01 /* speaker is currently on */ 112 113 /* temperature */ 114 #define SAFTE_TEMP_OFFSET -10 /* -10 to 245 degrees */ 115 116 /* temp out of range */ 117 #define SAFTE_TEMP_ETA 0x8000 /* any temp alert */ 118 119 120 /* usage statistics */ 121 struct safte_usage { 122 u_int32_t minutes; /* total number of minutes on */ 123 u_int32_t cycles; /* total number of power cycles */ 124 u_int8_t reserved[7]; 125 u_int8_t vendor_bytes; /* number of vendor specific bytes */ 126 }; 127 128 129 /* device insertions */ 130 /* u_int16_t * nslots */ 131 132 133 /* device slot status */ 134 #define SAFTE_SLOTSTAT_INSERT (1<<0) /* inserted */ 135 #define SAFTE_SLOTSTAT_SWAP (1<<1) /* ready to be inserted/removed */ 136 #define SAFTE_SLOTSTAT_OPER (1<<2) /* ready for operation */ 137 138 139 /* global flags */ 140 struct safte_globals { 141 u_int8_t flags1; 142 #define SAFTE_GLOBAL_ALARM (1<<0) /* audible alarm */ 143 #define SAFTE_GLOBAL_FAILURE (1<<1) /* global failure indication */ 144 #define SAFTE_GLOBAL_WARNING (1<<2) /* global warning indication */ 145 #define SAFTE_GLOBAL_POWER (1<<3) /* enclosure power */ 146 #define SAFTE_GLOBAL_COOLING (1<<4) /* cooling failure */ 147 #define SAFTE_GLOBAL_PWRFAIL (1<<5) /* power failure */ 148 #define SAFTE_GLOBAL_DRVFAIL (1<<6) /* drive failure */ 149 #define SAFTE_GLOBAL_DRVWARN (1<<6) /* drive warning */ 150 u_int8_t flags2; 151 #define SAFTE_GLOBAL_ARRAYFAIL (1<<0) /* array failure */ 152 #define SAFTE_GLOBAL_ARRAYWARN (1<<1) /* array warning */ 153 #define SAFTE_GLOBAL_LOCK (1<<2) /* enclosure lock */ 154 #define SAFTE_GLOBAL_IDENTIFY (1<<3) /* identify enclosure */ 155 u_int8_t flags3; 156 u_int8_t reserved[13]; 157 }; 158 159 160 /* perform slot operation */ 161 struct safte_slotop { 162 u_int8_t opcode; /* SAFTE_WRITE_SLOTOP */ 163 u_int8_t slot; 164 u_int8_t flags; 165 #define SAFTE_SLOTOP_OPERATE (1<<0) /* prepare for operation */ 166 #define SAFTE_SLOTOP_INSREM (1<<1) /* prepare for insert/removal */ 167 #define SAFTE_SLOTOP_IDENTIFY (1<<2) /* identify */ 168 u_int8_t reserved[61]; /* zero these */ 169 } __packed; 170 171 #endif /* _SCSI_SAFTE_H */ 172