1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/*
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * CDDL HEADER START
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * The contents of this file are subject to the terms of the
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * Common Development and Distribution License (the "License").
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * You may not use this file except in compliance with the License.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * or http://www.opensolaris.org/os/licensing.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * See the License for the specific language governing permissions
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * and limitations under the License.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * When distributing Covered Code, include this CDDL HEADER in each
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * If applicable, add the following below this CDDL HEADER, with the
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * fields enclosed by brackets "[]" replaced with your own identifying
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * information: Portions Copyright [yyyy] [name of copyright owner]
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * CDDL HEADER END
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth */
9a70fc3be3b1e966bf78825cdb8d509963a6f0a1Mark J. Nelson
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/*
07332de532a89d32d2d3d633033ac2950756858dChris Liu * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/*
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * Implementation of "scsi_vhci_f_sym" symmetric failover_ops.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * This file was historically meant for only symmetric implementation. It has
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * been extended to manage SUN "supported" symmetric controllers. The supported
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * VID/PID shall be listed in the symmetric_dev_table.
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/conf.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/file.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/ddi.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/sunddi.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/scsi/scsi.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth#include <sys/scsi/adapters/scsi_vhci.h>
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* Supported device table entries. */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthchar *symmetric_dev_table[] = {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* " 111111" */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* "012345670123456789012345" */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* "|-VID--||-----PID------|" */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth /* disks */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "IBM DDYFT",
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "IBM IC",
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SEAGATE ST",
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth /* enclosures */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN SENA", /* SES device */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN SESS01", /* VICOM SVE box */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUNW SUNWGS", /* Daktari enclosure */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth /* arrays */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "HITACHI OPEN", /* Hitachi storage */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN PSX1000", /* Pirus Matterhorn */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN SE6920", /* Pirus */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN SE6940", /* DSP - Nauset */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN StorEdge 3510", /* Minnow FC */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN StorEdge 3511", /* Minnow SATA RAID */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN StorageTek 6920", /* DSP */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN StorageTek 6940", /* DSP - Nauset */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN StorageTek NAS", /* StorageTek NAS */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN MRA300_R", /* Shamrock - Controller */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth "SUN MRA300_E", /* Shamrock - Expansion */
07332de532a89d32d2d3d633033ac2950756858dChris Liu "STEC ZeusIOPs", /* Zeus SAS SSD */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth NULL
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth};
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* Failover module plumbing. */
9a70fc3be3b1e966bf78825cdb8d509963a6f0a1Mark J. NelsonSCSI_FAILOVER_OP(SFO_NAME_SYM, symmetric);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_device_probe(struct scsi_device *sd, struct scsi_inquiry *stdinq,
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthvoid **ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth char **dt;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth VHCI_DEBUG(6, (CE_NOTE, NULL, "!inq str: %s\n", stdinq->inq_vid));
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth for (dt = symmetric_dev_table; *dt; dt++)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth if (strncmp(stdinq->inq_vid, *dt, strlen(*dt)) == 0)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (SFO_DEVICE_PROBE_VHCI);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth /*
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * No match, check for generic Sun supported disks:
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * "|-VID--||-----PID------|"
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * "012345670123456789012345"
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * ".................SUN..G."
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * ".................SUN..T."
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * ".................SUN...G"
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * ".................SUN...T"
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth if (bcmp(&stdinq->inq_pid[9], "SUN", 3) == 0) {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth if ((stdinq->inq_pid[14] == 'G' || stdinq->inq_pid[15] == 'G' ||
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth stdinq->inq_pid[14] == 'T' || stdinq->inq_pid[15] == 'T') &&
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth (stdinq->inq_dtype == DTYPE_DIRECT)) {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (SFO_DEVICE_PROBE_VHCI);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth }
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth }
cfc4930c5319f14873d497982c6536d82c25c23aYong-Feng Du if (bcmp(&stdinq->inq_vid[0], "ATA ", 8) == 0) {
cfc4930c5319f14873d497982c6536d82c25c23aYong-Feng Du return (SFO_DEVICE_PROBE_VHCI);
cfc4930c5319f14873d497982c6536d82c25c23aYong-Feng Du }
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (SFO_DEVICE_PROBE_PHCI);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic void
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_device_unprobe(struct scsi_device *sd, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth /*
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth * NOP for symmetric
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_path_activate(struct scsi_device *sd, char *pathclass, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (0);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_path_deactivate(struct scsi_device *sd, char *pathclass,
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthvoid *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (0);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_path_get_opinfo(struct scsi_device *sd,
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstruct scsi_path_opinfo *opinfo, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_rev = OPINFO_REV;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth (void) strcpy(opinfo->opinfo_path_attr, "primary");
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_path_state = SCSI_PATH_ACTIVE;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_pswtch_best = 0; /* N/A */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_pswtch_worst = 0; /* N/A */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_xlf_capable = 0;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_mode = SCSI_NO_FAILOVER;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth opinfo->opinfo_preferred = 1;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (0);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_path_ping(struct scsi_device *sd, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (1);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_analyze_sense(struct scsi_device *sd,
0c45178b5714d692c44817c2235320c3f2b030abwluint8_t *sense, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (SCSI_SENSE_NOFAILOVER);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth/* ARGSUSED */
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthstatic int
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcthsymmetric_pathclass_next(char *cur, char **nxt, void *ctpriv)
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth{
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth if (cur == NULL) {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth *nxt = PCLASS_PRIMARY;
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (0);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth } else if (strcmp(cur, PCLASS_PRIMARY) == 0) {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (ENOENT);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth } else {
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth return (EINVAL);
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth }
1e1ddd6cc98ab5af8293f7ebd132be62900730fdcth}