scsi_confsubr.c revision 392e836b07e8da771953e4d64233b2abe4393efe
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
/*
* Utility SCSI configuration routines
*/
/*
* Many routines in this file have built in parallel bus assumption
* which might need to change as other interconnect evolve.
*/
/*
* macro for filling in lun value for scsi-1 support
*/
}
extern struct mod_ops mod_miscops;
&mod_miscops, /* Type of module */
"SCSI Bus Utility Routines"
};
static struct modlinkage modlinkage = {
};
/*
* Contexts from which we call scsi_test
*/
enum scsi_test_ctxt {
/*
* Those in scsi_hba_probe_pi()
*/
/*
* Those in check_vpd_page_support8083()
*/
/*
* Those in scsi_device_identity()
*/
};
static void create_inquiry_props(struct scsi_device *);
static int scsi_check_ss2_LUN_limit(struct scsi_device *);
static void scsi_establish_LUN_limit(struct scsi_device *);
static void scsi_update_parent_ss2_prop(dev_info_t *, int, int);
int (*callback)(), int *, int *);
enum scsi_test_ctxt);
/*
* this int-array HBA-node property keeps track of strictly SCSI-2
* target IDs
*/
#define SS2_LUN0_TGT_LIST_PROP "ss2-targets"
/*
* for keeping track of nodes for which we do *NOT* want to probe above LUN 7
* (i.e. strict SCSI-2 targets)
*
* note that we could also keep track of dtype (SCSI device type) and
* ANSI (SCSI standard conformance level), but all currently-known cases of
* this problem are on SCSI-2 PROCESSOR device types
*/
typedef struct ss2_lun0_info {
const char *sli_vid; /* SCSI inquiry VID */
const char *sli_pid; /* SCSI inquiry PID */
const char *sli_rev; /* SCSI inquiry REV */
/*
* these two workarounds are for the SCSI-2 GEM2* chips used in the
* D1000 and D240
*/
#define SES_D1000_VID "SYMBIOS"
#define SES_D1000_REV "2"
#define SES_D240_VID "SUN"
#define SES_D240_REV "2"
/*
* a static list of targets where we do *not* want to probe above LUN 7
*/
static const ss2_lun0_info_t scsi_probe_strict_s2_list[] = {
};
static const int scsi_probe_strict_s2_size =
sizeof (scsi_probe_strict_s2_list) / sizeof (struct ss2_lun0_info);
#ifdef DEBUG
int scsi_probe_debug = 0;
#define SCSI_PROBE_DEBUG0(l, s) \
if (scsi_probe_debug >= (l)) printf(s)
#define SCSI_PROBE_DEBUG1(l, s, a1) \
#else /* DEBUG */
#define SCSI_PROBE_DEBUG0(l, s)
#define SCSI_PROBE_DEBUG1(l, s, a1)
#endif /* DEBUG */
/*
* Returns from scsi_test.
*
* SCSI_TEST_CMPLT_GOOD => TRAN_ACCEPT, CMD_CMPLT, STATUS_GOOD
*
* SCSI_TEST_CMPLT_BUSY => TRAN_ACCEPT, CMD_CMPLT, STATUS_BUSY
*
* SCSI_TEST_CMPLT_CHECK => TRAN_ACCEPT, CMD_CMPLT, STATUS_CHECK
*
* SCSI_TEST_CMPLT_OTHER => TRAN_ACCEPT, CMD_CMPLT, !STATUS_{GOOD,BUSY,CHECK}
*
* SCSI_TEST_CMD_INCOMPLETE => TRAN_ACCEPT, CMD_INCOMPLETE
*
* SCSI_TEST_NOTCMPLT => TRAN_ACCEPT, pkt_reason != CMD_{CMPLT,INCOMPLETE}
*
* SCSI_TEST_TRAN_BUSY => (Repeated) TRAN_BUSY from attempt scsi_transport
*
* SCSI_TEST_TRAN_REJECT => TRAN_BADPKT or TRAN_FATAL_ERROR
*
*/
#define SCSI_TEST_CMPLT_GOOD 0x01U
#define SCSI_TEST_CMPLT_BUSY 0x02U
#define SCSI_TEST_CMPLT_CHECK 0x04U
#define SCSI_TEST_CMPLT_OTHER 0x08U
#define SCSI_TEST_CMPLTMASK \
#define SCSI_TEST_PARTCMPLTMASK \
#define SCSI_TEST_CMD_INCOMPLETE 0x10U
#define SCSI_TEST_NOTCMPLT 0x20U
#define SCSI_TEST_TRAN_BUSY 0x40U
#define SCSI_TEST_TRAN_REJECT 0x80U
#define SCSI_TEST_FAILMASK \
#define SCSI_TEST_FAILURE(x) (((x) & SCSI_TEST_FAILMASK) != 0)
/*
* architecture dependent allocation restrictions. For x86, we'll set
* dma_attr_addr_hi to scsi_max_phys_addr and dma_attr_sgllen to
* scsi_sgl_size during _init().
*/
#if defined(__sparc)
DMA_ATTR_V0, /* version number */
0x0, /* lowest usable address */
0xFFFFFFFFull, /* high DMA address range */
0xFFFFFFFFull, /* DMA counter register */
1, /* DMA address alignment */
1, /* DMA burstsizes */
1, /* min effective DMA size */
0xFFFFFFFFull, /* max DMA xfer size */
0xFFFFFFFFull, /* segment boundary */
1, /* s/g list length */
512, /* granularity of device */
0 /* DMA transfer flags */
};
DMA_ATTR_V0, /* version number */
0x0, /* lowest usable address */
0x0, /* high DMA address range [set in _init()] */
0xFFFFull, /* DMA counter register */
1, /* DMA address alignment */
1, /* DMA burstsizes */
1, /* min effective DMA size */
0xFFFFFFFFull, /* max DMA xfer size */
0xFFFFFFFFull, /* segment boundary */
0, /* s/g list length */
512, /* granularity of device [set in _init()] */
0 /* DMA transfer flags */
};
int scsi_sgl_size = 0xFF;
#endif
int
_init()
{
#if defined(__x86)
/* set the max physical address for iob allocs on x86 */
/*
* set the sgllen for iob allocs on x86. If this is set less than
* the number of pages the buffer will take (taking into account
* alignment), it would force the allocator to try and allocate
* contiguous pages.
*/
#endif
/* bitmap to limit scsi_pkt allocation violation messages */
return (mod_install(&modlinkage));
}
/*
* there is no _fini() routine because this module is never unloaded
*/
int
{
}
static int
{
int rval = SCSIPROBE_EXISTS;
/*
* prepare rqsense packet
*/
goto out;
}
else
goto out;
}
/*
* The controller type is as yet unknown, so we
* have to do a throwaway non-extended request sense,
* and hope that that clears the check condition
* for that unit until we can find out what kind
* of drive it is. A non-extended request sense
* is specified by stating that the sense block
* has 0 length, which is taken to mean that it
* is four bytes in length.
*/
}
out:
if (rq_pkt) {
}
if (rq_bp) {
}
return (rval);
}
/*
*
* SCSI slave probe routine - provided as a service to target drivers
*
* Mostly attempts to allocate and fill sd inquiry data..
*/
int
{
int rval = SCSIPROBE_EXISTS;
/*
* the first test unit ready will tell us whether a target
* responded and if there was one, it will clear the unit attention
* condition
*/
return (SCSIPROBE_NOMEM_CB);
}
SCMD_TEST_UNIT_READY, 0, 0, 0);
else
/*
* scanner and processor devices can return a
* check condition here
*/
}
if (rval != SCSIPROBE_EXISTS) {
return (rval);
}
}
/*
* the second test unit ready, allows the host adapter to negotiate
* synchronous transfer period and offset
*/
else
}
/*
* do a rqsense if there was a check condition and ARQ was not done
*/
}
}
/*
* call scsi_probe to do the inquiry
*
* NOTE: there is minor difference with the old scsi_slave
* implementation: busy conditions are not handled in scsi_probe.
*/
if (rval == SCSIPROBE_EXISTS) {
} else {
return (rval);
}
}
/*
* Undo scsi_slave - older interface, but still supported
*
* as part of free of scsi_device(9S).
*/
/*ARGSUSED*/
void
{
}
/*
* Undo scsi_probe
*
* as part of free of scsi_device(9S).
*/
/*ARGSUSED*/
void
{
}
/*
* We log all scsi_test failures (as long as we are SE_HP etc). The
* following table controls the "driver-assessment" payload item
* in the ereports we raise. If a scsi_test return features in the
* retry mask then the calling context will retry; if it features in
* the fatal mask then the caller will not retry (although higher-level
* software might); if in neither (which shouldn't happen - you either
* retry or give up) default to 'retry'.
*/
static const struct scsi_test_profile {
} scsi_test_profile[] = {
/*
* This caller will retry on SCSI_TEST_FAILMASK as long as it was
* not SCSI_TEST_CMD_INCOMPLETE which is terminal. A return from
* SCSI_TEST_PARTCMPLTMASK (command complete but status other than
* STATUS_GOOD) is not terminal and we'll move on to the context
* of STC_PROBE_PARTIAL_SUCCESS so that's a retry, too.
*/
{
},
/*
* If the first inquiry fails outright we always retry just once
* (except for SCSI_TEST_CMD_INCOMPLETE as above). A return in
* SCSI_TEST_FAILMASK is terminal; for SCSI_TEST_PARTCMPLTMASK
* we will retry at STC_PROBE_PARTIAL_SUCCESS.
*/
{
},
/*
* If we've met with partial success we retry at caller context
* STC_PROBE_PARTIAL_SUCCESS. Any SCSI_TEST_FAILMASK return
* here is terminal, as too is SCSI_TEST_CMPLT_BUSY. A return in
* SCSI_TEST_PARTCMPLTMASK and we will continue with further
* inquiry attempts.
*/
{
},
/*
* If we get past the above target busy case then we will
* perform a sense request if scsi_test indicates STATUS_CHECK
* and ARQ was not done. We are not interested in logging telemetry
* for transports that do not perform ARQ automatically.
*/
{
0,
0
},
/*
* If "something" responded to the probe but then the next inquiry
* sees a change of heart then we fail the probe on any of
* SCSI_TEST_FAILMASK or SCSI_TEST_CMPLT_BUSY. For other values
* in SCSI_TEST_PARTCMPLTMASK we soldier on.
*/
{
},
/*
* If after all that there we still have STATUS_CHECK from the
* inquiry status then we resend the sense request but the
* result is ignored (just clearing the condition). Do not
* log.
*/
{
0,
0
},
/*
* After the above sense request we once again send an inquiry.
* If it fails outright or STATUS_CHECK persists we give up.
* Any partial result is considered success.
*/
{
0,
},
/*
* check_vpd_page_support8083 called from scsi_device_identity
* performs an inquiry with EVPD set (and page necessarily 0)
* to see what pages are supported.
*
* Some devices do not support this command and therefore
* check_vpd_page_support8083 only returns an error of kmem_zalloc
* fails. If the send_scsi_INQUIRY does not meet with complete
* success (SCSI_TEST_CMPLT_GOOD) it returns -1, othewise 0.
* So any scsi_test failure here will cause us to assume no page
* 80/83 support, and we will proceed without devid support.
* So -1 returns from send_scsi_INQUIRY are not terminal.
*/
{
0,
0
},
/*
* If the above inquiry claims pg80 support then scsi_device_identity
* will perform a send_scsi_INQUIRY to retrieve that page.
* Anything other than SCSI_TEST_CMPLT_GOOD is a failure and will
* cause scsi_device_identity to return non-zero at which point the
* caller goes to SCSIPROBE_FAILURE.
*/
{
0,
},
/*
* Similarly for pg83
*/
{
0,
}
};
int scsi_test_ereport_disable = 0;
extern int e_devid_cache_path_to_devid(char *, char *, char *, ddi_devid_t *);
static void
{
struct scsi_device *sd;
const char *d_ass;
const char *class;
char *pathbuf;
int err = 0;
int dad = 0;
int lun;
return;
return; /* Not SCSI_HBA_ADDR_COMPLEX */
/*
* We only raise telemetry for SE_HP style enumeration
*/
if (!ndi_dev_is_hotplug_node(hba))
return;
/*
* scsi_fm_ereport_post will use the hba for the fm-enabled devinfo
*/
return;
/*
* Retrieve the unit address we were probing and the target
* port component thereof.
*/
return;
/*
* Determine whether unit address is location based or identity (wwn)
* based. If we can't convert the target port address to a wwn then
* we're location based.
*/
return;
/*
* Get lun and lun64
*/
SCSI_ADDR_PROP_LUN, 0);
/*
* We are guaranteed not to be in interrupt or any other
* problematic context. So instead of repeated varargs
* style calls to scsi_fm_ereport_post for each flavour of
* ereport we have the luxury of being able to allocate
* and build an nvlist here.
*
* The ereports we raise here are all under the category
* ereport.io.scsi.cmd.disk category, namely
*
* ereport.io.scsi.cmd.disk.
* {dev.rqs.derr,dev.serr,tran}.
*
* For all ereports we also add the scsi_test specific payload.
* If we have it then we always include the devid in the payload
* (but only in the detector for device-as-detector ereports).
*
* Inherited From Member Name
* -------------------- -------------------
* .cmd driver-assessment
* .cmd op-code
* .cmd cdb
* .cmd pkt-reason
* .cmd pkt-state
* .cmd pkt-stats
* .cmd.disk stat-code
* - scsi-test-return
* - scsi-test-context
*/
return;
pkt->pkt_cdblen);
switch (stresult) {
case SCSI_TEST_CMPLT_BUSY:
dad = 1;
class = "cmd.disk.dev.serr";
break;
case SCSI_TEST_CMPLT_CHECK:
dad = 1;
struct scsi_arq_status *arqstat;
class = "cmd.disk.dev.rqs.derr";
/*
* Add to payload.
*/
} else {
class = "cmd.disk.dev.serr";
}
break;
case SCSI_TEST_CMPLT_OTHER:
dad = 1;
class = "cmd.disk.dev.serr";
break;
case SCSI_TEST_CMD_INCOMPLETE:
case SCSI_TEST_NOTCMPLT:
case SCSI_TEST_TRAN_BUSY:
case SCSI_TEST_TRAN_REJECT:
class = "cmd.disk.tran";
break;
}
/*
* Determine driver-assessment and add to payload.
*/
if (dad) {
/*
* While higher level software can retry the enumeration
* the belief is that any device-as-detector style error
* will be persistent and will survive retries. So we
* can make a local determination of driver assessment.
* Some day it may be more elegant to raise an ereport from
* scsi_tgtmap_scsi_deactivate to confirm retries failed,
* and correlate that ereport during diagnosis.
*/
d_ass = (const char *)"fatal";
d_ass = (const char *)"retry";
else
d_ass = (const char *)"retry";
} else {
/* We do not diagnose transport errors (yet) */
d_ass = (const char *)"retry";
}
/*
* If we're hoping for a device-as-detector style ereport then
* we're going to need a devid for the detector FMRI. We
* don't have the devid because the target won't talk to us.
* But we do know which hba iport we were probing out of, and
* we know the unit address that was being probed (but not
* what type of device is or should be there). So we
* search the devid cache for any cached devid matching
* path <iport-path>/<nodename>@<unit-address> with nodename
* wildcarded. If a match is made we are returned not only the
* devid but also the nodename for the path that cached that
* entry.
*
* We also attempt to dig up a devid even for transport errors;
* we'll include that in the payload but not in the detector FMRI.
*/
&devid) == DDI_SUCCESS) {
}
/*
* If this is lun 0 we will include the target-port-l0id
* in the dev scheme detector for device-as-detector.
*/
/* Construct the devpath to use in the detector */
/*
* Let's review.
*
* Device-as-detector ereports for which the attempted lookup of
* devid and nodename succeeded:
*
* - pathbuf has the full device path including nodename we
* dug up from the devid cache
*
* - class is one of cmd.disk.{dev.rqs.derr,dev.serr}
*
* - devidstr is non NULL and a valid devid string
*
* Would-be device-as-detector ereport for which the attempted lookup
* of devid failed:
*
* - pathbuf has a device path with leaf nodename of "unknown"
* but still including the unit-address
* - class is one of cmd.disk.{dev.rqs.derr,dev.serr}
*
* Transport errors:
*
* class is cmd.disk.tran
* devidstr is NULL
*
* - we may have succeeded in looking up a devid and nodename -
* the devid we'll have added to the payload but we must not
* add to detector FMRI, and if we have have nodename then
* we have a full devpath otherwise one with "unknown" for
* nodename
*/
if (err)
B_TRUE);
sd,
0, /* path_instance - always 0 */
pathbuf, /* devpath for detector */
class, /* ereport class suffix */
0, /* ENA - generate for us */
tpl0, /* target-port-l0id */
pl, /* preconstructed payload */
NULL);
if (devidstr_buf)
}
#ifdef DEBUG
/*
* Testing - fake scsi_test fails
*/
#endif
/*
* This is like scsi_poll, but only does retry for TRAN_BUSY.
*/
static uint32_t
{
int wait_usec;
int rc;
extern int do_polled_io;
}
/*
* Each TRAN_BUSY response waits scsi_test_busy_delay usec up to a
* maximum of scsi_test_busy_timeout.
*/
/* Initialize pkt status variables */
(scsi_test_busy_timeout == 0))
break;
/* transport busy, wait */
} else {
/* we busy wait during cpr_dump or interrupt threads */
}
}
#ifdef DEBUG
struct scsi_device *sd;
char ua[SCSI_MAXNAMELEN];
if (rc == TRAN_ACCEPT)
pkt->pkt_reason =
if (scsi_test_fail_status == STATUS_CHECK)
}
}
}
#endif
switch (rc) {
case TRAN_ACCEPT:
switch (pkt->pkt_reason) {
case CMD_CMPLT:
case STATUS_GOOD:
break;
case STATUS_BUSY:
break;
case STATUS_CHECK:
break;
default:
break;
}
break;
case CMD_INCOMPLETE:
break;
default:
break;
}
break;
case TRAN_BUSY:
break;
default:
break;
}
if (rval != SCSI_TEST_CMPLT_GOOD)
return (rval);
}
/*
* The implementation of scsi_probe now allows a particular
* HBA to intercept the call, for any post- or pre-processing
* it may need. The default, if the HBA does not override it,
* is to call scsi_hba_probe(), which retains the old functionality
* intact.
*/
int
{
int ret;
if (scsi_check_ss2_LUN_limit(sd) != 0) {
/*
* caller is trying to probe a strictly-SCSI-2 device
* with a LUN that is too large, so do not allow it
*/
return (SCSIPROBE_NORESP); /* skip probing this one */
}
} else {
}
if (ret == SCSIPROBE_EXISTS) {
/* is this a strictly-SCSI-2 node ?? */
}
return (ret);
}
/*
* probe scsi device using any available path
*
*/
int
{
}
/*
* probe scsi device using specific path
*
* scsi_hba_probe_pi does not do any test unit ready's which access the medium
* and could cause busy or not ready conditions.
* scsi_hba_probe_pi does 2 inquiries and a rqsense to clear unit attention
* and to allow sync negotiation to take place
* finally, scsi_hba_probe_pi does one more inquiry which should
* reliably tell us what kind of target we have.
* A scsi-2 compliant target should be able to return inquiry with 250ms
* and we actually wait more than a second after reset.
*/
int
{
int rval = SCSIPROBE_NOMEM;
int (*cb_flag)();
int pass = 1;
KM_SLEEP : KM_NOSLEEP));
goto out;
}
}
} else {
}
goto out;
}
goto out;
}
SCMD_INQUIRY, 0, SUN_INQSIZE, 0);
/*
* set transport path
*/
}
/*
* the first inquiry will tell us whether a target
* responded
*
* The FILL_SCSI1_LUN below will find "ansi_ver != 1" on first pass
* because of bzero initilization. If this assumption turns out to be
* incorrect after we have real sd_inq data (for lun0) we will do a
* second pass during which FILL_SCSI1_LUN will place lun in CDB.
*/
if (SCSI_TEST_FAILURE(str)) {
if (str == SCSI_TEST_CMD_INCOMPLETE) {
goto out;
}
/*
* Retry one more time for anything other than CMD_INCOMPLETE.
*/
if (SCSI_TEST_FAILURE(str)) {
goto out;
}
}
/*
* Did the inquiry complete and transfer inquiry information,
* perhaps after retry?
*/
if (str == SCSI_TEST_CMPLT_GOOD)
goto done;
/*
* We get here for SCSI_TEST_CMPLT_{BUSY,CHECK,OTHER}. We term
* this "partial success" in that at least something is talking
* to us.
*
* A second inquiry allows the host adapter to negotiate
* synchronous transfer period and offset
*/
if (SCSI_TEST_FAILURE(str)) {
if (str == SCSI_TEST_CMD_INCOMPLETE)
else
goto out;
}
/*
* If target is still busy, give up now.
* XXX There's no interval between retries - scsi_test should
* probably have a builtin retry on target busy.
*/
if (str == SCSI_TEST_CMPLT_BUSY) {
goto out;
}
/*
* At this point we are SCSI_TEST_CMPLT_GOOD, SCSI_TEST_CMPLT_CHECK
* or SCSI_TEST_CMPLT_OTHER.
*
* Do a rqsense if there was a check condition and ARQ was not done
*/
if (str == SCSI_TEST_CMPLT_CHECK &&
/*
* prepare rqsense packet
* there is no real need for this because the
* check condition should have been cleared by now.
*/
goto out;
}
goto out;
}
/*
* set transport path
*/
}
/*
* The FILL_SCSI1_LUN above will find "inq_ansi != 1"
* on first pass, see "again" comment above.
*
* The controller type is as yet unknown, so we
* have to do a throwaway non-extended request sense,
* and hope that that clears the check condition for
* that unit until we can find out what kind of drive
* it is. A non-extended request sense is specified
* by stating that the sense block has 0 length,
* which is taken to mean that it is four bytes in
* length.
*/
goto out;
}
}
/*
* At this point, we are guaranteed that something responded
* to this scsi bus target id. We don't know yet what
* kind of device it is, or even whether there really is
* a logical unit attached (as some SCSI target controllers
* lie about a unit being ready, e.g., the Emulex MD21).
*/
if (SCSI_TEST_FAILURE(str)) {
goto out;
}
if (str == SCSI_TEST_CMPLT_BUSY) {
goto out;
}
/*
* Okay we sent the INQUIRY command.
*
* If enough data was transferred, we count that the
* Inquiry command succeeded, else we have to assume
* that this is a non-CCS scsi target (or a nonexistent
*/
if (str == SCSI_TEST_CMPLT_CHECK) {
/*
* try a request sense if we have a pkt, otherwise
* just retry the inquiry one more time
*/
if (rq_pkt)
/*
* retry inquiry
*/
if (SCSI_TEST_FAILURE(str)) {
goto out;
} else if (str == SCSI_TEST_CMPLT_CHECK) {
goto out;
}
}
done:
/*
* If we got a parity error on receive of inquiry data,
* we're just plain out of luck because we told the host
* adapter to not watch for parity errors.
*/
} else {
}
out:
/*
* If lun > 0 we need to figure out if this is a scsi-1 device where
* the "real" lun needs to be embedded into the cdb.
*/
pass++;
goto again;
/*
* invalid lun for scsi-1,
* return probe failure.
*/
}
if (rq_pkt) {
}
if (inq_pkt) {
}
if (rq_bp) {
}
if (inq_bp) {
}
return (rval);
}
/*
* Convert from a scsi_device structure pointer to a scsi_hba_tran structure
* pointer. The correct way to do this is
*
* #define DEVP_TO_TRAN(sd) ((sd)->sd_address.a_hba_tran)
*
* however we have some consumers that place their own vector in a_hba_tran. To
* avoid problems, we implement this using the sd_tran_safe. See
* scsi_hba_initchild for more details.
*/
/*
* Function, callable from SCSA framework, to get 'human' readable REPORTDEV
* addressing information from scsi_device properties.
*/
int
{
/* use deprecated tran_get_bus_addr interface if it is defined */
/* NOTE: tran_get_bus_addr is a poor name choice for interface */
}
/*
* Function, callable from HBA driver's tran_get_bus_addr(9E) implementation,
* to get standard form of human readable REPORTDEV addressing information
* from scsi_device properties.
*/
int
{
char *tgt_port;
/* get device unit-address properties */
SCSI_ADDR_PROP_TARGET, -1);
return (0); /* no target */
SCSI_ADDR_PROP_LUN, 0);
SCSI_ADDR_PROP_SFUNC, -1);
/*
* XXX should the default be to print this in decimal for
* "human readable" form, so it matches conf files?
*/
if (tgt_port) {
if (sfunc == -1)
"%s %s lun %" PRIx64,
else
} else {
if (sfunc == -1)
"%s %x lun %" PRIx64,
else
}
return (1);
}
/*
* scsi_ua_get: using properties, return "unit-address" string.
* Called by SCSA framework, may call HBAs tran function.
*/
int
{
char *eua;
/* See if we already have established the unit-address. */
return (1);
}
/* Use deprecated tran_get_name interface if it is defined. */
/* NOTE: tran_get_name is a poor name choice for interface */
/* Use generic property implementation */
}
/*
* scsi_hba_ua_get: using properties, return "unit-address" string.
* This function may be called from an HBAs tran function.
*
* Function to get "unit-address" in "name@unit-address" /devices path
* component form from the scsi_device unit-address properties on a node.
*
* NOTE: This function works in conjunction with scsi_hba_ua_set().
*/
int
{
char *tgt_port;
/* get device unit-address properties */
SCSI_ADDR_PROP_TARGET, -1);
return (0); /* no target */
SCSI_ADDR_PROP_LUN, 0);
SCSI_ADDR_PROP_SFUNC, -1);
if (tgt_port) {
if (sfunc == -1)
else
} else {
if (sfunc == -1)
else
}
return (1);
}
static void
{
/*
* Create the following properties:
*
* inquiry-vendor-id Vendor id (INQUIRY data bytes 8-15)
* inquiry-product-id Product id (INQUIRY data bytes 16-31)
* inquiry-revision-id Product Rev level (INQUIRY data bytes 32-35)
*
* NOTE: We don't support creation of these properties for scsi-1
* devices (as the vid, pid and revision were not defined) and we
* don't create the property if they are of zero length when
* stripped of Nulls and spaces.
*
* NOTE: The first definition of these properties sticks. This gives
* a transport the ability to provide a higher-quality definition
* than the standard SCSI INQUIRY data.
*/
(void) scsi_device_prop_update_inqstring(sd,
(void) scsi_device_prop_update_inqstring(sd,
(void) scsi_device_prop_update_inqstring(sd,
}
}
/*
* Create 'inquiry' string properties. An 'inquiry' string gets special
* treatment to trim trailing blanks (etc) and ensure null termination.
*/
int
{
int ilen;
char *data_string;
int rv;
if (ilen <= 0)
return (DDI_PROP_INVAL_ARG);
/* ensure null termination */
return (rv);
}
/*
* Interfaces associated with SCSI_HBA_ADDR_COMPLEX
* per-scsi_device HBA private data support.
*
* scsi_address_device returns NULL if we're not SCSI_HBA_ADDR_COMPLEX,
* thereby allowing use of scsi_address_device as a test for
* SCSI_HBA_ADDR_COMPLEX.
*/
struct scsi_device *
{
}
void
{
}
void *
{
return (sd->sd_hba_private);
}
/*
* probed *may* be a request to probe a strictly SCSI-2 target (with respect
* to LUNs) -- and this probe may be for a LUN number greater than 7,
* which can cause a hardware hang
*
* return 0 if the probe can proceed,
*/
static int
{
dev_info_t *pdevi =
int ret_val = 0; /* default return value */
int i;
/*
* check for what *might* be a problem probe, only we don't
*/
return (0); /* okay to probe this target */
}
/*
* this *might* be a problematic probe, so look to see
* if the inquiry data matches
*/
"SCSA pre-probe: scanning parent node name: %s ...\n",
/*
* look for a special property of our parent node that lists
* the targets under it for which we do *NOT* want to probe
* if LUN>7 -- if the property is found, look to see if our
* target ID is on that list
*/
/*
* no list, so it must be okay to probe this target.LUN
*/
"SCSA pre-probe: NO parent prop found\n");
} else {
for (i = 0; i < tgt_nelements; i++) {
/*
* we found a match, which means we do *NOT*
* want to probe the specified target.LUN
*/
ret_val = 1;
break;
}
}
#ifdef DEBUG
if (ret_val == 1) {
"SCSA pre-probe: marker node FOUND for "
"tgt.LUN=%d.%d, so SKIPPING it\n",
} else {
"SCSA pre-probe: NO marker node found"
" -- OK to probe\n");
}
#endif
}
return (ret_val);
}
/*
* this routine is called from near the end of scsi_probe(),
* to see if the just-probed node is on our list of strictly-SCSI-2 nodes,
* and if it is we mark our parent node with this information
*/
static void
{
int i;
const ss2_lun0_info_t *p;
int bad_target_found = 0;
/*
* if this inquiry data shows that we have a strictly-SCSI-2 device
* at LUN 0, then add it to our list of strictly-SCSI-2 devices,
* so that we can avoid probes where LUN>7 on this device later
*/
/*
* this can't possibly be a node we want to look at, since
* either LUN is greater than 0, target is greater than or
* equal to 16, device type
* is not processor, or SCSI level is not SCSI-2,
* so don't bother checking for a strictly SCSI-2
* (only 8 LUN) target
*/
return; /* don't care */
}
/*
* we have a node that has been probed that is: LUN=0, target<16,
* PROCESSOR-type SCSI target, and at the SCSI-2 level, so
* check INQ properties to see if it's in our list of strictly
* SCSI-2 targets
*
* comparison
*/
goto dun;
}
goto dun;
}
goto dun;
}
/*
* now that we have the INQUIRY properties from the device node,
* compare them with our known offenders
*
* Note: comparison is *CASE* *SENSITIVE*
*/
for (i = 0; i < scsi_probe_strict_s2_size; i++) {
p = &scsi_probe_strict_s2_list[i];
/*
* we found a match -- do NOT want to probe this one
*/
"SCSA post-probe: recording strict SCSI-2 node "
/*
* so we can find out about this node later
*/
bad_target_found = 1;
break;
}
}
/*
* either add remove target number from parent property
*/
dun:
}
}
}
}
/*
* update the parent node to add in the supplied tgt number to the target
* list property already present (if any)
*
* since the target list can never be longer than 16, and each target
* number is also small, we can save having to alloc memory by putting
* a 16-byte array on the stack and using it for property memory
*
* if "add_tgt" is set then add the target to the parent's property, else
* remove it (if present)
*/
static void
{
int i;
int update_result;
"SCSA post-probe: updating parent=%s property to %s tgt=%d\n",
if (add_tgt) {
/*
* we found an existing property -- we might need
* to add to it
*/
for (i = 0; i < nelements; i++) {
/* target already in list */
" tgt %d already listed\n", tgt);
return;
}
}
/*
* need to append our target number to end of list
* (no need sorting list, as it's so short)
*/
/*
* will this new entry fit ?? -- it should, since
* the array is 16-wide and only keep track of
* 16 targets, but check just in case
*/
if (new_nelements >= NTARGETS_WIDE) {
"internal error: no room "
"for more targets?\n");
return;
}
/* copy existing list then add our tgt number to end */
} else {
/*
* we need to remove our target number from the list,
* so copy all of the other target numbers,
* skipping ours
*/
int tgt_removed = 0;
new_nelements = 0;
for (i = 0; i < nelements; i++) {
tgt_list[i];
} else {
/* skip this target */
tgt_removed++;
}
}
if (!tgt_removed) {
" no need to remove tgt %d\n", tgt);
return;
}
}
} else {
/*
* no property yet
*/
if (add_tgt) {
/*
* create a property with just our tgt
*/
} else {
/*
* no list so no need to remove tgt from that list
*/
return;
}
}
#ifdef DEBUG
/*
*/
if (update_result != DDI_PROP_SUCCESS) {
} else {
if (add_tgt) {
"SCSA post-probe: added tgt=%d to parent "
"prop=\"%s\" (now %d entries)\n",
} else {
"SCSA post-probe: removed tgt=%d from parent "
"prop=\"%s\" (now %d entries)\n",
}
}
#endif
}
/* XXX BEGIN: find a better place for this: inquiry.h? */
/*
* Definitions used by device id registration routines
*/
/* size for devid inquiries */
#define MAX_INQUIRY_SIZE 0xF0
/* XXX END: find a better place for these */
/*
* Decorate devinfo node with identity properties using information obtained
* from device. These properties are used by device enumeration code to derive
* the devid, and guid for the device. These properties are also used to
* determine if a device should be enumerated under the physical HBA (PHCI) or
* the virtual HBA (VHCI, for mpxio support).
*
* Return zero on success. If commands that should succeed fail or allocations
* fail then return failure (non-zero). It is possible for this function to
* return success and not have decorated the node with any additional identity
* information if the device correctly responds indicating that they are not
* supported. When failure occurs the caller should consider not making the
* device accessible.
*/
int
{
int rval;
/* find out what pages are supported by device */
return (-1);
/* if available, collect page 80 data and add as property */
if (pg80) {
rval = -1;
goto out;
}
if (rval)
goto out; /* should have worked */
"failed to add page80 prop");
rval = -1;
goto out;
}
}
/* if available, collect page 83 data and add as property */
if (pg83) {
rval = -1;
goto out;
}
if (rval)
goto out; /* should have worked */
"failed to add page83 prop");
rval = -1;
goto out;
}
}
/* Commands worked, identity information that exists has been added. */
rval = 0;
/* clean up resources */
return (rval);
}
/*
* Send an INQUIRY command with the EVPD bit set and a page code of 0x00 to
* the device, returning zero on success. Returned INQUIRY data is used to
* determine which vital product pages are supported. The device idenity
* fails the EVPD inquiry then no pages are supported but the call succeeds.
* Return -1 (failure) if there were memory allocation failures or if a
* command faild that should have worked.
*/
static int
{
int counter;
int rval;
/* pages are not supported */
*ppg80 = 0;
*ppg83 = 0;
/*
* We'll set the page length to the maximum to save figuring it out
* with an additional call.
*/
return (-1); /* memory allocation problem */
/* issue page 0 (Supported VPD Pages) INQUIRY with evpd set */
/*
* Now we must validate that the device accepted the command (some
* devices do not support it) and if the idenity pages we are
* interested in are supported.
*/
if ((rval == 0) &&
/* Loop to find one of the 2 pages we need */
/*
* Pages are returned in ascending order, and 0x83 is the
* last page we are hoping to find.
*/
VPD_HEAD_OFFSET))) {
/*
* Add 3 because page_list[3] is the number of
* pages minus 3
*/
case 0x80:
*ppg80 = 1;
break;
case 0x83:
*ppg83 = 1;
break;
}
counter++;
}
}
return (0);
}
/*
* Send INQUIRY command with specified EVPD and page code. Return
* zero on success. On success, the amount of data transferred
* is returned in *lenp.
*/
static int
enum scsi_test_ctxt ctxt)
{
int (*cb_flag)();
int rval = -1;
if (lenp)
*lenp = 0;
else
goto out; /* memory allocation problem */
goto out; /* memory allocation problem */
/* form INQUIRY cdb with specified EVPD and page code */
SCMD_INQUIRY, 0, buflen, 0);
/*
* Issue inquiry command thru scsi_test
*
* NOTE: This is important data about device identity, not sure why
* NOPARITY is used. Also seems like we should check pkt_stat for
* STATE_XFERRED_DATA.
*/
if (lenp)
rval = 0;
}
/*
* XXX We should retry on target busy
*/
if (inq_bp)
return (rval);
}