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.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * You can obtain a copy of the license at
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
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
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Copyright (c) 2004-2012 Emulex. All rights reserved.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Walking ones */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Walking zeros */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all zeros */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all ones */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all 5's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all a's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all 5a's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all a5's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Default pkt callback routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = (emlxs_port_t *)pkt->pkt_ulp_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the completed flag and wake up sleeping threads */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_pkt_callback() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_echo_run(emlxs_port_t *port, uint32_t did, uint32_t pattern)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if device is ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->state < FC_LINK_UP) || (port->did == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for the host node */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld ndlp = emlxs_node_find_did(port, port->did, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Prepare ECHO pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(pkt = emlxs_pkt_alloc(port, sizeof (uint32_t) + length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: Unable to allocate packet. size=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pkt initialization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build the fc header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.r_ctl = R_CTL_EXTENDED_SVC | R_CTL_UNSOL_CONTROL;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE | F_CTL_END_SEQ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build the command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill the transmit buffer with the pattern */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Program the default echo pattern */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Emulex. We network storage. Emulex. We network storage. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Emulex. We network storage. Emulex. We network storage.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send ECHO pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = emlxs_pkt_send(pkt, 1)) != FC_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: Packet send failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for ECHO completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte timeout = emlxs_timeout(hba, (pkt->pkt_timeout + 15));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((pkt_ret != -1) && !(pkt->pkt_tran_flags & FC_TRAN_COMPLETED)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan cv_timedwait(&EMLXS_PKT_CV, &EMLXS_PKT_LOCK, timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Packet timed out.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Transport error.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response payload */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < length; i++, pkt_resp++, pat++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Data miscompare. did=%06x length=%d. Offset %d "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "value %02x should be %02x.", did, length, i,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_complete_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "did=%06x length=%d pattern=%02x,%02x,%02x,%02x...",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pattern_buffer[1] & 0xff, pattern_buffer[2] & 0xff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the echo pkt */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_echo_run() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_biu_run(emlxs_hba_t *hba, uint32_t pattern)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if device is ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a buffer which will be used for the mailbox command
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: Mailbox allocation failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup and issue mailbox RUN BIU DIAG command Setup test buffers
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0) ||
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld ((mp1 = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: Buffer allocation failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill the transmit buffer with the pattern */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the default pattern into the trasmit buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)&emlxs_diag_pattern[0], (caddr_t)mp->virt,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp->dma_handle, 0, MEM_ELSBUF_SIZE,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create the biu diag request */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_mb_run_biu_diag(hba, mbq, mp->phys, mp1->phys);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, MBX_WAIT, 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BUI diagnostic timed out.");
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MEM_ELSBUF_SIZE; i++, outptr++, inptr++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Data miscompare. Offset %d value %02x should "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait half second before returning */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_complete_msg, "Status Good.");
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan if (emlxs_fm_check_dma_handle(hba, mp->dma_handle)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "diag_biu_run: hdl=%p",
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan if (emlxs_fm_check_dma_handle(hba, mp1->dma_handle)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "diag_biu_run: hdl=%p",
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_biu_run() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "POST: HBA shutdown.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take board offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to take adapter offline.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restart the adapter */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = EMLXS_SLI_HBA_RESET(hba, 1, 1, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_complete_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Status good.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA reset failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA busy. Quiece and retry.");
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_post_run() */