xref: /titanic_51/usr/src/uts/common/sys/scsi/conf/autoconf.h (revision e061a5d7a75180eab31acb1289368162e020bc71)
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_CONF_AUTOCONF_H
27 #define	_SYS_SCSI_CONF_AUTOCONF_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * SCSI subsystem scsi_options
35  */
36 
37 /*
38  * Following are for debugging purposes (few Sun drivers support this)
39  */
40 #define	SCSI_DEBUG_TGT	0x1	/* debug statements in target drivers */
41 #define	SCSI_DEBUG_LIB	0x2	/* debug statements in library */
42 #define	SCSI_DEBUG_HA	0x4	/* debug statements in host adapters */
43 
44 /*
45  * Following are applicable to all interconnects
46  */
47 #define	SCSI_OPTIONS_LINK	0x10	/* Global linked commands */
48 #define	SCSI_OPTIONS_TAG	0x80	/* Global tagged command support */
49 
50 /*
51  * Following are for parallel SCSI only
52  */
53 #define	SCSI_OPTIONS_DR		0x8	/* Global disconnect/reconnect	*/
54 #define	SCSI_OPTIONS_SYNC	0x20	/* Global synchronous xfer capability */
55 #define	SCSI_OPTIONS_PARITY	0x40	/* Global parity support */
56 #define	SCSI_OPTIONS_FAST	0x100	/* Global FAST scsi support */
57 #define	SCSI_OPTIONS_WIDE	0x200	/* Global WIDE scsi support */
58 #define	SCSI_OPTIONS_FAST20	0x400	/* Global FAST20 scsi support */
59 #define	SCSI_OPTIONS_FAST40	0x800	/* Global FAST40 scsi support */
60 #define	SCSI_OPTIONS_FAST80	0x1000	/* Global FAST80 scsi support */
61 #define	SCSI_OPTIONS_FAST160	0x2000	/* Global FAST160 scsi support */
62 #define	SCSI_OPTIONS_FAST320	0x4000	/* Global FAST320 scsi support */
63 
64 /*
65  * The following 3 bits are for being able to limit the max. number of LUNs
66  * a nexus driver will allow -- "default" means that the adapter will
67  * continue its default behavior.
68  */
69 #define	SCSI_OPTIONS_NLUNS_MASK		(0x70000)
70 
71 #define	SCSI_OPTIONS_NLUNS_DEFAULT	0x00000
72 #define	SCSI_OPTIONS_NLUNS_1		0x10000
73 #define	SCSI_OPTIONS_NLUNS_8		0x20000
74 #define	SCSI_OPTIONS_NLUNS_16		0x30000
75 #define	SCSI_OPTIONS_NLUNS_32		0x40000
76 #define	SCSI_OPTIONS_NLUNS_64		0x50000
77 #define	SCSI_OPTIONS_NLUNS_128		0x60000
78 #define	SCSI_OPTIONS_NLUNS_256		0x70000
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  * SCSI subsystem scsi_enumeration options.
158  *
159  * Knob for SPI (SCSI Parallel Intrconnect) enumeration. Unless an HBA defines
160  * it's own tran_bus_config, SPI enumeration is used. The "scsi_enumeration"
161  * knob determines how SPI enumeration is performed.
162  *
163  * The global variable "scsi_enumeration" is used as the default value of the
164  * "scsi-enumeration" property. In addition to enabling/disabling enumeration
165  * (bit 0), target and lun threading can be specified.  Having things
166  * multi-threaded does not guarantee reduce configuration time, however when
167  * the bus is marginal multi-threading can substaintaly reduce configuration
168  * time because targets negotiate to stable transfer speeds in parallel - so
169  * all targets have stabalized by the time the sequential attach(9E) operations
170  * begin.  Running multi-threaded also helps verification of framework and HBA
171  * locking: a BUS_CONFIG_ALL is equivalent to every target and lun combination
172  * getting a BUS_CONFIG_ONE from a separate thread at the same time.  A disable
173  * mechanism is provided to accomidate buggy HBAs (set scsi-enumeration=7
174  * driver.conf). Values are:
175  *
176  *	0	driver.conf enumeration
177  *	1	dynamic enumeration with target and lun multi-threading.
178  *	3	dynamic enumeration with lun multi-threading disabled.
179  *	5	dynamic enumeration with target multi-threading disabled;
180  *	7	dynamic enumeration with target/lun multi-threading disabled.
181  */
182 #define	SCSI_ENUMERATION_ENABLE			0x1
183 #define	SCSI_ENUMERATION_MT_LUN_DISABLE		0x2
184 #define	SCSI_ENUMERATION_MT_TARGET_DISABLE	0x4
185 
186 #ifdef	_KERNEL
187 /*
188  * Global SCSI config variables / options
189  */
190 extern int		scsi_options;
191 extern int		scsi_enumeration;
192 extern unsigned int	scsi_reset_delay;	/* specified in milli seconds */
193 extern int		scsi_tag_age_limit;
194 extern int		scsi_watchdog_tick;
195 extern int		scsi_selection_timeout;	/* specified in milli seconds */
196 extern int		scsi_host_id;
197 extern int		scsi_fm_capable;
198 #endif	/* _KERNEL */
199 
200 #ifdef	__cplusplus
201 }
202 #endif
203 
204 #endif	/* _SYS_SCSI_CONF_AUTOCONF_H */
205