xref: /illumos-gate/usr/src/uts/common/sys/scsi/impl/services.h (revision 46b592853d0f4f11781b6b0a7533f267c6aee132)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_IMPL_SERVICES_H
27 #define	_SYS_SCSI_IMPL_SERVICES_H
28 
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Implementation services not classified by type
36  */
37 
38 #ifdef	_KERNEL
39 
40 struct scsi_key_strings {
41 	int key;
42 	char *message;
43 };
44 
45 struct scsi_asq_key_strings {
46 	ushort_t asc;
47 	ushort_t ascq;
48 	char *message;
49 };
50 
51 int	scsi_poll(struct scsi_pkt *);
52 struct scsi_pkt	*get_pktiopb(struct scsi_address *,
53 		    caddr_t *datap, int cdblen, int statuslen,
54 		    int datalen, int readflag, int (*func)(void));
55 void		free_pktiopb(struct scsi_pkt *, caddr_t datap, int datalen);
56 
57 char	*scsi_dname(int dtyp);
58 char	*scsi_rname(uchar_t reason);
59 char	*scsi_mname(uchar_t msg);
60 char	*scsi_cname(uchar_t cmd, char **cmdvec);
61 char	*scsi_cmd_name(uchar_t cmd, struct scsi_key_strings *cmdlist,
62 	    char *tmpstr);
63 char	*scsi_sname(uchar_t sense_key);
64 char	*scsi_esname(uint_t sense_key, char *tmpstr);
65 char	*scsi_asc_name(uint_t asc, uint_t ascq, char *tmpstr);
66 
67 void	scsi_generic_errmsg(struct scsi_device *devp, char *label,
68 	    int severity, daddr_t blkno, daddr_t err_blkno,
69 	    uchar_t cmd_name, struct scsi_key_strings *cmdlist,
70 	    uint8_t *sensep, struct scsi_asq_key_strings *asc_list,
71 	    char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t));
72 
73 void	scsi_vu_errmsg(struct scsi_device *devp, struct scsi_pkt *pktp,
74 	    char *drv_name, int severity, daddr_t blkno, daddr_t err_blkno,
75 	    struct scsi_key_strings *cmdlist,
76 	    struct scsi_extended_sense *sensep,
77 	    struct scsi_asq_key_strings *asc_list,
78 	    char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t));
79 void	scsi_errmsg(struct scsi_device *devp, struct scsi_pkt *pkt,
80 	    char *label, int severity, daddr_t blkno, daddr_t err_blkno,
81 	    struct scsi_key_strings *cmdlist,
82 	    struct scsi_extended_sense *sensep);
83 
84 
85 
86 
87 /*PRINTFLIKE4*/
88 void	scsi_log(dev_info_t *dev, char *label,
89 	    uint_t level, const char *fmt, ...) __KPRINTFLIKE(4);
90 
91 extern char *scsi_state_bits;
92 extern char *sense_keys[NUM_SENSE_KEYS + NUM_IMPL_SENSE_KEYS];
93 
94 #define	SCSI_DEBUG	0xDEB00000
95 
96 #define	SCSI_ERR_ALL		0
97 #define	SCSI_ERR_UNKNOWN	1
98 #define	SCSI_ERR_INFO		2
99 #define	SCSI_ERR_RECOVERED	3
100 #define	SCSI_ERR_RETRYABLE	4
101 #define	SCSI_ERR_FATAL		5
102 #define	SCSI_ERR_NONE		6
103 
104 
105 /*
106  * Common Capability Strings Array
107  */
108 #define	SCSI_CAP_DMA_MAX		0
109 #define	SCSI_CAP_MSG_OUT		1
110 #define	SCSI_CAP_DISCONNECT		2
111 #define	SCSI_CAP_SYNCHRONOUS		3
112 #define	SCSI_CAP_WIDE_XFER		4
113 #define	SCSI_CAP_PARITY			5
114 #define	SCSI_CAP_INITIATOR_ID		6
115 #define	SCSI_CAP_UNTAGGED_QING		7
116 #define	SCSI_CAP_TAGGED_QING		8
117 #define	SCSI_CAP_ARQ			9
118 #define	SCSI_CAP_LINKED_CMDS		10
119 #define	SCSI_CAP_SECTOR_SIZE		11
120 #define	SCSI_CAP_TOTAL_SECTORS		12
121 #define	SCSI_CAP_GEOMETRY		13
122 #define	SCSI_CAP_RESET_NOTIFICATION	14
123 #define	SCSI_CAP_QFULL_RETRIES		15
124 #define	SCSI_CAP_QFULL_RETRY_INTERVAL	16
125 #define	SCSI_CAP_SCSI_VERSION		17
126 #define	SCSI_CAP_INTERCONNECT_TYPE	18
127 #define	SCSI_CAP_LUN_RESET		19
128 #define	SCSI_CAP_CDB_LEN		20
129 #define	SCSI_CAP_DMA_MAX_ARCH		21
130 #define	SCSI_CAP_TRAN_LAYER_RETRIES	22
131 #define	SCSI_CAP_ASCII		{					\
132 		"dma-max", "msg-out", "disconnect", "synchronous",	\
133 		"wide-xfer", "parity", "initiator-id", "untagged-qing",	\
134 		"tagged-qing", "auto-rqsense", "linked-cmds",		\
135 		"sector-size", "total-sectors", "geometry",		\
136 		"reset-notification", "qfull-retries",			\
137 		"qfull-retry-interval", "scsi-version",			\
138 		"interconnect-type", "lun-reset",			\
139 		"max-cdb-length", "dma-max-arch",			\
140 		"tran-layer-retries", NULL }
141 
142 /*
143  * Definitions used by some capabilities
144  */
145 /*					SCSI_CAP_SCSI_VERSION */
146 #define	SCSI_VERSION_1			1
147 #define	SCSI_VERSION_2			2
148 #define	SCSI_VERSION_3			3
149 
150 /*					SCSI_CAP_INTERCONNECT_TYPE */
151 #define	INTERCONNECT_PARALLEL		1
152 #define	INTERCONNECT_FIBRE		2	/* PLDA or hard ALPA */
153 #define	INTERCONNECT_1394		3
154 #define	INTERCONNECT_SSA		4	/* -EOLed */
155 #define	INTERCONNECT_FABRIC		5	/* soft ALPA or Switch */
156 #define	INTERCONNECT_USB		6
157 #define	INTERCONNECT_ATAPI		7
158 #define	INTERCONNECT_ISCSI		8
159 #define	INTERCONNECT_IBSRP		9
160 #define	INTERCONNECT_SATA		10
161 #define	INTERCONNECT_SAS		11
162 #define	INTERCONNECT_MAX		12	/* Change this appropriately, */
163 						/* as new one(s) are added.   */
164 						/* Is always the last & max.  */
165 
166 /*					INTERCONNECT TYPE STRINGS */
167 #define	INTERCONNECT_PARALLEL_STR	"SPI"
168 #define	INTERCONNECT_FIBRE_STR		"FIBRE"
169 #define	INTERCONNECT_1394_STR		"1394"
170 #define	INTERCONNECT_SSA_STR		""
171 #define	INTERCONNECT_FABRIC_STR		"FABRIC"
172 #define	INTERCONNECT_USB_STR		"USB"
173 #define	INTERCONNECT_ATAPI_STR		"ATAPI"
174 #define	INTERCONNECT_ISCSI_STR		"iSCSI"
175 #define	INTERCONNECT_IBSRP_STR		"IB"
176 #define	INTERCONNECT_SATA_STR		"SATA"
177 #define	INTERCONNECT_SAS_STR		"SAS"
178 
179 #define	INTERCONNECT_TYPE_ASCII		{				\
180 					"",				\
181 					INTERCONNECT_PARALLEL_STR,	\
182 					INTERCONNECT_FIBRE_STR,		\
183 					INTERCONNECT_1394_STR,		\
184 					INTERCONNECT_SSA_STR,		\
185 					INTERCONNECT_FABRIC_STR,	\
186 					INTERCONNECT_USB_STR,		\
187 					INTERCONNECT_ATAPI_STR,		\
188 					INTERCONNECT_ISCSI_STR,		\
189 					INTERCONNECT_IBSRP_STR,		\
190 					INTERCONNECT_SATA_STR,		\
191 					INTERCONNECT_SAS_STR,		\
192 					NULL				\
193 					};
194 
195 /*
196  * Compatibility...
197  */
198 #define	scsi_cmd_decode	scsi_cname
199 
200 #endif	/* _KERNEL */
201 
202 #ifdef	__cplusplus
203 }
204 #endif
205 
206 #endif	/* _SYS_SCSI_IMPL_SERVICES_H */
207