emlxs_mbox.c revision 291a2b48b9adcd7b3666c34e80ba6411929afe7f
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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Copyright 2009 Emulex. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to License terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_mb_set_mask(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mask,
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 {MBX_READ_EVENT_LOG_STATUS, "READ_EVENT_LOG_STATUS"},
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan {MBX_PORT_CAPABILITIES, "PORT_CAPABILITIES"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}; /* emlxs_mb_cmd_table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_async_event(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_async_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_heartbeat() */
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 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 Forteemlxs_mb_reset_ring(emlxs_hba_t *hba, MAILBOX *mb, uint32_t ringno)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_reset_ring() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_dump_vpd Issue a DUMP MEMORY mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_dump_vpd(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup to dump VPD region
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* limited by mailbox size */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varDmp.word_cnt = DMP_VPD_DUMP_WCOUNT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_dump_vpd() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_dump(emlxs_hba_t *hba, MAILBOX *mb, uint32_t offset, uint32_t words)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan} /* emlxs_mb_dump() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_nv Issue a READ NVPARAM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_nv */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_rev Issue a READ REV mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_rev(emlxs_hba_t *hba, MAILBOX *mb, uint32_t v3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_rev */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_run_biu_diag Issue a RUN_BIU_DIAG mailbox command
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;
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} /* End emlxs_mb_run_biu_diag */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_la Issue a READ LA mailbox command
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((mp = (MATCHMAP *)emlxs_mem_get(hba, MEM_BUF)) == 0) {
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 * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_la() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_clear_la Issue a CLEAR LA 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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_status Issue a READ STATUS mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_status(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End fc_read_status */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_lnk_stat Issue a LINK STATUS mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_lnk_stat(emlxs_hba_t *hba, MAILBOX *mb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_lnk_stat */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_write_nv Issue a WRITE NVPARAM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_emb_mb_write_nv(emlxs_hba_t *hba, MAILBOX *mb)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (void *)mb->un.varWTnvp.nodename, sizeof (NAME_TYPE));
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (void *)mb->un.varWTnvp.portname, sizeof (NAME_TYPE));
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_part_slim Issue a PARTITION SLIM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_part_slim(emlxs_hba_t *hba, MAILBOX *mb, uint32_t hbainit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_part_slim */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_ring Issue a CONFIG RING 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) {
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];
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 mb->un.varCfgRing.numMask = hba->ring_masks[ring];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_config_ring */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_link Issue a CONFIG LINK 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() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_init_link Issue an INIT LINK 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->mbxCommand = (volatile uint8_t) MBX_INIT_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init_link() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_down_link Issue a DOWN LINK mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_down_link() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_sparam Issue a READ SPARAM mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_read_sparam(emlxs_hba_t *hba, MAILBOX *mb)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((mp = (MATCHMAP *)emlxs_mem_get(hba, MEM_BUF)) == 0) {
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 * save address for completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_read_sparam() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_rpi Issue a READ RPI mailbox command
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_read_rpi(emlxs_hba_t *hba, uint32_t rpi, MAILBOX *mb,
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_xri Issue a READ XRI mailbox command
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_read_xri(emlxs_hba_t *hba, uint32_t xri, MAILBOX *mb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set flag to issue action on cmpl
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mb->un.varRdXRI.reqXri = (volatile uint16_t)xri;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_read_xri */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_check_sparm(emlxs_hba_t *hba, SERV_PARM *nsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the service parameters */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((nsp->cls2.rcvDataSizeMsb & 0x0f) << 8) | nsp->cls2.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If the receive data length is zero then set it to */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the CSP value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls2.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((nsp->cls3.rcvDataSizeMsb & 0x0f) << 8) | nsp->cls3.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If the receive data length is zero then set it to */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the CSP value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeMsb = nsp->cmn.bbRcvSizeMsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsp->cls3.rcvDataSizeLsb = nsp->cmn.bbRcvSizeLsb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_check_sparm() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_reg_did Issue a REG_LOGIN 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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((did == 0) && (!(hba->flag & FC_LOOPBACK_MODE))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Invalid service parameters. did=%06x rval=%d", did,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if the node limit has been reached */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_create_failed_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Limit reached. did=%06x count=%d", did,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
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);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bcopy((void *)param, (void *)mp->virt, sizeof (SERV_PARM));
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#endif /* SLI3_SUPPORT */
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} /* emlxs_mb_reg_did() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_unreg_rpi Issue a UNREG_LOGIN 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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If we just unregistered the host node then
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * clear the host DID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Unreg all */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SLI3_SUPPORT */
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} /* emlxs_mb_unreg_rpi() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_unreg_did Issue a UNREG_DID 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 /* 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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If the prev_did != 0 then we can look for the hosts
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * last known DID node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure the node does already exist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If we just unregistered the host node then
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * clear the host DID
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* SLI3_SUPPORT */
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} /* End emlxs_mb_unreg_did */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_mask Issue a SET MASK mailbox command
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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_debug Issue a special debug mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_set_debug(emlxs_hba_t *hba, MAILBOX *mb, uint32_t word0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End emlxs_mb_set_debug */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_set_var Issue a special debug mbox command to write slim
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_mb_set_var(emlxs_hba_t *hba, MAILBOX *mb, uint32_t addr,
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} /* End emlxs_disable_tc */
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].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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
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} /* emlxs_mb_reg_vpi() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX | MEM_PRI))) {
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} /* emlxs_mb_unreg_vpi() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_config_farp Issue a CONFIG FARP mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_config_farp(emlxs_hba_t *hba, MAILBOX *mb)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)&mb->un.varCfgFarp.portname, sizeof (NAME_TYPE));
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)&mb->un.varCfgFarp.nodename, sizeof (NAME_TYPE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_config_farp() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * emlxs_mb_read_nv Issue a READ CONFIG mailbox command
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.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * CALLED FROM: emlxs_sli_issue_mbox_cmd
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * INPUT: hba - pointer to the device info area
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * mbp - pointer to mailbox queue entry of mailbox cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: NULL - command queued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queue command to end of list
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((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
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan p_first = (MAILBOXQ *)hba->mbox_queue.q_first;
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)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* FMA_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the Mailbox timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize mailbox */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* MBOX_EXT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_init() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_mb_fini(emlxs_hba_t *hba, MAILBOX *mb, uint32_t mbxStatus)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* MBOX_EXT_SUPPORT */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Copy the local mailbox provided back into */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the 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",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#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 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_sli_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 count = sizeof (emlxs_mb_cmd_table) / sizeof (emlxs_table_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* emlxs_mb_cmd_xlate() */