xref: /titanic_50/usr/src/uts/common/sys/scsi/impl/services.h (revision c242ec1b4cd260e90178d81575297bb3b3648766)
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_ASCII		{					\
131 		"dma-max", "msg-out", "disconnect", "synchronous",	\
132 		"wide-xfer", "parity", "initiator-id", "untagged-qing",	\
133 		"tagged-qing", "auto-rqsense", "linked-cmds",		\
134 		"sector-size", "total-sectors", "geometry",		\
135 		"reset-notification", "qfull-retries",			\
136 		"qfull-retry-interval", "scsi-version",			\
137 		"interconnect-type", "lun-reset",			\
138 		"max-cdb-length", "dma-max-arch", NULL }
139 
140 /*
141  * Definitions used by some capabilities
142  */
143 /*					SCSI_CAP_SCSI_VERSION */
144 #define	SCSI_VERSION_1			1
145 #define	SCSI_VERSION_2			2
146 #define	SCSI_VERSION_3			3
147 
148 /*					SCSI_CAP_INTERCONNECT_TYPE */
149 #define	INTERCONNECT_PARALLEL		1
150 #define	INTERCONNECT_FIBRE		2	/* PLDA or hard ALPA */
151 #define	INTERCONNECT_1394		3
152 #define	INTERCONNECT_SSA		4	/* -EOLed */
153 #define	INTERCONNECT_FABRIC		5	/* soft ALPA or Switch */
154 #define	INTERCONNECT_USB		6
155 #define	INTERCONNECT_ATAPI		7
156 #define	INTERCONNECT_ISCSI		8
157 #define	INTERCONNECT_IBSRP		9
158 #define	INTERCONNECT_SATA		10
159 #define	INTERCONNECT_SAS		11
160 #define	INTERCONNECT_MAX		12	/* Change this appropriately, */
161 						/* as new one(s) are added.   */
162 						/* Is always the last & max.  */
163 
164 /*					INTERCONNECT TYPE STRINGS */
165 #define	INTERCONNECT_PARALLEL_STR	"SPI"
166 #define	INTERCONNECT_FIBRE_STR		"FIBRE"
167 #define	INTERCONNECT_1394_STR		"1394"
168 #define	INTERCONNECT_SSA_STR		""
169 #define	INTERCONNECT_FABRIC_STR		"FABRIC"
170 #define	INTERCONNECT_USB_STR		"USB"
171 #define	INTERCONNECT_ATAPI_STR		"ATAPI"
172 #define	INTERCONNECT_ISCSI_STR		"iSCSI"
173 #define	INTERCONNECT_IBSRP_STR		"IB"
174 #define	INTERCONNECT_SATA_STR		"SATA"
175 #define	INTERCONNECT_SAS_STR		"SAS"
176 
177 #define	INTERCONNECT_TYPE_ASCII		{				\
178 					"",				\
179 					INTERCONNECT_PARALLEL_STR,	\
180 					INTERCONNECT_FIBRE_STR,		\
181 					INTERCONNECT_1394_STR,		\
182 					INTERCONNECT_SSA_STR,		\
183 					INTERCONNECT_FABRIC_STR,	\
184 					INTERCONNECT_USB_STR,		\
185 					INTERCONNECT_ATAPI_STR,		\
186 					INTERCONNECT_ISCSI_STR,		\
187 					INTERCONNECT_IBSRP_STR,		\
188 					INTERCONNECT_SATA_STR,		\
189 					INTERCONNECT_SAS_STR,		\
190 					NULL				\
191 					};
192 
193 /*
194  * Compatibility...
195  */
196 #define	scsi_cmd_decode	scsi_cname
197 
198 #endif	/* _KERNEL */
199 
200 #ifdef	__cplusplus
201 }
202 #endif
203 
204 #endif	/* _SYS_SCSI_IMPL_SERVICES_H */
205