emlxs_mbox.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Emulex. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to License terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "emlxs.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_MBOX_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hbainit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ringno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb, uint32_t word0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t word1, uint32_t word2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int32_t emlxs_mb_handle_cmd(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_init(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_retry(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_table_t emlxs_mb_cmd_table[] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_SHUTDOWN, "SHUTDOWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_LOAD_SM, "LOAD_SM"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_NV, "READ_NV"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_WRITE_NV, "WRITE_NV"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RUN_BIU_DIAG, "RUN_BIU_DIAG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_INIT_LINK, "INIT_LINK"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_DOWN_LINK, "DOWN_LINK"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_LINK, "CONFIG_LINK"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_PART_SLIM, "PART_SLIM"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_RING, "CONFIG_RING"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RESET_RING, "RESET_RING"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_CONFIG, "READ_CONFIG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_RCONFIG, "READ_RCONFIG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_SPARM, "READ_SPARM"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_STATUS, "READ_STATUS"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_RPI, "READ_RPI"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_XRI, "READ_XRI"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_REV, "READ_REV"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_LNK_STAT, "READ_LNK_STAT"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_REG_LOGIN, "REG_LOGIN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_UNREG_LOGIN, "UNREG_LOGIN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_LA, "READ_LA"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CLEAR_LA, "CLEAR_LA"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_DUMP_MEMORY, "DUMP_MEMORY"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_DUMP_CONTEXT, "DUMP_CONTEXT"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RUN_DIAGS, "RUN_DIAGS"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RESTART, "RESTART"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_UPDATE_CFG, "UPDATE_CFG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_DOWN_LOAD, "DOWN_LOAD"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_DEL_LD_ENTRY, "DEL_LD_ENTRY"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RUN_PROGRAM, "RUN_PROGRAM"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_SET_MASK, "SET_MASK"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_SET_VARIABLE, "SET_VARIABLE"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_UNREG_D_ID, "UNREG_D_ID"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_KILL_BOARD, "KILL_BOARD"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_FARP, "CONFIG_FARP"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_LOAD_AREA, "LOAD_AREA"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_RUN_BIU_DIAG64, "RUN_BIU_DIAG64"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_PORT, "CONFIG_PORT"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_SPARM64, "READ_SPARM64"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_RPI64, "READ_RPI64"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_MSI, "CONFIG_MSI"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_MSIX, "CONFIG_MSIX"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_REG_LOGIN64, "REG_LOGIN64"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_LA64, "READ_LA64"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_FLASH_WR_ULA, "FLASH_WR_ULA"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_SET_DEBUG, "SET_DEBUG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_GET_DEBUG, "GET_DEBUG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_LOAD_EXP_ROM, "LOAD_EXP_ROM"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_BEACON, "BEACON"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_CONFIG_HBQ, "CONFIG_HBQ"}, /* SLI3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_REG_VPI, "REG_VPI"}, /* NPIV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_ASYNC_EVENT, "ASYNC_EVENT"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_HEARTBEAT, "HEARTBEAT"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_EVENT_LOG_STATUS, "READ_EVENT_LOG_STATUS"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_EVENT_LOG, "READ_EVENT_LOG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_WRITE_EVENT_LOG, "WRITE_EVENT_LOG"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_NV_LOG, "NV_LOG"}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}; /* emlxs_mb_cmd_table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_async_event(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_ASYNC_EVENT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = FC_ELS_RING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_async_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_heartbeat(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_HEARTBEAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_heartbeat() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MSI_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_msi(emlxs_hba_t *hba, MAILBOX *mb, uint32_t *intr_map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t intr_count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_MSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the default message id to zero */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.defaultPresent = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.defaultMessageNumber = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 1; i < intr_count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = intr_map[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.attConditions |= mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef EMLXS_BIG_ENDIAN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R0ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[3] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R1ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[7] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R2ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[11] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R3ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[15] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_LATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[29] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_MBATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[30] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_ERATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[31] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_BIG_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef EMLXS_LITTLE_ENDIAN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Accounts for half word swap of LE architecture */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R0ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[2] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R1ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[6] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R2ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[10] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R3ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[14] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_LATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[28] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_MBATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[31] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_ERATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSI.messageNumberByHA[30] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_LITTLE_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_msi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_msix(emlxs_hba_t *hba, MAILBOX *mb, uint32_t *intr_map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t intr_count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_MSIX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the default message id to zero */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.defaultPresent = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.defaultMessageNumber = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 1; i < intr_count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = intr_map[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.attConditions1 |= mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef EMLXS_BIG_ENDIAN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R0ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[3] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R1ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[7] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R2ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[11] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R3ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[15] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_LATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[29] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_MBATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[30] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_ERATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[31] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_BIG_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef EMLXS_LITTLE_ENDIAN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Accounts for word swap of LE architecture */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R0ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[0] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R1ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[4] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R2ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[8] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_R3ATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[12] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_LATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[30] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_MBATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[29] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mask & HA_ERATT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgMSIX.messageNumberByHA[28] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_LITTLE_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_msix() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MSI_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_reset_ring(emlxs_hba_t *hba, MAILBOX *mb, uint32_t ringno)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_RESET_RING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRstRing.ring_no = ringno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reset_ring() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_dump_vpd Issue a DUMP MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_dump_vpd(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup to dump VPD region
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_DUMP_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.cv = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.type = DMP_NV_PARAMS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.entry_index = offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.region_id = DMP_VPD_REGION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.word_cnt = DMP_VPD_DUMP_WCOUNT; /* limited by */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mailbox size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.co = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.resp_offset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_dump_vpd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_nv Issue a READ NVPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_nv(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_NV;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_nv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_rev Issue a READ REV
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rev(emlxs_hba_t *hba, MAILBOX *mb, uint32_t v3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdRev.cv = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (v3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdRev.cv3 = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_REV;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_rev */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_run_biu_diag Issue a RUN_BIU_DIAG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_run_biu_diag(emlxs_hba_t *hba, MAILBOX *mb, uint64_t out,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t in)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_RUN_BIU_DIAG64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.xmit_bde64.tus.f.bdeSize = MEM_ELSBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.xmit_bde64.addrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.xmit_bde64.addrLow =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrLow(out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.tus.f.bdeSize = MEM_ELSBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.addrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(in);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.addrLow = (uint32_t)putPaddrLow(in);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_run_biu_diag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_la Issue a READ LA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_la(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_LA64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_LA64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varReadLA.un.lilpBde64.tus.f.bdeSize = 128;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varReadLA.un.lilpBde64.addrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varReadLA.un.lilpBde64.addrLow =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrLow(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((MAILBOXQ *)mb)->bp = (uint8_t *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_la() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_clear_la Issue a CLEAR LA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_clear_la(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef FC_RPI_CHECK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_rpi_check(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* FC_RPI_CHECK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varClearLA.eventTag = hba->link_event_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CLEAR_LA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_clear_la */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_status Issue a READ STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_status(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End fc_read_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_lnk_stat Issue a LINK STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_lnk_stat(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_LNK_STAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_lnk_stat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_write_nv Issue a WRITE NVPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_emb_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *) &hba->wwnn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *) mb->un.varWTnvp.nodename,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *) &hba->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *) mb->un.varWTnvp.portname,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.pref_DID = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.hardAL_PA = (uint8_t)cfg[CFG_ASSIGN_ALPA].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.rsvd1[0] = 0xffffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.rsvd1[1] = 0xffffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.rsvd1[2] = 0xffffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 21; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.rsvd3[i] = 0xffffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_WRITE_NV;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_write_nv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_part_slim Issue a PARTITION SLIM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb, uint32_t hbainit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varSlim.numRing = hba->ring_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varSlim.hbainit = hbainit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_PART_SLIM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_part_slim */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_ring Issue a CONFIG RING
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_ring(emlxs_hba_t *hba, int32_t ring, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ring; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j += hba->ring_masks[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < hba->ring_masks[ring]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((j + i) >= 6) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].rval = hba->ring_rval[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].rmask = hba->ring_rmask[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].tval = hba->ring_tval[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].tmask = hba->ring_tmask[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.ring = ring;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.profile = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.maxOrigXchg = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.maxRespXchg = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.recvNotify = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.numMask = hba->ring_masks[ring];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_RING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_config_ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_link Issue a CONFIG LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_link(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NEW_FEATURE SLI-2, Coalescing Response Feature.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg[CFG_CR_DELAY].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.cr = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.ci = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.cr_delay = cfg[CFG_CR_DELAY].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.cr_count = cfg[CFG_CR_COUNT].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg[CFG_ACK0].current)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.ack0_enable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.myId = port->did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.edtov = hba->fc_edtov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.arbtov = hba->fc_arbtov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.ratov = hba->fc_ratov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.rttov = hba->fc_rttov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.altov = hba->fc_altov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.crtov = hba->fc_crtov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgLnk.citov = hba->fc_citov;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_init_link Issue an INIT LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_init_link(emlxs_hba_t *hba, MAILBOX *mb, uint32_t topology,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t linkspeed)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_vpd_t *vpd = &VPD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (topology) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FLAGS_LOCAL_LB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_LOCAL_LB;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FLAGS_TOPOLOGY_MODE_LOOP_PT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FLAGS_TOPOLOGY_MODE_PT_PT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FLAGS_TOPOLOGY_MODE_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FLAGS_TOPOLOGY_MODE_PT_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg[CFG_LILP_ENABLE].current == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable LIRP/LILP support */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_LIRP_LILP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting up the link speed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (linkspeed) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vpd->link_speed & LMT_1GB_CAPABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vpd->link_speed & LMT_2GB_CAPABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vpd->link_speed & LMT_4GB_CAPABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 8:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vpd->link_speed & LMT_8GB_CAPABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 10:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vpd->link_speed & LMT_10GB_CAPABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((linkspeed > 0) && (vpd->feaLevelHigh >= 0x02)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_speed = linkspeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_PREABORT_RETURN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.fabric_AL_PA = (uint8_t)cfg[CFG_ASSIGN_ALPA].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = (volatile uint8_t) MBX_INIT_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_down_link Issue a DOWN LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_down_link(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_DOWN_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_down_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_sparam Issue a READ SPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_sparam(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_SPARM64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.addrHigh = (uint32_t)putPaddrHigh(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.addrLow = (uint32_t)putPaddrLow(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_SPARM64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((MAILBOXQ *)mb)->bp = (uint8_t *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_sparam() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_rpi Issue a READ RPI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rpi(emlxs_hba_t *hba, uint32_t rpi, MAILBOX *mb, uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flag to issue action on cmpl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[30] = flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdRPI.reqRpi = (volatile uint16_t) rpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_RPI64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_rpi */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_xri Issue a READ XRI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_xri(emlxs_hba_t *hba, uint32_t xri, MAILBOX *mb, uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flag to issue action on cmpl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[30] = flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdXRI.reqXri = (volatile uint16_t) xri;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_XRI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_xri */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_check_sparm(emlxs_hba_t *hba, SERV_PARM *nsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t nsp_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *iptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsp->cmn.fPort) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the service parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iptr = (uint32_t *)& nsp->portName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iptr[0] == 0 && iptr[1] == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iptr = (uint32_t *)& nsp->nodeName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iptr[0] == 0 && iptr[1] == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsp->cls2.classValid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp_value = ((nsp->cls2.rcvDataSizeMsb & 0x0f) << 8) |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the receive data length is zero then set it to the CSP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nsp_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsp->cls3.classValid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp_value = ((nsp->cls3.rcvDataSizeMsb & 0x0f) << 8) |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the receive data length is zero then set it to the CSP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This prevents a Emulex adapter bug from occurring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nsp_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_check_sparm() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_reg_did Issue a REG_LOGIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_reg_did(emlxs_port_t *port, uint32_t did, SERV_PARM *param,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp, fc_unsol_buf_t *ubp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for invalid node ids to register */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == 0 || (did & 0xff000000)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = emlxs_mb_check_sparm(hba, param))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Invalid service parameters. did=%06x rval=%d", did, rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if the node limit has been reached */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->node_count >= hba->max_nodes) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Limit reached. did=%06x count=%d", did, port->node_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build login request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF | MEM_PRI)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *) param, (void *) mp->virt, sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.addrHigh = (uint32_t)putPaddrHigh(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.addrLow = (uint32_t)putPaddrLow(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.rpi = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.did = did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[30] = 0; /* flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_REG_LOGIN64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.vpi =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = (uint8_t *)sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = (uint8_t *)ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->iocbq = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->bp = (uint8_t *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reg_did() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_unreg_rpi Issue a UNREG_LOGIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_unreg_rpi(emlxs_port_t *port, uint32_t rpi, emlxs_buf_t *sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rpi != 0xffff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure the node does already exist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = emlxs_node_find_rpi(port, rpi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we just unregistered the host node then clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp->nlp_DID == port->did) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->did = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_rm(port, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Unreg all */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_destroy_all(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varUnregLogin.rpi = (uint16_t)rpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varUnregLogin.vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_UNREG_LOGIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = (uint8_t *)sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = (uint8_t *)ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->iocbq = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_rpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_unreg_did Issue a UNREG_DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_unreg_did(emlxs_port_t *port, uint32_t did, emlxs_buf_t *sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Unregister all default RPIs if did == 0xffffffff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did != 0xffffffff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == Bcast_DID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just flush base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, &port->node_base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, &port->node_base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A zero DID means that we are trying to unreg the host node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * after a link bounce
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the prev_did == 0 then the adapter has been reset and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * there is no need in unregistering
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the prev_did != 0 then we can look for the hosts last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * known DID node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->prev_did == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did = port->prev_did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure the node does already exist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = emlxs_node_find_did(port, did);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_rm(port, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we just unregistered the host node then clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == port->did) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->did = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varUnregDID.did = did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varUnregDID.vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_UNREG_D_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = (uint8_t *)sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = (uint8_t *)ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->iocbq = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_unreg_did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_mask Issue a SET MASK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ringno)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = 0x11223344; /* set passwd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[1] = mask; /* set mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[2] = ringno; /* set ringno */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_SET_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_debug Issue a special debug
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb, uint32_t word0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t word1, uint32_t word2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = word0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[1] = word1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[2] = word2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_SET_DEBUG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_debug */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_var Issue a special debug mbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command to write slim
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_var(emlxs_hba_t *hba, MAILBOX *mb, uint32_t addr, uint32_t value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* addr = 0x090597 is AUTO ABTS disable for ELS commands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* addr = 0x052198 is DELAYED ABTS enable for ELS commands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* addr = 0x100506 is for setting PCI MAX READ value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Always turn on DELAYED ABTS for ELS timeouts
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((addr == 0x052198) && (value == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[1] = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_SET_VARIABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_var */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disable Traffic Cop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_disable_tc(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = 0x50797;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[2] = 0xfffffffe;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_SET_VARIABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_disable_tc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_port Issue a CONFIG_PORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_port(emlxs_hba_t *hba, MAILBOX *mb, uint32_t sli_mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hbainit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_vpd_t *vpd = &VPD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RING *rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t pcb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t mbx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t hgp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t pgp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t rgp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SLIM2 *slim;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SLI2_RDSC *rdsc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t Laddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slim = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.pcbLen = sizeof (PCB);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.hbainit[0] = hbainit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.hbainit = hbainit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcb = hba->slim2.phys + (uint64_t)(unsigned long)& (slim->pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.pcbLow = (uint32_t)putPaddrLow(pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.pcbHigh = (uint32_t)putPaddrHigh(pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set Host pointers in SLIM flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.hps = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize hba structure for assumed default SLI2 mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If config port succeeds, then we will update it then */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->sli_mode = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->vpi_max = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_NPIV_ENABLED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sli_mode >= 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.sli_mode = 3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.cerbm = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.max_hbq = EMLXS_NUM_HBQ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef NPIV_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg[CFG_NPIV_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vpd->feaLevelHigh >= 0x09) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->model_info.chip >= EMLXS_SATURN_CHIP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.vpi_max =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_VPORTS - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.vpi_max =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_VPORTS_LIMITED - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.cmv = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_init_debug_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "CFGPORT: Firmware does not support NPIV. "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "level=%d", vpd->feaLevelHigh);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* NPIV_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now setup pcb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.type = TYPE_NATIVE_SLI2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.feature = FEATURE_INITIAL_SLI2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.maxRing = (hba->ring_count - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.mailBoxSize = sizeof (MAILBOX) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_EXTENSION_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbx = hba->slim2.phys + (uint64_t)(unsigned long)& (slim->mbx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.mbAddrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(mbx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.mbAddrLow = (uint32_t)putPaddrLow(mbx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set up HGP - Port Memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR0Put - SLI2(no HBQs) = 0xc0, With HBQs = 0x80
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR0Get 0xc4 0x84
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR1Put 0xc8 0x88
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR1Get 0xcc 0x8c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR2Put 0xd0 0x90
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR2Get 0xd4 0x94
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR3Put 0xd8 0x98
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR3Get 0xdc 0x9c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reserved 0xa0-0xbf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If HBQs configured:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 0 Put ptr 0xc0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 1 Put ptr 0xc4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 2 Put ptr 0xc8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ......
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ(M-1)Put Pointer 0xc0+(M-1)*4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sli_mode >= 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERBM is enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hgp_ring_offset = 0x80;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hgp_hbq_offset = 0xC0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else /* SLI2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERBM is disabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hgp_ring_offset = 0xC0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hgp_hbq_offset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The Sbus card uses Host Memory. The PCI card uses SLIM POINTER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->bus_type == SBUS_FC) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hgp = hba->slim2.phys +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)& (mbox->us.s2.host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.hgpAddrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(hgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.hgpAddrLow =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrLow(hgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.hgpAddrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)ddi_get32(hba->pci_acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(hba->pci_addr + PCI_BAR_1_REGISTER));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Laddr = ddi_get32(hba->pci_acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(hba->pci_addr + PCI_BAR_0_REGISTER));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Laddr &= ~0x4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.hgpAddrLow =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)(Laddr + hba->hgp_ring_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgp = hba->slim2.phys + (uint64_t)(unsigned long)& (mbox->us.s2.port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.pgpAddrHigh =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)putPaddrHigh(pgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.pgpAddrLow = (uint32_t)putPaddrLow(pgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 4; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp = &hba->ring[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc = &((SLIM2 *) hba->slim2.virt)->pcb.rdsc[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup command ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rgp = hba->slim2.phys +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)& (slim->IOCBs[offset]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->cmdAddrHigh = (uint32_t)putPaddrHigh(rgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->cmdAddrLow = (uint32_t)putPaddrLow(rgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->cmdEntries = rp->fc_numCiocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_cmdringaddr = (void *) &((SLIM2 *) hba->slim2.virt)->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBs[offset];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset += rdsc->cmdEntries * hba->iocb_cmd_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup response ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rgp = hba->slim2.phys +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)& (slim->IOCBs[offset]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->rspAddrHigh = (uint32_t)putPaddrHigh(rgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->rspAddrLow = (uint32_t)putPaddrLow(rgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc->rspEntries = rp->fc_numRiocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_rspringaddr = (void *) &((SLIM2 *) hba->slim2.virt)->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBs[offset];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset += rdsc->rspEntries * hba->iocb_rsp_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)(&((SLIM2 *) hba->slim2.virt)->pcb),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(&((SLIM2 *) hba->slim2.virt)->pcb), sizeof (PCB));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uint64_t)(unsigned long)& (((SLIM2 *) hba->slim2.virt)->pcb) -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)hba->slim2.virt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, (off_t)offset, sizeof (PCB),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_port() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_hbq(emlxs_hba_t *hba, MAILBOX *mb, int hbq_id)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBQ_INIT_t *hbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbq = &hba->hbq_table[hbq_id];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqId = hbq_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.numEntries = hbq->HBQ_numEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.recvNotify = hbq->HBQ_recvNotify;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.numMask = hbq->HBQ_num_mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.profile = hbq->HBQ_profile;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.ringMask = hbq->HBQ_ringMask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.headerLen = hbq->HBQ_headerLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.logEntry = hbq->HBQ_logEntry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqaddrLow = putPaddrLow(hbq->HBQ_host_buf.phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqaddrHigh = putPaddrHigh(hbq->HBQ_host_buf.phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_HBQ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy info for profiles 2,3,5. Other profiles this area is reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hbq->HBQ_profile == 2) || (hbq->HBQ_profile == 3) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hbq->HBQ_profile == 5)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&hbq->profiles.allprofiles,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &mb->un.varCfgHbq.profiles.allprofiles,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (hbq->profiles));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return if no rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hbq->HBQ_num_mask) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Otherwise we setup specific rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < hbq->HBQ_num_mask; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].tmatch = hbq->HBQ_Masks[i].tmatch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].tmask = hbq->HBQ_Masks[i].tmask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].rctlmatch =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbq->HBQ_Masks[i].rctlmatch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].rctlmask =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbq->HBQ_Masks[i].rctlmask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_hbq() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_reg_vpi(emlxs_port_t *port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->flag & FC_NPIV_ENABLED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Can't reg vpi until ClearLA is sent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state != FC_READY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must have port id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!port->did) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->flag |= EMLXS_PORT_REGISTERED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegVpi.vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegVpi.sid = port->did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_REG_VPI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reg_vpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_unreg_vpi(emlxs_port_t *port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(port->flag & EMLXS_PORT_REGISTERED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->flag &= ~EMLXS_PORT_REGISTERED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varUnregVpi.vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_UNREG_VPI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_vpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_farp Issue a CONFIG FARP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_farp(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& hba->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& mb->un.varCfgFarp.portname,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& hba->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& mb->un.varCfgFarp.nodename,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgFarp.filterEnable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgFarp.portName = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgFarp.nodeName = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_CONFIG_FARP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_farp() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_nv Issue a READ CONFIG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_config(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_CONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_config() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NAME: emlxs_mb_put
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FUNCTION: put mailbox cmd onto the mailbox queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXECUTION ENVIRONMENT: process and interrupt level.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CALLED FROM: emlxs_mb_issue_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT: hba - pointer to the device info area mbp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - pointer to mailbox queue entry of mailbox cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: NULL - command queued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_put(emlxs_hba_t *hba, MAILBOXQ *mbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue.q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queue command to end of list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((MAILBOXQ *) hba->mbox_queue.q_last)->next = mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_last = (uint8_t *)mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add command to empty list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_first = (uint8_t *)mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_last = (uint8_t *)mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_put() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NAME: emlxs_mb_get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FUNCTION: get a mailbox command from mailbox command queue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXECUTION ENVIRONMENT: interrupt level.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CALLED FROM: emlxs_handle_mb_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT: hba - pointer to the device info area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: NULL - no match found mb pointer - pointer to a mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern MAILBOXQ *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_get(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *p_first = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue.q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_first = (MAILBOXQ *) hba->mbox_queue.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_first = (uint8_t *)p_first->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue.q_first == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_last = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_first->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (p_first);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_get() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* EMLXS_PORT_LOCK must be held when calling this */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_init(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t flag, uint32_t tmo)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxIssued++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue_flag = flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the Mailbox timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_timer = hba->timer_tics + tmo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->flag &= MBQ_INIT_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbqflag = mbq->flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->next = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == MBX_NOWAIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbq = (uint8_t *)mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->bp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = (MATCHMAP *) mbq->bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(mp->dma_handle, 0, mp->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_bp = mbq->bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->bp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = mbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->ubp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp = mbq->ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_iocbq = mbq->iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->iocbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->extbuf && mbq->extsize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext = mbq->extbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size = mbq->extsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_fini(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mbxStatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *mbox_sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *mbox_ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *mbox_iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbox_mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t mbox_queue_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_priv_t *ub_priv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbxStatus != MBX_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_bp = (MATCHMAP *) hba->mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_sbp = (emlxs_buf_t *)hba->mbox_sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_ubp = (fc_unsol_buf_t *)hba->mbox_ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_iocbq = (IOCBQ *) hba->mbox_iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_mbq = (MAILBOXQ *) hba->mbox_mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_queue_flag = hba->mbox_queue_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_bp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_iocbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbqflag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_timer = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_mbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy the local mailbox provided back into the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * original mailbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint32_t *)mb, (uint32_t *)mbox_mbq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = (MAILBOX *) mbox_mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->mbxStatus = mbxStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mark mailbox complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_mbq->flag |= MBQ_COMPLETED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wake up the sleeping thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_queue_flag == MBX_SLEEP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_MBOX_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred MBUF cleanup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_bp && (mbox_queue_flag == MBX_NOWAIT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_BUF, (uint8_t *)mbox_bp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_sbp && mbox_sbp->fct_cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "FCT mailbox: %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred pkt completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbxStatus != MBX_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set error status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_sbp->pkt_flags &= ~PACKET_STATE_VALID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_set_pkt_state(mbox_sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_NO_RESOURCES, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(mbox_sbp, -1, 0, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred ub completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_ubp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv = mbox_ubp->ub_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = ub_priv->port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_callback(port, mbox_ubp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred iocb tx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_issue_iocb_cmd(hba, mbox_iocbq->ring, mbox_iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_fini() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* This should only be called with active MBX_NOWAIT mailboxes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_retry(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq = (MAILBOXQ *) mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->bp = (uint8_t *)hba->mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = (uint8_t *)hba->mbox_sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = (uint8_t *)hba->mbox_ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->iocbq = (uint8_t *)hba->mbox_iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_bp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_iocbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_mbqflag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_retry() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_handle_mb_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description: Process a Mailbox Attention.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called from host_interrupt to process MBATT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_handle_mb_event(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *swpmb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t control;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uint32_t word0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t la_enable;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ mailbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte swpmb = (MAILBOX *) & word0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb = (MAILBOX *) & mailbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (hba->mbox_queue_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_mbox_intr_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "No mailbox active.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_POLL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark mailbox complete, this should wake up any polling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * threads
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This can happen if interrupts are enabled while a polled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command is outstanding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we don't set MBQ_COMPLETED here, the polling thread may
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wait until timeout error occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq = (MAILBOXQ *) hba->mbox_mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox event. Completing Polled command.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->flag |= MBQ_COMPLETED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SLEEP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_NOWAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Invalid Mailbox flag (%x).");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM2_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (off_t)((uint64_t)(unsigned long)mbox -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)hba->slim2.virt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t), DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = *((volatile uint32_t *) mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = PCIMEM_LONG(word0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM1_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = READ_SLIM_ADDR(hba, ((volatile uint32_t *) mbox));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (swpmb->mbxOwner == OWN_CHIP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i++ > 10000) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_mbox_intr_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "OWN_CHIP: %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(swpmb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte swpmb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t), DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = *((volatile uint32_t *) mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = PCIMEM_LONG(word0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = READ_SLIM_ADDR(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((volatile uint32_t *) mbox));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now that we are the owner, DMA Sync entire mailbox if needed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE, DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mbox, (uint32_t *)mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_WSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_ext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_EXTENSION_OFFSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size, DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy(mbox_ext, (uint32_t *)hba->mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)hba->mbox_ext, mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->mbox_ext_size / 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now sync the memory buffer if one was used */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_bp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_bp = (MATCHMAP *) hba->mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(mbox_bp->dma_handle, 0, mbox_bp->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mailbox has been completely received at this point */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxCommand == MBX_HEARTBEAT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->heartbeat_active = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue_flag == MBX_SLEEP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Received. %s: status=%x Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(swpmb->mbxCommand), swpmb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(swpmb->mbxCommand), swpmb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Filter out passthru mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_mbqflag & MBQ_PASSTHRU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If succesful, process the result */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_handle_cmd(hba, mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERROR RETURNED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for no resources */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mb->mbxStatus == MBXERR_NO_RESOURCES) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->mbox_queue_flag == MBX_NOWAIT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Retry only MBX_NOWAIT requests */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Retrying. %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mem_get(hba, MEM_MBOX))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)mb, (uint8_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (mbox->mbxCommand) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varRdSparm.un.sp.bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_read_sparam(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varRdSparm.un.sp64.tus.f.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_read_sparam(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varRegLogin.un.sp.bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varRegLogin.un.sp64.tus.f.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varReadLA.un.lilpBde.bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_read_la(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte control = mbox->un.varReadLA.un.lilpBde64.tus.f.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_read_la(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->mbxStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Refresh the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_retry(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox, MBX_NOWAIT, 0) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: status=0x%x", emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ERROR: process mailbox command error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (mb->mbxCommand) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == MBXERR_RPI_FULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &VPORT(mb->un.varRegLogin.vpi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Limit reached. count=%d", port->node_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->hc_copy & HC_LAINT_ENA)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba, FC_HC_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy |= HC_LAINT_ENA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CLEAR_LA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte la_enable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == 0x1601) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a buffer which will be used for mailbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * commands
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mem_get(hba, MEM_MBOX |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get link attention message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_read_la(hba, mbox) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX, (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte la_enable = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (la_enable) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->hc_copy & HC_LAINT_ENA)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy |= HC_LAINT_ENA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->hc_copy & HC_LAINT_ENA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy &= ~HC_LAINT_ENA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_INIT_LINK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->flag & FC_SLIM2_MODE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->mbox_queue_flag == MBX_NOWAIT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Retry only MBX_NOWAIT requests */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg[CFG_LINK_SPEED].current > 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((mb->mbxStatus == 0x0011) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (mb->mbxStatus == 0x0500))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Retrying. %s: status=%x. Auto-speed set.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mem_get(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)mb, (uint8_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->un.varInitLnk.link_flags &=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~FLAGS_LINK_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->un.varInitLnk.link_speed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox->mbxStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Refresh the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_retry(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX, (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clean up the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_fini(hba, mb, mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to send pending mailboxes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mb_get(hba))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_handle_mb_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_handle_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description: Process a Mailbox Command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called from host_interrupt to process MBATT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_handle_cmd(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *vport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile SERV_PARM *sp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ldata;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ldid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t lrpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t lvpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_LA_VAR la;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = (MATCHMAP *) hba->mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mailbox command completed successfully, process completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (mb->mbxCommand) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SHUTDOWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_SM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_NV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_WRITE_NV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RUN_BIU_DIAG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RUN_BIU_DIAG64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_INIT_LINK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DOWN_LINK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_LINK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_PART_SLIM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_RING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RESET_RING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_RCONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_STATUS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_XRI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_REV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LNK_STAT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_UNREG_LOGIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DUMP_MEMORY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DUMP_CONTEXT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RUN_DIAGS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RESTART:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_UPDATE_CFG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DOWN_LOAD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DEL_LD_ENTRY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_RUN_PROGRAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SET_MASK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SET_VARIABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_UNREG_D_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_KILL_BOARD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_FARP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_AREA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_MSI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_FLASH_WR_ULA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SET_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_GET_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_EXP_ROM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_BEACON:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_RPI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_RPI64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_VPI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_UNREG_VPI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_HBQ:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_ASYNC_EVENT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_HEARTBEAT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CONFIG_MSIX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM: /* a READ SPARAM command completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM64: /* a READ SPARAM command completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)mp->virt, (caddr_t)& hba->sparam,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->sparam.nodeName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& hba->wwnn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->sparam.portName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& hba->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize the physical port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->sparam,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& port->sparam,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& port->wwpn, sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->wwnn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& port->wwnn, sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize the virtual ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 1; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vport = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vport->flag & EMLXS_PORT_BOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& hba->sparam,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& vport->sparam,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& vport->wwnn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& vport->sparam.nodeName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)& vport->wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)& vport->sparam.portName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_REG_LOGIN64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!mp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldata = mb->un.varWords[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lvpi = ldata & 0xffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &VPORT(lvpi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldata = mb->un.varWords[0]; /* get rpi */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lrpi = ldata & 0xffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldata = mb->un.varWords[1]; /* get did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldid = ldata & Mask_DID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = (volatile SERV_PARM *) mp->virt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = emlxs_node_find_did(port, ldid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ndlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to create a node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ndlp = (NODELIST *) emlxs_mem_get(hba, MEM_NLP))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_Rpi = lrpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_DID = ldid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)sp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->sparm,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& sp->nodeName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->nlp_nodename,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& sp->portName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->nlp_portname,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_active = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_flag[FC_CT_RING] |= NLP_CLOSED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_flag[FC_ELS_RING] |= NLP_CLOSED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_flag[FC_FCP_RING] |= NLP_CLOSED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_flag[FC_IP_RING] |= NLP_CLOSED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_add(port, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_CT_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_ELS_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_IP_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_FCP_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn = (uint8_t *)& sp->portName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to allocate node. did=%06x rpi=%x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldid, lrpi, wwn[0], wwn[1], wwn[2], wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn[4], wwn[5], wwn[6], wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_Rpi = lrpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_DID = ldid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)sp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->sparm,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& sp->nodeName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->nlp_nodename,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)& sp->portName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)& ndlp->nlp_portname,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn = (uint8_t *)& ndlp->nlp_portname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_update_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "node=%p did=%06x rpi=%x wwpn="
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x%02x%02x%02x%02x%02x%02x%02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp, ndlp->nlp_DID, ndlp->nlp_Rpi, wwn[0], wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn[2], wwn[3], wwn[4], wwn[5], wwn[6], wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_CT_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_ELS_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_IP_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_open(port, ndlp, FC_FCP_RING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this was a fabric login */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp->nlp_DID == Fabric_DID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If CLEAR_LA has been sent, then attempt to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * register the vpi now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state == FC_READY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_reg_vpi(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If NPIV Fabric support has just been established
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the physical port, then notify the vports of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the link up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lvpi == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->flag & FC_NPIV_ENABLED) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->flag & FC_NPIV_SUPPORTED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip the physical port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 1; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vport = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vport->flag & EMLXS_PORT_BOUND) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(vport->flag &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_PORT_ENABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_online(vport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef NPIV_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_iocbq == (uint8_t *)1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_iocbq = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_unreg_did(port, ldid, NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* NPIV_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_sbp || hba->mbox_ubp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_dhc_auth_start(port, ndlp, hba->mbox_sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Auth started - auth completion will handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sbp and ubp now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_sbp && ((emlxs_buf_t *)hba->mbox_sbp)->fct_cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *cmd_sbp = (emlxs_buf_t *)hba->mbox_sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd_sbp->fct_state == EMLXS_FCT_REG_PENDING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_sbp->node = ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_sbp->fct_state = EMLXS_FCT_REG_COMPLETE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_PKT_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_LA64:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint32_t *)((char *)mb + sizeof (uint32_t)),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)& la, sizeof (READ_LA_VAR));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)mp->virt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)port->alpa_map, 128);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((caddr_t)port->alpa_map, 128);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_atten_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "type=%s tag=%d -> %d ALPA=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((la.attType == AT_LINK_UP) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "LinkUp" : "LinkDown"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)hba->link_event_tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)la.eventTag, (uint32_t)la.granted_AL_PA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (la.pb) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_BYPASSED_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_BYPASSED_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->link_event_tag == la.eventTag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.LinkMultiEvent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (hba->link_event_tag + 1 < la.eventTag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.LinkMultiEvent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state > FC_LINK_DOWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare link down here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_linkdown(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->link_event_tag = la.eventTag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->lip_type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If link not already up then declare it up now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((la.attType == AT_LINK_UP) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->state < FC_LINK_UP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the linkspeed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkspeed = la.UlnkSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for old model adapters that only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported 1Gb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->linkspeed == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->model_info.chip &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_DRAGONFLY_CHIP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkspeed = LA_1GHZ_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->topology = la.topology) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TOPOLOGY_LOOP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->did = la.granted_AL_PA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->lip_type = la.lipType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = la.un.lilpBde64.tus.f.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = la.un.lilpBde.bdeSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->alpa_map[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *alpa_map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check number of devices in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->alpa_map[0] > 127) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->alpa_map[0] = 127;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map = (uint8_t *)port->alpa_map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_atten_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alpa_map: %d device(s): %02x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x %02x %02x %02x %02x %02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[0], alpa_map[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[2], alpa_map[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[4], alpa_map[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[6], alpa_map[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 8; j <= alpa_map[0]; j += 8) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_atten_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alpa_map: %02x %02x %02x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x %02x %02x %02x %02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alpa_map[j + 7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MENLO_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Menlo maintenance mode is enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->model_info.device_id ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PCI_DEVICE_ID_LP21000_M) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (la.mm == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_atten_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Maintenance Mode enabled.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_MENLO_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_LINKUP_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_atten_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Maintenance Mode disabled.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check FCoE attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (la.fa == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) thread_create(NULL, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_fcoe_attention_thread,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)hba, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &p0, TS_RUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte v.v_maxsyspri - 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MENLO_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOXQ *) emlxs_mem_get(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This should turn on DELAYED ABTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for ELS timeouts
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_set_var(hba, (MAILBOX *) mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00052198, 0x1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_put(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOXQ *) emlxs_mem_get(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If link not already down then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * declare it down now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_read_sparam(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAILBOX *) mbox) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_put(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOXQ *) emlxs_mem_get(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_config_link(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAILBOX *) mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_put(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare the linkup here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_linkup(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If link not already down then declare it down now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if ((la.attType == AT_LINK_DOWN) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->state > FC_LINK_DOWN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare link down here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_linkdown(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link attention interrupt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->hc_copy & HC_LAINT_ENA)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy |= HC_LAINT_ENA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HC_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->csr_addr), hba->hc_copy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log the link event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_log_link_event(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_CLEAR_LA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable on Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->hc_copy & HC_LAINT_ENA)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba, FC_HC_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy |= HC_LAINT_ENA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->hc_copy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ffstate_change_locked(hba, FC_READY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adapter is now ready for FCP traffic */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state == FC_READY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Register vpi's for all ports that have did's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vport = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vport->flag & EMLXS_PORT_BOUND) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(vport->did)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_reg_vpi(vport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to send any pending IO */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_issue_iocb_cmd(hba, &hba->ring[FC_FCP_RING], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unknown mailbox cmd: 0x%x", mb->mbxCommand);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxInvalid++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_handle_cmd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_NOWAIT - returns MBX_BUSY or MBX_SUCCESS or MBX_HARDWARE_ERROR */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_WAIT - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_SLEEP - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_POLL - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_issue_cmd(emlxs_hba_t *hba, MAILBOX *mb, int32_t flag, uint32_t tmo)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uint32_t word0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uint32_t ldata;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ha_copy;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmo_local;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX *swpmb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq = (MAILBOXQ *) mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte swpmb = (MAILBOX *) & word0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxStatus = MBX_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for minimum timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (mb->mbxCommand) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mailbox commands that erase/write flash */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DOWN_LOAD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_UPDATE_CFG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_AREA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_EXP_ROM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_WRITE_NV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_FLASH_WR_ULA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_DEL_LD_ENTRY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_LOAD_SM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo < 300) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo = 300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo < 30) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo = 30;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust wait flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != MBX_NOWAIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If interrupt is enabled, use sleep, otherwise poll */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->hc_copy & HC_MBINT_ENA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = MBX_SLEEP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = MBX_POLL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for hardware error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_HARDWARE_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxStatus = (hba->flag & FC_OVERTEMP_EVENT) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBX_OVERTEMP_ERROR : MBX_HARDWARE_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Hardware error reported. %s failed. status=%x mb=%p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb->mbxStatus, mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MBX_HARDWARE_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If we are not polling, then queue it for later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == MBX_NOWAIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Busy. %s: mb=%p NoWait.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_put(hba, mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.MboxBusy++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MBX_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo_local = tmo * 20; /* Convert tmo seconds to 50 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* millisecond tics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (hba->mbox_queue_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo_local-- == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d Waiting.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Non-lethalStatus mailbox timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Does not indicate a hardware error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxStatus = MBX_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MBX_TIMEOUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DELAYMS(50);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_init(hba, mbq, flag, tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_NOWAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxCommand != MBX_HEARTBEAT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p NoWait.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SLEEP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_POLL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_CHIP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HA_REG(hba, hba->csr_addr), HA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM2_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (off_t)((uint64_t)(unsigned long)mbox -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)hba->slim2.virt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_ext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_EXTENSION_OFFSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)hba->mbox_ext, mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size, DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE, DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for config port command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (mb->mbxCommand == MBX_CONFIG_PORT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy command data into host mbox for cmpl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM2_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (off_t)((uint64_t)(unsigned long)mbox -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)hba->slim2.virt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE, DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM1_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_COPY(hba, &mb->un.varWords, &mbox->un.varWords,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAILBOX_CMD_WSIZE - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy over last word, with mbxOwner set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldata = *((volatile uint32_t *) mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_ADDR(hba, ((volatile uint32_t *) mbox), ldata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* switch over to host mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->mbox_queueaddr = (uint32_t *)&((SLIM2 *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->slim2.virt)->mbx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_SLIM2_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* SLIM 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM1_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_ext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_EXTENSION_OFFSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_COPY(hba, (uint32_t *)hba->mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_ext, (hba->mbox_ext_size / 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_COPY(hba, &mb->un.varWords, &mbox->un.varWords,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAILBOX_CMD_WSIZE - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy over last word, with mbxOwner set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ldata = *((volatile uint32_t *) mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_ADDR(hba, ((volatile uint32_t *) mbox), ldata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Interrupt board to do it right away */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_CA_REG(hba, hba->csr_addr), CA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_NOWAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MBX_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_SLEEP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The driver clock is timing the mailbox. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* emlxs_mb_fini() will be called externally. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (!(mbq->flag & MBQ_COMPLETED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_wait(&EMLXS_MBOX_CV, &EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == MBX_TIMEOUT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb, tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: mb=%p status=%x Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_POLL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo_local = tmo * 2000; /* Convert tmo seconds to 500 usec */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* tics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_INIT_START) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha_copy = READ_CSR_REG(hba, FC_HA_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for command to complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (!(ha_copy & HA_MBATT) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(mbq->flag & MBQ_COMPLETED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hba->timer_id && (tmo_local-- == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* self time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_hardware_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox Timeout: %s: mb=%p Polled",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_MBOX_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ffstate_change(hba, FC_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_fini(hba, NULL, MBX_TIMEOUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DELAYUS(500);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FC_HA_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == MBX_TIMEOUT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM2_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (off_t)((uint64_t)(unsigned long)mbox -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)hba->slim2.virt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t), DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = *((volatile uint32_t *) mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = PCIMEM_LONG(word0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox = FC_SLIM1_MAILBOX(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = READ_SLIM_ADDR(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((volatile uint32_t *) mbox));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for command to complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((swpmb->mbxOwner == OWN_CHIP) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(mbq->flag & MBQ_COMPLETED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hba->timer_id && (tmo_local-- == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* self time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_hardware_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox Timeout: %s: mb=%p Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_MBOX_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ffstate_change(hba, FC_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_fini(hba, NULL, MBX_TIMEOUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DELAYUS(500);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t), DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = *((volatile uint32_t *) mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = PCIMEM_LONG(word0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = READ_SLIM_ADDR(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((volatile uint32_t *) mbox));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb->mbxStatus == MBX_TIMEOUT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_event_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb, tmo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy results back to user */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE, DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mbox, (uint32_t *)mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_WSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MBOX_EXT_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_ext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_EXTENSION_OFFSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_SLIM2_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset_ext, hba->mbox_ext_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy(mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)hba->mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ext_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)hba->mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_ext, (hba->mbox_ext_size / 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync the memory buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_bp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_bp = (MATCHMAP *) hba->mbox_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(mbox_bp->dma_handle, 0, mbox_bp->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: mb=%p status=%x Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb, mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Process the result */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq->flag & MBQ_PASSTHRU)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_handle_cmd(hba, mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HA_REG(hba, hba->csr_addr), HA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clean up the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_fini(hba, NULL, mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* switch (flag) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_issue_cmd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_cmd_xlate(uint8_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static char buffer[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = sizeof (emlxs_mb_cmd_table) / sizeof (emlxs_table_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd == emlxs_mb_cmd_table[i].code) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (emlxs_mb_cmd_table[i].string);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(buffer, "Cmd=0x%x", cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_cmd_xlate() */