safte.h 6.1 KB

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