1f6ad3f23SAlexander Motin /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0) 3f24882ecSPedro F. Giffuni * 4f6ad3f23SAlexander Motin * Copyright (c) 2000 by Matthew Jacob 5f6ad3f23SAlexander Motin * All rights reserved. 6f6ad3f23SAlexander Motin * 7f6ad3f23SAlexander Motin * Redistribution and use in source and binary forms, with or without 8f6ad3f23SAlexander Motin * modification, are permitted provided that the following conditions 9f6ad3f23SAlexander Motin * are met: 10f6ad3f23SAlexander Motin * 1. Redistributions of source code must retain the above copyright 11f6ad3f23SAlexander Motin * notice, this list of conditions, and the following disclaimer, 12f6ad3f23SAlexander Motin * without modification, immediately at the beginning of the file. 13f6ad3f23SAlexander Motin * 2. The name of the author may not be used to endorse or promote products 14f6ad3f23SAlexander Motin * derived from this software without specific prior written permission. 15f6ad3f23SAlexander Motin * 16f6ad3f23SAlexander Motin * Alternatively, this software may be distributed under the terms of the 17f6ad3f23SAlexander Motin * the GNU Public License ("GPL"). 18f6ad3f23SAlexander Motin * 19f6ad3f23SAlexander Motin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20f6ad3f23SAlexander Motin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21f6ad3f23SAlexander Motin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22f6ad3f23SAlexander Motin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 23f6ad3f23SAlexander Motin * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24f6ad3f23SAlexander Motin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25f6ad3f23SAlexander Motin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26f6ad3f23SAlexander Motin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27f6ad3f23SAlexander Motin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28f6ad3f23SAlexander Motin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29f6ad3f23SAlexander Motin * SUCH DAMAGE. 30f6ad3f23SAlexander Motin * 31f6ad3f23SAlexander Motin */ 32f6ad3f23SAlexander Motin #ifndef _SCSI_ENC_H_ 33f6ad3f23SAlexander Motin #define _SCSI_ENC_H_ 34f6ad3f23SAlexander Motin 35f6ad3f23SAlexander Motin #include <cam/scsi/scsi_ses.h> 36f6ad3f23SAlexander Motin 37f6ad3f23SAlexander Motin #define ENCIOC ('s' - 040) 38f6ad3f23SAlexander Motin #define ENCIOC_GETNELM _IO(ENCIOC, 1) 39f6ad3f23SAlexander Motin #define ENCIOC_GETELMMAP _IO(ENCIOC, 2) 40f6ad3f23SAlexander Motin #define ENCIOC_GETENCSTAT _IO(ENCIOC, 3) 41f6ad3f23SAlexander Motin #define ENCIOC_SETENCSTAT _IO(ENCIOC, 4) 42f6ad3f23SAlexander Motin #define ENCIOC_GETELMSTAT _IO(ENCIOC, 5) 43f6ad3f23SAlexander Motin #define ENCIOC_SETELMSTAT _IO(ENCIOC, 6) 44f6ad3f23SAlexander Motin #define ENCIOC_GETTEXT _IO(ENCIOC, 7) 45f6ad3f23SAlexander Motin #define ENCIOC_INIT _IO(ENCIOC, 8) 46f6ad3f23SAlexander Motin #define ENCIOC_GETELMDESC _IO(ENCIOC, 9) 47f6ad3f23SAlexander Motin #define ENCIOC_GETELMDEVNAMES _IO(ENCIOC, 10) 48f6ad3f23SAlexander Motin #define ENCIOC_GETSTRING _IO(ENCIOC, 11) 49f6ad3f23SAlexander Motin #define ENCIOC_SETSTRING _IO(ENCIOC, 12) 506d2a1fbfSAlexander Motin #define ENCIOC_GETENCNAME _IO(ENCIOC, 13) 516d2a1fbfSAlexander Motin #define ENCIOC_GETENCID _IO(ENCIOC, 14) 52f6ad3f23SAlexander Motin 53f6ad3f23SAlexander Motin /* 54f6ad3f23SAlexander Motin * Platform Independent Definitions for enclosure devices. 55f6ad3f23SAlexander Motin */ 56f6ad3f23SAlexander Motin /* 57f6ad3f23SAlexander Motin * SCSI Based Environmental Services Application Defines 58f6ad3f23SAlexander Motin * 59f6ad3f23SAlexander Motin * Based almost entirely on SCSI-3 ENC Revision 8A specification, 60f6ad3f23SAlexander Motin * but slightly abstracted as the underlying device may in fact 61f6ad3f23SAlexander Motin * be a SAF-TE or vendor unique device. 62f6ad3f23SAlexander Motin */ 63f6ad3f23SAlexander Motin /* 64f6ad3f23SAlexander Motin * ENC Driver Operations: 65f6ad3f23SAlexander Motin * (The defines themselves are platform and access method specific) 66f6ad3f23SAlexander Motin * 67f6ad3f23SAlexander Motin * ENCIOC_GETNELM 68f6ad3f23SAlexander Motin * ENCIOC_GETELMMAP 69f6ad3f23SAlexander Motin * ENCIOC_GETENCSTAT 70f6ad3f23SAlexander Motin * ENCIOC_SETENCSTAT 71f6ad3f23SAlexander Motin * ENCIOC_GETELMSTAT 72f6ad3f23SAlexander Motin * ENCIOC_SETELMSTAT 73f6ad3f23SAlexander Motin * ENCIOC_INIT 74f6ad3f23SAlexander Motin * 75f6ad3f23SAlexander Motin * 76f6ad3f23SAlexander Motin * An application finds out how many elements an enclosure instance 77170a0a8eSAlan Somers * manages by performing a ENCIOC_GETNELM operation. It then 78170a0a8eSAlan Somers * performs an ENCIOC_GETELMMAP to get the map that contains the 79170a0a8eSAlan Somers * element identifiers for all elements (see encioc_element_t below). 80f6ad3f23SAlexander Motin * This information is static. 81f6ad3f23SAlexander Motin * 82f6ad3f23SAlexander Motin * The application may perform ENCIOC_GETELMSTAT operations to retrieve 83170a0a8eSAlan Somers * status on an element (see the encioc_elm_status_t structure below), 84170a0a8eSAlan Somers * and ENCIOC_SETELMSTAT operations to set status for an element. 85f6ad3f23SAlexander Motin * 86170a0a8eSAlan Somers * Similarly, overall enclosure status may be fetched or set via 87f6ad3f23SAlexander Motin * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t 88f6ad3f23SAlexander Motin * below). 89f6ad3f23SAlexander Motin * 90f6ad3f23SAlexander Motin * Readers should note that there is nothing that requires either a set 91f6ad3f23SAlexander Motin * or a clear operation to actually latch and do anything in the target. 92f6ad3f23SAlexander Motin * 93170a0a8eSAlan Somers * An ENCIOC_INIT operation causes the enclosure to be initialized. 94f6ad3f23SAlexander Motin */ 95f6ad3f23SAlexander Motin 96f6ad3f23SAlexander Motin /* Element Types */ 97f6ad3f23SAlexander Motin typedef enum { 98f6ad3f23SAlexander Motin ELMTYP_UNSPECIFIED = 0x00, 99f6ad3f23SAlexander Motin ELMTYP_DEVICE = 0x01, 100f6ad3f23SAlexander Motin ELMTYP_POWER = 0x02, 101f6ad3f23SAlexander Motin ELMTYP_FAN = 0x03, 102f6ad3f23SAlexander Motin ELMTYP_THERM = 0x04, 103f6ad3f23SAlexander Motin ELMTYP_DOORLOCK = 0x05, 104f6ad3f23SAlexander Motin ELMTYP_ALARM = 0x06, 105f6ad3f23SAlexander Motin ELMTYP_ESCC = 0x07, /* Enclosure SCC */ 106f6ad3f23SAlexander Motin ELMTYP_SCC = 0x08, /* SCC */ 107f6ad3f23SAlexander Motin ELMTYP_NVRAM = 0x09, 108f6ad3f23SAlexander Motin ELMTYP_INV_OP_REASON = 0x0a, 109f6ad3f23SAlexander Motin ELMTYP_UPS = 0x0b, 110f6ad3f23SAlexander Motin ELMTYP_DISPLAY = 0x0c, 111f6ad3f23SAlexander Motin ELMTYP_KEYPAD = 0x0d, 112f6ad3f23SAlexander Motin ELMTYP_ENCLOSURE = 0x0e, 113f6ad3f23SAlexander Motin ELMTYP_SCSIXVR = 0x0f, 114f6ad3f23SAlexander Motin ELMTYP_LANGUAGE = 0x10, 115f6ad3f23SAlexander Motin ELMTYP_COMPORT = 0x11, 116f6ad3f23SAlexander Motin ELMTYP_VOM = 0x12, 117f6ad3f23SAlexander Motin ELMTYP_AMMETER = 0x13, 118f6ad3f23SAlexander Motin ELMTYP_SCSI_TGT = 0x14, 119f6ad3f23SAlexander Motin ELMTYP_SCSI_INI = 0x15, 120f6ad3f23SAlexander Motin ELMTYP_SUBENC = 0x16, 121f6ad3f23SAlexander Motin ELMTYP_ARRAY_DEV = 0x17, 12253f5ac13SAlexander Motin ELMTYP_SAS_EXP = 0x18, /* SAS Expander */ 12353f5ac13SAlexander Motin ELMTYP_SAS_CONN = 0x19, /* SAS Connector */ 12453f5ac13SAlexander Motin ELMTYP_LAST = ELMTYP_SAS_CONN 125f6ad3f23SAlexander Motin } elm_type_t; 126f6ad3f23SAlexander Motin 12753f5ac13SAlexander Motin #define ELM_TYPE_NAMES { \ 12853f5ac13SAlexander Motin "Unspecified", \ 12953f5ac13SAlexander Motin "Device Slot", \ 13053f5ac13SAlexander Motin "Power Supply", \ 13153f5ac13SAlexander Motin "Cooling", \ 1321fb52e43SAlan Somers "Temperature Sensor", \ 13353f5ac13SAlexander Motin "Door", \ 13453f5ac13SAlexander Motin "Audible alarm", \ 13553f5ac13SAlexander Motin "Enclosure Services Controller Electronics", \ 13653f5ac13SAlexander Motin "SCC Controller Electronics", \ 13753f5ac13SAlexander Motin "Nonvolatile Cache", \ 13853f5ac13SAlexander Motin "Invalid Operation Reason", \ 13953f5ac13SAlexander Motin "Uninterruptible Power Supply", \ 14053f5ac13SAlexander Motin "Display", \ 14153f5ac13SAlexander Motin "Key Pad Entry", \ 14253f5ac13SAlexander Motin "Enclosure", \ 14353f5ac13SAlexander Motin "SCSI Port/Transceiver", \ 14453f5ac13SAlexander Motin "Language", \ 14553f5ac13SAlexander Motin "Communication Port", \ 14653f5ac13SAlexander Motin "Voltage Sensor", \ 14753f5ac13SAlexander Motin "Current Sensor", \ 14853f5ac13SAlexander Motin "SCSI Target Port", \ 14953f5ac13SAlexander Motin "SCSI Initiator Port", \ 15053f5ac13SAlexander Motin "Simple Subenclosure", \ 15153f5ac13SAlexander Motin "Array Device Slot", \ 15253f5ac13SAlexander Motin "SAS Expander", \ 15353f5ac13SAlexander Motin "SAS Connector" \ 15453f5ac13SAlexander Motin } 15553f5ac13SAlexander Motin 156cc2d08d3SAlan Somers #ifdef _KERNEL 15753f5ac13SAlexander Motin extern const char *elm_type_names[]; 158cc2d08d3SAlan Somers #endif 15953f5ac13SAlexander Motin 160f6ad3f23SAlexander Motin typedef struct encioc_element { 161f6ad3f23SAlexander Motin /* Element Index */ 162f6ad3f23SAlexander Motin unsigned int elm_idx; 163f6ad3f23SAlexander Motin 164f6ad3f23SAlexander Motin /* ID of SubEnclosure containing Element*/ 165f6ad3f23SAlexander Motin unsigned int elm_subenc_id; 166f6ad3f23SAlexander Motin 167f6ad3f23SAlexander Motin /* Element Type */ 168f6ad3f23SAlexander Motin elm_type_t elm_type; 169f6ad3f23SAlexander Motin } encioc_element_t; 170f6ad3f23SAlexander Motin 171f6ad3f23SAlexander Motin /* 172f6ad3f23SAlexander Motin * Overall Enclosure Status 173f6ad3f23SAlexander Motin */ 174f6ad3f23SAlexander Motin typedef unsigned char encioc_enc_status_t; 175f6ad3f23SAlexander Motin 176f6ad3f23SAlexander Motin /* 177f6ad3f23SAlexander Motin * Element Status 178f6ad3f23SAlexander Motin */ 179f6ad3f23SAlexander Motin typedef struct encioc_elm_status { 180f6ad3f23SAlexander Motin unsigned int elm_idx; 181f6ad3f23SAlexander Motin unsigned char cstat[4]; 182f6ad3f23SAlexander Motin } encioc_elm_status_t; 183f6ad3f23SAlexander Motin 184f6ad3f23SAlexander Motin /* 185f6ad3f23SAlexander Motin * ENC String structure, for StringIn and StringOut commands; use this with 186f6ad3f23SAlexander Motin * the ENCIOC_GETSTRING and ENCIOC_SETSTRING ioctls. 187f6ad3f23SAlexander Motin */ 188f6ad3f23SAlexander Motin typedef struct encioc_string { 189f6ad3f23SAlexander Motin size_t bufsiz; /* IN/OUT: length of string provided/returned */ 190f6ad3f23SAlexander Motin #define ENC_STRING_MAX 0xffff 191f6ad3f23SAlexander Motin uint8_t *buf; /* IN/OUT: string */ 192f6ad3f23SAlexander Motin } encioc_string_t; 193f6ad3f23SAlexander Motin 194f6ad3f23SAlexander Motin /*============================================================================*/ 195f6ad3f23SAlexander Motin 196f6ad3f23SAlexander Motin /* 197f6ad3f23SAlexander Motin * SES v2 r20 6.1.10 (pg 39) - Element Descriptor diagnostic page 198f6ad3f23SAlexander Motin * Tables 21, 22, and 23 199f6ad3f23SAlexander Motin */ 200f6ad3f23SAlexander Motin typedef struct encioc_elm_desc { 201f6ad3f23SAlexander Motin unsigned int elm_idx; /* IN: elment requested */ 202f6ad3f23SAlexander Motin uint16_t elm_desc_len; /* IN: buffer size; OUT: bytes written */ 203f6ad3f23SAlexander Motin char *elm_desc_str; /* IN/OUT: buffer for descriptor data */ 204f6ad3f23SAlexander Motin } encioc_elm_desc_t; 205f6ad3f23SAlexander Motin 206f6ad3f23SAlexander Motin /* 207f6ad3f23SAlexander Motin * ENCIOC_GETELMDEVNAMES: 208f6ad3f23SAlexander Motin * ioctl structure to get an element's device names, if available 209f6ad3f23SAlexander Motin */ 210f6ad3f23SAlexander Motin typedef struct encioc_elm_devnames { 211f6ad3f23SAlexander Motin unsigned int elm_idx; /* IN: element index */ 212f6ad3f23SAlexander Motin size_t elm_names_size;/* IN: size of elm_devnames */ 213f6ad3f23SAlexander Motin size_t elm_names_len; /* OUT: actual size returned */ 214f6ad3f23SAlexander Motin /* 215f6ad3f23SAlexander Motin * IN/OUT: comma separated list of peripheral driver 216f6ad3f23SAlexander Motin * instances servicing this element. 217f6ad3f23SAlexander Motin */ 218f6ad3f23SAlexander Motin char *elm_devnames; 219f6ad3f23SAlexander Motin } encioc_elm_devnames_t; 220f6ad3f23SAlexander Motin 221f6ad3f23SAlexander Motin /* ioctl structure for requesting FC info for a port */ 222f6ad3f23SAlexander Motin typedef struct encioc_elm_fc_port { 223f6ad3f23SAlexander Motin unsigned int elm_idx; 224f6ad3f23SAlexander Motin unsigned int port_idx; 225f6ad3f23SAlexander Motin struct ses_elm_fc_port port_data; 226f6ad3f23SAlexander Motin } encioc_elm_fc_port_t; 227f6ad3f23SAlexander Motin 228f6ad3f23SAlexander Motin /* ioctl structure for requesting SAS info for element phys */ 229f6ad3f23SAlexander Motin typedef struct encioc_elm_sas_device_phy { 230f6ad3f23SAlexander Motin unsigned int elm_idx; 231f6ad3f23SAlexander Motin unsigned int phy_idx; 232f6ad3f23SAlexander Motin struct ses_elm_sas_device_phy phy_data; 233f6ad3f23SAlexander Motin } enioc_elm_sas_phy_t; 234f6ad3f23SAlexander Motin 235f6ad3f23SAlexander Motin /* ioctl structure for requesting SAS info for an expander phy */ 236f6ad3f23SAlexander Motin typedef struct encioc_elm_sas_expander_phy { 237f6ad3f23SAlexander Motin unsigned int elm_idx; 238f6ad3f23SAlexander Motin unsigned int phy_idx; 239f6ad3f23SAlexander Motin struct ses_elm_sas_expander_phy phy_data; 240f6ad3f23SAlexander Motin } encioc_elm_sas_expander_phy_t; 241f6ad3f23SAlexander Motin 242f6ad3f23SAlexander Motin /* ioctl structure for requesting SAS info for a port phy */ 243f6ad3f23SAlexander Motin typedef struct encioc_elm_sas_port_phy { 244f6ad3f23SAlexander Motin unsigned int elm_idx; 245f6ad3f23SAlexander Motin unsigned int phy_idx; 246f6ad3f23SAlexander Motin struct ses_elm_sas_port_phy phy_data; 247f6ad3f23SAlexander Motin } enioc_elm_sas_port_phy_t; 248f6ad3f23SAlexander Motin 249f6ad3f23SAlexander Motin /* ioctl structure for requesting additional status for an element */ 250f6ad3f23SAlexander Motin typedef struct encioc_addl_status { 251f6ad3f23SAlexander Motin unsigned int elm_idx; 252f6ad3f23SAlexander Motin union ses_elm_addlstatus_descr_hdr addl_hdr; 253f6ad3f23SAlexander Motin union ses_elm_addlstatus_proto_hdr proto_hdr; 254f6ad3f23SAlexander Motin } enioc_addl_status_t; 255f6ad3f23SAlexander Motin 256f6ad3f23SAlexander Motin #endif /* _SCSI_ENC_H_ */ 257