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