scsi_hba.c revision a195726fa33097e56cf1c25c31feddb827e140f0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Generic SCSI Host Bus Adapter interface implementation
*/
#include <sys/ddi_impldefs.h>
#include <sys/ndi_impldefs.h>
static kmutex_t scsi_hba_mutex;
struct scsi_hba_inst {
struct scsi_hba_inst *inst_next;
struct scsi_hba_inst *inst_prev;
};
/*
* Prototypes for static functions
*/
static int scsi_hba_bus_ctl(
void *arg,
void *result);
static int scsi_hba_map_fault(
static int scsi_hba_get_eventcookie(
char *name,
static int scsi_hba_add_eventcall(
void (*callback)(
void *arg,
void *bus_impldata),
void *arg,
static int scsi_hba_remove_eventcall(
static int scsi_hba_post_event(
void *bus_impldata);
static int scsi_hba_info(
void *arg,
void **result);
/*
* Busops vector for SCSI HBA's.
*/
static struct bus_ops scsi_hba_busops = {
nullbusmap, /* bus_map */
NULL, /* bus_get_intrspec */
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
scsi_hba_map_fault, /* bus_map_fault */
ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
ddi_dma_unbindhdl, /* bus_unbindhdl */
ddi_dma_flush, /* bus_dma_flush */
ddi_dma_win, /* bus_dma_win */
ddi_dma_mctl, /* bus_dma_ctl */
scsi_hba_bus_ctl, /* bus_ctl */
ddi_bus_prop_op, /* bus_prop_op */
scsi_hba_get_eventcookie, /* bus_get_eventcookie */
scsi_hba_add_eventcall, /* bus_add_eventcall */
scsi_hba_remove_eventcall, /* bus_remove_eventcall */
scsi_hba_post_event, /* bus_post_event */
NULL, /* bus_intr_ctl */
scsi_hba_bus_config, /* bus_config */
scsi_hba_bus_unconfig, /* bus_unconfig */
NULL, /* bus_fm_init */
NULL, /* bus_fm_fini */
NULL, /* bus_fm_access_enter */
NULL, /* bus_fm_access_exit */
scsi_hba_bus_power /* bus_power */
};
static struct cb_ops scsi_hba_cbops = {
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
scsi_hba_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
NULL, /* stream */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
/*
* Called from _init() when loading scsi module
*/
void
{
}
#ifdef NO_SCSI_FINI_YET
/*
* Called from _fini() when unloading scsi module
*/
void
{
}
#endif /* NO_SCSI_FINI_YET */
/*
* Called by an HBA from _init()
*/
int
{
struct dev_ops *hba_dev_ops;
/*
* Get the devops structure of the hba,
* and put our busops vector in its place.
*/
hba_dev_ops = ((struct modldrv *)
/*
* Provide getinfo and hotplugging ioctl if driver
* does not provide them already
*/
}
}
return (0);
}
/*
* Implement this older interface in terms of the new.
* This is hardly in the critical path, so avoiding
* unnecessary code duplication is more important.
*/
/*ARGSUSED*/
int
int flags,
void *hba_options)
{
}
/*
* Called by an HBA to attach an instance of the driver
*/
int
int flags)
{
struct dev_ops *hba_dev_ops;
struct scsi_hba_inst *elem;
int value;
int len;
char *prop_name;
char *errmsg =
"scsi_hba_attach: cannot create property '%s' for %s%d\n";
/*
* Link this instance into the scsi_hba_list
*/
if (scsi_hba_list == NULL) {
}
if (scsi_hba_list_tail) {
}
/*
* Save all the important HBA information that must be accessed
* later by scsi_hba_bus_ctl(), and scsi_hba_map().
*/
/*
* Note: we only need dma_attr_minxfer and dma_attr_burstsizes
* from the DMA attributes. scsi_hba_attach(9f) only
* guarantees that these two fields are initialized properly.
* If this changes, be sure to revisit the implementation
* of scsi_hba_attach(9F).
*/
/*
* Attach scsi configuration property parameters
* to this instance of the hba.
*/
prop_name = "scsi-reset-delay";
len = 0;
}
}
prop_name = "scsi-tag-age-limit";
len = 0;
}
}
prop_name = "scsi-watchdog-tick";
len = 0;
}
}
prop_name = "scsi-options";
len = 0;
}
}
prop_name = "scsi-selection-timeout";
len = 0;
}
}
/*
* Create devctl minor node unless driver supplied its own
*/
/*
* Make sure that instance number doesn't overflow
* when forming minor numbers.
*/
(L_MAXMIN >> INST_MINOR_SHIFT));
DDI_NT_SCSI_NEXUS, 0) != DDI_SUCCESS) ||
DDI_NT_SCSI_ATTACHMENT_POINT, 0) != DDI_SUCCESS)) {
}
}
return (DDI_SUCCESS);
}
/*
* Called by an HBA to detach an instance of the driver
*/
int
{
struct dev_ops *hba_dev_ops;
struct scsi_hba_inst *elem;
}
/*
* XXX - scsi_transport.h states that these data fields should not be
* referenced by the HBA. However, to be consistent with
* scsi_hba_attach(), they are being reset.
*/
hba->tran_hba_flags = 0;
/*
* Remove HBA instance from scsi_hba_list
*/
break;
}
return (DDI_FAILURE);
}
if (elem == scsi_hba_list) {
if (scsi_hba_list) {
}
if (elem == scsi_hba_list_tail) {
}
} else if (elem == scsi_hba_list_tail) {
if (scsi_hba_list_tail) {
(struct scsi_hba_inst *)NULL;
}
} else {
}
return (DDI_SUCCESS);
}
/*
* Called by an HBA from _fini()
*/
void
{
struct dev_ops *hba_dev_ops;
/*
* Get the devops structure of this module
* and clear bus_ops vector.
*/
hba_dev_ops = ((struct modldrv *)
}
}
}
/*
* Generic bus_ctl operations for SCSI HBA's,
* hiding the busctl interface from the HBA.
*/
/*ARGSUSED*/
static int
void *arg,
void *result)
{
switch (op) {
case DDI_CTLOPS_REPORTDEV:
{
struct scsi_device *devp;
} else {
char name[SCSI_MAXNAMELEN];
char bus_addr[SCSI_MAXNAMELEN];
SCSI_MAXNAMELEN) != 1) {
return (DDI_FAILURE);
}
SCSI_MAXNAMELEN) != 1) {
return (DDI_FAILURE);
}
"?%s%d at %s%d: name %s, bus address %s\n",
}
return (DDI_SUCCESS);
}
case DDI_CTLOPS_IOMIN:
{
int val;
/*
* The 'arg' value of nonzero indicates 'streaming'
* mode. If in streaming mode, pick the largest
* of our burstsizes available and say that that
* is our minimum value (modulo what minxfer is).
*/
}
case DDI_CTLOPS_INITCHILD:
{
struct scsi_device *sd;
char name[SCSI_MAXNAMELEN];
/*
* Clone transport structure if requested, so
* the HBA can maintain target-specific info, if
* necessary. At least all SCSI-3 HBAs will do this.
*/
} else {
}
/*
* Make sure that HBA either supports both or none
*/
"%s%d: should support both or none of "
"tran_get_name and tran_get_bus_addr\n",
goto failure;
}
}
/*
* In case HBA doesn't support tran_get_name/tran_get_bus_addr
* (e.g. most pre-SCSI-3 HBAs), we have to continue
* to provide old semantics. In case a HBA driver does
* support it, a_target and a_lun fields of scsi_address
* are not defined and will be 0 except for parallel bus.
*/
{
int t_len;
int targ = 0;
int lun = 0;
&t_len) != DDI_SUCCESS) {
sizeof (struct scsi_device));
if (hba->tran_hba_flags &
sizeof (scsi_hba_tran_t));
}
return (DDI_NOT_WELL_FORMED);
}
}
&t_len);
/*
* If the HBA does not implement tran_get_name then it
* doesn't have any hope of supporting a LUN >= 256.
*/
goto failure;
}
/*
* This is also to make sure that if someone plugs in
* a SCSI-2 disks to a SCSI-3 parallel bus HBA,
* his SCSI-2 target driver still continue to work.
*/
}
/*
* In case HBA support tran_get_name (e.g. all SCSI-3 HBAs),
* give it a chance to tell us the name.
* If it doesn't support this entry point, a name will be
* fabricated
*/
goto failure;
}
/*
* Prevent duplicate nodes.
*/
goto failure;
}
/*
* This is a grotty hack that allows direct-access
* (non-scsi) drivers using this interface to
* put its own vector in the 'a_hba_tran' field.
* When the drivers are fixed, remove this hack.
*/
/*
* call hba's target init entry point if it exists
*/
if ((*hba->tran_tgt_init)
goto failure;
}
/*
* Another grotty hack to undo initialization
* some hba's think they have authority to
* perform.
*
* XXX - Pending dadk_probe() semantics
* change. (Re: 1171432)
*/
}
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
case DDI_CTLOPS_UNINITCHILD:
{
struct scsi_device *sd;
/*
* This is a grotty hack, continued. This
* should be:
* hba = sd->sd_address.a_hba_tran;
*/
} else {
}
}
}
return (DDI_SUCCESS);
}
case DDI_CTLOPS_SIDDEV:
return (ndi_dev_is_persistent_node(rdip) ?
/* XXX these should be handled */
case DDI_CTLOPS_POWER:
case DDI_CTLOPS_ATTACH:
case DDI_CTLOPS_DETACH:
return (DDI_SUCCESS);
/*
* These ops correspond to functions that "shouldn't" be called
* by a SCSI target driver. So we whine when we're called.
*/
case DDI_CTLOPS_DMAPMAPC:
case DDI_CTLOPS_REPORTINT:
case DDI_CTLOPS_REGSIZE:
case DDI_CTLOPS_NREGS:
case DDI_CTLOPS_SLAVEONLY:
case DDI_CTLOPS_AFFINITY:
case DDI_CTLOPS_POKE:
case DDI_CTLOPS_PEEK:
return (DDI_FAILURE);
/*
*/
default:
}
}
/*
* Called by an HBA to allocate a scsi_hba_tran structure
*/
/*ARGSUSED*/
int flags)
{
return (kmem_zalloc(sizeof (scsi_hba_tran_t),
}
/*
* Called by an HBA to free a scsi_hba_tran structure
*/
void
{
}
/*
* Private wrapper for scsi_pkt's allocated via scsi_hba_pkt_alloc()
*/
struct scsi_pkt_wrapper {
int pkt_wrapper_len;
};
#if !defined(lint)
#endif
/*
* Round up all allocations so that we can guarantee
* long-long alignment. This is the same alignment
* provided by kmem_alloc().
*/
/*
* Called by an HBA to allocate a scsi_pkt
*/
/*ARGSUSED*/
struct scsi_pkt *
struct scsi_address *ap,
int cmdlen,
int statuslen,
int tgtlen,
int hbalen,
{
struct scsi_pkt_wrapper *hba_pkt;
caddr_t p;
int pktlen;
/*
* Sanity check
*/
" either SLEEP or NULL\n");
}
/*
* Round up so everything gets allocated on long-word boundaries
*/
pktlen = sizeof (struct scsi_pkt_wrapper)
return (NULL);
}
/*
* Set up our private info on this pkt
*/
/*
* Set up pointers to private data areas, cdb, and status.
*/
if (hbalen > 0) {
p += hbalen;
}
if (tgtlen > 0) {
p += tgtlen;
}
if (statuslen > 0) {
p += statuslen;
}
if (cmdlen > 0) {
}
/*
* Initialize the pkt's scsi_address
*/
return (pkt);
}
/*
* Called by an HBA to free a scsi_pkt
*/
/*ARGSUSED*/
void
struct scsi_address *ap,
{
}
/*
* Called by an HBA to map strings to capability indices
*/
int
char *capstr)
{
/*
* Capability strings, masking the the '-' vs. '_' misery
*/
static struct cap_strings {
char *cap_string;
int cap_index;
} cap_strings[] = {
{ "dma_max", SCSI_CAP_DMA_MAX },
{ "dma-max", SCSI_CAP_DMA_MAX },
{ "msg_out", SCSI_CAP_MSG_OUT },
{ "msg-out", SCSI_CAP_MSG_OUT },
{ "disconnect", SCSI_CAP_DISCONNECT },
{ "synchronous", SCSI_CAP_SYNCHRONOUS },
{ "wide_xfer", SCSI_CAP_WIDE_XFER },
{ "wide-xfer", SCSI_CAP_WIDE_XFER },
{ "parity", SCSI_CAP_PARITY },
{ "initiator-id", SCSI_CAP_INITIATOR_ID },
{ "untagged-qing", SCSI_CAP_UNTAGGED_QING },
{ "tagged-qing", SCSI_CAP_TAGGED_QING },
{ "auto-rqsense", SCSI_CAP_ARQ },
{ "linked-cmds", SCSI_CAP_LINKED_CMDS },
{ "sector-size", SCSI_CAP_SECTOR_SIZE },
{ "total-sectors", SCSI_CAP_TOTAL_SECTORS },
{ "geometry", SCSI_CAP_GEOMETRY },
{ "reset-notification", SCSI_CAP_RESET_NOTIFICATION },
{ "qfull-retries", SCSI_CAP_QFULL_RETRIES },
{ "qfull-retry-interval", SCSI_CAP_QFULL_RETRY_INTERVAL },
{ "scsi-version", SCSI_CAP_SCSI_VERSION },
{ "interconnect-type", SCSI_CAP_INTERCONNECT_TYPE },
{ "lun-reset", SCSI_CAP_LUN_RESET },
{ NULL, 0 }
};
struct cap_strings *cp;
}
}
return (-1);
}
/*
* Called by an HBA to determine if the system is in 'panic' state.
*/
int
{
}
/*
* If a SCSI target driver attempts to mmap memory,
* the buck stops here.
*/
/*ARGSUSED*/
static int
{
return (DDI_FAILURE);
}
static int
char *name,
{
return (DDI_SUCCESS);
}
}
static int
void (*callback)(
void *arg,
void *bus_impldata),
void *arg,
{
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
{
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
void *bus_impldata)
{
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/*
* framework, hence, DDI_DEVT2DEVINFO doesn't make much sense (because
* it ask drivers to hold individual dips in memory.
*/
static dev_info_t *
{
return (NULL);
}
}
return (dip);
}
/*
* Default getinfo(9e) for scsi_hba
*/
/* ARGSUSED */
static int
void **result)
{
int error = DDI_SUCCESS;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_FAILURE;
}
break;
case DDI_INFO_DEVT2INSTANCE:
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*
* Default open and close routine for scsi_hba
*/
/* ARGSUSED */
int
{
int rv = 0;
return (EINVAL);
return (ENXIO);
return (ENXIO);
/*
* tran_open_flag bit field:
* 0: closed
* 1: shared open by minor at bit position
* 1 at 31st bit: exclusive open
*/
if (hba->tran_open_flag != 0) {
} else {
}
} else {
} else {
/*
* Ensure that the last framework reserved minor
* is unused. Otherwise, the exclusive open
* mechanism may break.
*/
}
}
return (rv);
}
/* ARGSUSED */
int
{
return (EINVAL);
return (ENXIO);
return (ENXIO);
hba->tran_open_flag = 0;
} else {
}
return (0);
}
/*
* standard ioctl commands for SCSI hotplugging
*/
/* ARGSUSED */
int
int *rvalp)
{
struct scsi_device *sd;
struct devctl_iocdata *dcp;
int rv = 0;
int circ;
return (ENXIO);
return (ENXIO);
/*
* For these ioctls, the general implementation suffices
*/
switch (cmd) {
case DEVCTL_DEVICE_GETSTATE:
case DEVCTL_DEVICE_ONLINE:
case DEVCTL_DEVICE_OFFLINE:
case DEVCTL_DEVICE_REMOVE:
case DEVCTL_BUS_GETSTATE:
}
switch (cmd) {
case DEVCTL_DEVICE_RESET:
break;
}
/*
* read devctl ioctl data
*/
return (EFAULT);
return (EINVAL);
}
return (ENXIO);
}
/*
* See DDI_CTLOPS_INITCHILD above
*/
}
break;
case DEVCTL_BUS_QUIESCE:
(bus_state == BUS_QUIESCED)) {
break;
}
} else {
}
break;
case DEVCTL_BUS_UNQUIESCE:
(bus_state == BUS_ACTIVE)) {
break;
}
} else {
}
break;
case DEVCTL_BUS_RESET:
/*
* Use tran_bus_reset
*/
}
break;
case DEVCTL_BUS_RESETALL:
break;
}
/*
* Find a child's scsi_address and invoke tran_reset
*
* XXX If no child exists, one may to able to fake a child.
* This will be a enhancement for the future.
* For now, we fall back to BUS_RESET.
*/
while (child) {
break;
}
if ((*hba->tran_reset)
}
} else {
}
}
break;
case DEVCTL_BUS_CONFIGURE:
}
break;
case DEVCTL_BUS_UNCONFIGURE:
if (ndi_devi_unconfig(self,
}
break;
default:
} /* end of outer switch */
return (rv);
}
static int
{
}
/*
* Force reprobe for BUS_CONFIG_ONE or when manually reconfiguring
* via devfsadm(1m) to emulate deferred attach.
* Reprobe only discovers driver.conf enumerated nodes, more
* dynamic implementations probably require their own bus_config.
*/
}
static int
void *arg)
{
}
}
/*
* Convert scsi ascii string data to NULL terminated (semi) legal IEEE 1275
* "compatible" (name) property form.
*
* For ASCII INQUIRY data, a one-way conversion algorithm is needed to take
* SCSI_ASCII (20h - 7Eh) to a 1275-like compatible form. The 1275 spec allows
* letters, digits, one ",", and ". _ + -", all limited by a maximum 31
* character length. Since ", ." are used as separators in the compatible
* string itself, they are converted to "_". All SCSI_ASCII characters that
* are illegal in 1275, as well as any illegal SCSI_ASCII characters
* encountered, are converted to "_". To reduce length, trailing blanks are
* trimmed from SCSI_ASCII fields prior to conversion.
*
* Example: SCSI_ASCII "ST32550W SUN2.1G" -> "ST32550W_SUN2_1G"
*
* NOTE: the 1275 string form is always less than or equal to the scsi form.
*/
static char *
{
while (len >= 0) {
else
break;
}
while (len >= 0) {
len--; /* legal 1275 */
else
}
return (s_1275);
}
/*
* Given the inquiry data, binding_set, and dtype_node for a scsi device,
* return the nodename and compatible property for the device. The "compatible"
* concept comes from IEEE-1275. The compatible information is returned is in
* the correct form for direct use defining the "compatible" string array
* property. Internally, "compatible" is also used to determine the nodename
* to return.
*
* This function is provided as a separate entry point for use by drivers that
* currently issue their own non-SCSA inquiry command and perform their own
* node creation based their own private compiled in tables. Converting these
* drivers to use this interface provides a quick easy way of obtaining
* consistency as well as the flexibility associated with the 1275 techniques.
*
* The dtype_node is passed as a separate argument (instead of having the
* implementation use inq_dtype). It indicates that information about
* a secondary function embedded service should be produced.
*
* Callers must always use scsi_hba_nodename_compatible_free, even if
* *nodenamep is null, to free the nodename and compatible information
* when done.
*
* If a nodename can't be determined then **compatiblep will point to a
* diagnostic string containing all the compatible forms.
*
* NOTE: some compatible strings may violate the 31 character restriction
* imposed by IEEE-1275. This is not a problem because Solaris does not care
* about this 31 character limit.
*
* The following compatible forms, in high to low precedence
* order, are defined for SCSI target device nodes.
*
* scsiclass,DDEEFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (1 *1&2)
* scsiclass,DDEE.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (2 *1)
* scsiclass,DDFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (3 *2)
* scsiclass,DD.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (4)
* scsiclass,DDEEFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP (5 *1&2)
* scsiclass,DDEE.vVVVVVVVV.pPPPPPPPPPPPPPPPP (6 *1)
* scsiclass,DDFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP (7 *2)
* scsiclass,DD.vVVVVVVVV.pPPPPPPPPPPPPPPPP (8)
* scsa,DD.bBBBBBBBB (8.5 *3)
* scsiclass,DDEEFFF (9 *1&2)
* scsiclass,DDEE (10 *1)
* scsiclass,DDFFF (11 *2)
* scsiclass,DD (12)
* scsiclass (13)
*
* *1 only produced on a secondary function node
* *2 only produced on a node with flags
* *3 only produces when binding-set legacy support is needed
*
* where:
*
* v is the letter 'v'. Denotest the
* beginning of VVVVVVVV.
*
* VVVVVVVV Translated scsi_vendor.
*
* p is the letter 'p'. Denotes the
* beginning of PPPPPPPPPPPPPPPP.
*
* PPPPPPPPPPPPPPPP Translated scsi_product.
*
* r is the letter 'r'. Denotes the
* beginning of RRRR.
*
* RRRR Translated scsi_revision.
*
* DD is a two digit ASCII hexadecimal
* number. The value of the two digits is
* based one the SCSI "Peripheral device
* type" command set associated with the
* node. On a primary node this is the
* scsi_dtype of the primary command set,
* on a secondary node this is the
* scsi_dtype associated with the embedded
* function command set.
*
* EE Same encoding used for DD. This form is
* only generated on secondary function
* nodes. The DD function is embedded in
* an EE device.
*
* FFF Concatenation, in alphabetical order,
* of the flag characters below. The
* following flag characters are defined:
*
* R Removable media: Used when
* scsi_rmb is set.
*
* Forms using FFF are only be generated
* if there are applicable flag
* characters.
*
* b is the letter 'b'. Denotes the
* beginning of BBBBBBBB.
*
* BBBBBBBB Binding-set. Operating System Specific:
* scsi-binding-set property of HBA.
*/
#define COMPAT_LONGEST (strlen( \
"scsiclass,DDEEFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR" + 1))
void
int dtype_node, char *compat0,
{
char f[sizeof ("ER")];
int dtype_device;
int ncompat; /* number of compatible */
char **compatp; /* compatible ptrs */
int i;
char *nname; /* nodename */
char *dname; /* driver name */
char **csp;
char *p;
int tlen;
int len;
/*
* Nodename_aliases: This table was originally designed to be
* implemented via a new nodename_aliases file - a peer to the
* driver_aliases that selects a nodename based on compatible
* forms in much the same say driver_aliases is used to select
* driver bindings from compatible forms. Each compatible form
* is an 'alias'. Until a more general need for a
* nodename_aliases file exists, which may never occur, the
* scsi mappings are described here via a compiled in table.
*
* This table contains nodename mappings for self-identifying
* scsi devices enumerated by the Solaris kernel. For a given
* device, the highest precedence "compatible" form with a
* mapping is used to select the nodename for the device. This
* will typically be a generic nodename, however in some legacy
* compatibility cases a driver nodename mapping may be selected.
*
* Because of possible breakage associated with switching SCSI
* target devices from driver nodenames to generic nodenames,
* we are currently unable to support generic nodenames for all
* SCSI devices (binding-sets). Although /devices paths are
* defined as unstable, avoiding possible breakage is
* important. Some of the newer SCSI transports (USB) already
* use generic nodenames. All new SCSI transports and target
* devices should use generic nodenames. At times this decision
* may be architecture dependent (sparc .vs. intel) based on when
* a transport was supported on a particular architecture.
*
* We provide a base set of generic nodename mappings based on
* scsiclass dtype and higher-precedence driver nodename
* mappings based on scsa "binding-set" to cover legacy
* issues. The binding-set is typically associated with
* "scsi-binding-set" property value of the HBA. The legacy
* mappings are provided independent of whether the driver they
* refer to is installed. This allows a correctly named node
* an add_drv of the legacy driver occurs.
*
* We also have mappings for legacy SUN hardware that
* misidentifies itself (enclosure services which identify
* themselves as processors). All future hardware should use
* the correct dtype.
*
* As SCSI HBAs are modified to use the SCSA interfaces for
* self-identifying SCSI target devices (PSARC/2004/116) the
* nodename_aliases table (PSARC/2004/420) should be augmented
* with legacy mappings in order to maintain compatibility with
* existing /devices paths, especially for devices that house
* an OS. Failure to do this may cause upgrade problems.
* Additions for new target devices or transports should not
* add scsa binding-set compatible mappings.
*/
static struct nodename_aliases {
char *na_nodename; /* nodename */
char *na_alias; /* compatible form match */
} na[] = {
/* # mapping to generic nodenames based on scsi dtype */
{"disk", "scsiclass,00"},
{"tape", "scsiclass,01"},
{"printer", "scsiclass,02"},
{"processor", "scsiclass,03"},
{"worm", "scsiclass,04"},
{"cdrom", "scsiclass,05"},
{"scanner", "scsiclass,06"},
{"optical-disk", "scsiclass,07"},
{"medium-changer", "scsiclass,08"},
{"obsolete", "scsiclass,09"},
{"prepress-a", "scsiclass,0a"},
{"prepress-b", "scsiclass,0b"},
{"array-controller", "scsiclass,0c"},
{"enclosure", "scsiclass,0d"},
{"disk", "scsiclass,0e"},
{"card-reader", "scsiclass,0f"},
{"bridge", "scsiclass,10"},
{"object-store", "scsiclass,11"},
{"reserved", "scsiclass,12"},
{"reserved", "scsiclass,13"},
{"reserved", "scsiclass,14"},
{"reserved", "scsiclass,15"},
{"reserved", "scsiclass,16"},
{"reserved", "scsiclass,17"},
{"reserved", "scsiclass,18"},
{"reserved", "scsiclass,19"},
{"reserved", "scsiclass,1a"},
{"reserved", "scsiclass,1b"},
{"reserved", "scsiclass,1c"},
{"reserved", "scsiclass,1d"},
{"well-known-lun", "scsiclass,1e"},
{"unknown", "scsiclass,1f"},
#ifdef sparc
/* # legacy mapping to driver nodenames for fcp binding-set */
{"ssd", "scsa,00.bfcp"},
{"st", "scsa,01.bfcp"},
{"sgen", "scsa,08.bfcp"},
{"ses", "scsa,0d.bfcp"},
/* # legacy mapping to driver nodenames for vhci binding-set */
{"ssd", "scsa,00.bvhci"},
{"st", "scsa,01.bvhci"},
{"sgen", "scsa,08.bvhci"},
{"ses", "scsa,0d.bvhci"},
#else /* sparc */
/* # for x86 fcp and vhci use generic nodenames */
#endif /* sparc */
#ifdef notdef
/*
* The following binding-set specific mappings are not being
* delivered at this time, but are listed here as an examples of
* the type of mappings needed.
*/
/* # legacy mapping to driver nodenames for spi binding-set */
{"sd", "scsa,00.bspi"},
{"sd", "scsa,05.bspi"},
{"sd", "scsa,07.bspi"},
{"st", "scsa,01.bspi"},
{"ses", "scsa,0d.bspi"},
/* # SUN misidentified spi hardware */
{"ses", "scsiclass,03.vSUN.pD2"},
{"ses", "scsiclass,03.vSYMBIOS.pD1000"},
/* # legacy mapping to driver nodenames for atapi binding-set */
{"sd", "scsa,00.batapi"},
{"sd", "scsa,05.batapi"},
{"sd", "scsa,07.batapi"},
{"st", "scsa,01.batapi"},
{"unknown", "scsa,0d.batapi"},
/* # legacy mapping to generic nodenames for usb binding-set */
{"disk", "scsa,05.busb"},
{"disk", "scsa,07.busb"},
{"changer", "scsa,08.busb"},
{"comm", "scsa,09.busb"},
{"array_ctlr", "scsa,0c.busb"},
{"esi", "scsa,0d.busb"},
#endif /* notdef */
};
struct nodename_aliases *nap;
(ncompatiblep == NULL))
return;
/*
* In order to reduce runtime we allocate one block of memory that
* contains both the NULL terminated array of pointers to compatible
* forms and the individual compatible strings. This block is
* somewhat larger than needed, but is short lived - it only exists
* until the caller can transfer the information into the "compatible"
* string array property and call scsi_hba_nodename_compatible_free.
*/
/* convert inquiry data from SCSI ASCII to 1275 string */
sizeof (inq->inq_revision));
/*
* Form flags alphabetically:
* R - removable:
* Set when inq_rmb is set and for well known scsi dtypes. For a
* bus where the entire device is removable (like USB), we expect
* the HBA to intercept the inquiry data and set inq_rmb.
* Since OBP does not distinguish removable media in its generic
* name selection we avoid setting the 'R' flag if the root is not
* yet mounted.
*/
i = 0;
(dtype_device == DTYPE_WORM) ||
(dtype_device == DTYPE_RODIRECT) ||
(dtype_device == DTYPE_OPTICAL)))
f[i++] = 'R';
f[i] = '\0';
/*
* Construct all applicable compatible forms. See comment at the
* head of the function for a description of the compatible forms.
*/
/* ( 0) driver (optional, not documented in scsi(4)) */
if (compat0) {
*csp++ = p;
p += len;
}
/* ( 1) scsiclass,DDEEF.vV.pP.rR */
*csp++ = p;
p += len;
}
/* ( 2) scsiclass,DDEE.vV.pP.rR */
*csp++ = p;
p += len;
}
/* ( 3) scsiclass,DDF.vV.pP.rR */
*csp++ = p;
p += len;
}
/* ( 4) scsiclass,DD.vV.pP.rR */
*csp++ = p;
p += len;
}
/* ( 5) scsiclass,DDEEF.vV.pP */
*csp++ = p;
p += len;
}
/* ( 6) scsiclass,DDEE.vV.pP */
*csp++ = p;
p += len;
}
/* ( 7) scsiclass,DDF.vV.pP */
*csp++ = p;
p += len;
}
/* ( 8) scsiclass,DD.vV.pP */
*csp++ = p;
p += len;
}
/* (8.5) scsa,DD.bB (not documented in scsi(4)) */
if (binding_set) {
*csp++ = p;
p += len;
}
/* ( 9) scsiclass,DDEEF */
if ((dtype_device != dtype_node) && *f) {
*csp++ = p;
dtype_node, dtype_device, f);
p += len;
}
/* (10) scsiclass,DDEEF */
if (dtype_device != dtype_node) {
*csp++ = p;
p += len;
}
/* (11) scsiclass,DDF */
if (*f) {
*csp++ = p;
dtype_node, f);
p += len;
}
/* (12) scsiclass,DD */
*csp++ = p;
p += len;
/* (13) scsiclass */
*csp++ = p;
p += len;
/*
* When determining a nodename, a nodename_aliases specified
* mapping has precedence over using a driver_aliases specified
* driver binding as a nodename.
*
* See if any of the compatible forms have a nodename_aliases
* specified nodename. These mappings are described by
* nodename_aliases entries like:
*
* disk "scsiclass,00"
* enclosure "scsiclass,03.vSYMBIOS.pD1000"
* ssd "scsa,00.bfcp"
*
* All nodename_aliases mappings should idealy be to generic
* names, however a higher precedence legacy mapping to a
* driver name may exist. The highest precedence mapping
* provides the nodename, so legacy driver nodename mappings
* (if they exist) take precedence over generic nodename
* mappings.
*/
break;
}
}
}
/*
* If no nodename_aliases mapping exists then use the
* driver_aliases specified driver binding as a nodename.
* Determine the driver based on compatible (which may
* have the passed in compat0 as the first item). The
* driver_aliases file has entries like
*
* sd "scsiclass,00"
*
* that map compatible forms to specific drivers. These
* entries are established by add_drv. We use the most specific
* driver binding as the nodename. This matches the eventual
* ddi_driver_compatible_major() binding that will be
* established by bind_node()
*/
continue;
break;
}
}
/* return results */
if (nname) {
} else {
/*
* If no nodename could be determined return a special
* 'compatible' to be used for a diagnostic message. This
* compatible contains all compatible forms concatenated
* into a single string pointed to by the first element.
*/
ncompat = 1;
}
}
*compatiblep = compatp;
*ncompatiblep = ncompat;
}
/* Free allocations associated with scsi_hba_nodename_compatible_get use. */
void
{
if (nodename)
if (compatible)
(NCOMPAT * COMPAT_LONGEST));
}
static int
{
}
}