xref: /titanic_50/usr/src/uts/common/sys/scsi/impl/services.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 2006 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_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",			\
127 		"max-cdb-length", NULL }
128 
129 /*
130  * Definitions used by some capabilities
131  */
132 /*					SCSI_CAP_SCSI_VERSION */
133 #define	SCSI_VERSION_1			1
134 #define	SCSI_VERSION_2			2
135 #define	SCSI_VERSION_3			3
136 
137 /*					SCSI_CAP_INTERCONNECT_TYPE */
138 #define	INTERCONNECT_PARALLEL		1
139 #define	INTERCONNECT_FIBRE		2	/* PLDA or hard ALPA */
140 #define	INTERCONNECT_1394		3
141 #define	INTERCONNECT_SSA		4	/* -EOLed */
142 #define	INTERCONNECT_FABRIC		5	/* soft ALPA or Switch */
143 #define	INTERCONNECT_USB		6
144 #define	INTERCONNECT_ATAPI		7
145 #define	INTERCONNECT_ISCSI		8
146 #define	INTERCONNECT_IBSRP		9
147 #define	INTERCONNECT_SATA		10
148 #define	INTERCONNECT_MAX		11	/* Change this appropriately, */
149 						/* as new one(s) are added.   */
150 						/* Is always the last & max.  */
151 
152 /*					INTERCONNECT TYPE STRINGS */
153 #define	INTERCONNECT_PARALLEL_STR	"SPI"
154 #define	INTERCONNECT_FIBRE_STR		"FIBRE"
155 #define	INTERCONNECT_1394_STR		"1394"
156 #define	INTERCONNECT_SSA_STR		""
157 #define	INTERCONNECT_FABRIC_STR		"FABRIC"
158 #define	INTERCONNECT_USB_STR		"USB"
159 #define	INTERCONNECT_ATAPI_STR		"ATAPI"
160 #define	INTERCONNECT_ISCSI_STR		"iSCSI"
161 #define	INTERCONNECT_IBSRP_STR		"IB"
162 #define	INTERCONNECT_SATA_STR		"SATA"
163 
164 #define	INTERCONNECT_TYPE_ASCII		{				\
165 					"",				\
166 					INTERCONNECT_PARALLEL_STR,	\
167 					INTERCONNECT_FIBRE_STR,		\
168 					INTERCONNECT_1394_STR,		\
169 					INTERCONNECT_SSA_STR,		\
170 					INTERCONNECT_FABRIC_STR,	\
171 					INTERCONNECT_USB_STR,		\
172 					INTERCONNECT_ATAPI_STR,		\
173 					INTERCONNECT_ISCSI_STR,		\
174 					INTERCONNECT_IBSRP_STR,		\
175 					INTERCONNECT_SATA_STR,		\
176 					NULL				\
177 					};
178 
179 /*
180  * Compatibility...
181  */
182 #define	scsi_cmd_decode	scsi_cname
183 
184 #endif	/* _KERNEL */
185 
186 #ifdef	__cplusplus
187 }
188 #endif
189 
190 #endif	/* _SYS_SCSI_IMPL_SERVICES_H */
191