2 * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)
4 * Copyright (c) 2000 by Matthew Jacob
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification, immediately at the beginning of the file.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * Alternatively, this software may be distributed under the terms of the
17 * the GNU Public License ("GPL").
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <cam/scsi/scsi_ses.h>
37 #define ENCIOC ('s' - 040)
38 #define ENCIOC_GETNELM _IO(ENCIOC, 1)
39 #define ENCIOC_GETELMMAP _IO(ENCIOC, 2)
40 #define ENCIOC_GETENCSTAT _IO(ENCIOC, 3)
41 #define ENCIOC_SETENCSTAT _IO(ENCIOC, 4)
42 #define ENCIOC_GETELMSTAT _IO(ENCIOC, 5)
43 #define ENCIOC_SETELMSTAT _IO(ENCIOC, 6)
44 #define ENCIOC_GETTEXT _IO(ENCIOC, 7)
45 #define ENCIOC_INIT _IO(ENCIOC, 8)
46 #define ENCIOC_GETELMDESC _IO(ENCIOC, 9)
47 #define ENCIOC_GETELMDEVNAMES _IO(ENCIOC, 10)
48 #define ENCIOC_GETSTRING _IO(ENCIOC, 11)
49 #define ENCIOC_SETSTRING _IO(ENCIOC, 12)
50 #define ENCIOC_GETENCNAME _IO(ENCIOC, 13)
51 #define ENCIOC_GETENCID _IO(ENCIOC, 14)
54 * Platform Independent Definitions for enclosure devices.
57 * SCSI Based Environmental Services Application Defines
59 * Based almost entirely on SCSI-3 ENC Revision 8A specification,
60 * but slightly abstracted as the underlying device may in fact
61 * be a SAF-TE or vendor unique device.
64 * ENC Driver Operations:
65 * (The defines themselves are platform and access method specific)
76 * An application finds out how many elements an enclosure instance
77 * manages by performing a ENCIOC_GETNELM operation. It then
78 * performs an ENCIOC_GETELMMAP to get the map that contains the
79 * element identifiers for all elements (see encioc_element_t below).
80 * This information is static.
82 * The application may perform ENCIOC_GETELMSTAT operations to retrieve
83 * status on an element (see the encioc_elm_status_t structure below),
84 * and ENCIOC_SETELMSTAT operations to set status for an element.
86 * Similarly, overall enclosure status may be fetched or set via
87 * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t
90 * Readers should note that there is nothing that requires either a set
91 * or a clear operation to actually latch and do anything in the target.
93 * An ENCIOC_INIT operation causes the enclosure to be initialized.
98 ELMTYP_UNSPECIFIED = 0x00,
103 ELMTYP_DOORLOCK = 0x05,
105 ELMTYP_ESCC = 0x07, /* Enclosure SCC */
106 ELMTYP_SCC = 0x08, /* SCC */
108 ELMTYP_INV_OP_REASON = 0x0a,
110 ELMTYP_DISPLAY = 0x0c,
111 ELMTYP_KEYPAD = 0x0d,
112 ELMTYP_ENCLOSURE = 0x0e,
113 ELMTYP_SCSIXVR = 0x0f,
114 ELMTYP_LANGUAGE = 0x10,
115 ELMTYP_COMPORT = 0x11,
117 ELMTYP_AMMETER = 0x13,
118 ELMTYP_SCSI_TGT = 0x14,
119 ELMTYP_SCSI_INI = 0x15,
120 ELMTYP_SUBENC = 0x16,
121 ELMTYP_ARRAY_DEV = 0x17,
122 ELMTYP_SAS_EXP = 0x18, /* SAS Expander */
123 ELMTYP_SAS_CONN = 0x19, /* SAS Connector */
124 ELMTYP_LAST = ELMTYP_SAS_CONN
127 #define ELM_TYPE_NAMES { \
132 "Temperature Sensor", \
135 "Enclosure Services Controller Electronics", \
136 "SCC Controller Electronics", \
137 "Nonvolatile Cache", \
138 "Invalid Operation Reason", \
139 "Uninterruptible Power Supply", \
143 "SCSI Port/Transceiver", \
145 "Communication Port", \
148 "SCSI Target Port", \
149 "SCSI Initiator Port", \
150 "Simple Subenclosure", \
151 "Array Device Slot", \
157 extern const char *elm_type_names[];
160 typedef struct encioc_element {
162 unsigned int elm_idx;
164 /* ID of SubEnclosure containing Element*/
165 unsigned int elm_subenc_id;
172 * Overall Enclosure Status
174 typedef unsigned char encioc_enc_status_t;
179 typedef struct encioc_elm_status {
180 unsigned int elm_idx;
181 unsigned char cstat[4];
182 } encioc_elm_status_t;
185 * ENC String structure, for StringIn and StringOut commands; use this with
186 * the ENCIOC_GETSTRING and ENCIOC_SETSTRING ioctls.
188 typedef struct encioc_string {
189 size_t bufsiz; /* IN/OUT: length of string provided/returned */
190 #define ENC_STRING_MAX 0xffff
191 uint8_t *buf; /* IN/OUT: string */
194 /*============================================================================*/
197 * SES v2 r20 6.1.10 (pg 39) - Element Descriptor diagnostic page
198 * Tables 21, 22, and 23
200 typedef struct encioc_elm_desc {
201 unsigned int elm_idx; /* IN: elment requested */
202 uint16_t elm_desc_len; /* IN: buffer size; OUT: bytes written */
203 char *elm_desc_str; /* IN/OUT: buffer for descriptor data */
207 * ENCIOC_GETELMDEVNAMES:
208 * ioctl structure to get an element's device names, if available
210 typedef struct encioc_elm_devnames {
211 unsigned int elm_idx; /* IN: element index */
212 size_t elm_names_size;/* IN: size of elm_devnames */
213 size_t elm_names_len; /* OUT: actual size returned */
215 * IN/OUT: comma separated list of peripheral driver
216 * instances servicing this element.
219 } encioc_elm_devnames_t;
221 /* ioctl structure for requesting FC info for a port */
222 typedef struct encioc_elm_fc_port {
223 unsigned int elm_idx;
224 unsigned int port_idx;
225 struct ses_elm_fc_port port_data;
226 } encioc_elm_fc_port_t;
228 /* ioctl structure for requesting SAS info for element phys */
229 typedef struct encioc_elm_sas_device_phy {
230 unsigned int elm_idx;
231 unsigned int phy_idx;
232 struct ses_elm_sas_device_phy phy_data;
233 } enioc_elm_sas_phy_t;
235 /* ioctl structure for requesting SAS info for an expander phy */
236 typedef struct encioc_elm_sas_expander_phy {
237 unsigned int elm_idx;
238 unsigned int phy_idx;
239 struct ses_elm_sas_expander_phy phy_data;
240 } encioc_elm_sas_expander_phy_t;
242 /* ioctl structure for requesting SAS info for a port phy */
243 typedef struct encioc_elm_sas_port_phy {
244 unsigned int elm_idx;
245 unsigned int phy_idx;
246 struct ses_elm_sas_port_phy phy_data;
247 } enioc_elm_sas_port_phy_t;
249 /* ioctl structure for requesting additional status for an element */
250 typedef struct encioc_addl_status {
251 unsigned int elm_idx;
252 union ses_elm_addlstatus_descr_hdr addl_hdr;
253 union ses_elm_addlstatus_proto_hdr proto_hdr;
254 } enioc_addl_status_t;
256 #endif /* _SCSI_ENC_H_ */