fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard/*
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard * Copyright 2009 QLogic Corporation. All rights reserved.
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard * Use is subject to license terms.
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard */
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _QLT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _QLT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#include <sys/stmf_defines.h>
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#include "qlt_regs.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Qlogic logging
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int enable_extended_logging;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Caution: 1) LOG will be available in debug/non-debug mode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2) Anything which can potentially flood the log should be under
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extended logging, and use QLT_EXT_LOG.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 3) Don't use QLT_EXT_LOG in performance-critical code path, such
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as normal SCSI I/O code path. It could hurt system performance.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 4) Use kmdb to change enable_extened_logging in the fly to adjust
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tracing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_EXT_LOG(log_ident, ...) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enable_extended_logging) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(log_ident, __VA_ARGS__); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_LOG(log_ident, ...) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(log_ident, __VA_ARGS__)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Error codes. FSC stands for Failure sub code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FAILURE FCT_FCA_FAILURE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_SUCCESS FCT_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FSC(x) ((uint64_t)(x) << 40)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_DMA_STUCK (QLT_FAILURE | QLT_FSC(1))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MAILBOX_STUCK (QLT_FAILURE | QLT_FSC(2))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_ROM_STUCK (QLT_FAILURE | QLT_FSC(3))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_UNEXPECTED_RESPONSE (QLT_FAILURE | QLT_FSC(4))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MBOX_FAILED (QLT_FAILURE | QLT_FSC(5))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MBOX_NOT_INITIALIZED (QLT_FAILURE | QLT_FSC(6))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MBOX_BUSY (QLT_FAILURE | QLT_FSC(7))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MBOX_ABORTED (QLT_FAILURE | QLT_FSC(8))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MBOX_TIMEOUT (QLT_FAILURE | QLT_FSC(9))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_RESP_TIMEOUT (QLT_FAILURE | QLT_FSC(10))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FLASH_TIMEOUT (QLT_FAILURE | QLT_FSC(11))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FLASH_ACCESS_ERROR (QLT_FAILURE | QLT_FSC(12))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_BAD_NVRAM_DATA (QLT_FAILURE | QLT_FSC(13))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FIRMWARE_ERROR_CODE (QLT_FAILURE | QLT_FSC(14))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FIRMWARE_ERROR(s, c1, c2) (QLT_FIRMWARE_ERROR_CODE | \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((uint64_t)s) << 32) | (((uint64_t)c1) << 24) | ((uint64_t)c2))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_code01[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_length01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_addr01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_code02[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_length02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2400_addr02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_code01[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_length01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_addr01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_code02[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_length02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fw2500_addr02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_code01[];
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_length01;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_addr01;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_code02[];
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_length02;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardextern uint32_t fw8100_addr02;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_STATE_UNKNOWN = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_STATE_READY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_STATE_CMD_RUNNING,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MBOX_STATE_CMD_DONE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} mbox_state_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard/*
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard * ISP mailbox commands
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOAD_RAM 0x01 /* Load RAM. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_EXECUTE_FIRMWARE 0x02 /* Execute firmware. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_DUMP_RAM 0x03 /* Dump RAM. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_WRITE_RAM_WORD 0x04 /* Write RAM word. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_READ_RAM_WORD 0x05 /* Read RAM word. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_MAILBOX_REGISTER_TEST 0x06 /* Wrap incoming mailboxes */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_VERIFY_CHECKSUM 0x07 /* Verify checksum. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ABOUT_FIRMWARE 0x08 /* About Firmware. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_DUMP_RISC_RAM 0x0a /* Dump RISC RAM command. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOAD_RAM_EXTENDED 0x0b /* Load RAM extended. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_DUMP_RAM_EXTENDED 0x0c /* Dump RAM extended. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_WRITE_RAM_EXTENDED 0x0d /* Write RAM word. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_READ_RAM_EXTENDED 0x0f /* Read RAM extended. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SERDES_TRANSMIT_PARAMETERS 0x10 /* Serdes Xmit Parameters */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_2300_EXECUTE_IOCB 0x12 /* ISP2300 Execute IOCB cmd */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_IO_STATUS 0x12 /* ISP2422 Get I/O Status */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_STOP_FIRMWARE 0x14 /* Stop firmware */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ABORT_COMMAND_IOCB 0x15 /* Abort IOCB command. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_RESET 0x18 /* Target reset. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_XMIT_PARM 0x19 /* Change default xmit parms */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_PORT_PARAM 0x1a /* Get/set port speed parms */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_ID 0x20 /* Get loop id of ISP2200. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_TIMEOUT_PARAMETERS 0x22 /* Get Timeout Parameters. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_TRACE_CONTROL 0x27 /* Trace control. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_FIRMWARE_OPTIONS 0x28 /* Get firmware options */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_READ_SFP 0x31 /* Read SFP. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SET_ADDITIONAL_FIRMWARE_OPT 0x38 /* set firmware options */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define OPT_PUREX_ENABLE (BIT_10)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_RESET_MENLO 0x3a /* Reset Menlo. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_RESTART_MPI 0x3d /* Restart MPI. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_FLASH_ACCESS 0x3e /* Flash Access Control */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOOP_PORT_BYPASS 0x40 /* Loop Port Bypass. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOOP_PORT_ENABLE 0x41 /* Loop Port Enable. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_RESOURCE_COUNTS 0x42 /* Get Resource Counts. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_NON_PARTICIPATE 0x43 /* Non-Participating Mode. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ECHO 0x44 /* ELS ECHO */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ONLINE_SELF_TEST 0x46 /* Online self-test. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get Port Database + login */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_INITIALIZE_MULTI_ID_FW 0x48 /* Initialize multi-id fw */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_DCBX_PARAMS 0x51 /* Get DCBX parameters */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_RESET_LINK_STATUS 0x52 /* Reset Link Error Status */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_EXECUTE_IOCB 0x54 /* 64 Bit Execute IOCB cmd. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SEND_RNID_ELS 0x57 /* Send RNID ELS request */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SET_PARAMETERS 0x59 /* Set parameters */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define RNID_PARAMS_DF_FMT 0x00
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define RNID_PARAMS_E0_FMT 0x01
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define PUREX_ELS_CMDS 0x05
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define FLOGI_PARAMS 0x06
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define PARAM_TYPE_FIELD_MASK 0xff
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define PARAM_TYPE_FIELD_SHIFT 8
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define PARAM_TYPE(type) ((type & PARAM_TYPE_FIELD_MASK) << \
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard PARAM_TYPE_FIELD_SHIFT)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_PARAMETERS 0x5a /* Get RNID parameters */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_DATA_RATE 0x5d /* Data Rate */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_INITIALIZE_FIRMWARE 0x60 /* Initialize firmware */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_INITIATE_LIP 0x62 /* Initiate LIP */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_PORT_DATABASE 0x64 /* Get Port Database. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_CLEAR_ACA 0x65 /* Clear ACA. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_TARGET_RESET 0x66 /* Target Reset. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_CLEAR_TASK_SET 0x67 /* Clear Task Set. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_ABORT_TASK_SET 0x68 /* Abort Task Set. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_FIRMWARE_STATE 0x69 /* Get firmware state. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_PORT_NAME 0x6a /* Get port name. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_LINK_STATUS 0x6b /* Get Link Status. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LIP_RESET 0x6c /* LIP reset. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_STATUS_COUNTS 0x6d /* Get Link Statistics and */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard /* Private Data Counts */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SEND_SNS_COMMAND 0x6e /* Send Simple Name Server */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOGIN_FABRIC_PORT 0x6f /* Login fabric port. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SEND_CHANGE_REQUEST 0x70 /* Send Change Request. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOGOUT_FABRIC_PORT 0x71 /* Logout fabric port. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LIP_FULL_LOGIN 0x72 /* Full login LIP. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LOGIN_LOOP_PORT 0x74 /* Login Loop Port. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_PORT_NODE_NAME_LIST 0x75 /* Get port/node name list */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_INITIALIZE_IP 0x77 /* Initialize IP */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SEND_FARP_REQ_COMMAND 0x78 /* FARP request. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_UNLOAD_IP 0x79 /* Unload IP */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_XGMAC_STATS 0x7a /* Get XGMAC Statistics. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_ID_LIST 0x7c /* Get port ID list. */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SEND_LFA_COMMAND 0x7d /* Send Loop Fabric Address */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_LUN_RESET 0x7e /* Send Task mgmt LUN reset */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_IDC_REQUEST 0x100 /* IDC request */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_IDC_ACK 0x101 /* IDC acknowledge */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_IDC_TIME_EXTEND 0x102 /* IDC extend time */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_PORT_RESET 0x120 /* Port Reset */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_SET_PORT_CONFIG 0x122 /* Set port configuration */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MBC_GET_PORT_CONFIG 0x123 /* Get port configuration */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IOCB_SIZE 64
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These should not be constents but should be obtained from fw.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MAX_LOGINS 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MAX_XCHGES 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_MBOXES 32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MBOX_TIMEOUT (2*1000*1000)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEREG_RP_TIMEOUT (2*1000*1000)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t to_fw[MAX_MBOXES];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t to_fw_mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t from_fw[MAX_MBOXES];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t from_fw_mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_data_buf_t *dbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} mbox_cmd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct qlt_abts_cmd {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t buf[IOCB_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} qlt_abts_cmd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct qlt_dmem_bucket;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moorestruct qlt_ddi_dma_handle_pool;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_INTR_FIXED 0x1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_INTR_MSI 0x2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_INTR_MSIX 0x4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardtypedef struct qlt_el_trace_desc {
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard kmutex_t mutex;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard uint16_t next;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard uint32_t trace_buffer_size;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard char *trace_buffer;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard} qlt_el_trace_desc_t;
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct qlt_state {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_info_t *dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char qlt_minor_name[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char qlt_port_alias[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_local_port_t *qlt_port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct qlt_dmem_bucket **dmem_buckets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore struct qlt_dma_handle_pool
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore *qlt_dma_handle_pool;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t qlt_state:7,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlt_state_not_acked:1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t qlt_intr_enabled:1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlt_25xx_chip:1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlt_stay_offline:1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlt_link_up,
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard qlt_81xx_chip:1,
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard qlt_rsvd1:3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t cur_topology;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Registers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t regs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_acc_handle_t regs_acc_handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_acc_handle_t pcicfg_acc_handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Interrupt stuff */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t intr_lock; /* Only used by intr routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int intr_sneak_counter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_intr_handle_t *htable;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int intr_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int intr_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t intr_pri;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int intr_cap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int intr_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Queues */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_handle_t queue_mem_dma_handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_acc_handle_t queue_mem_acc_handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t queue_mem_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t queue_mem_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t req_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t req_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t req_ndx_to_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t req_ndx_from_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t req_available;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t resp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t resp_ndx_to_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t resp_ndx_from_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t preq_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t preq_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t preq_ndx_to_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t preq_ndx_from_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t rp_dereg_cv; /* for deregister cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rp_id_in_dereg; /* remote port in deregistering */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_status_t rp_dereg_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t atio_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t atio_ndx_to_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t atio_ndx_from_fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t dma_mem_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* MailBox data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t mbox_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t mbox_cv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_state_t mbox_io_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbox_cmd_t *mcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlt_nvram_t *nvram;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t link_speed; /* Cached from intr routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_major;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_minor;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_subminor;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_endaddrlo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_endaddrhi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t fw_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_addr01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_length01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *fw_code01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_addr02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_length02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *fw_code02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t qlt_ioctl_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t qlt_ioctl_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t qlt_fwdump_buf; /* FWDUMP will use ioctl flags/lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t qlt_change_state_flags; /* Cached for ACK handling */
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard qlt_el_trace_desc_t *el_trace_desc;
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard /* temp ref & stat counters */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard uint32_t qlt_bucketcnt[5]; /* element 0 = 2k */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard uint64_t qlt_bufref[5]; /* element 0 = 2k */
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard uint64_t qlt_bumpbucket; /* bigger buffer supplied */
3f3ce7b9c6904157b36f09490c71d18c41312a06Daniel Beauregard uint64_t qlt_pmintry;
3f3ce7b9c6904157b36f09490c71d18c41312a06Daniel Beauregard uint64_t qlt_pmin_ok;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} qlt_state_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FWDUMP flags (part of IOCTL flags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FWDUMP_INPROGRESS 0x0100 /* if it's dumping now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FWDUMP_TRIGGERED_BY_USER 0x0200 /* if users triggered it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FWDUMP_FETCHED_BY_USER 0x0400 /* if users have viewed it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_FWDUMP_ISVALID 0x0800
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL supporting stuff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_IOCTL_FLAG_MASK 0xFF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_IOCTL_FLAG_IDLE 0x00
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_IOCTL_FLAG_OPEN 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_IOCTL_FLAG_EXCL 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct qlt_cmd {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_data_buf_t *dbuf; /* dbuf with handle 0 for SCSI cmds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_data_buf_t *dbuf_rsp_iu; /* dbuf for possible FCP_RSP IU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_xchg_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte union {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t resp_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t atio_byte3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } param;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} qlt_cmd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_CMD_ABORTING 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_CMD_ABORTED 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_CMD_TYPE_SOLICITED 4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int dummy;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} qlt_remote_port_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REQUEST_QUEUE_ENTRIES 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RESPONSE_QUEUE_ENTRIES 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ATIO_QUEUE_ENTRIES 2048
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRIORITY_QUEUE_ENTRIES 128
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REQUEST_QUEUE_OFFSET 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RESPONSE_QUEUE_OFFSET (REQUEST_QUEUE_OFFSET + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (REQUEST_QUEUE_ENTRIES * IOCB_SIZE))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ATIO_QUEUE_OFFSET (RESPONSE_QUEUE_OFFSET + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (RESPONSE_QUEUE_ENTRIES * IOCB_SIZE))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRIORITY_QUEUE_OFFSET (ATIO_QUEUE_OFFSET + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ATIO_QUEUE_ENTRIES * IOCB_SIZE))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MBOX_DMA_MEM_SIZE 4096
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MBOX_DMA_MEM_OFFSET (PRIORITY_QUEUE_OFFSET + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (PRIORITY_QUEUE_ENTRIES * IOCB_SIZE))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TOTAL_DMA_MEM_SIZE (MBOX_DMA_MEM_OFFSET + MBOX_DMA_MEM_SIZE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QLT_MAX_ITERATIONS_PER_INTR 32
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#define QLT_INFO_LEN 160
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REG_RD16(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get16(qlt->regs_acc_handle, (uint16_t *)(qlt->regs + addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REG_RD32(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get32(qlt->regs_acc_handle, (uint32_t *)(qlt->regs + addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REG_WR16(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(qlt->regs_acc_handle, (uint16_t *)(qlt->regs + addr), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(data))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REG_WR32(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(qlt->regs_acc_handle, (uint32_t *)(qlt->regs + addr), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)(data))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PCICFG_RD16(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_config_get16(qlt->pcicfg_acc_handle, (off_t)(addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PCICFG_RD32(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_config_get32(qlt->pcicfg_acc_handle, (off_t)(addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PCICFG_WR16(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_config_put16(qlt->pcicfg_acc_handle, (off_t)(addr), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(data))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QMEM_RD16(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get16(qlt->queue_mem_acc_handle, (uint16_t *)(addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DMEM_RD16(qlt, addr) LE_16((uint16_t)(*((uint16_t *)(addr))))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QMEM_RD32(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get32(qlt->queue_mem_acc_handle, (uint32_t *)(addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DMEM_RD32(qlt, addr) LE_32((uint32_t)(*((uint32_t *)(addr))))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * #define QMEM_RD64(qlt, addr) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ddi_get64(qlt->queue_mem_acc_handle, (uint64_t *)(addr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QMEM_WR16(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(qlt->queue_mem_acc_handle, (uint16_t *)(addr), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(data))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DMEM_WR16(qlt, addr, data) (*((uint16_t *)(addr)) = \
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard (uint16_t)LE_16((uint16_t)(data)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QMEM_WR32(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(qlt->queue_mem_acc_handle, (uint32_t *)(addr), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)(data))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DMEM_WR32(qlt, addr, data) (*((uint32_t *)(addr)) = \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32((uint32_t)(data)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * [QD]MEM is always little endian so the [QD]MEM_WR64 macro works for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * both sparc and x86.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define QMEM_WR64(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QMEM_WR32(qlt, addr, (data & 0xffffffff)), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QMEM_WR32(qlt, (addr)+4, ((uint64_t)data) >> 32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DMEM_WR64(qlt, addr, data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DMEM_WR32(qlt, addr, (data & 0xffffffff)), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DMEM_WR32(qlt, (addr)+4, ((uint64_t)data) >> 32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard/*
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard * Structure used to associate values with strings which describe them.
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard */
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregardtypedef struct string_table_entry {
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard uint32_t value;
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard char *string;
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard} string_table_t;
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregardchar *prop_text(int prop_status);
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregardchar *value2string(string_table_t *entry, int value, int delimiter);
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define PROP_STATUS_DELIMITER ((uint32_t)0xFFFF)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define DDI_PROP_STATUS() \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard{ \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_SUCCESS, "DDI_PROP_SUCCESS"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_NOT_FOUND, "DDI_PROP_NOT_FOUND"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_UNDEFINED, "DDI_PROP_UNDEFINED"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_NO_MEMORY, "DDI_PROP_NO_MEMORY"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_INVAL_ARG, "DDI_PROP_INVAL_ARG"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_BUF_TOO_SMALL, "DDI_PROP_BUF_TOO_SMALL"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_CANNOT_DECODE, "DDI_PROP_CANNOT_DECODE"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_CANNOT_ENCODE, "DDI_PROP_CANNOT_ENCODE"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {DDI_PROP_END_OF_DATA, "DDI_PROP_END_OF_DATA"}, \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard {PROP_STATUS_DELIMITER, "DDI_PROP_UNKNOWN"} \
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard}
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#ifndef TRUE
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define TRUE B_TRUE
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#endif
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#ifndef FALSE
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define FALSE B_FALSE
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#endif
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard/* Little endian machine correction defines. */
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#ifdef _LITTLE_ENDIAN
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_16(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_24(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_32(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_64(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN(bp, bytes)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_16(x) qlt_chg_endian((uint8_t *)x, 2)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_24(x) qlt_chg_endian((uint8_t *)x, 3)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_32(x) qlt_chg_endian((uint8_t *)x, 4)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_64(x) qlt_chg_endian((uint8_t *)x, 8)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN(bp, bytes) qlt_chg_endian((uint8_t *)bp, bytes)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#endif /* _LITTLE_ENDIAN */
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard/* Big endian machine correction defines. */
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#ifdef _BIG_ENDIAN
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_16(x) qlt_chg_endian((uint8_t *)x, 2)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_24(x) qlt_chg_endian((uint8_t *)x, 3)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_32(x) qlt_chg_endian((uint8_t *)x, 4)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN_64(x) qlt_chg_endian((uint8_t *)x, 8)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define LITTLE_ENDIAN(bp, bytes) qlt_chg_endian((uint8_t *)bp, bytes)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_16(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_24(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_32(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN_64(x)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#define BIG_ENDIAN(bp, bytes)
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard#endif /* _BIG_ENDIAN */
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define LSB(x) (uint8_t)(x)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MSB(x) (uint8_t)((uint16_t)(x) >> 8)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MSW(x) (uint16_t)((uint32_t)(x) >> 16)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define LSW(x) (uint16_t)(x)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define LSD(x) (uint32_t)(x)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard#define MSD(x) (uint32_t)((uint64_t)(x) >> 32)
a2255df3e7bbadf7b06c76c8226a1f6f5bbc9e07Daniel Beauregard
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregardvoid qlt_chg_endian(uint8_t *, size_t);
0ff6bfafbd510fac2721570482eceb0d24afe291Daniel Beauregard
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardvoid qlt_el_msg(qlt_state_t *qlt, const char *fn, int ce, ...);
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregardvoid qlt_dump_el_trace_buffer(qlt_state_t *qlt);
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard#define EL(qlt, ...) qlt_el_msg(qlt, __func__, CE_CONT, __VA_ARGS__);
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard#define EL_TRACE_BUF_SIZE 8192
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard#define EL_BUFFER_RESERVE 256
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard#define DEBUG_STK_DEPTH 24
c4ddbbe1ca066fd6662bdb8c477ad412b97c5590Daniel Beauregard#define EL_TRACE_BUF_SIZE 8192
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _QLT_H */