xref: /titanic_51/usr/src/uts/common/sys/scsi/conf/autoconf.h (revision 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5602ca9eaScth  * Common Development and Distribution License (the "License").
6602ca9eaScth  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*4c06356bSdh142964  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_CONF_AUTOCONF_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SCSI_CONF_AUTOCONF_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
341e32c0dcScth  * SCSI subsystem scsi_options
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * Following are for debugging purposes (few Sun drivers support this)
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate #define	SCSI_DEBUG_TGT	0x1	/* debug statements in target drivers */
417c478bd9Sstevel@tonic-gate #define	SCSI_DEBUG_LIB	0x2	/* debug statements in library */
427c478bd9Sstevel@tonic-gate #define	SCSI_DEBUG_HA	0x4	/* debug statements in host adapters */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Following are applicable to all interconnects
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_LINK	0x10	/* Global linked commands */
487c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_TAG	0x80	/* Global tagged command support */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * Following are for parallel SCSI only
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_DR		0x8	/* Global disconnect/reconnect	*/
547c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_SYNC	0x20	/* Global synchronous xfer capability */
557c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_PARITY	0x40	/* Global parity support */
567c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST	0x100	/* Global FAST scsi support */
577c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_WIDE	0x200	/* Global WIDE scsi support */
587c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST20	0x400	/* Global FAST20 scsi support */
597c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST40	0x800	/* Global FAST40 scsi support */
607c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST80	0x1000	/* Global FAST80 scsi support */
617c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST160	0x2000	/* Global FAST160 scsi support */
627c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_FAST320	0x4000	/* Global FAST320 scsi support */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
651e32c0dcScth  * The following 3 bits are for being able to limit the max. number of LUNs
667c478bd9Sstevel@tonic-gate  * a nexus driver will allow -- "default" means that the adapter will
671e32c0dcScth  * continue its default behavior.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_MASK		(0x70000)
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_DEFAULT	0x00000
727c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_1		0x10000
737c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_8		0x20000
747c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_16		0x30000
757c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS_32		0x40000
76*4c06356bSdh142964 #define	SCSI_OPTIONS_NLUNS_64		0x50000
77*4c06356bSdh142964 #define	SCSI_OPTIONS_NLUNS_128		0x60000
78*4c06356bSdh142964 #define	SCSI_OPTIONS_NLUNS_256		0x70000
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_NLUNS(n)		((n) & SCSI_OPTIONS_NLUNS_MASK)
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define	SCSI_OPTIONS_QAS	0x100000 /* Global Quick Arbitration Select */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * SCSI autoconfiguration definitions.
867c478bd9Sstevel@tonic-gate  *
877c478bd9Sstevel@tonic-gate  * The library routine scsi_slave() is provided as a service to target
887c478bd9Sstevel@tonic-gate  * driver to check for existence  and readiness of a SCSI device. It is
897c478bd9Sstevel@tonic-gate  * defined as:
907c478bd9Sstevel@tonic-gate  *
911e32c0dcScth  *	int scsi_slave(struct scsi_device *devp, int (*callback)(void))
927c478bd9Sstevel@tonic-gate  *
937c478bd9Sstevel@tonic-gate  * where devp is the scsi_device structure passed to the target driver
947c478bd9Sstevel@tonic-gate  * at probe time, and where callback declares whether scsi_slave() can
957c478bd9Sstevel@tonic-gate  * sleep awaiting resources or must return an error if it cannot get
967c478bd9Sstevel@tonic-gate  * resources (callback == SLEEP_FUNC implies that scsi_slave()
977c478bd9Sstevel@tonic-gate  * can sleep - although this
987c478bd9Sstevel@tonic-gate  * does not fully guarantee that resources will become available as
997c478bd9Sstevel@tonic-gate  * some are allocated from the iopbmap which may just be completely
1007c478bd9Sstevel@tonic-gate  * full).  The user call also supplies a callback function or NULL_FUNC.
1017c478bd9Sstevel@tonic-gate  * In the process of determining the existence of a SCSI device,
1027c478bd9Sstevel@tonic-gate  * scsi_slave will allocate space for the sd_inq field of the scsi_device
1037c478bd9Sstevel@tonic-gate  * pointed to by devp (if it is non-zero upon entry).
1047c478bd9Sstevel@tonic-gate  *
1057c478bd9Sstevel@tonic-gate  * scsi_slave() attempts to follow this sequence in order to determine
1067c478bd9Sstevel@tonic-gate  * the existence of a SCSI device:
1077c478bd9Sstevel@tonic-gate  *
1087c478bd9Sstevel@tonic-gate  *	Attempt to send 2 TEST UNIT READY commands to the device.
1097c478bd9Sstevel@tonic-gate  *
1107c478bd9Sstevel@tonic-gate  *		If that gets a check condition, run a non-extended
1117c478bd9Sstevel@tonic-gate  *		REQUEST SENSE command. Ignore the results of it, as
1127c478bd9Sstevel@tonic-gate  *		a the non-extended sense information contains only
1137c478bd9Sstevel@tonic-gate  *		Vendor Unique error codes (the idea is that during
1147c478bd9Sstevel@tonic-gate  *		probe time the nearly invariant first command to a
1157c478bd9Sstevel@tonic-gate  *		device will get a Check Condition, and the real reason
1167c478bd9Sstevel@tonic-gate  *		is that the device wants to tell you that a SCSI bus
1177c478bd9Sstevel@tonic-gate  *		reset just occurred.
1187c478bd9Sstevel@tonic-gate  *
1197c478bd9Sstevel@tonic-gate  *	Attempt to allocate an inquiry buffer and
1207c478bd9Sstevel@tonic-gate  *	run an INQUIRY command (with response data format 0 set).
1217c478bd9Sstevel@tonic-gate  *
1227c478bd9Sstevel@tonic-gate  *		If that gets a check condition, run another
1237c478bd9Sstevel@tonic-gate  *		non-extended REQUEST SENSE command.
1247c478bd9Sstevel@tonic-gate  *
1257c478bd9Sstevel@tonic-gate  * The library routine scsi_probe() is provided as a service to target
1267c478bd9Sstevel@tonic-gate  * driver to check for bare-bones existence of a SCSI device. It is
1277c478bd9Sstevel@tonic-gate  * defined as:
1287c478bd9Sstevel@tonic-gate  *
1291e32c0dcScth  *	int scsi_probe(struct scsi_device *devp, int (*callback)(void))
1307c478bd9Sstevel@tonic-gate  *
1317c478bd9Sstevel@tonic-gate  * scsi_probe() only executes an inquiry.
1327c478bd9Sstevel@tonic-gate  *
1337c478bd9Sstevel@tonic-gate  * Both functions return one of the integer values as defined below:
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate #define	SCSIPROBE_EXISTS	0	/* device exists, inquiry data valid */
1367c478bd9Sstevel@tonic-gate #define	SCSIPROBE_NONCCS	1	/* device exists, no inquiry data */
1377c478bd9Sstevel@tonic-gate #define	SCSIPROBE_NORESP	2	/* device didn't respond */
1387c478bd9Sstevel@tonic-gate #define	SCSIPROBE_NOMEM		3	/* no space available for structures */
1397c478bd9Sstevel@tonic-gate #define	SCSIPROBE_FAILURE	4	/* polled cmnd failure- unspecified */
1407c478bd9Sstevel@tonic-gate #define	SCSIPROBE_BUSY		5	/* device was busy */
1411e32c0dcScth #define	SCSIPROBE_NOMEM_CB	6	/* no space, callback queued */
1421e32c0dcScth #define	SCSIPROBE_ASCII					\
1431e32c0dcScth 	{"EXISTS", "NONCCS", "NORESP", "NOMEM",		\
1441e32c0dcScth 	"FAILURE", "BUSY", "NOMEM_CB", NULL}
1451e32c0dcScth 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * default value for scsi_reset_delay
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	SCSI_DEFAULT_RESET_DELAY	3000
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * default value for scsi_selection_timeout
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate #define	SCSI_DEFAULT_SELECTION_TIMEOUT	250
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate /*
157*4c06356bSdh142964  * SCSI subsystem scsi_enumeration options.
158*4c06356bSdh142964  *
159*4c06356bSdh142964  * Knob for SPI (SCSI Parallel Intrconnect) enumeration. Unless an HBA defines
160*4c06356bSdh142964  * it's own tran_bus_config, SPI enumeration is used. The "scsi_enumeration"
161*4c06356bSdh142964  * knob determines how SPI enumeration is performed.
162*4c06356bSdh142964  *
163*4c06356bSdh142964  * The global variable "scsi_enumeration" is used as the default value of the
164*4c06356bSdh142964  * "scsi-enumeration" property. In addition to enabling/disabling enumeration
165*4c06356bSdh142964  * (bit 0), target and lun threading can be specified.  Having things
166*4c06356bSdh142964  * multi-threaded does not guarantee reduce configuration time, however when
167*4c06356bSdh142964  * the bus is marginal multi-threading can substaintaly reduce configuration
168*4c06356bSdh142964  * time because targets negotiate to stable transfer speeds in parallel - so
169*4c06356bSdh142964  * all targets have stabalized by the time the sequential attach(9E) operations
170*4c06356bSdh142964  * begin.  Running multi-threaded also helps verification of framework and HBA
171*4c06356bSdh142964  * locking: a BUS_CONFIG_ALL is equivalent to every target and lun combination
172*4c06356bSdh142964  * getting a BUS_CONFIG_ONE from a separate thread at the same time.  A disable
173*4c06356bSdh142964  * mechanism is provided to accomidate buggy HBAs (set scsi-enumeration=7
174*4c06356bSdh142964  * driver.conf). Values are:
175*4c06356bSdh142964  *
176*4c06356bSdh142964  *	0	driver.conf enumeration
177*4c06356bSdh142964  *	1	dynamic enumeration with target and lun multi-threading.
178*4c06356bSdh142964  *	3	dynamic enumeration with lun multi-threading disabled.
179*4c06356bSdh142964  *	5	dynamic enumeration with target multi-threading disabled;
180*4c06356bSdh142964  *	7	dynamic enumeration with target/lun multi-threading disabled.
1817c478bd9Sstevel@tonic-gate  */
182*4c06356bSdh142964 #define	SCSI_ENUMERATION_ENABLE			0x1
183*4c06356bSdh142964 #define	SCSI_ENUMERATION_MT_LUN_DISABLE		0x2
184*4c06356bSdh142964 #define	SCSI_ENUMERATION_MT_TARGET_DISABLE	0x4
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
1877c478bd9Sstevel@tonic-gate /*
1881e32c0dcScth  * Global SCSI config variables / options
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate extern int		scsi_options;
191*4c06356bSdh142964 extern int		scsi_enumeration;
1927c478bd9Sstevel@tonic-gate extern unsigned int	scsi_reset_delay;	/* specified in milli seconds */
1931e32c0dcScth extern int		scsi_tag_age_limit;
1941e32c0dcScth extern int		scsi_watchdog_tick;
1957c478bd9Sstevel@tonic-gate extern int		scsi_selection_timeout;	/* specified in milli seconds */
1961e32c0dcScth extern int		scsi_host_id;
197602ca9eaScth extern int		scsi_fm_capable;
1987c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate #endif
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #endif	/* _SYS_SCSI_CONF_AUTOCONF_H */
205