emlxs_mbox.c revision 291a2b48b9adcd7b3666c34e80ba6411929afe7f
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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Copyright 2009 Emulex. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to License terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_MBOX_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t hbainit);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t ringno);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t word0, uint32_t word1, uint32_t word2);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic int32_t emlxs_mb_handle_cmd(emlxs_hba_t *hba, MAILBOX *mb);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_table_t emlxs_mb_cmd_table[] = {
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"},
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan {MBX_NV_LOG, "NV_LOG"},
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan {MBX_PORT_CAPABILITIES, "PORT_CAPABILITIES"},
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan {MBX_IOV_CONTROL, "IOV_CONTROL"},
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan {MBX_IOV_MBX, "IOV_MBX"}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}; /* emlxs_mb_cmd_table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_reset_ring(emlxs_hba_t *hba, MAILBOX *mb, uint32_t ringno)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_dump_vpd Issue a DUMP MEMORY mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_dump_vpd(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* limited by mailbox size */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.word_cnt = DMP_VPD_DUMP_WCOUNT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.co = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.resp_offset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_dump_vpd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanextern void
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_dump(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset, uint32_t words)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->mbxCommand = MBX_DUMP_MEMORY;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.type = DMP_MEM_REG;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.word_cnt = words;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.base_adr = offset;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.co = 0;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.resp_offset = 0;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->mbxOwner = OWN_HOST;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan} /* emlxs_mb_dump() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_nv Issue a READ NVPARAM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_nv(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_NV;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_nv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_rev Issue a READ REV mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rev(emlxs_hba_t *hba, MAILBOX *mb, uint32_t v3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_read_rev */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_run_biu_diag Issue a RUN_BIU_DIAG mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varBIUdiag.un.s2.xmit_bde64.addrHigh = putPaddrHigh(out);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varBIUdiag.un.s2.xmit_bde64.addrLow = putPaddrLow(out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.tus.f.bdeSize = MEM_ELSBUF_SIZE;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varBIUdiag.un.s2.rcv_bde64.addrHigh = putPaddrHigh(in);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varBIUdiag.un.s2.rcv_bde64.addrLow = putPaddrLow(in);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_run_biu_diag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_la Issue a READ LA 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_LA64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varReadLA.un.lilpBde64.tus.f.bdeSize = 128;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varReadLA.un.lilpBde64.addrHigh = putPaddrHigh(mp->phys);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varReadLA.un.lilpBde64.addrLow = 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_clear_la Issue a CLEAR LA 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_status Issue a READ STATUS mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_status(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End fc_read_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_lnk_stat Issue a LINK STATUS mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_lnk_stat(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_LNK_STAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_lnk_stat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_write_nv Issue a WRITE NVPARAM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_emb_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan int32_t i;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((void *)&hba->wwnn,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (void *)mb->un.varWTnvp.nodename, sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((void *)&hba->wwpn,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (void *)mb->un.varWTnvp.portname, 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_part_slim Issue a PARTITION SLIM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb, uint32_t hbainit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_part_slim */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_ring Issue a CONFIG RING 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_link Issue a CONFIG LINK mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_link(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_init_link Issue an INIT LINK 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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_vpd_t *vpd = &VPD;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_PREABORT_RETURN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varInitLnk.fabric_AL_PA =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_down_link Issue a DOWN LINK mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_down_link(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_sparam Issue a READ SPARAM 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRdSparm.un.sp64.addrLow = 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_rpi Issue a READ RPI mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_read_rpi(emlxs_hba_t *hba, uint32_t rpi, MAILBOX *mb,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_read_rpi */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_xri Issue a READ XRI mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_read_xri(emlxs_hba_t *hba, uint32_t xri, MAILBOX *mb,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_read_xri */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the service parameters */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iptr = (uint32_t *)&nsp->portName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iptr[0] == 0 && iptr[1] == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iptr = (uint32_t *)&nsp->nodeName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iptr[0] == 0 && iptr[1] == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsp->cls2.classValid) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan nsp_value =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((nsp->cls2.rcvDataSizeMsb & 0x0f) << 8) | nsp->cls2.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rcvDataSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If the receive data length is zero then set it to */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the CSP value */
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsp->cls3.classValid) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan nsp_value =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((nsp->cls3.rcvDataSizeMsb & 0x0f) << 8) | nsp->cls3.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rcvDataSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If the receive data length is zero then set it to */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the CSP value */
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_check_sparm() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_reg_did Issue a REG_LOGIN 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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_hba_t *hba = HBA;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MATCHMAP *mp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOX *mb;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for invalid node ids to register */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((did == 0) && (!(hba->flag & FC_LOOPBACK_MODE))) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return (1);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (did & 0xff000000) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = emlxs_mb_check_sparm(hba, param))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Invalid service parameters. did=%06x rval=%d", did,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Limit reached. did=%06x count=%d", did,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan port->node_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build login request */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((void *)param, (void *)mp->virt, sizeof (SERV_PARM));
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb = (MAILBOX *)mbq->mbox;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRegLogin.un.sp64.addrLow = 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRegLogin.vpi = 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (emlxs_sli_issue_mbox_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reg_did() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_unreg_rpi Issue a UNREG_LOGIN 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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_hba_t *hba = HBA;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOX *mb;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If we just unregistered the host node then
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * clear the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp->nlp_DID == port->did) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->did = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_node_destroy_all(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (emlxs_sli_issue_mbox_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_rpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_unreg_did Issue a UNREG_DID 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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_hba_t *hba = HBA;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan NODELIST *ndlp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (void) emlxs_chipq_node_flush(port, 0,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &port->node_base, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If the prev_did != 0 then we can look for the hosts
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * last 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did = port->prev_did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If we just unregistered the host node then
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * clear the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == port->did) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->did = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (emlxs_sli_issue_mbox_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_unreg_did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_mask Issue a SET MASK mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_set_mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_debug Issue a special debug mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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} /* End emlxs_mb_set_debug */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_var Issue a special debug mbox command to write slim
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_set_var(emlxs_hba_t *hba, MAILBOX *mb, uint32_t addr,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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} /* End emlxs_mb_set_var */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disable Traffic Cop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_disable_tc(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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#ifdef SLI3_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_hbq(emlxs_hba_t *hba, MAILBOX *mb, int hbq_id)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan HBQ_INIT_t *hbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return if no rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hbq->HBQ_num_mask) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Otherwise we setup specific rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < hbq->HBQ_num_mask; i++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varCfgHbq.hbqMasks[i].tmatch =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_hba_t *hba = HBA;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOX *mb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->flag & FC_NPIV_ENABLED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->flag |= EMLXS_PORT_REGISTERED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb = (MAILBOX *)mbq->mbox;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (emlxs_sli_issue_mbox_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_hba_t *hba = HBA;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->flag &= ~EMLXS_PORT_REGISTERED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb = (MAILBOX *)mbq->mbox;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (emlxs_sli_issue_mbox_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_vpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_farp Issue a CONFIG FARP mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_farp(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((uint8_t *)&hba->wwpn,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)&mb->un.varCfgFarp.portname, sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((uint8_t *)&hba->wwpn,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)&mb->un.varCfgFarp.nodename, 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/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_nv Issue a READ CONFIG mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_config(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)mb, MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = MBX_READ_CONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxOwner = OWN_HOST;
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 *
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * CALLED FROM: emlxs_sli_issue_mbox_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * INPUT: hba - pointer to the device info area
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * mbp - 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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *p_first = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_MBOX_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_queue.q_first) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanvoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_init(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t flag, uint32_t tmo)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef FMA_SUPPORT
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_port_t *port = &PPORT;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* FMA_SUPPORT */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_sbp = mbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->sbp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbq->ubp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_ubp = mbq->ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbq->ubp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#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{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_port_t *port = &PPORT;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MATCHMAP *mbox_bp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_buf_t *mbox_sbp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan fc_unsol_buf_t *mbox_ubp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan IOCBQ *mbox_iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOXQ *mbox_mbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan MAILBOX *mbox;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t mbox_queue_flag;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mbox_iocbq = (IOCBQ *)hba->mbox_iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#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) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Copy the local mailbox provided back into */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the original mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint32_t *)mb, (uint32_t *)mbox_mbq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOX_CMD_BSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(mbox_sbp, -1, 0, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred iocb tx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbox_iocbq) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_sli_issue_iocb_cmd(hba, mbox_iocbq->ring, mbox_iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanvoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_retry(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanextern char *
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_cmd_xlate(uint8_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan static char buffer[32];
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t i;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan 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() */