xref: /titanic_51/usr/src/uts/common/sys/scsi/targets/sesio.h (revision d24234c24aeaca4ca56ee3ac2794507968f274c4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SESIO_H
27 #define	_SYS_SESIO_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Enclosure Services Interface Structures
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Data Structures and definitions for SES Applications
41  */
42 
43 typedef struct {
44 	unsigned int obj_id;		/* Object Identifier */
45 	unsigned int		:  16,	/* reserved */
46 		subencid	:  8,	/* SubEnclosure ID */
47 		elem_type	:  8;	/* Element Type */
48 } ses_object;
49 
50 /* Known Enclosure Types */
51 #define	SESTYP_UNSPECIFIED	0x00
52 #define	SESTYP_DEVICE		0x01
53 #define	SESTYP_POWER		0x02
54 #define	SESTYP_FAN		0x03
55 #define	SESTYP_THERM		0x04
56 #define	SESTYP_DOORLOCK		0x05
57 #define	SESTYP_ALARM		0x06
58 #define	SESTYP_ESCC		0x07	/* Enclosure SCC */
59 #define	SESTYP_SCC		0x08	/* SCC */
60 #define	SESTYP_NVRAM		0x09
61 #define	SESTYP_UPS		0x0b
62 #define	SESTYP_DISPLAY		0x0c
63 #define	SESTYP_KEYPAD		0x0d
64 #define	SESTYP_SCSIXVR		0x0f
65 #define	SESTYP_LANGUAGE		0x10
66 #define	SESTYP_COMPORT		0x11
67 #define	SESTYP_VOM		0x12
68 #define	SESTYP_AMMETER		0x13
69 #define	SESTYP_SCSI_TGT		0x14
70 #define	SESTYP_SCSI_INI		0x15
71 #define	SESTYP_SUBENC		0x16
72 #define	SESTYP_ARRAY		0x17	/* SES2r19 #7.1 */
73 #define	SESTYP_SASEXPANDER	0x18	/* SES2r19 #7.1 */
74 #define	SESTYP_SASCONNECTOR	0x19	/* SES2r19 #7.1 */
75 
76 
77 /*
78  * Overall Enclosure Status
79  */
80 #define	ENCSTAT_UNRECOV		0x1
81 #define	ENCSTAT_CRITICAL	0x2
82 #define	ENCSTAT_NONCRITICAL	0x4
83 #define	ENCSTAT_INFO		0x8
84 
85 typedef struct {
86 	uint_t obj_id;
87 	uchar_t cstat[4];
88 } ses_objarg;
89 
90 /* Summary SES Status Defines, Common Status Codes */
91 #define	SESSTAT_UNSUPPORTED	0
92 #define	SESSTAT_OK		1
93 #define	SESSTAT_CRIT		2
94 #define	SESSTAT_NONCRIT		3
95 #define	SESSTAT_UNRECOV		4
96 #define	SESSTAT_NOTINSTALLED	5
97 #define	SESSTAT_UNKNOWN		6
98 #define	SESSTAT_NOTAVAIL	7
99 
100 /*
101  * For control pages, cstat[0] is the same for the
102  * enclosure and is common across all device types.
103  *
104  * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP
105  * are checked, otherwise bits that are specific to the device
106  * type in the other 3 bytes of cstat or checked.
107  */
108 #define	SESCTL_CSEL		0x80
109 #define	SESCTL_PRDFAIL		0x40
110 #define	SESCTL_DISABLE		0x20
111 #define	SESCTL_RSTSWAP		0x10
112 
113 
114 /* Control bits, Device Elements, byte 2 */
115 #define	SESCTL_DRVLCK	0x40	/* "DO NOT REMOVE" */
116 #define	SESCTL_RQSINS	0x08	/* RQST INSERT */
117 #define	SESCTL_RQSRMV	0x04	/* RQST REMOVE */
118 #define	SESCTL_RQSID	0x02	/* RQST IDENT */
119 /* Control bits, Device Elements, byte 3 */
120 #define	SESCTL_RQSFLT	0x20	/* RQST FAULT */
121 #define	SESCTL_DEVOFF	0x10	/* DEVICE OFF */
122 
123 /* Control bits, Generic, byte 3 */
124 #define	SESCTL_RQSTFAIL	0x40
125 #define	SESCTL_RQSTON	0x20
126 
127 
128 /*
129  * SES Driver ioctls
130  */
131 #define	SESIOC			('e'<<8)
132 #define	SESIOC_IOCTL_GETSTATE	(SESIOC|1)	/* get esi status */
133 #define	SESIOC_IOCTL_SETSTATE	(SESIOC|2)	/* set esi state */
134 #define	SESIOC_IOCTL_INQUIRY	(SESIOC|3)	/* get SCSI Inquiry info */
135 #define	SESIOC_GETNOBJ		(SESIOC|10)
136 #define	SESIOC_GETOBJMAP	(SESIOC|11)
137 #define	SESIOC_INIT		(SESIOC|12)
138 #define	SESIOC_GETENCSTAT	(SESIOC|13)
139 #define	SESIOC_SETENCSTAT	(SESIOC|14)
140 #define	SESIOC_GETOBJSTAT	(SESIOC|15)
141 #define	SESIOC_SETOBJSTAT	(SESIOC|16)
142 
143 /*
144  * The following structure is used by the SES_IOCTL_GETSTATE
145  * and the SES_IOCTL_SETSTATE ioctls
146  */
147 struct ses_ioctl {
148     uint32_t	page_size;	/* Size of page to be read/written */
149     uint8_t	page_code;	/* Page to be read/written */
150     caddr_t	page;		/* Address of page to be read/written */
151 };
152 
153 
154 #ifdef	__cplusplus
155 }
156 #endif
157 
158 #endif	/* _SYS_SESIO_H */
159