emlxs_mbox.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Emulex. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to License terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb, uint32_t word0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int32_t emlxs_mb_handle_cmd(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_init(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_mb_retry(emlxs_hba_t *hba, MAILBOX *mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {MBX_READ_EVENT_LOG_STATUS, "READ_EVENT_LOG_STATUS"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}; /* emlxs_mb_cmd_table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_async_event(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_async_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_heartbeat() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_msi(emlxs_hba_t *hba, MAILBOX *mb, uint32_t *intr_map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the default message id to zero */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_BIG_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Accounts for half word swap of LE architecture */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_LITTLE_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_msi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_msix(emlxs_hba_t *hba, MAILBOX *mb, uint32_t *intr_map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the default message id to zero */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_BIG_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Accounts for word swap of LE architecture */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* EMLXS_LITTLE_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_msix() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MSI_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_reset_ring(emlxs_hba_t *hba, MAILBOX *mb, uint32_t ringno)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reset_ring() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_dump_vpd Issue a DUMP MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_dump_vpd(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup to dump VPD region
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varDmp.word_cnt = DMP_VPD_DUMP_WCOUNT; /* limited by */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mailbox size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_dump_vpd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_nv Issue a READ NVPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_nv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_rev Issue a READ REV
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rev(emlxs_hba_t *hba, MAILBOX *mb, uint32_t v3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_rev */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_run_biu_diag Issue a RUN_BIU_DIAG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_run_biu_diag(emlxs_hba_t *hba, MAILBOX *mb, uint64_t out,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.xmit_bde64.tus.f.bdeSize = MEM_ELSBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.tus.f.bdeSize = MEM_ELSBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varBIUdiag.un.s2.rcv_bde64.addrLow = (uint32_t)putPaddrLow(in);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_run_biu_diag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_la Issue a READ LA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varReadLA.un.lilpBde64.tus.f.bdeSize = 128;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_la() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_clear_la Issue a CLEAR LA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* FC_RPI_CHECK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varClearLA.eventTag = hba->link_event_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_clear_la */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_status Issue a READ STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_status(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End fc_read_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_lnk_stat Issue a LINK STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_lnk_stat(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_lnk_stat */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_write_nv Issue a WRITE NVPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_emb_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWTnvp.hardAL_PA = (uint8_t)cfg[CFG_ASSIGN_ALPA].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 21; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_write_nv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_part_slim Issue a PARTITION SLIM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb, uint32_t hbainit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_part_slim */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_ring Issue a CONFIG RING
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_ring(emlxs_hba_t *hba, int32_t ring, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ring; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((j + i) >= 6) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].rval = hba->ring_rval[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgRing.rrRegs[i].rmask = hba->ring_rmask[j + i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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 mb->un.varCfgRing.numMask = hba->ring_masks[ring];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_config_ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_link Issue a CONFIG LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_link(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NEW_FEATURE SLI-2, Coalescing Response Feature.
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} /* emlxs_mb_config_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_init_link Issue an INIT LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_init_link(emlxs_hba_t *hba, MAILBOX *mb, uint32_t topology,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_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 /* Disable LIRP/LILP support */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting up the link speed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((linkspeed > 0) && (vpd->feaLevelHigh >= 0x02)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.link_flags |= FLAGS_PREABORT_RETURN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.fabric_AL_PA = (uint8_t)cfg[CFG_ASSIGN_ALPA].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxCommand = (volatile uint8_t) MBX_INIT_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_down_link Issue a DOWN LINK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_down_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_sparam Issue a READ SPARAM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_sparam(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.addrHigh = (uint32_t)putPaddrHigh(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdSparm.un.sp64.addrLow = (uint32_t)putPaddrLow(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_sparam() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_rpi Issue a READ RPI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rpi(emlxs_hba_t *hba, uint32_t rpi, MAILBOX *mb, uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flag to issue action on cmpl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdRPI.reqRpi = (volatile uint16_t) rpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_rpi */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_xri Issue a READ XRI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_xri(emlxs_hba_t *hba, uint32_t xri, MAILBOX *mb, uint32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flag to issue action on cmpl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRdXRI.reqXri = (volatile uint16_t) xri;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_xri */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_check_sparm(emlxs_hba_t *hba, SERV_PARM *nsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the service parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp_value = ((nsp->cls2.rcvDataSizeMsb & 0x0f) << 8) |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the receive data length is zero then set it to the CSP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp_value = ((nsp->cls3.rcvDataSizeMsb & 0x0f) << 8) |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the receive data length is zero then set it to the CSP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This prevents a Emulex adapter bug from occurring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_check_sparm() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_reg_did Issue a REG_LOGIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
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 /* Check for invalid node ids to register */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Invalid service parameters. did=%06x rval=%d", did, rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if the node limit has been reached */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Limit reached. did=%06x count=%d", did, port->node_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build login request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF | MEM_PRI)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *) param, (void *) mp->virt, sizeof (SERV_PARM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (SERV_PARM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.addrHigh = (uint32_t)putPaddrHigh(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varRegLogin.un.sp64.addrLow = (uint32_t)putPaddrLow(mp->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reg_did() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_unreg_rpi Issue a UNREG_LOGIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_unreg_rpi(emlxs_port_t *port, uint32_t rpi, emlxs_buf_t *sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure the node does already exist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we just unregistered the host node then clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Unreg all */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_rpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_unreg_did Issue a UNREG_DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_unreg_did(emlxs_port_t *port, uint32_t did, emlxs_buf_t *sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Unregister all default RPIs if did == 0xffffffff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just flush base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, &port->node_base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, &port->node_base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A zero DID means that we are trying to unreg the host node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * after a link bounce
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the prev_did == 0 then the adapter has been reset and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * there is no need in unregistering
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the prev_did != 0 then we can look for the hosts last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * known DID node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure the node does already exist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we just unregistered the host node then clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_unreg_did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_mask Issue a SET MASK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varWords[0] = 0x11223344; /* set passwd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_debug Issue a special debug
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb, uint32_t word0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_debug */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_set_var Issue a special debug mbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command to write slim
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_var(emlxs_hba_t *hba, MAILBOX *mb, uint32_t addr, uint32_t value)
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 * Always turn on DELAYED ABTS for ELS timeouts
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_var */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disable Traffic Cop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_disable_tc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_port Issue a CONFIG_PORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_port(emlxs_hba_t *hba, MAILBOX *mb, uint32_t sli_mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcb = hba->slim2.phys + (uint64_t)(unsigned long)& (slim->pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.pcbLow = (uint32_t)putPaddrLow(pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgPort.pcbHigh = (uint32_t)putPaddrHigh(pcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set Host pointers in SLIM flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize hba structure for assumed default SLI2 mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If config port succeeds, then we will update it then */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "CFGPORT: Firmware does not support NPIV. "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* NPIV_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now setup pcb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.type = TYPE_NATIVE_SLI2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.feature = FEATURE_INITIAL_SLI2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.maxRing = (hba->ring_count - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *) hba->slim2.virt)->pcb.mailBoxSize = sizeof (MAILBOX) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbx = hba->slim2.phys + (uint64_t)(unsigned long)& (slim->mbx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.mbAddrLow = (uint32_t)putPaddrLow(mbx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set up HGP - Port Memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR0Put - SLI2(no HBQs) = 0xc0, With HBQs = 0x80
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR0Get 0xc4 0x84
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR1Put 0xc8 0x88
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR1Get 0xcc 0x8c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR2Put 0xd0 0x90
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR2Get 0xd4 0x94
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CR3Put 0xd8 0x98
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RR3Get 0xdc 0x9c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reserved 0xa0-0xbf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If HBQs configured:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 0 Put ptr 0xc0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 1 Put ptr 0xc4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ 2 Put ptr 0xc8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBQ(M-1)Put Pointer 0xc0+(M-1)*4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERBM is enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else /* SLI2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERBM is disabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The Sbus card uses Host Memory. The PCI card uses SLIM POINTER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(hba->pci_addr + PCI_BAR_1_REGISTER));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(hba->pci_addr + PCI_BAR_0_REGISTER));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgp = hba->slim2.phys + (uint64_t)(unsigned long)& (mbox->us.s2.port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((SLIM2 *)hba->slim2.virt)->pcb.pgpAddrLow = (uint32_t)putPaddrLow(pgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 4; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdsc = &((SLIM2 *) hba->slim2.virt)->pcb.rdsc[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup command ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)& (slim->IOCBs[offset]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_cmdringaddr = (void *) &((SLIM2 *) hba->slim2.virt)->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup response ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint64_t)(unsigned long)& (slim->IOCBs[offset]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_rspringaddr = (void *) &((SLIM2 *) hba->slim2.virt)->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)(&((SLIM2 *) hba->slim2.virt)->pcb),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(&((SLIM2 *) hba->slim2.virt)->pcb), sizeof (PCB));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uint64_t)(unsigned long)& (((SLIM2 *) hba->slim2.virt)->pcb) -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, (off_t)offset, sizeof (PCB),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_port() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_hbq(emlxs_hba_t *hba, MAILBOX *mb, int 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.hbqaddrLow = putPaddrLow(hbq->HBQ_host_buf.phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqaddrHigh = putPaddrHigh(hbq->HBQ_host_buf.phys);
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 /* Return if no rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Otherwise we setup specific rctl / type masks for this HBQ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].tmatch = hbq->HBQ_Masks[i].tmatch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varCfgHbq.hbqMasks[i].tmask = hbq->HBQ_Masks[i].tmask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_hbq() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Can't reg vpi until ClearLA is sent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must have port id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reg_vpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mb, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_unreg_vpi() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_config_farp Issue a CONFIG FARP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_farp(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_farp() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_read_nv Issue a READ CONFIG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_config(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_config() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NAME: emlxs_mb_put
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FUNCTION: put mailbox cmd onto the mailbox queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXECUTION ENVIRONMENT: process and interrupt level.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CALLED FROM: emlxs_mb_issue_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT: hba - pointer to the device info area mbp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - pointer to mailbox queue entry of mailbox cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: NULL - command queued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queue command to end of list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((MAILBOXQ *) hba->mbox_queue.q_last)->next = mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add command to empty list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_put() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NAME: emlxs_mb_get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FUNCTION: get a mailbox command from mailbox command queue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXECUTION ENVIRONMENT: interrupt level.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CALLED FROM: emlxs_handle_mb_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT: hba - pointer to the device info area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: NULL - no match found mb pointer - pointer to a mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->mbox_queue.q_first = (uint8_t *)p_first->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_get() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* EMLXS_PORT_LOCK must be held when calling this */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_init(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t flag, uint32_t tmo)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the Mailbox timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_fini(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mbxStatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy the local mailbox provided back into the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * original mailbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mark mailbox complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wake up the sleeping thread */
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 "FCT mailbox: %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred pkt completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set error status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_set_pkt_state(mbox_sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred ub completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for deferred iocb tx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_issue_iocb_cmd(hba, mbox_iocbq->ring, mbox_iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_fini() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* This should only be called with active MBX_NOWAIT mailboxes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_retry() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_handle_mb_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description: Process a Mailbox Attention.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called from host_interrupt to process MBATT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_mbox_intr_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "No mailbox active.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark mailbox complete, this should wake up any polling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This can happen if interrupts are enabled while a polled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mailbox command is outstanding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we don't set MBQ_COMPLETED here, the polling thread may
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wait until timeout error occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox event. Completing Polled command.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Invalid Mailbox flag (%x).");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte word0 = READ_SLIM_ADDR(hba, ((volatile uint32_t *) mbox));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i++ > 10000) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_mbox_intr_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "OWN_CHIP: %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now that we are the owner, DMA Sync entire mailbox if needed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mbox, (uint32_t *)mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy(mbox_ext, (uint32_t *)hba->mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)hba->mbox_ext, mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now sync the memory buffer if one was used */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(mbox_bp->dma_handle, 0, mbox_bp->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mailbox has been completely received at this point */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Received. %s: status=%x Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(swpmb->mbxCommand), swpmb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(swpmb->mbxCommand), swpmb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Filter out passthru mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If succesful, process the result */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ERROR RETURNED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for no resources */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Retry only MBX_NOWAIT requests */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Retrying. %s: status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mem_get(hba, MEM_MBOX))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Refresh the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox, MBX_NOWAIT, 0) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: status=0x%x", emlxs_mb_cmd_xlate(mb->mbxCommand),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ERROR: process mailbox command error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba, FC_HC_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a buffer which will be used for mailbox
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mbox = (MAILBOX *) emlxs_mem_get(hba, MEM_MBOX |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get link attention message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Retry only MBX_NOWAIT requests */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Retrying. %s: status=%x. Auto-speed set.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Refresh the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clean up the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to send pending mailboxes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_mb_issue_cmd(hba, mbox, MBX_NOWAIT, 0) != MBX_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_handle_mb_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_mb_handle_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description: Process a Mailbox Command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called from host_interrupt to process MBATT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_handle_cmd(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mailbox command completed successfully, process completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM: /* a READ SPARAM command completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBX_READ_SPARM64: /* a READ SPARAM command completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize the physical port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize the virtual ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to create a node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ndlp = (NODELIST *) emlxs_mem_get(hba, MEM_NLP))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to allocate node. did=%06x rpi=%x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_update_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "node=%p did=%06x rpi=%x wwpn="
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x%02x%02x%02x%02x%02x%02x%02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp, ndlp->nlp_DID, ndlp->nlp_Rpi, wwn[0], wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this was a fabric login */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If CLEAR_LA has been sent, then attempt to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * register the vpi now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If NPIV Fabric support has just been established
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the physical port, then notify the vports of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the link up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lvpi == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip the physical port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_mb_unreg_did(port, ldid, NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* NPIV_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_dhc_auth_start(port, ndlp, hba->mbox_sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Auth started - auth completion will handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sbp and ubp now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_sbp && ((emlxs_buf_t *)hba->mbox_sbp)->fct_cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *cmd_sbp = (emlxs_buf_t *)hba->mbox_sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd_sbp->fct_state == EMLXS_FCT_REG_PENDING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint32_t *)((char *)mb + sizeof (uint32_t)),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "type=%s tag=%d -> %d ALPA=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)la.eventTag, (uint32_t)la.granted_AL_PA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (hba->link_event_tag + 1 < la.eventTag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare link down here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If link not already up then declare it up now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the linkspeed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for old model adapters that only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported 1Gb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check number of devices in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alpa_map: %d device(s): %02x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x %02x %02x %02x %02x %02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alpa_map: %02x %02x %02x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x %02x %02x %02x %02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Menlo maintenance mode is enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Maintenance Mode enabled.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Maintenance Mode disabled.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check FCoE attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MENLO_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This should turn on DELAYED ABTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for ELS timeouts
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If link not already down then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * declare it down now
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare the linkup here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If link not already down then declare it down now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Declare link down here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Link attention interrupt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC_HC_REG(hba, hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log the link event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable on Link Attention interrupts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->hc_copy = READ_CSR_REG(hba, FC_HC_REG(hba,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->csr_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HC_REG(hba, hba->csr_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adapter is now ready for FCP traffic */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Register vpi's for all ports that have did's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to send any pending IO */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_issue_iocb_cmd(hba, &hba->ring[FC_FCP_RING], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_handle_cmd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_NOWAIT - returns MBX_BUSY or MBX_SUCCESS or MBX_HARDWARE_ERROR */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_WAIT - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_SLEEP - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* MBX_POLL - returns MBX_TIMEOUT or mailbox_status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_issue_cmd(emlxs_hba_t *hba, MAILBOX *mb, int32_t flag, uint32_t tmo)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for minimum timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mailbox commands that erase/write flash */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust wait flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If interrupt is enabled, use sleep, otherwise poll */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for hardware error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->mbxStatus = (hba->flag & FC_OVERTEMP_EVENT) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Hardware error reported. %s failed. status=%x mb=%p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb->mbxStatus, mb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If we are not polling, then queue it for later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Busy. %s: mb=%p NoWait.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo_local = tmo * 20; /* Convert tmo seconds to 50 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* millisecond tics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo_local-- == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d Waiting.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Non-lethalStatus mailbox timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Does not indicate a hardware error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p NoWait.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sending. %s: mb=%p Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HA_REG(hba, hba->csr_addr), HA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)hba->mbox_ext, mbox_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(hba->slim2.dma_handle, offset_ext,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for config port command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy command data into host mbox for cmpl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_COPY(hba, &mb->un.varWords, &mbox->un.varWords,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy over last word, with mbxOwner set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_ADDR(hba, ((volatile uint32_t *) mbox), ldata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* switch over to host mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->mbox_queueaddr = (uint32_t *)&((SLIM2 *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hba->slim2.virt)->mbx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* SLIM 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First copy command data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_COPY(hba, &mb->un.varWords, &mbox->un.varWords,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy over last word, with mbxOwner set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_SLIM_ADDR(hba, ((volatile uint32_t *) mbox), ldata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Interrupt board to do it right away */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_CA_REG(hba, hba->csr_addr), CA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The driver clock is timing the mailbox. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* emlxs_mb_fini() will be called externally. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: mb=%p status=%x Sleep.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo_local = tmo * 2000; /* Convert tmo seconds to 500 usec */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for command to complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* self time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox Timeout: %s: mb=%p Polled",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for command to complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* self time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Mailbox Timeout: %s: mb=%p Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get first word of mailbox */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Timeout. %s: mb=%p tmo=%d. Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy results back to user */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pcimem_bcopy((uint32_t *)mbox, (uint32_t *)mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte READ_SLIM_COPY(hba, (uint32_t *)mb, (uint32_t *)mbox,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *mbox_ext = (uint32_t *)((uint8_t *)mbox +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t offset_ext = offset + MBOX_EXTENSION_OFFSET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync the memory buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mpdata_sync(mbox_bp->dma_handle, 0, mbox_bp->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_mbox_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Completed. %s: mb=%p status=%x Polled.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_cmd_xlate(mb->mbxCommand), mb, mb->mbxStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Process the result */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the attention bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRITE_CSR_REG(hba, FC_HA_REG(hba, hba->csr_addr), HA_MBATT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clean up the mailbox area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* switch (flag) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_issue_cmd() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = sizeof (emlxs_mb_cmd_table) / sizeof (emlxs_table_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_cmd_xlate() */