scsi_ses.h revision 222336
1/* $FreeBSD: head/sys/cam/scsi/scsi_ses.h 222336 2011-05-27 03:23:39Z mav $ */ 2/*- 3 * Copyright (c) 2000 by Matthew Jacob 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * 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 products 13 * derived from this software without specific prior written permission. 14 * 15 * Alternatively, this software may be distributed under the terms of the 16 * the GNU Public License ("GPL"). 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 */ 31 32#define SESIOC ('s' - 040) 33#define SESIOC_GETNOBJ _IO(SESIOC, 1) 34#define SESIOC_GETOBJMAP _IO(SESIOC, 2) 35#define SESIOC_GETENCSTAT _IO(SESIOC, 3) 36#define SESIOC_SETENCSTAT _IO(SESIOC, 4) 37#define SESIOC_GETOBJSTAT _IO(SESIOC, 5) 38#define SESIOC_SETOBJSTAT _IO(SESIOC, 6) 39#define SESIOC_GETTEXT _IO(SESIOC, 7) 40#define SESIOC_INIT _IO(SESIOC, 8) 41 42/* 43 * Platform Independent Definitions for SES devices. 44 */ 45/* 46 * SCSI Based Environmental Services Application Defines 47 * 48 * Based almost entirely on SCSI-3 SES Revision 8A specification, 49 * but slightly abstracted as the underlying device may in fact 50 * be a SAF-TE or vendor unique device. 51 */ 52/* 53 * SES Driver Operations: 54 * (The defines themselves are platform and access method specific) 55 * 56 * SESIOC_GETNOBJ 57 * SESIOC_GETOBJMAP 58 * SESIOC_GETENCSTAT 59 * SESIOC_SETENCSTAT 60 * SESIOC_GETOBJSTAT 61 * SESIOC_SETOBJSTAT 62 * SESIOC_INIT 63 * 64 * 65 * An application finds out how many objects an SES instance 66 * is managing by performing a SESIOC_GETNOBJ operation. It then 67 * performs a SESIOC_GETOBJMAP to get the map that contains the 68 * object identifiers for all objects (see ses_object below). 69 * This information is static. 70 * 71 * The application may perform SESIOC_GETOBJSTAT operations to retrieve 72 * status on an object (see the ses_objstat structure below), SESIOC_SETOBJSTAT 73 * operations to set status for an object. 74 * 75 * Similarly overall enclosure status me be fetched or set via 76 * SESIOC_GETENCSTAT or SESIOC_SETENCSTAT operations (see ses_encstat below). 77 * 78 * Readers should note that there is nothing that requires either a set 79 * or a clear operation to actually latch and do anything in the target. 80 * 81 * A SESIOC_INIT operation causes the enclosure to be initialized. 82 */ 83 84typedef struct { 85 unsigned int obj_id; /* Object Identifier */ 86 unsigned char subencid; /* SubEnclosure ID */ 87 unsigned char object_type; /* Object Type */ 88} ses_object; 89 90/* Object Types */ 91#define SESTYP_UNSPECIFIED 0x00 92#define SESTYP_DEVICE 0x01 93#define SESTYP_POWER 0x02 94#define SESTYP_FAN 0x03 95#define SESTYP_THERM 0x04 96#define SESTYP_DOORLOCK 0x05 97#define SESTYP_ALARM 0x06 98#define SESTYP_ESCC 0x07 /* Enclosure SCC */ 99#define SESTYP_SCC 0x08 /* SCC */ 100#define SESTYP_NVRAM 0x09 101#define SESTYP_UPS 0x0b 102#define SESTYP_DISPLAY 0x0c 103#define SESTYP_KEYPAD 0x0d 104#define SESTYP_ENCLOSURE 0x0e 105#define SESTYP_SCSIXVR 0x0f 106#define SESTYP_LANGUAGE 0x10 107#define SESTYP_COMPORT 0x11 108#define SESTYP_VOM 0x12 109#define SESTYP_AMMETER 0x13 110#define SESTYP_SCSI_TGT 0x14 111#define SESTYP_SCSI_INI 0x15 112#define SESTYP_SUBENC 0x16 113#define SESTYP_ARRAY 0x17 114#define SESTYP_SAS_EXP 0x18 115#define SESTYP_SAS_CONN 0x19 116 117/* 118 * Overall Enclosure Status 119 */ 120typedef unsigned char ses_encstat; 121#define SES_ENCSTAT_UNRECOV 0x1 122#define SES_ENCSTAT_CRITICAL 0x2 123#define SES_ENCSTAT_NONCRITICAL 0x4 124#define SES_ENCSTAT_INFO 0x8 125 126/* 127 * Object Status 128 */ 129typedef struct { 130 unsigned int obj_id; 131 unsigned char cstat[4]; 132} ses_objstat; 133 134/* Summary SES Status Defines, Common Status Codes */ 135#define SES_OBJSTAT_UNSUPPORTED 0 136#define SES_OBJSTAT_OK 1 137#define SES_OBJSTAT_CRIT 2 138#define SES_OBJSTAT_NONCRIT 3 139#define SES_OBJSTAT_UNRECOV 4 140#define SES_OBJSTAT_NOTINSTALLED 5 141#define SES_OBJSTAT_UNKNOWN 6 142#define SES_OBJSTAT_NOTAVAIL 7 143 144/* 145 * For control pages, cstat[0] is the same for the 146 * enclosure and is common across all device types. 147 * 148 * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP 149 * are checked, otherwise bits that are specific to the device 150 * type in the other 3 bytes of cstat or checked. 151 */ 152#define SESCTL_CSEL 0x80 153#define SESCTL_PRDFAIL 0x40 154#define SESCTL_DISABLE 0x20 155#define SESCTL_RSTSWAP 0x10 156 157 158/* Control bits, Device Elements, byte 2 */ 159#define SESCTL_DRVLCK 0x40 /* "DO NOT REMOVE" */ 160#define SESCTL_RQSINS 0x08 /* RQST INSERT */ 161#define SESCTL_RQSRMV 0x04 /* RQST REMOVE */ 162#define SESCTL_RQSID 0x02 /* RQST IDENT */ 163/* Control bits, Device Elements, byte 3 */ 164#define SESCTL_RQSFLT 0x20 /* RQST FAULT */ 165#define SESCTL_DEVOFF 0x10 /* DEVICE OFF */ 166 167/* Control bits, Generic, byte 3 */ 168#define SESCTL_RQSTFAIL 0x40 169#define SESCTL_RQSTON 0x20 170 171/* 172 * Getting text for an object type is a little 173 * trickier because it's string data that can 174 * go up to 64 KBytes. Build this union and 175 * fill the obj_id with the id of the object who's 176 * help text you want, and if text is available, 177 * obj_text will be filled in, null terminated. 178 */ 179 180typedef union { 181 unsigned int obj_id; 182 char obj_text[1]; 183} ses_hlptxt; 184