fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Copyright (c) 2004-2012 Emulex. All rights reserved.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_DIAG_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_diag_pattern[256] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Walking ones */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x80000000, 0x40000000, 0x20000000, 0x10000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x08000000, 0x04000000, 0x02000000, 0x01000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00800000, 0x00400000, 0x00200000, 0x00100000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00080000, 0x00040000, 0x00020000, 0x00010000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00008000, 0x00004000, 0x00002000, 0x00001000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000800, 0x00000400, 0x00000200, 0x00000100,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000080, 0x00000040, 0x00000020, 0x00000010,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000008, 0x00000004, 0x00000002, 0x00000001,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Walking zeros */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x7fffffff, 0xbfffffff, 0xdfffffff, 0xefffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xf7ffffff, 0xfbffffff, 0xfdffffff, 0xfeffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xff7fffff, 0xffbfffff, 0xffdfffff, 0xffefffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xfff7ffff, 0xfffbffff, 0xfffdffff, 0xfffeffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffff7fff, 0xffffbfff, 0xffffdfff, 0xffffefff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xfffff7ff, 0xfffffbff, 0xfffffdff, 0xfffffeff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffff7f, 0xffffffbf, 0xffffffdf, 0xffffffef,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xfffffff7, 0xfffffffb, 0xfffffffd, 0xfffffffe,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all zeros */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x00000000, 0x00000000, 0x00000000, 0x00000000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all ones */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all 5's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x55555555, 0x55555555, 0x55555555, 0x55555555,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all a's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all 5a's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a, 0x5a5a5a5a,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all a5's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5, 0xa5a5a5a5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Default pkt callback routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_pkt_callback(fc_packet_t *pkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = (emlxs_port_t *)pkt->pkt_ulp_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the completed flag and wake up sleeping threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_tran_flags |= FC_TRAN_COMPLETED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_PKT_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_pkt_callback() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_echo_run(emlxs_port_t *port, uint32_t did, uint32_t pattern)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t pkt_ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ELS_PKT *els;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t timeout;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *pkt_resp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *pattern_buffer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *lptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *pat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check did */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (did == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did = port->did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if device is ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->state < FC_LINK_UP) || (port->did == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_TRAN_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for the host node */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld ndlp = emlxs_node_find_did(port, port->did, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ndlp || !ndlp->nlp_active) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_TRAN_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length = 124;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Prepare ECHO pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(pkt = emlxs_pkt_alloc(port, sizeof (uint32_t) + length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t) + length, 0, KM_NOSLEEP))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: Unable to allocate packet. size=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint32_t) + length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_NOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pkt initialization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_tran_type = FC_PKT_EXCHANGE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_timeout = 60;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build the fc header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.d_id = did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.r_ctl = R_CTL_EXTENDED_SVC | R_CTL_UNSOL_CONTROL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.s_id = port->did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.type = FC_TYPE_EXTENDED_LS;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan pkt->pkt_cmd_fhdr.f_ctl =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE | F_CTL_END_SEQ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.seq_id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.df_ctl = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.seq_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.ox_id = 0xffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.rx_id = 0xffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_cmd_fhdr.ro = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_comp = emlxs_diag_pkt_callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build the command */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan els = (ELS_PKT *) pkt->pkt_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->elsCode = 0x10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pattern_buffer = (char *)els->un.pad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pattern) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill the transmit buffer with the pattern */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lptr = (uint32_t *)pattern_buffer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < length; i += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lptr++ = pattern;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Program the default echo pattern */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(pattern_buffer, length);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(pattern_buffer, length,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Emulex. We network storage. Emulex. We network storage. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Emulex. We network storage. Emulex. We network storage.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send ECHO pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = emlxs_pkt_send(pkt, 1)) != FC_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ECHO: Packet send failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for ECHO completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte timeout = emlxs_timeout(hba, (pkt->pkt_timeout + 15));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((pkt_ret != -1) && !(pkt->pkt_tran_flags & FC_TRAN_COMPLETED)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan pkt_ret =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan cv_timedwait(&EMLXS_PKT_CV, &EMLXS_PKT_LOCK, timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PKT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt_ret == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Packet timed out.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_ABORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt->pkt_state != FC_PKT_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Transport error.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_TRANSPORT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response payload */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_resp = (uint8_t *)pkt->pkt_resp + 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pat = (uint8_t *)pattern_buffer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < length; i++, pkt_resp++, pat++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*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,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan *pkt_resp, *pat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EMLXS_TEST_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == FC_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_echo_complete_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "did=%06x length=%d pattern=%02x,%02x,%02x,%02x...",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did, length, pattern_buffer[0] & 0xff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pattern_buffer[1] & 0xff, pattern_buffer[2] & 0xff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pattern_buffer[3] & 0xff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the echo pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_free(pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_echo_run() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_biu_run(emlxs_hba_t *hba, uint32_t pattern)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld MAILBOXQ *mbq = NULL;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld MATCHMAP *mp = NULL;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld MATCHMAP *mp1 = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *inptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *outptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *lptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if device is ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state < FC_LINK_DOWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: HBA not ready.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_TRAN_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a buffer which will be used for the mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: Mailbox allocation failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_NOMEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup and issue mailbox RUN BIU DIAG command Setup test buffers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
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 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BIU: Buffer allocation failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_NOMEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pattern) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill the transmit buffer with the pattern */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lptr = (uint32_t *)mp->virt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MEM_ELSBUF_SIZE; i += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lptr++ = pattern;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the default pattern into the trasmit buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)&emlxs_diag_pattern[0], (caddr_t)mp->virt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MEM_ELSBUF_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp->dma_handle, 0, MEM_ELSBUF_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(mp1->virt, MEM_ELSBUF_SIZE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create the biu diag request */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_mb_run_biu_diag(hba, mbq, mp->phys, mp1->phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, MBX_WAIT, 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == MBX_TIMEOUT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "BUI diagnostic timed out.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EMLXS_TEST_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outptr = mp->virt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inptr = mp1->virt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MEM_ELSBUF_SIZE; i++, outptr++, inptr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*outptr != *inptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Data miscompare. Offset %d value %02x should "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "be %02x.", i, *inptr, *outptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EMLXS_TEST_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait half second before returning */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte delay(drv_usectohz(500000));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_complete_msg, "Status Good.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (mp) {
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#ifdef FMA_SUPPORT
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan if (emlxs_fm_check_dma_handle(hba, mp->dma_handle)
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan != DDI_FM_OK) {
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan &emlxs_invalid_dma_handle_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "diag_biu_run: hdl=%p",
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan mp->dma_handle);
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan rval = EMLXS_TEST_FAILED;
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan }
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_BUF, (void *)mp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (mp1) {
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#ifdef FMA_SUPPORT
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan if (emlxs_fm_check_dma_handle(hba, mp1->dma_handle)
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan != DDI_FM_OK) {
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan &emlxs_invalid_dma_handle_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "diag_biu_run: hdl=%p",
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan mp1->dma_handle);
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan rval = EMLXS_TEST_FAILED;
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan }
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_BUF, (void *)mp1);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (mbq) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_MBOX, (void *)mbq);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_biu_run() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_diag_post_run(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "POST: HBA shutdown.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FC_TRAN_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take board offline */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((rval = emlxs_offline(hba, 0))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to take adapter offline.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_RESETFAIL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restart the adapter */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = EMLXS_SLI_HBA_RESET(hba, 1, 1, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (rval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_online(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_complete_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Status good.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1: /* failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA reset failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_RESETFAIL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: /* failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA busy. Quiece and retry.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = FC_STATEC_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_diag_post_run() */