root/scsi/safte.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /*      $OpenBSD: safte.h,v 1.6 2006/01/08 06:28:42 dlg 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 #define SAFTE_EXTRA_OFFSET      0x05
   23 /* scsi_inquiry_data.extra */
   24 struct safte_inq {
   25         u_int8_t        uniqueid[7];
   26         u_int8_t        chanid;
   27         u_int8_t        ident[6];
   28 #define SAFTE_IDENT             "SAF-TE"
   29         u_int8_t        revision[4];
   30 #ifdef notyet
   31         u_int8_t        reserved[2];
   32 #endif
   33 } __packed;
   34 #define SAFTE_INQ_LEN           54
   35 
   36 struct safte_readbuf_cmd {
   37         u_int8_t        opcode;         /* READ_BUFFER */
   38         u_int8_t        flags;
   39 #define SAFTE_RD_LUNMASK        0xe0    /* the lun should always be 0 */
   40 #define SAFTE_RD_MODEMASK       0x07
   41 #define SAFTE_RD_MODE           0x01    /* 0x01 is the SAF-TE command mode */
   42         u_int8_t        bufferid;
   43 #define SAFTE_RD_CONFIG         0x00    /* enclosure configuration */
   44 #define SAFTE_RD_ENCSTAT        0x01    /* enclosure status */
   45 #define SAFTE_RD_USAGE          0x02    /* usage statistics */
   46 #define SAFTE_RD_INSERTS        0x03    /* device insertions */
   47 #define SAFTE_RD_SLOTSTAT       0x04    /* slot status */
   48 #define SAFTE_RD_GLOBALS        0x05    /* global flags */
   49         u_int32_t       reserved1;
   50         u_int16_t       length;         /* transfer length (big endian) */
   51         u_int8_t        reserved2;
   52 } __packed;
   53 
   54 struct safte_writebuf_cmd {
   55         u_int8_t        opcode;         /* WRITE_BUFFER */
   56         u_int8_t        flags;
   57 #define SAFTE_WR_LUNMASK        0xe0    /* the lun should always be 0 */
   58 #define SAFTE_WR_MODEMASK       0x07
   59 #define SAFTE_WR_MODE           0x01    /* 0x01 is the SAF-TE command mode */
   60         u_int8_t        reserved1[5];
   61         u_int16_t       length;         /* transfer length (big endian) */
   62         u_int8_t        reserved2;
   63 } __packed;
   64 
   65 #define SAFTE_WRITE_SLOTSTAT    0x10    /* write device slot status */
   66 #define SAFTE_WRITE_SETID       0x11    /* set scsi id */
   67 #define SAFTE_WRITE_SLOTOP      0x12    /* perform slot operation */
   68 #define SAFTE_WRITE_FANSPEED    0x13    /* set fan speed */
   69 #define SAFTE_WRITE_PWRSUP      0x14    /* activate power supply */
   70 #define SAFTE_WRITE_GLOBALS     0x15    /* global flags */
   71 
   72 
   73 /* enclosure configuration */
   74 struct safte_config {
   75         u_int8_t        nfans;          /* number of fans */
   76         u_int8_t        npwrsup;        /* number of power supplies */
   77         u_int8_t        nslots;         /* number of device slots */
   78         u_int8_t        doorlock;       /* door lock installed */
   79         u_int8_t        ntemps;         /* number of temp sensors */
   80         u_int8_t        alarm;          /* audible alarm installed */
   81         u_int8_t        therm;          /* temps in C and num of thermostats */
   82 #define SAFTE_CFG_CELSIUSMASK   0x80
   83 #define SAFTE_CFG_CELSIUS(a)    ((a) & SAFTE_CFG_CELSIUSMASK ? 1 : 0)
   84 #define SAFTE_CFG_NTHERMMASK    0x0f
   85 #define SAFTE_CFG_NTHERM(a)     ((a) & SAFTE_CFG_NTHERMMASK)
   86         u_int8_t        reserved[56]; /* 7 to 62 */
   87         u_int8_t        vendor_bytes;   /* number of vendor specific bytes */
   88 } __packed;
   89 #define SAFTE_CONFIG_LEN        sizeof(struct safte_config)
   90 
   91 /* enclosure status fields */
   92 /* fan status field */
   93 #define SAFTE_FAN_OP            0x00    /* operational */
   94 #define SAFTE_FAN_MF            0x01    /* malfunctioning */
   95 #define SAFTE_FAN_NOTINST       0x02    /* not installed */
   96 #define SAFTE_FAN_UNKNOWN       0x80    /* unknown status or unreportable */
   97 
   98 /* power supply status field */
   99 #define SAFTE_PWR_OP_ON         0x00    /* operational and on */
  100 #define SAFTE_PWR_OP_OFF        0x01    /* operational and off */
  101 #define SAFTE_PWR_MF_ON         0x10    /* malfunctioning and on */
  102 #define SAFTE_PWR_MF_OFF        0x11    /* malfunctioning and off */
  103 #define SAFTE_PWR_NOTINST       0x20    /* not present */
  104 #define SAFTE_PWR_PRESENT       0x21    /* present */
  105 #define SAFTE_PWR_UNKNOWN       0x80    /* unknown status or unreportable */
  106 
  107 /* scsi id fields */
  108 /* are integers, not bitfields */
  109 
  110 /* door lock status */
  111 #define SAFTE_DOOR_LOCKED       0x00    /* locked */
  112 #define SAFTE_DOOR_UNLOCKED     0x01    /* unlocked or uncontrollable */
  113 #define SAFTE_DOOR_UNKNOWN      0x80    /* unknown status or unreportable */
  114 
  115 /* speaker status */
  116 #define SAFTE_SPKR_OFF          0x00    /* off or not installed */
  117 #define SAFTE_SPKR_ON           0x01    /* speaker is currently on */
  118 
  119 /* temperature */
  120 #define SAFTE_TEMP_OFFSET       -10     /* -10 to 245 degrees */
  121 
  122 /* temp out of range */
  123 #define SAFTE_TEMP_ETA          0x8000  /* any temp alert */
  124 
  125 
  126 /* usage statistics */
  127 struct safte_usage {
  128         u_int32_t       minutes;        /* total number of minutes on */
  129         u_int32_t       cycles;         /* total number of power cycles */
  130         u_int8_t        reserved[7];
  131         u_int8_t        vendor_bytes;   /* number of vendor specific bytes */
  132 };
  133 
  134 
  135 /* device insertions */
  136 /* u_int16_t * nslots */
  137 
  138 
  139 /* device slot status */
  140 #define SAFTE_SLOTSTAT_INSERT   (1<<0)  /* inserted */
  141 #define SAFTE_SLOTSTAT_SWAP     (1<<1)  /* ready to be inserted/removed */
  142 #define SAFTE_SLOTSTAT_OPER     (1<<2)  /* ready for operation */
  143 
  144 
  145 /* global flags */
  146 struct safte_globals {
  147         u_int8_t        flags1;
  148 #define SAFTE_GLOBAL_ALARM      (1<<0)  /* audible alarm */
  149 #define SAFTE_GLOBAL_FAILURE    (1<<1)  /* global failure indication */
  150 #define SAFTE_GLOBAL_WARNING    (1<<2)  /* global warning indication */
  151 #define SAFTE_GLOBAL_POWER      (1<<3)  /* enclosure power */
  152 #define SAFTE_GLOBAL_COOLING    (1<<4)  /* cooling failure */
  153 #define SAFTE_GLOBAL_PWRFAIL    (1<<5)  /* power failure */
  154 #define SAFTE_GLOBAL_DRVFAIL    (1<<6)  /* drive failure */
  155 #define SAFTE_GLOBAL_DRVWARN    (1<<6)  /* drive warning */
  156         u_int8_t        flags2;
  157 #define SAFTE_GLOBAL_ARRAYFAIL  (1<<0)  /* array failure */
  158 #define SAFTE_GLOBAL_ARRAYWARN  (1<<1)  /* array warning */
  159 #define SAFTE_GLOBAL_LOCK       (1<<2)  /* enclosure lock */
  160 #define SAFTE_GLOBAL_IDENTIFY   (1<<3)  /* identify enclosure */
  161         u_int8_t        flags3;
  162         u_int8_t        reserved[13];
  163 };
  164 
  165 
  166 /*  perform slot operation */
  167 struct safte_slotop {
  168         u_int8_t        opcode;         /* SAFTE_WRITE_SLOTOP */
  169         u_int8_t        slot;
  170         u_int8_t        flags;
  171 #define SAFTE_SLOTOP_OPERATE    (1<<0)  /* prepare for operation */
  172 #define SAFTE_SLOTOP_INSREM     (1<<1)  /* prepare for insert/removal */
  173 #define SAFTE_SLOTOP_IDENTIFY   (1<<2)  /* identify */
  174         u_int8_t        reserved[61];   /* zero these */
  175 } __packed;
  176 
  177 #endif /* _SCSI_SAFTE_H_ */

/* [<][>][^][v][top][bottom][index][help] */