FreeBSD kernel CAM code
scsi_enc.h
Go to the documentation of this file.
1/* $FreeBSD$ */
2/*-
3 * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD OR GPL-2.0)
4 *
5 * Copyright (c) 2000 by Matthew Jacob
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
16 *
17 * Alternatively, this software may be distributed under the terms of the
18 * the GNU Public License ("GPL").
19 *
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
30 * SUCH DAMAGE.
31 *
32 */
33#ifndef _SCSI_ENC_H_
34#define _SCSI_ENC_H_
35
36#include <cam/scsi/scsi_ses.h>
37
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)
53
54/*
55 * Platform Independent Definitions for enclosure devices.
56 */
57/*
58 * SCSI Based Environmental Services Application Defines
59 *
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.
63 */
64/*
65 * ENC Driver Operations:
66 * (The defines themselves are platform and access method specific)
67 *
68 * ENCIOC_GETNELM
69 * ENCIOC_GETELMMAP
70 * ENCIOC_GETENCSTAT
71 * ENCIOC_SETENCSTAT
72 * ENCIOC_GETELMSTAT
73 * ENCIOC_SETELMSTAT
74 * ENCIOC_INIT
75 *
76 *
77 * An application finds out how many elements an enclosure instance
78 * manages by performing a ENCIOC_GETNELM operation. It then
79 * performs an ENCIOC_GETELMMAP to get the map that contains the
80 * element identifiers for all elements (see encioc_element_t below).
81 * This information is static.
82 *
83 * The application may perform ENCIOC_GETELMSTAT operations to retrieve
84 * status on an element (see the encioc_elm_status_t structure below),
85 * and ENCIOC_SETELMSTAT operations to set status for an element.
86 *
87 * Similarly, overall enclosure status may be fetched or set via
88 * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t
89 * below).
90 *
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.
93 *
94 * An ENCIOC_INIT operation causes the enclosure to be initialized.
95 */
96
97/* Element Types */
98typedef enum {
106 ELMTYP_ESCC = 0x07, /* Enclosure SCC */
107 ELMTYP_SCC = 0x08, /* SCC */
123 ELMTYP_SAS_EXP = 0x18, /* SAS Expander */
124 ELMTYP_SAS_CONN = 0x19, /* SAS Connector */
127
128#define ELM_TYPE_NAMES { \
129 "Unspecified", \
130 "Device Slot", \
131 "Power Supply", \
132 "Cooling", \
133 "Temperature Sensor", \
134 "Door", \
135 "Audible alarm", \
136 "Enclosure Services Controller Electronics", \
137 "SCC Controller Electronics", \
138 "Nonvolatile Cache", \
139 "Invalid Operation Reason", \
140 "Uninterruptible Power Supply", \
141 "Display", \
142 "Key Pad Entry", \
143 "Enclosure", \
144 "SCSI Port/Transceiver", \
145 "Language", \
146 "Communication Port", \
147 "Voltage Sensor", \
148 "Current Sensor", \
149 "SCSI Target Port", \
150 "SCSI Initiator Port", \
151 "Simple Subenclosure", \
152 "Array Device Slot", \
153 "SAS Expander", \
154 "SAS Connector" \
155}
156
157#ifdef _KERNEL
158extern const char *elm_type_names[];
159#endif
160
161typedef struct encioc_element {
162 /* Element Index */
163 unsigned int elm_idx;
164
165 /* ID of SubEnclosure containing Element*/
166 unsigned int elm_subenc_id;
167
168 /* Element Type */
171
172/*
173 * Overall Enclosure Status
174 */
175typedef unsigned char encioc_enc_status_t;
176
177/*
178 * Element Status
179 */
180typedef struct encioc_elm_status {
181 unsigned int elm_idx;
182 unsigned char cstat[4];
184
185/*
186 * ENC String structure, for StringIn and StringOut commands; use this with
187 * the ENCIOC_GETSTRING and ENCIOC_SETSTRING ioctls.
188 */
189typedef struct encioc_string {
190 size_t bufsiz; /* IN/OUT: length of string provided/returned */
191#define ENC_STRING_MAX 0xffff
192 uint8_t *buf; /* IN/OUT: string */
194
195/*============================================================================*/
196
197/*
198 * SES v2 r20 6.1.10 (pg 39) - Element Descriptor diagnostic page
199 * Tables 21, 22, and 23
200 */
201typedef struct encioc_elm_desc {
202 unsigned int elm_idx; /* IN: elment requested */
203 uint16_t elm_desc_len; /* IN: buffer size; OUT: bytes written */
204 char *elm_desc_str; /* IN/OUT: buffer for descriptor data */
206
207/*
208 * ENCIOC_GETELMDEVNAMES:
209 * ioctl structure to get an element's device names, if available
210 */
211typedef struct encioc_elm_devnames {
212 unsigned int elm_idx; /* IN: element index */
213 size_t elm_names_size;/* IN: size of elm_devnames */
214 size_t elm_names_len; /* OUT: actual size returned */
215 /*
216 * IN/OUT: comma separated list of peripheral driver
217 * instances servicing this element.
218 */
221
222/* ioctl structure for requesting FC info for a port */
223typedef struct encioc_elm_fc_port {
224 unsigned int elm_idx;
225 unsigned int port_idx;
228
229/* ioctl structure for requesting SAS info for element phys */
231 unsigned int elm_idx;
232 unsigned int phy_idx;
235
236/* ioctl structure for requesting SAS info for an expander phy */
238 unsigned int elm_idx;
239 unsigned int phy_idx;
242
243/* ioctl structure for requesting SAS info for a port phy */
245 unsigned int elm_idx;
246 unsigned int phy_idx;
249
250/* ioctl structure for requesting additional status for an element */
251typedef struct encioc_addl_status {
252 unsigned int elm_idx;
256
257#endif /* _SCSI_ENC_H_ */
struct encioc_element encioc_element_t
struct encioc_elm_sas_expander_phy encioc_elm_sas_expander_phy_t
struct encioc_elm_status encioc_elm_status_t
struct encioc_elm_sas_device_phy enioc_elm_sas_phy_t
struct encioc_elm_sas_port_phy enioc_elm_sas_port_phy_t
unsigned char encioc_enc_status_t
Definition: scsi_enc.h:175
struct encioc_string encioc_string_t
struct encioc_elm_devnames encioc_elm_devnames_t
struct encioc_elm_desc encioc_elm_desc_t
struct encioc_elm_fc_port encioc_elm_fc_port_t
struct encioc_addl_status enioc_addl_status_t
elm_type_t
Definition: scsi_enc.h:98
@ ELMTYP_SCSI_TGT
Definition: scsi_enc.h:119
@ ELMTYP_ENCLOSURE
Definition: scsi_enc.h:113
@ ELMTYP_VOM
Definition: scsi_enc.h:117
@ ELMTYP_COMPORT
Definition: scsi_enc.h:116
@ ELMTYP_KEYPAD
Definition: scsi_enc.h:112
@ ELMTYP_AMMETER
Definition: scsi_enc.h:118
@ ELMTYP_ESCC
Definition: scsi_enc.h:106
@ ELMTYP_FAN
Definition: scsi_enc.h:102
@ ELMTYP_LANGUAGE
Definition: scsi_enc.h:115
@ ELMTYP_SAS_CONN
Definition: scsi_enc.h:124
@ ELMTYP_POWER
Definition: scsi_enc.h:101
@ ELMTYP_ARRAY_DEV
Definition: scsi_enc.h:122
@ ELMTYP_SCC
Definition: scsi_enc.h:107
@ ELMTYP_DOORLOCK
Definition: scsi_enc.h:104
@ ELMTYP_ALARM
Definition: scsi_enc.h:105
@ ELMTYP_UPS
Definition: scsi_enc.h:110
@ ELMTYP_LAST
Definition: scsi_enc.h:125
@ ELMTYP_SCSI_INI
Definition: scsi_enc.h:120
@ ELMTYP_THERM
Definition: scsi_enc.h:103
@ ELMTYP_SUBENC
Definition: scsi_enc.h:121
@ ELMTYP_UNSPECIFIED
Definition: scsi_enc.h:99
@ ELMTYP_DEVICE
Definition: scsi_enc.h:100
@ ELMTYP_NVRAM
Definition: scsi_enc.h:108
@ ELMTYP_SCSIXVR
Definition: scsi_enc.h:114
@ ELMTYP_INV_OP_REASON
Definition: scsi_enc.h:109
@ ELMTYP_DISPLAY
Definition: scsi_enc.h:111
@ ELMTYP_SAS_EXP
Definition: scsi_enc.h:123
const char * elm_type_names[]
Definition: scsi_enc.c:92
unsigned int elm_idx
Definition: scsi_enc.h:252
union ses_elm_addlstatus_proto_hdr proto_hdr
Definition: scsi_enc.h:254
union ses_elm_addlstatus_descr_hdr addl_hdr
Definition: scsi_enc.h:253
unsigned int elm_subenc_id
Definition: scsi_enc.h:166
elm_type_t elm_type
Definition: scsi_enc.h:169
unsigned int elm_idx
Definition: scsi_enc.h:163
uint16_t elm_desc_len
Definition: scsi_enc.h:203
unsigned int elm_idx
Definition: scsi_enc.h:202
char * elm_desc_str
Definition: scsi_enc.h:204
size_t elm_names_len
Definition: scsi_enc.h:214
size_t elm_names_size
Definition: scsi_enc.h:213
unsigned int elm_idx
Definition: scsi_enc.h:212
struct ses_elm_fc_port port_data
Definition: scsi_enc.h:226
unsigned int elm_idx
Definition: scsi_enc.h:224
unsigned int port_idx
Definition: scsi_enc.h:225
unsigned int phy_idx
Definition: scsi_enc.h:232
struct ses_elm_sas_device_phy phy_data
Definition: scsi_enc.h:233
unsigned int elm_idx
Definition: scsi_enc.h:231
struct ses_elm_sas_expander_phy phy_data
Definition: scsi_enc.h:240
unsigned int phy_idx
Definition: scsi_enc.h:246
struct ses_elm_sas_port_phy phy_data
Definition: scsi_enc.h:247
unsigned int elm_idx
Definition: scsi_enc.h:245
unsigned char cstat[4]
Definition: scsi_enc.h:182
unsigned int elm_idx
Definition: scsi_enc.h:181
uint8_t * buf
Definition: scsi_enc.h:192
size_t bufsiz
Definition: scsi_enc.h:190