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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SCSI_IMPL_SERVICES_H
28 #define	_SYS_SCSI_IMPL_SERVICES_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Implementation services not classified by type
38  */
39 
40 #ifdef	_KERNEL
41 
42 struct scsi_key_strings {
43 	int key;
44 	char *message;
45 };
46 
47 struct scsi_asq_key_strings {
48 	ushort_t asc;
49 	ushort_t ascq;
50 	char *message;
51 };
52 
53 int	scsi_poll(struct scsi_pkt *);
54 struct scsi_pkt	*get_pktiopb(struct scsi_address *,
55 		    caddr_t *datap, int cdblen, int statuslen,
56 		    int datalen, int readflag, int (*func)(void));
57 void		free_pktiopb(struct scsi_pkt *, caddr_t datap, int datalen);
58 
59 char	*scsi_dname(int dtyp);
60 char	*scsi_rname(uchar_t reason);
61 char	*scsi_mname(uchar_t msg);
62 char	*scsi_cname(uchar_t cmd, char **cmdvec);
63 char	*scsi_cmd_name(uchar_t cmd, struct scsi_key_strings *cmdlist,
64 	    char *tmpstr);
65 char	*scsi_sname(uchar_t sense_key);
66 char	*scsi_esname(uint_t sense_key, char *tmpstr);
67 char	*scsi_asc_name(uint_t asc, uint_t ascq, char *tmpstr);
68 void	scsi_vu_errmsg(struct scsi_device *devp, struct scsi_pkt *pktp,
69 	    char *drv_name, int severity, daddr_t blkno, daddr_t err_blkno,
70 	    struct scsi_key_strings *cmdlist,
71 	    struct scsi_extended_sense *sensep,
72 	    struct scsi_asq_key_strings *asc_list,
73 	    char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t));
74 void	scsi_errmsg(struct scsi_device *devp, struct scsi_pkt *pkt,
75 	    char *label, int severity, daddr_t blkno, daddr_t err_blkno,
76 	    struct scsi_key_strings *cmdlist,
77 	    struct scsi_extended_sense *sensep);
78 /*PRINTFLIKE4*/
79 void	scsi_log(dev_info_t *dev, char *label,
80 	    uint_t level, const char *fmt, ...) __KPRINTFLIKE(4);
81 
82 extern char *scsi_state_bits;
83 extern char *sense_keys[NUM_SENSE_KEYS + NUM_IMPL_SENSE_KEYS];
84 
85 #define	SCSI_DEBUG	0xDEB00000
86 
87 #define	SCSI_ERR_ALL		0
88 #define	SCSI_ERR_UNKNOWN	1
89 #define	SCSI_ERR_INFO		2
90 #define	SCSI_ERR_RECOVERED	3
91 #define	SCSI_ERR_RETRYABLE	4
92 #define	SCSI_ERR_FATAL		5
93 #define	SCSI_ERR_NONE		6
94 
95 
96 /*
97  * Common Capability Strings Array
98  */
99 #define	SCSI_CAP_DMA_MAX		0
100 #define	SCSI_CAP_MSG_OUT		1
101 #define	SCSI_CAP_DISCONNECT		2
102 #define	SCSI_CAP_SYNCHRONOUS		3
103 #define	SCSI_CAP_WIDE_XFER		4
104 #define	SCSI_CAP_PARITY			5
105 #define	SCSI_CAP_INITIATOR_ID		6
106 #define	SCSI_CAP_UNTAGGED_QING		7
107 #define	SCSI_CAP_TAGGED_QING		8
108 #define	SCSI_CAP_ARQ			9
109 #define	SCSI_CAP_LINKED_CMDS		10
110 #define	SCSI_CAP_SECTOR_SIZE		11
111 #define	SCSI_CAP_TOTAL_SECTORS		12
112 #define	SCSI_CAP_GEOMETRY		13
113 #define	SCSI_CAP_RESET_NOTIFICATION	14
114 #define	SCSI_CAP_QFULL_RETRIES		15
115 #define	SCSI_CAP_QFULL_RETRY_INTERVAL	16
116 #define	SCSI_CAP_SCSI_VERSION		17
117 #define	SCSI_CAP_INTERCONNECT_TYPE	18
118 #define	SCSI_CAP_LUN_RESET		19
119 #define	SCSI_CAP_ASCII		{					\
120 		"dma-max", "msg-out", "disconnect", "synchronous",	\
121 		"wide-xfer", "parity", "initiator-id", "untagged-qing",	\
122 		"tagged-qing", "auto-rqsense", "linked-cmds",		\
123 		"sector-size", "total-sectors", "geometry",		\
124 		"reset-notification", "qfull-retries",			\
125 		"qfull-retry-interval", "scsi-version",			\
126 		"interconnect-type", "lun-reset", NULL }
127 
128 /*
129  * Definitions used by some capabilities
130  */
131 /*					SCSI_CAP_SCSI_VERSION */
132 #define	SCSI_VERSION_1			1
133 #define	SCSI_VERSION_2			2
134 #define	SCSI_VERSION_3			3
135 
136 /*					SCSI_CAP_INTERCONNECT_TYPE */
137 #define	INTERCONNECT_PARALLEL		1
138 #define	INTERCONNECT_FIBRE		2	/* PLDA or hard ALPA */
139 #define	INTERCONNECT_1394		3
140 #define	INTERCONNECT_SSA		4	/* -EOLed */
141 #define	INTERCONNECT_FABRIC		5	/* soft ALPA or Switch */
142 #define	INTERCONNECT_USB		6
143 #define	INTERCONNECT_ATAPI		7
144 #define	INTERCONNECT_ISCSI		8
145 #define	INTERCONNECT_IBSRP		9
146 #define	INTERCONNECT_SATA		10
147 #define	INTERCONNECT_MAX		11	/* Change this appropriately, */
148 						/* as new one(s) are added.   */
149 						/* Is always the last & max.  */
150 
151 /*					INTERCONNECT TYPE STRINGS */
152 #define	INTERCONNECT_PARALLEL_STR	"SPI"
153 #define	INTERCONNECT_FIBRE_STR		"FIBRE"
154 #define	INTERCONNECT_1394_STR		"1394"
155 #define	INTERCONNECT_SSA_STR		""
156 #define	INTERCONNECT_FABRIC_STR		"FABRIC"
157 #define	INTERCONNECT_USB_STR		"USB"
158 #define	INTERCONNECT_ATAPI_STR		"ATAPI"
159 #define	INTERCONNECT_ISCSI_STR		"iSCSI"
160 #define	INTERCONNECT_IBSRP_STR		"IB"
161 #define	INTERCONNECT_SATA_STR		"SATA"
162 
163 #define	INTERCONNECT_TYPE_ASCII		{				\
164 					"",				\
165 					INTERCONNECT_PARALLEL_STR,	\
166 					INTERCONNECT_FIBRE_STR,		\
167 					INTERCONNECT_1394_STR,		\
168 					INTERCONNECT_SSA_STR,		\
169 					INTERCONNECT_FABRIC_STR,	\
170 					INTERCONNECT_USB_STR,		\
171 					INTERCONNECT_ATAPI_STR,		\
172 					INTERCONNECT_ISCSI_STR,		\
173 					INTERCONNECT_IBSRP_STR,		\
174 					INTERCONNECT_SATA_STR,		\
175 					NULL				\
176 					};
177 
178 /*
179  * Compatibility...
180  */
181 #define	scsi_cmd_decode	scsi_cname
182 
183 #endif	/* _KERNEL */
184 
185 #ifdef	__cplusplus
186 }
187 #endif
188 
189 #endif	/* _SYS_SCSI_IMPL_SERVICES_H */
190