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