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