xref: /titanic_44/usr/src/uts/common/sys/scsi/conf/autoconf.h (revision 672986541be54a7a471bb088e60780c37e371d7e)
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_CONF_AUTOCONF_H
28 #define	_SYS_SCSI_CONF_AUTOCONF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * SCSI subsystem scsi_options
38  */
39 
40 /*
41  * Following are for debugging purposes (few Sun drivers support this)
42  */
43 #define	SCSI_DEBUG_TGT	0x1	/* debug statements in target drivers */
44 #define	SCSI_DEBUG_LIB	0x2	/* debug statements in library */
45 #define	SCSI_DEBUG_HA	0x4	/* debug statements in host adapters */
46 
47 /*
48  * Following are applicable to all interconnects
49  */
50 #define	SCSI_OPTIONS_LINK	0x10	/* Global linked commands */
51 #define	SCSI_OPTIONS_TAG	0x80	/* Global tagged command support */
52 
53 /*
54  * Following are for parallel SCSI only
55  */
56 #define	SCSI_OPTIONS_DR		0x8	/* Global disconnect/reconnect	*/
57 #define	SCSI_OPTIONS_SYNC	0x20	/* Global synchronous xfer capability */
58 #define	SCSI_OPTIONS_PARITY	0x40	/* Global parity support */
59 #define	SCSI_OPTIONS_FAST	0x100	/* Global FAST scsi support */
60 #define	SCSI_OPTIONS_WIDE	0x200	/* Global WIDE scsi support */
61 #define	SCSI_OPTIONS_FAST20	0x400	/* Global FAST20 scsi support */
62 #define	SCSI_OPTIONS_FAST40	0x800	/* Global FAST40 scsi support */
63 #define	SCSI_OPTIONS_FAST80	0x1000	/* Global FAST80 scsi support */
64 #define	SCSI_OPTIONS_FAST160	0x2000	/* Global FAST160 scsi support */
65 #define	SCSI_OPTIONS_FAST320	0x4000	/* Global FAST320 scsi support */
66 
67 /*
68  * The following 3 bits are for being able to limit the max. number of LUNs
69  * a nexus driver will allow -- "default" means that the adapter will
70  * continue its default behavior.
71  */
72 #define	SCSI_OPTIONS_NLUNS_MASK		(0x70000)
73 
74 #define	SCSI_OPTIONS_NLUNS_DEFAULT	0x00000
75 #define	SCSI_OPTIONS_NLUNS_1		0x10000
76 #define	SCSI_OPTIONS_NLUNS_8		0x20000
77 #define	SCSI_OPTIONS_NLUNS_16		0x30000
78 #define	SCSI_OPTIONS_NLUNS_32		0x40000
79 
80 #define	SCSI_OPTIONS_NLUNS(n)		((n) & SCSI_OPTIONS_NLUNS_MASK)
81 
82 #define	SCSI_OPTIONS_QAS	0x100000 /* Global Quick Arbitration Select */
83 
84 /*
85  * SCSI autoconfiguration definitions.
86  *
87  * The library routine scsi_slave() is provided as a service to target
88  * driver to check for existence  and readiness of a SCSI device. It is
89  * defined as:
90  *
91  *	int scsi_slave(struct scsi_device *devp, int (*callback)(void))
92  *
93  * where devp is the scsi_device structure passed to the target driver
94  * at probe time, and where callback declares whether scsi_slave() can
95  * sleep awaiting resources or must return an error if it cannot get
96  * resources (callback == SLEEP_FUNC implies that scsi_slave()
97  * can sleep - although this
98  * does not fully guarantee that resources will become available as
99  * some are allocated from the iopbmap which may just be completely
100  * full).  The user call also supplies a callback function or NULL_FUNC.
101  * In the process of determining the existence of a SCSI device,
102  * scsi_slave will allocate space for the sd_inq field of the scsi_device
103  * pointed to by devp (if it is non-zero upon entry).
104  *
105  * scsi_slave() attempts to follow this sequence in order to determine
106  * the existence of a SCSI device:
107  *
108  *	Attempt to send 2 TEST UNIT READY commands to the device.
109  *
110  *		If that gets a check condition, run a non-extended
111  *		REQUEST SENSE command. Ignore the results of it, as
112  *		a the non-extended sense information contains only
113  *		Vendor Unique error codes (the idea is that during
114  *		probe time the nearly invariant first command to a
115  *		device will get a Check Condition, and the real reason
116  *		is that the device wants to tell you that a SCSI bus
117  *		reset just occurred.
118  *
119  *	Attempt to allocate an inquiry buffer and
120  *	run an INQUIRY command (with response data format 0 set).
121  *
122  *		If that gets a check condition, run another
123  *		non-extended REQUEST SENSE command.
124  *
125  * The library routine scsi_probe() is provided as a service to target
126  * driver to check for bare-bones existence of a SCSI device. It is
127  * defined as:
128  *
129  *	int scsi_probe(struct scsi_device *devp, int (*callback)(void))
130  *
131  * scsi_probe() only executes an inquiry.
132  *
133  * Both functions return one of the integer values as defined below:
134  */
135 #define	SCSIPROBE_EXISTS	0	/* device exists, inquiry data valid */
136 #define	SCSIPROBE_NONCCS	1	/* device exists, no inquiry data */
137 #define	SCSIPROBE_NORESP	2	/* device didn't respond */
138 #define	SCSIPROBE_NOMEM		3	/* no space available for structures */
139 #define	SCSIPROBE_FAILURE	4	/* polled cmnd failure- unspecified */
140 #define	SCSIPROBE_BUSY		5	/* device was busy */
141 #define	SCSIPROBE_NOMEM_CB	6	/* no space, callback queued */
142 #define	SCSIPROBE_ASCII					\
143 	{"EXISTS", "NONCCS", "NORESP", "NOMEM",		\
144 	"FAILURE", "BUSY", "NOMEM_CB", NULL}
145 
146 /*
147  * default value for scsi_reset_delay
148  */
149 #define	SCSI_DEFAULT_RESET_DELAY	3000
150 
151 /*
152  * default value for scsi_selection_timeout
153  */
154 #define	SCSI_DEFAULT_SELECTION_TIMEOUT	250
155 
156 /*
157  * Kernel references
158  */
159 
160 #ifdef	_KERNEL
161 /*
162  * Global SCSI config variables / options
163  */
164 extern int		scsi_options;
165 extern unsigned int	scsi_reset_delay;	/* specified in milli seconds */
166 extern int		scsi_tag_age_limit;
167 extern int		scsi_watchdog_tick;
168 extern int		scsi_selection_timeout;	/* specified in milli seconds */
169 extern int		scsi_host_id;
170 #endif	/* _KERNEL */
171 
172 #ifdef	__cplusplus
173 }
174 #endif
175 
176 #endif	/* _SYS_SCSI_CONF_AUTOCONF_H */
177