/*-1* SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)2*3* Copyright (c) 2000 by Matthew Jacob4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* 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 products13* derived from this software without specific prior written permission.14*15* Alternatively, this software may be distributed under the terms of the16* the GNU Public License ("GPL").17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR22* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*30*/31#ifndef _SCSI_ENC_H_32#define _SCSI_ENC_H_3334#include <cam/scsi/scsi_ses.h>3536#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#define ENCIOC_GETENCNAME _IO(ENCIOC, 13)50#define ENCIOC_GETENCID _IO(ENCIOC, 14)5152/*53* Platform Independent Definitions for enclosure devices.54*/55/*56* SCSI Based Environmental Services Application Defines57*58* Based almost entirely on SCSI-3 ENC Revision 8A specification,59* but slightly abstracted as the underlying device may in fact60* be a SAF-TE or vendor unique device.61*/62/*63* ENC Driver Operations:64* (The defines themselves are platform and access method specific)65*66* ENCIOC_GETNELM67* ENCIOC_GETELMMAP68* ENCIOC_GETENCSTAT69* ENCIOC_SETENCSTAT70* ENCIOC_GETELMSTAT71* ENCIOC_SETELMSTAT72* ENCIOC_INIT73*74*75* An application finds out how many elements an enclosure instance76* manages by performing a ENCIOC_GETNELM operation. It then77* performs an ENCIOC_GETELMMAP to get the map that contains the78* element identifiers for all elements (see encioc_element_t below).79* This information is static.80*81* The application may perform ENCIOC_GETELMSTAT operations to retrieve82* status on an element (see the encioc_elm_status_t structure below),83* and ENCIOC_SETELMSTAT operations to set status for an element.84*85* Similarly, overall enclosure status may be fetched or set via86* ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t87* below).88*89* Readers should note that there is nothing that requires either a set90* or a clear operation to actually latch and do anything in the target.91*92* An ENCIOC_INIT operation causes the enclosure to be initialized.93*/9495/* Element Types */96typedef enum {97ELMTYP_UNSPECIFIED = 0x00,98ELMTYP_DEVICE = 0x01,99ELMTYP_POWER = 0x02,100ELMTYP_FAN = 0x03,101ELMTYP_THERM = 0x04,102ELMTYP_DOORLOCK = 0x05,103ELMTYP_ALARM = 0x06,104ELMTYP_ESCC = 0x07, /* Enclosure SCC */105ELMTYP_SCC = 0x08, /* SCC */106ELMTYP_NVRAM = 0x09,107ELMTYP_INV_OP_REASON = 0x0a,108ELMTYP_UPS = 0x0b,109ELMTYP_DISPLAY = 0x0c,110ELMTYP_KEYPAD = 0x0d,111ELMTYP_ENCLOSURE = 0x0e,112ELMTYP_SCSIXVR = 0x0f,113ELMTYP_LANGUAGE = 0x10,114ELMTYP_COMPORT = 0x11,115ELMTYP_VOM = 0x12,116ELMTYP_AMMETER = 0x13,117ELMTYP_SCSI_TGT = 0x14,118ELMTYP_SCSI_INI = 0x15,119ELMTYP_SUBENC = 0x16,120ELMTYP_ARRAY_DEV = 0x17,121ELMTYP_SAS_EXP = 0x18, /* SAS Expander */122ELMTYP_SAS_CONN = 0x19, /* SAS Connector */123ELMTYP_LAST = ELMTYP_SAS_CONN124} elm_type_t;125126#define ELM_TYPE_NAMES { \127"Unspecified", \128"Device Slot", \129"Power Supply", \130"Cooling", \131"Temperature Sensor", \132"Door", \133"Audible alarm", \134"Enclosure Services Controller Electronics", \135"SCC Controller Electronics", \136"Nonvolatile Cache", \137"Invalid Operation Reason", \138"Uninterruptible Power Supply", \139"Display", \140"Key Pad Entry", \141"Enclosure", \142"SCSI Port/Transceiver", \143"Language", \144"Communication Port", \145"Voltage Sensor", \146"Current Sensor", \147"SCSI Target Port", \148"SCSI Initiator Port", \149"Simple Subenclosure", \150"Array Device Slot", \151"SAS Expander", \152"SAS Connector" \153}154155#ifdef _KERNEL156extern const char *elm_type_names[];157#endif158159typedef struct encioc_element {160/* Element Index */161unsigned int elm_idx;162163/* ID of SubEnclosure containing Element*/164unsigned int elm_subenc_id;165166/* Element Type */167elm_type_t elm_type;168} encioc_element_t;169170/*171* Overall Enclosure Status172*/173typedef unsigned char encioc_enc_status_t;174175/*176* Element Status177*/178typedef struct encioc_elm_status {179unsigned int elm_idx;180unsigned char cstat[4];181} encioc_elm_status_t;182183/*184* ENC String structure, for StringIn and StringOut commands; use this with185* the ENCIOC_GETSTRING and ENCIOC_SETSTRING ioctls.186*/187typedef struct encioc_string {188size_t bufsiz; /* IN/OUT: length of string provided/returned */189#define ENC_STRING_MAX 0xffff190uint8_t *buf; /* IN/OUT: string */191} encioc_string_t;192193/*============================================================================*/194195/*196* SES v2 r20 6.1.10 (pg 39) - Element Descriptor diagnostic page197* Tables 21, 22, and 23198*/199typedef struct encioc_elm_desc {200unsigned int elm_idx; /* IN: elment requested */201uint16_t elm_desc_len; /* IN: buffer size; OUT: bytes written */202char *elm_desc_str; /* IN/OUT: buffer for descriptor data */203} encioc_elm_desc_t;204205/*206* ENCIOC_GETELMDEVNAMES:207* ioctl structure to get an element's device names, if available208*/209typedef struct encioc_elm_devnames {210unsigned int elm_idx; /* IN: element index */211size_t elm_names_size;/* IN: size of elm_devnames */212size_t elm_names_len; /* OUT: actual size returned */213/*214* IN/OUT: comma separated list of peripheral driver215* instances servicing this element.216*/217char *elm_devnames;218} encioc_elm_devnames_t;219220/* ioctl structure for requesting FC info for a port */221typedef struct encioc_elm_fc_port {222unsigned int elm_idx;223unsigned int port_idx;224struct ses_elm_fc_port port_data;225} encioc_elm_fc_port_t;226227/* ioctl structure for requesting SAS info for element phys */228typedef struct encioc_elm_sas_device_phy {229unsigned int elm_idx;230unsigned int phy_idx;231struct ses_elm_sas_device_phy phy_data;232} enioc_elm_sas_phy_t;233234/* ioctl structure for requesting SAS info for an expander phy */235typedef struct encioc_elm_sas_expander_phy {236unsigned int elm_idx;237unsigned int phy_idx;238struct ses_elm_sas_expander_phy phy_data;239} encioc_elm_sas_expander_phy_t;240241/* ioctl structure for requesting SAS info for a port phy */242typedef struct encioc_elm_sas_port_phy {243unsigned int elm_idx;244unsigned int phy_idx;245struct ses_elm_sas_port_phy phy_data;246} enioc_elm_sas_port_phy_t;247248/* ioctl structure for requesting additional status for an element */249typedef struct encioc_addl_status {250unsigned int elm_idx;251union ses_elm_addlstatus_descr_hdr addl_hdr;252union ses_elm_addlstatus_proto_hdr proto_hdr;253} enioc_addl_status_t;254255#endif /* _SCSI_ENC_H_ */256257258