1 /* $FreeBSD$ */ 2 /*- 3 * Copyright (c) 2000 by Matthew Jacob 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer, 11 * without modification, immediately at the beginning of the file. 12 * 2. The name of the author may not be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * Alternatively, this software may be distributed under the terms of the 16 * the GNU Public License ("GPL"). 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 */ 31 #ifndef _SCSI_ENC_H_ 32 #define _SCSI_ENC_H_ 33 34 #include <cam/scsi/scsi_ses.h> 35 36 #define ENCIOC ('s' - 040) 37 #define ENCIOC_GETNELM _IO(ENCIOC, 1) 38 #define ENCIOC_GETELMMAP _IO(ENCIOC, 2) 39 #define ENCIOC_GETENCSTAT _IO(ENCIOC, 3) 40 #define ENCIOC_SETENCSTAT _IO(ENCIOC, 4) 41 #define ENCIOC_GETELMSTAT _IO(ENCIOC, 5) 42 #define ENCIOC_SETELMSTAT _IO(ENCIOC, 6) 43 #define ENCIOC_GETTEXT _IO(ENCIOC, 7) 44 #define ENCIOC_INIT _IO(ENCIOC, 8) 45 #define ENCIOC_GETELMDESC _IO(ENCIOC, 9) 46 #define ENCIOC_GETELMDEVNAMES _IO(ENCIOC, 10) 47 #define ENCIOC_GETSTRING _IO(ENCIOC, 11) 48 #define ENCIOC_SETSTRING _IO(ENCIOC, 12) 49 50 /* 51 * Platform Independent Definitions for enclosure devices. 52 */ 53 /* 54 * SCSI Based Environmental Services Application Defines 55 * 56 * Based almost entirely on SCSI-3 ENC Revision 8A specification, 57 * but slightly abstracted as the underlying device may in fact 58 * be a SAF-TE or vendor unique device. 59 */ 60 /* 61 * ENC Driver Operations: 62 * (The defines themselves are platform and access method specific) 63 * 64 * ENCIOC_GETNELM 65 * ENCIOC_GETELMMAP 66 * ENCIOC_GETENCSTAT 67 * ENCIOC_SETENCSTAT 68 * ENCIOC_GETELMSTAT 69 * ENCIOC_SETELMSTAT 70 * ENCIOC_INIT 71 * 72 * 73 * An application finds out how many elements an enclosure instance 74 * is managing by performing a ENCIOC_GETNELM operation. It then 75 * performs a ENCIOC_GETELMMAP to get the map that contains the 76 * elment identifiers for all elements (see encioc_element_t below). 77 * This information is static. 78 * 79 * The application may perform ENCIOC_GETELMSTAT operations to retrieve 80 * status on an element (see the enc_elm_status_t structure below), 81 * ENCIOC_SETELMSTAT operations to set status for an element. 82 * 83 * Similarly, overall enclosure status me be fetched or set via 84 * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t 85 * below). 86 * 87 * Readers should note that there is nothing that requires either a set 88 * or a clear operation to actually latch and do anything in the target. 89 * 90 * A ENCIOC_INIT operation causes the enclosure to be initialized. 91 */ 92 93 /* Element Types */ 94 typedef enum { 95 ELMTYP_UNSPECIFIED = 0x00, 96 ELMTYP_DEVICE = 0x01, 97 ELMTYP_POWER = 0x02, 98 ELMTYP_FAN = 0x03, 99 ELMTYP_THERM = 0x04, 100 ELMTYP_DOORLOCK = 0x05, 101 ELMTYP_ALARM = 0x06, 102 ELMTYP_ESCC = 0x07, /* Enclosure SCC */ 103 ELMTYP_SCC = 0x08, /* SCC */ 104 ELMTYP_NVRAM = 0x09, 105 ELMTYP_INV_OP_REASON = 0x0a, 106 ELMTYP_UPS = 0x0b, 107 ELMTYP_DISPLAY = 0x0c, 108 ELMTYP_KEYPAD = 0x0d, 109 ELMTYP_ENCLOSURE = 0x0e, 110 ELMTYP_SCSIXVR = 0x0f, 111 ELMTYP_LANGUAGE = 0x10, 112 ELMTYP_COMPORT = 0x11, 113 ELMTYP_VOM = 0x12, 114 ELMTYP_AMMETER = 0x13, 115 ELMTYP_SCSI_TGT = 0x14, 116 ELMTYP_SCSI_INI = 0x15, 117 ELMTYP_SUBENC = 0x16, 118 ELMTYP_ARRAY_DEV = 0x17, 119 ELMTYP_SAS_EXP = 0x18, /* SAS expander */ 120 ELMTYP_SAS_CONN = 0x19 /* SAS connector */ 121 } elm_type_t; 122 123 typedef struct encioc_element { 124 /* Element Index */ 125 unsigned int elm_idx; 126 127 /* ID of SubEnclosure containing Element*/ 128 unsigned int elm_subenc_id; 129 130 /* Element Type */ 131 elm_type_t elm_type; 132 } encioc_element_t; 133 134 /* 135 * Overall Enclosure Status 136 */ 137 typedef unsigned char encioc_enc_status_t; 138 139 /* 140 * Element Status 141 */ 142 typedef struct encioc_elm_status { 143 unsigned int elm_idx; 144 unsigned char cstat[4]; 145 } encioc_elm_status_t; 146 147 /* 148 * ENC String structure, for StringIn and StringOut commands; use this with 149 * the ENCIOC_GETSTRING and ENCIOC_SETSTRING ioctls. 150 */ 151 typedef struct encioc_string { 152 size_t bufsiz; /* IN/OUT: length of string provided/returned */ 153 #define ENC_STRING_MAX 0xffff 154 uint8_t *buf; /* IN/OUT: string */ 155 } encioc_string_t; 156 157 /*============================================================================*/ 158 159 /* 160 * SES v2 r20 6.1.10 (pg 39) - Element Descriptor diagnostic page 161 * Tables 21, 22, and 23 162 */ 163 typedef struct encioc_elm_desc { 164 unsigned int elm_idx; /* IN: elment requested */ 165 uint16_t elm_desc_len; /* IN: buffer size; OUT: bytes written */ 166 char *elm_desc_str; /* IN/OUT: buffer for descriptor data */ 167 } encioc_elm_desc_t; 168 169 /* 170 * ENCIOC_GETELMDEVNAMES: 171 * ioctl structure to get an element's device names, if available 172 */ 173 typedef struct encioc_elm_devnames { 174 unsigned int elm_idx; /* IN: element index */ 175 size_t elm_names_size;/* IN: size of elm_devnames */ 176 size_t elm_names_len; /* OUT: actual size returned */ 177 /* 178 * IN/OUT: comma separated list of peripheral driver 179 * instances servicing this element. 180 */ 181 char *elm_devnames; 182 } encioc_elm_devnames_t; 183 184 /* ioctl structure for requesting FC info for a port */ 185 typedef struct encioc_elm_fc_port { 186 unsigned int elm_idx; 187 unsigned int port_idx; 188 struct ses_elm_fc_port port_data; 189 } encioc_elm_fc_port_t; 190 191 /* ioctl structure for requesting SAS info for element phys */ 192 typedef struct encioc_elm_sas_device_phy { 193 unsigned int elm_idx; 194 unsigned int phy_idx; 195 struct ses_elm_sas_device_phy phy_data; 196 } enioc_elm_sas_phy_t; 197 198 /* ioctl structure for requesting SAS info for an expander phy */ 199 typedef struct encioc_elm_sas_expander_phy { 200 unsigned int elm_idx; 201 unsigned int phy_idx; 202 struct ses_elm_sas_expander_phy phy_data; 203 } encioc_elm_sas_expander_phy_t; 204 205 /* ioctl structure for requesting SAS info for a port phy */ 206 typedef struct encioc_elm_sas_port_phy { 207 unsigned int elm_idx; 208 unsigned int phy_idx; 209 struct ses_elm_sas_port_phy phy_data; 210 } enioc_elm_sas_port_phy_t; 211 212 /* ioctl structure for requesting additional status for an element */ 213 typedef struct encioc_addl_status { 214 unsigned int elm_idx; 215 union ses_elm_addlstatus_descr_hdr addl_hdr; 216 union ses_elm_addlstatus_proto_hdr proto_hdr; 217 } enioc_addl_status_t; 218 219 #endif /* _SCSI_ENC_H_ */ 220