10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 56640Scth * Common Development and Distribution License (the "License"). 66640Scth * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*10696SDavid.Hollister@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_SCSI_CONF_AUTOCONF_H 270Sstevel@tonic-gate #define _SYS_SCSI_CONF_AUTOCONF_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate /* 34176Scth * SCSI subsystem scsi_options 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* 380Sstevel@tonic-gate * Following are for debugging purposes (few Sun drivers support this) 390Sstevel@tonic-gate */ 400Sstevel@tonic-gate #define SCSI_DEBUG_TGT 0x1 /* debug statements in target drivers */ 410Sstevel@tonic-gate #define SCSI_DEBUG_LIB 0x2 /* debug statements in library */ 420Sstevel@tonic-gate #define SCSI_DEBUG_HA 0x4 /* debug statements in host adapters */ 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 450Sstevel@tonic-gate * Following are applicable to all interconnects 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate #define SCSI_OPTIONS_LINK 0x10 /* Global linked commands */ 480Sstevel@tonic-gate #define SCSI_OPTIONS_TAG 0x80 /* Global tagged command support */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * Following are for parallel SCSI only 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate #define SCSI_OPTIONS_DR 0x8 /* Global disconnect/reconnect */ 540Sstevel@tonic-gate #define SCSI_OPTIONS_SYNC 0x20 /* Global synchronous xfer capability */ 550Sstevel@tonic-gate #define SCSI_OPTIONS_PARITY 0x40 /* Global parity support */ 560Sstevel@tonic-gate #define SCSI_OPTIONS_FAST 0x100 /* Global FAST scsi support */ 570Sstevel@tonic-gate #define SCSI_OPTIONS_WIDE 0x200 /* Global WIDE scsi support */ 580Sstevel@tonic-gate #define SCSI_OPTIONS_FAST20 0x400 /* Global FAST20 scsi support */ 590Sstevel@tonic-gate #define SCSI_OPTIONS_FAST40 0x800 /* Global FAST40 scsi support */ 600Sstevel@tonic-gate #define SCSI_OPTIONS_FAST80 0x1000 /* Global FAST80 scsi support */ 610Sstevel@tonic-gate #define SCSI_OPTIONS_FAST160 0x2000 /* Global FAST160 scsi support */ 620Sstevel@tonic-gate #define SCSI_OPTIONS_FAST320 0x4000 /* Global FAST320 scsi support */ 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 65176Scth * The following 3 bits are for being able to limit the max. number of LUNs 660Sstevel@tonic-gate * a nexus driver will allow -- "default" means that the adapter will 67176Scth * continue its default behavior. 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_MASK (0x70000) 700Sstevel@tonic-gate 710Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_DEFAULT 0x00000 720Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_1 0x10000 730Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_8 0x20000 740Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_16 0x30000 750Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS_32 0x40000 76*10696SDavid.Hollister@Sun.COM #define SCSI_OPTIONS_NLUNS_64 0x50000 77*10696SDavid.Hollister@Sun.COM #define SCSI_OPTIONS_NLUNS_128 0x60000 78*10696SDavid.Hollister@Sun.COM #define SCSI_OPTIONS_NLUNS_256 0x70000 790Sstevel@tonic-gate 800Sstevel@tonic-gate #define SCSI_OPTIONS_NLUNS(n) ((n) & SCSI_OPTIONS_NLUNS_MASK) 810Sstevel@tonic-gate 820Sstevel@tonic-gate #define SCSI_OPTIONS_QAS 0x100000 /* Global Quick Arbitration Select */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * SCSI autoconfiguration definitions. 860Sstevel@tonic-gate * 870Sstevel@tonic-gate * The library routine scsi_slave() is provided as a service to target 880Sstevel@tonic-gate * driver to check for existence and readiness of a SCSI device. It is 890Sstevel@tonic-gate * defined as: 900Sstevel@tonic-gate * 91176Scth * int scsi_slave(struct scsi_device *devp, int (*callback)(void)) 920Sstevel@tonic-gate * 930Sstevel@tonic-gate * where devp is the scsi_device structure passed to the target driver 940Sstevel@tonic-gate * at probe time, and where callback declares whether scsi_slave() can 950Sstevel@tonic-gate * sleep awaiting resources or must return an error if it cannot get 960Sstevel@tonic-gate * resources (callback == SLEEP_FUNC implies that scsi_slave() 970Sstevel@tonic-gate * can sleep - although this 980Sstevel@tonic-gate * does not fully guarantee that resources will become available as 990Sstevel@tonic-gate * some are allocated from the iopbmap which may just be completely 1000Sstevel@tonic-gate * full). The user call also supplies a callback function or NULL_FUNC. 1010Sstevel@tonic-gate * In the process of determining the existence of a SCSI device, 1020Sstevel@tonic-gate * scsi_slave will allocate space for the sd_inq field of the scsi_device 1030Sstevel@tonic-gate * pointed to by devp (if it is non-zero upon entry). 1040Sstevel@tonic-gate * 1050Sstevel@tonic-gate * scsi_slave() attempts to follow this sequence in order to determine 1060Sstevel@tonic-gate * the existence of a SCSI device: 1070Sstevel@tonic-gate * 1080Sstevel@tonic-gate * Attempt to send 2 TEST UNIT READY commands to the device. 1090Sstevel@tonic-gate * 1100Sstevel@tonic-gate * If that gets a check condition, run a non-extended 1110Sstevel@tonic-gate * REQUEST SENSE command. Ignore the results of it, as 1120Sstevel@tonic-gate * a the non-extended sense information contains only 1130Sstevel@tonic-gate * Vendor Unique error codes (the idea is that during 1140Sstevel@tonic-gate * probe time the nearly invariant first command to a 1150Sstevel@tonic-gate * device will get a Check Condition, and the real reason 1160Sstevel@tonic-gate * is that the device wants to tell you that a SCSI bus 1170Sstevel@tonic-gate * reset just occurred. 1180Sstevel@tonic-gate * 1190Sstevel@tonic-gate * Attempt to allocate an inquiry buffer and 1200Sstevel@tonic-gate * run an INQUIRY command (with response data format 0 set). 1210Sstevel@tonic-gate * 1220Sstevel@tonic-gate * If that gets a check condition, run another 1230Sstevel@tonic-gate * non-extended REQUEST SENSE command. 1240Sstevel@tonic-gate * 1250Sstevel@tonic-gate * The library routine scsi_probe() is provided as a service to target 1260Sstevel@tonic-gate * driver to check for bare-bones existence of a SCSI device. It is 1270Sstevel@tonic-gate * defined as: 1280Sstevel@tonic-gate * 129176Scth * int scsi_probe(struct scsi_device *devp, int (*callback)(void)) 1300Sstevel@tonic-gate * 1310Sstevel@tonic-gate * scsi_probe() only executes an inquiry. 1320Sstevel@tonic-gate * 1330Sstevel@tonic-gate * Both functions return one of the integer values as defined below: 1340Sstevel@tonic-gate */ 1350Sstevel@tonic-gate #define SCSIPROBE_EXISTS 0 /* device exists, inquiry data valid */ 1360Sstevel@tonic-gate #define SCSIPROBE_NONCCS 1 /* device exists, no inquiry data */ 1370Sstevel@tonic-gate #define SCSIPROBE_NORESP 2 /* device didn't respond */ 1380Sstevel@tonic-gate #define SCSIPROBE_NOMEM 3 /* no space available for structures */ 1390Sstevel@tonic-gate #define SCSIPROBE_FAILURE 4 /* polled cmnd failure- unspecified */ 1400Sstevel@tonic-gate #define SCSIPROBE_BUSY 5 /* device was busy */ 141176Scth #define SCSIPROBE_NOMEM_CB 6 /* no space, callback queued */ 142176Scth #define SCSIPROBE_ASCII \ 143176Scth {"EXISTS", "NONCCS", "NORESP", "NOMEM", \ 144176Scth "FAILURE", "BUSY", "NOMEM_CB", NULL} 145176Scth 1460Sstevel@tonic-gate /* 1470Sstevel@tonic-gate * default value for scsi_reset_delay 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate #define SCSI_DEFAULT_RESET_DELAY 3000 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * default value for scsi_selection_timeout 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate #define SCSI_DEFAULT_SELECTION_TIMEOUT 250 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate /* 157*10696SDavid.Hollister@Sun.COM * SCSI subsystem scsi_enumeration options. 158*10696SDavid.Hollister@Sun.COM * 159*10696SDavid.Hollister@Sun.COM * Knob for SPI (SCSI Parallel Intrconnect) enumeration. Unless an HBA defines 160*10696SDavid.Hollister@Sun.COM * it's own tran_bus_config, SPI enumeration is used. The "scsi_enumeration" 161*10696SDavid.Hollister@Sun.COM * knob determines how SPI enumeration is performed. 162*10696SDavid.Hollister@Sun.COM * 163*10696SDavid.Hollister@Sun.COM * The global variable "scsi_enumeration" is used as the default value of the 164*10696SDavid.Hollister@Sun.COM * "scsi-enumeration" property. In addition to enabling/disabling enumeration 165*10696SDavid.Hollister@Sun.COM * (bit 0), target and lun threading can be specified. Having things 166*10696SDavid.Hollister@Sun.COM * multi-threaded does not guarantee reduce configuration time, however when 167*10696SDavid.Hollister@Sun.COM * the bus is marginal multi-threading can substaintaly reduce configuration 168*10696SDavid.Hollister@Sun.COM * time because targets negotiate to stable transfer speeds in parallel - so 169*10696SDavid.Hollister@Sun.COM * all targets have stabalized by the time the sequential attach(9E) operations 170*10696SDavid.Hollister@Sun.COM * begin. Running multi-threaded also helps verification of framework and HBA 171*10696SDavid.Hollister@Sun.COM * locking: a BUS_CONFIG_ALL is equivalent to every target and lun combination 172*10696SDavid.Hollister@Sun.COM * getting a BUS_CONFIG_ONE from a separate thread at the same time. A disable 173*10696SDavid.Hollister@Sun.COM * mechanism is provided to accomidate buggy HBAs (set scsi-enumeration=7 174*10696SDavid.Hollister@Sun.COM * driver.conf). Values are: 175*10696SDavid.Hollister@Sun.COM * 176*10696SDavid.Hollister@Sun.COM * 0 driver.conf enumeration 177*10696SDavid.Hollister@Sun.COM * 1 dynamic enumeration with target and lun multi-threading. 178*10696SDavid.Hollister@Sun.COM * 3 dynamic enumeration with lun multi-threading disabled. 179*10696SDavid.Hollister@Sun.COM * 5 dynamic enumeration with target multi-threading disabled; 180*10696SDavid.Hollister@Sun.COM * 7 dynamic enumeration with target/lun multi-threading disabled. 1810Sstevel@tonic-gate */ 182*10696SDavid.Hollister@Sun.COM #define SCSI_ENUMERATION_ENABLE 0x1 183*10696SDavid.Hollister@Sun.COM #define SCSI_ENUMERATION_MT_LUN_DISABLE 0x2 184*10696SDavid.Hollister@Sun.COM #define SCSI_ENUMERATION_MT_TARGET_DISABLE 0x4 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate #ifdef _KERNEL 1870Sstevel@tonic-gate /* 188176Scth * Global SCSI config variables / options 1890Sstevel@tonic-gate */ 190176Scth extern int scsi_options; 191*10696SDavid.Hollister@Sun.COM extern int scsi_enumeration; 192176Scth extern unsigned int scsi_reset_delay; /* specified in milli seconds */ 193176Scth extern int scsi_tag_age_limit; 194176Scth extern int scsi_watchdog_tick; 195176Scth extern int scsi_selection_timeout; /* specified in milli seconds */ 196176Scth extern int scsi_host_id; 1976640Scth extern int scsi_fm_capable; 1980Sstevel@tonic-gate #endif /* _KERNEL */ 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate #ifdef __cplusplus 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate #endif 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate #endif /* _SYS_SCSI_CONF_AUTOCONF_H */ 205