pmcs_attach.c revision 5c45adf04db8ffdcb5dd969bb5203ff9b17677db
e57b9183811d515e3bbcd1a104516f0102fde114cg * CDDL HEADER START
e57b9183811d515e3bbcd1a104516f0102fde114cg * The contents of this file are subject to the terms of the
e57b9183811d515e3bbcd1a104516f0102fde114cg * Common Development and Distribution License (the "License").
e57b9183811d515e3bbcd1a104516f0102fde114cg * You may not use this file except in compliance with the License.
e57b9183811d515e3bbcd1a104516f0102fde114cg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e57b9183811d515e3bbcd1a104516f0102fde114cg * See the License for the specific language governing permissions
e57b9183811d515e3bbcd1a104516f0102fde114cg * and limitations under the License.
e57b9183811d515e3bbcd1a104516f0102fde114cg * When distributing Covered Code, include this CDDL HEADER in each
e57b9183811d515e3bbcd1a104516f0102fde114cg * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e57b9183811d515e3bbcd1a104516f0102fde114cg * If applicable, add the following below this CDDL HEADER, with the
e57b9183811d515e3bbcd1a104516f0102fde114cg * fields enclosed by brackets "[]" replaced with your own identifying
e57b9183811d515e3bbcd1a104516f0102fde114cg * information: Portions Copyright [yyyy] [name of copyright owner]
e57b9183811d515e3bbcd1a104516f0102fde114cg * CDDL HEADER END
e57b9183811d515e3bbcd1a104516f0102fde114cg * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
e57b9183811d515e3bbcd1a104516f0102fde114cg * Use is subject to license terms.
e57b9183811d515e3bbcd1a104516f0102fde114cg * Non-DDI Compliant stuff
e57b9183811d515e3bbcd1a104516f0102fde114cgextern char hw_serial[];
e57b9183811d515e3bbcd1a104516f0102fde114cg * Global driver data
e57b9183811d515e3bbcd1a104516f0102fde114cg * Tracing and Logging info
e57b9183811d515e3bbcd1a104516f0102fde114cg * If pmcs_force_syslog value is non-zero, all messages put in the trace log
e57b9183811d515e3bbcd1a104516f0102fde114cg * will also be sent to system log.
e57b9183811d515e3bbcd1a104516f0102fde114cg * External References
e57b9183811d515e3bbcd1a104516f0102fde114cg * Local static data
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic int block_mask = 0;
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic int debug_mask = 0;
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic int disable_msix = 0;
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic int disable_msi = 0;
e57b9183811d515e3bbcd1a104516f0102fde114cg * Local prototypes
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic int pmcs_add_more_chunks(pmcs_hw_t *, unsigned long);
e57b9183811d515e3bbcd1a104516f0102fde114cgstatic void pmcs_watchdog(void *);
e57b9183811d515e3bbcd1a104516f0102fde114cg * Local configuration data
e57b9183811d515e3bbcd1a104516f0102fde114cg 0, /* refcnt */
e57b9183811d515e3bbcd1a104516f0102fde114cg 0 /* dma_attr_flags */
e57b9183811d515e3bbcd1a104516f0102fde114cg * Attach/Detach functions
e57b9183811d515e3bbcd1a104516f0102fde114cg ret = ddi_soft_state_init(&pmcs_softc_state, sizeof (pmcs_hw_t), 1);
e57b9183811d515e3bbcd1a104516f0102fde114cg if (ret != 0) {
e57b9183811d515e3bbcd1a104516f0102fde114cg * Allocate soft state for iports
e57b9183811d515e3bbcd1a104516f0102fde114cg if (ret != 0) {
e57b9183811d515e3bbcd1a104516f0102fde114cg cmn_err(CE_WARN, "?iport soft state init failed for pmcs");
e57b9183811d515e3bbcd1a104516f0102fde114cg if (ret != 0) {
e57b9183811d515e3bbcd1a104516f0102fde114cg cmn_err(CE_WARN, "?mod_install failed for pmcs (%d)", ret);
e57b9183811d515e3bbcd1a104516f0102fde114cg /* Initialize the global trace lock */
e57b9183811d515e3bbcd1a104516f0102fde114cg return (0);
e57b9183811d515e3bbcd1a104516f0102fde114cg /* Free pmcs log buffer and destroy the global lock */
e57b9183811d515e3bbcd1a104516f0102fde114cg return (0);
e57b9183811d515e3bbcd1a104516f0102fde114cg "%s: iport%d attach invoked with NULL parent (HBA) node)",
e57b9183811d515e3bbcd1a104516f0102fde114cg if ((pwp->state == STATE_UNPROBING) || (pwp->state == STATE_DEAD)) {
e57b9183811d515e3bbcd1a104516f0102fde114cg if ((iport_ua = scsi_hba_iport_unit_address(dip)) == NULL) {
e57b9183811d515e3bbcd1a104516f0102fde114cg "%s: invoked with NULL unit address, inst (%d)",
e57b9183811d515e3bbcd1a104516f0102fde114cg if (ddi_soft_state_zalloc(pmcs_iport_softstate, inst) != DDI_SUCCESS) {
e57b9183811d515e3bbcd1a104516f0102fde114cg "cannot get iport soft state");
if (ua_priv) {
goto iport_attach_fail2;
goto iport_attach_fail2;
goto iport_attach_fail3;
return (DDI_SUCCESS);
return (DDI_FAILURE);
int inst, i;
int protocol = 0;
int num_phys = 0;
switch (cmd) {
case DDI_ATTACH:
case DDI_PM_RESUME:
case DDI_RESUME:
if (!tran) {
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
#ifdef DEBUG
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
* Get driver.conf properties
(pmcs_tbuf_num_elems == 0)) {
pmcs_tbuf_idx = 0;
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
case PMCS_PM8001_REV_A:
case PMCS_PM8001_REV_B:
goto failure;
case PMCS_PM8001_REV_C:
goto failure;
goto failure;
B_FALSE) {
goto failure;
goto failure;
NULL, 0);
case EIO:
goto failure;
goto failure;
phyp++;
goto failure;
goto failure;
goto failure;
goto failure;
goto failure;
goto failure;
goto failure;
goto failure;
goto failure;
&sm_hba);
hw_rev);
case PMCS_FW_TYPE_RELEASED:
case PMCS_FW_TYPE_DEVELOPMENT:
case PMCS_FW_TYPE_ALPHA:
case PMCS_FW_TYPE_BETA:
fw_rev);
&num_phys);
&protocol);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
switch (cmd) {
case DDI_DETACH:
if (iport) {
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_SUCCESS);
case DDI_SUSPEND:
case DDI_PM_SUSPEND:
if (iport) {
return (DDI_SUCCESS);
return (DDI_FAILURE);
if (!tran) {
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
#ifdef DEBUG
for (i = 0; i < PMCS_NOQ; i++) {
DDI_SUCCESS) {
for (i = 0; i < PMCS_NIQ; i++) {
DDI_SUCCESS) {
return (DDI_SUCCESS);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
int result, i;
uint16_t *a;
if (result) {
return (result);
static boolean_t
case SATA:
return (B_FALSE);
case SAS:
case EXPANDER:
return (B_TRUE);
unsigned long dl;
for (i = 0; i < PMCS_NIQ; i++) {
goto hot_reset;
goto hot_reset;
goto hot_reset;
* See pmcs_subr.c for more details.
int rval;
#ifdef DEBUG
if (rval) {
__func__);
int i, r, rslt = 0;
for (i = 0; i < icnt; i++) {
if (r == DDI_SUCCESS) {
return (rslt);
if (r != DDI_SUCCESS) {
for (i = 0; i < icnt; i++) {
for (i = 0; i < icnt; i++) {
switch (type) {
case DDI_INTR_TYPE_MSIX:
case DDI_INTR_TYPE_MSI:
case DDI_INTR_TYPE_FIXED:
return (EAGAIN);
if (disable_msix) {
if (disable_msi) {
itypes = 0;
itypes = 0;
itypes = 0;
return (EAGAIN);
return (EAGAIN);
if (r != DDI_SUCCESS) {
return (EIO);
return (EIO);
return (EAGAIN);
return (EIO);
return (EIO);
return (EAGAIN);
if (r != DDI_SUCCESS) {
return (EIO);
return (EIO);
return (EFAULT);
if (r == DDI_SUCCESS) {
return (EIO);
return (EIO);
return (EIO);
return (EAGAIN);
return (EIO);
return (EIO);
return (EIO);
return (EAGAIN);
#ifdef DEBUG
for (i = 0; i < PMCS_NIQ; i++) {
return (EIO);
return (EIO);
return (EIO);
static uint_t
return (DDI_INTR_CLAIMED);
static uint_t
return (DDI_INTR_CLAIMED);
static uint_t
return (DDI_INTR_CLAIMED);
static uint_t
return (DDI_INTR_CLAIMED);
static uint_t
return (DDI_INTR_CLAIMED);
return (DDI_INTR_CLAIMED);
static uint_t
int handled = 0;
return (DDI_INTR_CLAIMED);
handled++;
handled++;
handled++;
if (obdb) {
handled++;
handled++;
* See pmcs_subr.c for more details.
case SAS:
case EXPANDER:
case SATA:
return (B_FALSE);
return (B_FALSE);
return (B_TRUE);
unsigned int vtgt;
int written = 0;
char *ptr;
int system_log_level;
switch (level) {
case PMCS_PRT_DEBUG_DEVEL:
case PMCS_PRT_DEBUG_DEV_STATE:
case PMCS_PRT_DEBUG_UNDERFLOW:
case PMCS_PRT_DEBUG_CONFIG:
case PMCS_PRT_DEBUG_IPORT:
case PMCS_PRT_DEBUG_MAP:
case PMCS_PRT_DEBUG3:
case PMCS_PRT_DEBUG2:
case PMCS_PRT_DEBUG1:
case PMCS_PRT_DEBUG:
case PMCS_PRT_INFO:
case PMCS_PRT_WARN:
case PMCS_PRT_ERR:
pmcs_tbuf_idx = 0;
if (pmcs_force_syslog) {
if (system_log) {
switch (system_log_level) {
case CE_CONT:
case CE_NOTE:
case CE_WARN:
local[0] = 0;
int rval;
if (!wait) {
return (rval);
int ndata;
ks_name);
goto fail;
goto fail;
goto fail;
goto fail;
fail:
return (ret);
static boolean_t
char *cp, c;
cp = &c;
if (adr == 0) {
__func__);
for (i = 0; i < PMCS_MAX_PORTS; i++) {
return (B_TRUE);