1c3aac50fSPeter Wemm /* $FreeBSD$ */ 2098ca2bdSWarner Losh /*- 32df76c16SMatt Jacob * Copyright (c) 1997-2009 by Matthew Jacob 46054c3f6SMatt Jacob * All rights reserved. 57e90346eSMatt Jacob * 66054c3f6SMatt Jacob * Redistribution and use in source and binary forms, with or without 76054c3f6SMatt Jacob * modification, are permitted provided that the following conditions 86054c3f6SMatt Jacob * are met: 96054c3f6SMatt Jacob * 10e48b2487SMatt Jacob * 1. Redistributions of source code must retain the above copyright 11e48b2487SMatt Jacob * notice, this list of conditions and the following disclaimer. 12e48b2487SMatt Jacob * 2. Redistributions in binary form must reproduce the above copyright 13e48b2487SMatt Jacob * notice, this list of conditions and the following disclaimer in the 14e48b2487SMatt Jacob * documentation and/or other materials provided with the distribution. 15e48b2487SMatt Jacob * 16e48b2487SMatt Jacob * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 176054c3f6SMatt Jacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 186054c3f6SMatt Jacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19e48b2487SMatt Jacob * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 20e48b2487SMatt Jacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 216054c3f6SMatt Jacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 226054c3f6SMatt Jacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 236054c3f6SMatt Jacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 246054c3f6SMatt Jacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 256054c3f6SMatt Jacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 266054c3f6SMatt Jacob * SUCH DAMAGE. 272df76c16SMatt Jacob * 286054c3f6SMatt Jacob */ 29e48b2487SMatt Jacob /* 30e48b2487SMatt Jacob * Soft Definitions for for Qlogic ISP SCSI adapters. 31e48b2487SMatt Jacob */ 326054c3f6SMatt Jacob 336054c3f6SMatt Jacob #ifndef _ISPVAR_H 346054c3f6SMatt Jacob #define _ISPVAR_H 356054c3f6SMatt Jacob 3657c801f5SMatt Jacob #if defined(__NetBSD__) || defined(__OpenBSD__) 3710365e5aSMatt Jacob #include <dev/ic/isp_stds.h> 386054c3f6SMatt Jacob #include <dev/ic/ispmbox.h> 396054c3f6SMatt Jacob #endif 406054c3f6SMatt Jacob #ifdef __FreeBSD__ 4110365e5aSMatt Jacob #include <dev/isp/isp_stds.h> 426054c3f6SMatt Jacob #include <dev/isp/ispmbox.h> 436054c3f6SMatt Jacob #endif 446054c3f6SMatt Jacob #ifdef __linux__ 4510365e5aSMatt Jacob #include "isp_stds.h" 46c3055363SMatt Jacob #include "ispmbox.h" 4780ae5655SMatt Jacob #endif 481dae40ebSMatt Jacob #ifdef __svr4__ 4910365e5aSMatt Jacob #include "isp_stds.h" 501dae40ebSMatt Jacob #include "ispmbox.h" 516054c3f6SMatt Jacob #endif 526054c3f6SMatt Jacob 53c8b8a2c4SMatt Jacob #define ISP_CORE_VERSION_MAJOR 7 5410365e5aSMatt Jacob #define ISP_CORE_VERSION_MINOR 0 55478f8a96SJustin T. Gibbs 566054c3f6SMatt Jacob /* 57cbf57b47SMatt Jacob * Vector for bus specific code to provide specific services. 586054c3f6SMatt Jacob */ 591dae40ebSMatt Jacob typedef struct ispsoftc ispsoftc_t; 606054c3f6SMatt Jacob struct ispmdvec { 612df76c16SMatt Jacob int (*dv_rd_isr) (ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); 6210365e5aSMatt Jacob uint32_t (*dv_rd_reg) (ispsoftc_t *, int); 6310365e5aSMatt Jacob void (*dv_wr_reg) (ispsoftc_t *, int, uint32_t); 641dae40ebSMatt Jacob int (*dv_mbxdma) (ispsoftc_t *); 652df76c16SMatt Jacob int (*dv_dmaset) (ispsoftc_t *, XS_T *, void *); 6610365e5aSMatt Jacob void (*dv_dmaclr) (ispsoftc_t *, XS_T *, uint32_t); 671dae40ebSMatt Jacob void (*dv_reset0) (ispsoftc_t *); 681dae40ebSMatt Jacob void (*dv_reset1) (ispsoftc_t *); 691dae40ebSMatt Jacob void (*dv_dregs) (ispsoftc_t *, const char *); 705f634111SMatt Jacob const void * dv_ispfw; /* ptr to f/w */ 711dae40ebSMatt Jacob uint16_t dv_conf1; 721dae40ebSMatt Jacob uint16_t dv_clock; /* clock frequency */ 736054c3f6SMatt Jacob }; 746054c3f6SMatt Jacob 7553cff3bbSMatt Jacob /* 7653cff3bbSMatt Jacob * Overall parameters 7753cff3bbSMatt Jacob */ 786054c3f6SMatt Jacob #define MAX_TARGETS 16 792df76c16SMatt Jacob #ifndef MAX_FC_TARG 80f7c631bcSMatt Jacob #define MAX_FC_TARG 512 812df76c16SMatt Jacob #endif 820f747d72SMatt Jacob #define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) 835e09512cSMatt Jacob #define ISP_MAX_LUNS(isp) (isp)->isp_maxluns 840f747d72SMatt Jacob 85126ec864SMatt Jacob /* 8653cff3bbSMatt Jacob * Macros to access ISP registers through bus specific layers- 8753cff3bbSMatt Jacob * mostly wrappers to vector through the mdvec structure. 8880ae5655SMatt Jacob */ 89126ec864SMatt Jacob #define ISP_READ_ISR(isp, isrp, semap, mbox0p) \ 90126ec864SMatt Jacob (*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p) 9180ae5655SMatt Jacob 9280ae5655SMatt Jacob #define ISP_READ(isp, reg) \ 9380ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 9480ae5655SMatt Jacob 9580ae5655SMatt Jacob #define ISP_WRITE(isp, reg, val) \ 9680ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 9780ae5655SMatt Jacob 9880ae5655SMatt Jacob #define ISP_MBOXDMASETUP(isp) \ 9980ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 10080ae5655SMatt Jacob 1012df76c16SMatt Jacob #define ISP_DMASETUP(isp, xs, req) \ 1022df76c16SMatt Jacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req)) 10380ae5655SMatt Jacob 10480ae5655SMatt Jacob #define ISP_DMAFREE(isp, xs, hndl) \ 10580ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_dmaclr) \ 10680ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) 10780ae5655SMatt Jacob 10880ae5655SMatt Jacob #define ISP_RESET0(isp) \ 10980ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 11080ae5655SMatt Jacob #define ISP_RESET1(isp) \ 11180ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 11253cff3bbSMatt Jacob #define ISP_DUMPREGS(isp, m) \ 11353cff3bbSMatt Jacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) 11480ae5655SMatt Jacob 11580ae5655SMatt Jacob #define ISP_SETBITS(isp, reg, val) \ 11680ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 11780ae5655SMatt Jacob 11880ae5655SMatt Jacob #define ISP_CLRBITS(isp, reg, val) \ 11980ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 12080ae5655SMatt Jacob 12153cff3bbSMatt Jacob /* 12253cff3bbSMatt Jacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization 12353cff3bbSMatt Jacob * on Request and Response Queues, Scratch DMA areas, and Registers) 12453cff3bbSMatt Jacob * 12553cff3bbSMatt Jacob * Defined Memory Barrier Synchronization Types 12653cff3bbSMatt Jacob */ 12753cff3bbSMatt Jacob #define SYNC_REQUEST 0 /* request queue synchronization */ 12853cff3bbSMatt Jacob #define SYNC_RESULT 1 /* result queue synchronization */ 12953cff3bbSMatt Jacob #define SYNC_SFORDEV 2 /* scratch, sync for ISP */ 13053cff3bbSMatt Jacob #define SYNC_SFORCPU 3 /* scratch, sync for CPU */ 13153cff3bbSMatt Jacob #define SYNC_REG 4 /* for registers */ 13210365e5aSMatt Jacob #define SYNC_ATIOQ 5 /* atio result queue (24xx) */ 13353cff3bbSMatt Jacob 13453cff3bbSMatt Jacob /* 13553cff3bbSMatt Jacob * Request/Response Queue defines and macros. 13653cff3bbSMatt Jacob * The maximum is defined per platform (and can be based on board type). 13753cff3bbSMatt Jacob */ 13853cff3bbSMatt Jacob /* This is the size of a queue entry (request and response) */ 1396054c3f6SMatt Jacob #define QENTRY_LEN 64 14053cff3bbSMatt Jacob /* Both request and result queue length must be a power of two */ 14153cff3bbSMatt Jacob #define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) 1421923f739SMatt Jacob #ifdef ISP_TARGET_MODE 1431923f739SMatt Jacob #define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) 1441923f739SMatt Jacob #else 14553cff3bbSMatt Jacob #define RESULT_QUEUE_LEN(x) \ 14653cff3bbSMatt Jacob (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) 1471923f739SMatt Jacob #endif 1481dae40ebSMatt Jacob #define ISP_QUEUE_ENTRY(q, idx) (((uint8_t *)q) + ((idx) * QENTRY_LEN)) 1496054c3f6SMatt Jacob #define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 150478f8a96SJustin T. Gibbs #define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 151b6b6ad2fSMatt Jacob #define ISP_QFREE(in, out, qlen) \ 152478f8a96SJustin T. Gibbs ((in == out)? (qlen - 1) : ((in > out)? \ 153478f8a96SJustin T. Gibbs ((qlen - 1) - (in - out)) : (out - in - 1))) 154b6b6ad2fSMatt Jacob #define ISP_QAVAIL(isp) \ 155b6b6ad2fSMatt Jacob ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) 15680ae5655SMatt Jacob 1574fd13c1bSMatt Jacob #define ISP_ADD_REQUEST(isp, nxti) \ 15837bb79f1SMarius Strobl MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1); \ 15910365e5aSMatt Jacob ISP_WRITE(isp, isp->isp_rqstinrp, nxti); \ 1604fd13c1bSMatt Jacob isp->isp_reqidx = nxti 16180ae5655SMatt Jacob 1622df76c16SMatt Jacob #define ISP_SYNC_REQUEST(isp) \ 16337bb79f1SMarius Strobl MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1); \ 1642df76c16SMatt Jacob isp->isp_reqidx = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp)); \ 1652df76c16SMatt Jacob ISP_WRITE(isp, isp->isp_rqstinrp, isp->isp_reqidx) 1662df76c16SMatt Jacob 1676054c3f6SMatt Jacob /* 1688259d081SMatt Jacob * SCSI Specific Host Adapter Parameters- per bus, per target 1696054c3f6SMatt Jacob */ 1706054c3f6SMatt Jacob typedef struct { 1712df76c16SMatt Jacob uint32_t : 8, 1722df76c16SMatt Jacob update : 1, 1732df76c16SMatt Jacob sendmarker : 1, 1742df76c16SMatt Jacob role : 2, 1758259d081SMatt Jacob isp_req_ack_active_neg : 1, 1766054c3f6SMatt Jacob isp_data_line_active_neg: 1, 1776054c3f6SMatt Jacob isp_cmd_dma_burst_enable: 1, 1786054c3f6SMatt Jacob isp_data_dma_burst_enabl: 1, 179128101f3SMatt Jacob isp_fifo_threshold : 3, 18010365e5aSMatt Jacob isp_ptisp : 1, 181cbf57b47SMatt Jacob isp_ultramode : 1, 1826054c3f6SMatt Jacob isp_diffmode : 1, 1834394c92fSMatt Jacob isp_lvdmode : 1, 184b6b6ad2fSMatt Jacob isp_fast_mttr : 1, /* fast sram */ 1856054c3f6SMatt Jacob isp_initiator_id : 4, 1866054c3f6SMatt Jacob isp_async_data_setup : 4; 1871dae40ebSMatt Jacob uint16_t isp_selection_timeout; 1881dae40ebSMatt Jacob uint16_t isp_max_queue_depth; 1891dae40ebSMatt Jacob uint8_t isp_tag_aging; 1901dae40ebSMatt Jacob uint8_t isp_bus_reset_delay; 1911dae40ebSMatt Jacob uint8_t isp_retry_count; 1921dae40ebSMatt Jacob uint8_t isp_retry_delay; 1936054c3f6SMatt Jacob struct { 1941dae40ebSMatt Jacob uint32_t 195d9c272f3SMatt Jacob exc_throttle : 8, 1968259d081SMatt Jacob : 1, 197d9c272f3SMatt Jacob dev_enable : 1, /* ignored */ 198cbf57b47SMatt Jacob dev_update : 1, 199cbf57b47SMatt Jacob dev_refresh : 1, 200d9c272f3SMatt Jacob actv_offset : 4, 201d9c272f3SMatt Jacob goal_offset : 4, 202d9c272f3SMatt Jacob nvrm_offset : 4; 2031dae40ebSMatt Jacob uint8_t actv_period; /* current sync period */ 2041dae40ebSMatt Jacob uint8_t goal_period; /* goal sync period */ 2051dae40ebSMatt Jacob uint8_t nvrm_period; /* nvram sync period */ 2061dae40ebSMatt Jacob uint16_t actv_flags; /* current device flags */ 2071dae40ebSMatt Jacob uint16_t goal_flags; /* goal device flags */ 2081dae40ebSMatt Jacob uint16_t nvrm_flags; /* nvram device flags */ 2096054c3f6SMatt Jacob } isp_devparam[MAX_TARGETS]; 2108259d081SMatt Jacob } sdparam; 2116054c3f6SMatt Jacob 2126054c3f6SMatt Jacob /* 2136054c3f6SMatt Jacob * Device Flags 2146054c3f6SMatt Jacob */ 215478f8a96SJustin T. Gibbs #define DPARM_DISC 0x8000 216478f8a96SJustin T. Gibbs #define DPARM_PARITY 0x4000 217478f8a96SJustin T. Gibbs #define DPARM_WIDE 0x2000 218478f8a96SJustin T. Gibbs #define DPARM_SYNC 0x1000 219478f8a96SJustin T. Gibbs #define DPARM_TQING 0x0800 220478f8a96SJustin T. Gibbs #define DPARM_ARQ 0x0400 221478f8a96SJustin T. Gibbs #define DPARM_QFRZ 0x0200 222478f8a96SJustin T. Gibbs #define DPARM_RENEG 0x0100 223b6b6ad2fSMatt Jacob #define DPARM_NARROW 0x0080 224b6b6ad2fSMatt Jacob #define DPARM_ASYNC 0x0040 225b6b6ad2fSMatt Jacob #define DPARM_PPR 0x0020 22610f20e40SMatt Jacob #define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) 227478f8a96SJustin T. Gibbs #define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) 228478f8a96SJustin T. Gibbs 2294394c92fSMatt Jacob /* technically, not really correct, as they need to be rated based upon clock */ 230b6b6ad2fSMatt Jacob #define ISP_80M_SYNCPARMS 0x0c09 231b6b6ad2fSMatt Jacob #define ISP_40M_SYNCPARMS 0x0c0a 232b6b6ad2fSMatt Jacob #define ISP_20M_SYNCPARMS 0x0c0c 233b6b6ad2fSMatt Jacob #define ISP_20M_SYNCPARMS_1040 0x080c 2346054c3f6SMatt Jacob #define ISP_10M_SYNCPARMS 0x0c19 2356054c3f6SMatt Jacob #define ISP_08M_SYNCPARMS 0x0c25 2366054c3f6SMatt Jacob #define ISP_05M_SYNCPARMS 0x0c32 2376054c3f6SMatt Jacob #define ISP_04M_SYNCPARMS 0x0c41 2386054c3f6SMatt Jacob 2396054c3f6SMatt Jacob /* 2406054c3f6SMatt Jacob * Fibre Channel Specifics 2416054c3f6SMatt Jacob */ 242dd9fc7c3SMatt Jacob /* These are for non-2K Login Firmware cards */ 24310365e5aSMatt Jacob #define FL_ID 0x7e /* FL_Port Special ID */ 24410365e5aSMatt Jacob #define SNS_ID 0x80 /* SNS Server Special ID */ 24510365e5aSMatt Jacob #define NPH_MAX 0xfe 2467e90346eSMatt Jacob 2472df76c16SMatt Jacob /* Use this handle for the base for multi-id firmware SNS logins */ 2482df76c16SMatt Jacob #define NPH_SNS_HDLBASE 0x400 2492df76c16SMatt Jacob 250dd9fc7c3SMatt Jacob /* These are for 2K Login Firmware cards */ 25110365e5aSMatt Jacob #define NPH_RESERVED 0x7F0 /* begin of reserved N-port handles */ 25210365e5aSMatt Jacob #define NPH_MGT_ID 0x7FA /* Management Server Special ID */ 25310365e5aSMatt Jacob #define NPH_SNS_ID 0x7FC /* SNS Server Special ID */ 2542df76c16SMatt Jacob #define NPH_FABRIC_CTLR 0x7FD /* Fabric Controller (0xFFFFFD) */ 2552df76c16SMatt Jacob #define NPH_FL_ID 0x7FE /* F Port Special ID (0xFFFFFE) */ 2562df76c16SMatt Jacob #define NPH_IP_BCST 0x7ff /* IP Broadcast Special ID (0xFFFFFF) */ 257dd9fc7c3SMatt Jacob #define NPH_MAX_2K 0x800 258dd9fc7c3SMatt Jacob 259dd9fc7c3SMatt Jacob /* 260dd9fc7c3SMatt Jacob * "Unassigned" handle to be used internally 261dd9fc7c3SMatt Jacob */ 262dd9fc7c3SMatt Jacob #define NIL_HANDLE 0xffff 263029f13c6SMatt Jacob 26410365e5aSMatt Jacob /* 26510365e5aSMatt Jacob * Limit for devices on an arbitrated loop. 26610365e5aSMatt Jacob */ 26710365e5aSMatt Jacob #define LOCAL_LOOP_LIM 126 26810365e5aSMatt Jacob 26910365e5aSMatt Jacob /* 2702df76c16SMatt Jacob * Limit for (2K login) N-port handle amounts 2712df76c16SMatt Jacob */ 2722df76c16SMatt Jacob #define MAX_NPORT_HANDLE 2048 2732df76c16SMatt Jacob 2742df76c16SMatt Jacob /* 2752df76c16SMatt Jacob * Special Constants 2762df76c16SMatt Jacob */ 2772df76c16SMatt Jacob #define INI_NONE ((uint64_t) 0) 2782df76c16SMatt Jacob #define ISP_NOCHAN 0xff 2792df76c16SMatt Jacob 2802df76c16SMatt Jacob /* 28110365e5aSMatt Jacob * Special Port IDs 28210365e5aSMatt Jacob */ 28310365e5aSMatt Jacob #define MANAGEMENT_PORT_ID 0xFFFFFA 28410365e5aSMatt Jacob #define SNS_PORT_ID 0xFFFFFC 28510365e5aSMatt Jacob #define FABRIC_PORT_ID 0xFFFFFE 2862df76c16SMatt Jacob #define PORT_ANY 0xFFFFFF 2872df76c16SMatt Jacob #define PORT_NONE 0 2882df76c16SMatt Jacob #define DOMAIN_CONTROLLER_BASE 0xFFFC00 2892df76c16SMatt Jacob #define DOMAIN_CONTROLLER_END 0xFFFCFF 29010365e5aSMatt Jacob 291c8b8a2c4SMatt Jacob /* 292c8b8a2c4SMatt Jacob * Command Handles 293c8b8a2c4SMatt Jacob * 294c8b8a2c4SMatt Jacob * Most QLogic initiator or target have 32 bit handles associated with them. 295c8b8a2c4SMatt Jacob * We want to have a quick way to index back and forth between a local SCSI 296c8b8a2c4SMatt Jacob * command context and what the firmware is passing back to us. We also 297c8b8a2c4SMatt Jacob * want to avoid working on stale information. This structure handles both 298c8b8a2c4SMatt Jacob * at the expense of some local memory. 299c8b8a2c4SMatt Jacob * 300c8b8a2c4SMatt Jacob * The handle is architected thusly: 301c8b8a2c4SMatt Jacob * 302c8b8a2c4SMatt Jacob * 0 means "free handle" 303c8b8a2c4SMatt Jacob * bits 0..12 index commands 304c8b8a2c4SMatt Jacob * bits 13..15 bits index usage 305c8b8a2c4SMatt Jacob * bits 16..31 contain a rolling sequence 306c8b8a2c4SMatt Jacob * 307c8b8a2c4SMatt Jacob * 308c8b8a2c4SMatt Jacob */ 309c8b8a2c4SMatt Jacob typedef struct { 310c8b8a2c4SMatt Jacob void * cmd; /* associated command context */ 311c8b8a2c4SMatt Jacob uint32_t handle; /* handle associated with this command */ 312c8b8a2c4SMatt Jacob } isp_hdl_t; 313c8b8a2c4SMatt Jacob #define ISP_HANDLE_FREE 0x00000000 314c8b8a2c4SMatt Jacob #define ISP_HANDLE_CMD_MASK 0x00001fff 315c8b8a2c4SMatt Jacob #define ISP_HANDLE_USAGE_MASK 0x0000e000 316c8b8a2c4SMatt Jacob #define ISP_HANDLE_USAGE_SHIFT 13 317c8b8a2c4SMatt Jacob #define ISP_H2HT(hdl) ((hdl & ISP_HANDLE_USAGE_MASK) >> ISP_HANDLE_USAGE_SHIFT) 318c8b8a2c4SMatt Jacob # define ISP_HANDLE_NONE 0 319c8b8a2c4SMatt Jacob # define ISP_HANDLE_INITIATOR 1 320c8b8a2c4SMatt Jacob # define ISP_HANDLE_TARGET 2 321c8b8a2c4SMatt Jacob #define ISP_HANDLE_SEQ_MASK 0xffff0000 322c8b8a2c4SMatt Jacob #define ISP_HANDLE_SEQ_SHIFT 16 323c8b8a2c4SMatt Jacob #define ISP_H2SEQ(hdl) ((hdl & ISP_HANDLE_SEQ_MASK) >> ISP_HANDLE_SEQ_SHIFT) 324c8b8a2c4SMatt Jacob #define ISP_VALID_INI_HANDLE(c, hdl) \ 325c8b8a2c4SMatt Jacob (ISP_H2HT(hdl) == ISP_HANDLE_INITIATOR && (hdl & ISP_HANDLE_CMD_MASK) < (c)->isp_maxcmds && \ 326c8b8a2c4SMatt Jacob ISP_H2SEQ(hdl) == ISP_H2SEQ((c)->isp_xflist[hdl & ISP_HANDLE_CMD_MASK].handle)) 327c8b8a2c4SMatt Jacob #ifdef ISP_TARGET_MODE 328c8b8a2c4SMatt Jacob #define ISP_VALID_TGT_HANDLE(c, hdl) \ 329c8b8a2c4SMatt Jacob (ISP_H2HT(hdl) == ISP_HANDLE_TARGET && (hdl & ISP_HANDLE_CMD_MASK) < (c)->isp_maxcmds && \ 330c8b8a2c4SMatt Jacob ISP_H2SEQ(hdl) == ISP_H2SEQ((c)->isp_tgtlist[hdl & ISP_HANDLE_CMD_MASK].handle)) 331c8b8a2c4SMatt Jacob #define ISP_VALID_HANDLE(c, hdl) \ 332c8b8a2c4SMatt Jacob (ISP_VALID_INI_HANDLE((c), hdl) || ISP_VALID_TGT_HANDLE((c), hdl)) 333c8b8a2c4SMatt Jacob #else 334c8b8a2c4SMatt Jacob #define ISP_VALID_HANDLE ISP_VALID_INI_HANDLE 335c8b8a2c4SMatt Jacob #endif 336c8b8a2c4SMatt Jacob #define ISP_BAD_HANDLE_INDEX 0xffffffff 337c8b8a2c4SMatt Jacob 33810365e5aSMatt Jacob 33910365e5aSMatt Jacob /* 34010365e5aSMatt Jacob * FC Port Database entry. 34110365e5aSMatt Jacob * 34210365e5aSMatt Jacob * It has a handle that the f/w uses to address commands to a device. 34310365e5aSMatt Jacob * This handle's value may be assigned by the firmware (e.g., for local loop 34410365e5aSMatt Jacob * devices) or by the driver (e.g., for fabric devices). 34510365e5aSMatt Jacob * 34610365e5aSMatt Jacob * It has a state. If the state if VALID, that means that we've logged into 34710365e5aSMatt Jacob * the device. We also *may* have a initiator map index entry. This is a value 3482df76c16SMatt Jacob * from 0..MAX_FC_TARG that is used to index into the isp_dev_map array. If 34910365e5aSMatt Jacob * the value therein is non-zero, then that value minus one is used to index 35010365e5aSMatt Jacob * into the Port Database to find the handle for forming commands. There is 35110365e5aSMatt Jacob * back-index minus one value within to Port Database entry that tells us 3522df76c16SMatt Jacob * which entry in isp_dev_map points to us (to avoid searching). 35310365e5aSMatt Jacob * 35410365e5aSMatt Jacob * Local loop devices the firmware automatically performs PLOGI on for us 35510365e5aSMatt Jacob * (which is why that handle is imposed upon us). Fabric devices we assign 35610365e5aSMatt Jacob * a handle to and perform the PLOGI on. 35710365e5aSMatt Jacob * 35810365e5aSMatt Jacob * When a PORT DATABASE CHANGED asynchronous event occurs, we mark all VALID 35910365e5aSMatt Jacob * entries as PROBATIONAL. This allows us, if policy says to, just keep track 36010365e5aSMatt Jacob * of devices whose handles change but are otherwise the same device (and 36110365e5aSMatt Jacob * thus keep 'target' constant). 36210365e5aSMatt Jacob * 36310365e5aSMatt Jacob * In any case, we search all possible local loop handles. For each one that 36410365e5aSMatt Jacob * has a port database entity returned, we search for any PROBATIONAL entry 36510365e5aSMatt Jacob * that matches it and update as appropriate. Otherwise, as a new entry, we 36610365e5aSMatt Jacob * find room for it in the Port Database. We *try* and use the handle as the 36710365e5aSMatt Jacob * index to put it into the Database, but that's just an optimization. We mark 36810365e5aSMatt Jacob * the entry VALID and make sure that the target index is updated and correct. 36910365e5aSMatt Jacob * 37010365e5aSMatt Jacob * When we get done searching the local loop, we then search similarily for 37110365e5aSMatt Jacob * a list of devices we've gotten from the fabric name controller (if we're 37210365e5aSMatt Jacob * on a fabric). VALID marking is also done similarily. 37310365e5aSMatt Jacob * 37410365e5aSMatt Jacob * When all of this is done, we can march through the database and clean up 37510365e5aSMatt Jacob * any entry that is still PROBATIONAL (these represent devices which have 37610365e5aSMatt Jacob * departed). Then we're done and can resume normal operations. 37710365e5aSMatt Jacob * 37810365e5aSMatt Jacob * Negative invariants that we try and test for are: 37910365e5aSMatt Jacob * 38010365e5aSMatt Jacob * + There can never be two non-NIL entries with the same { Port, Node } WWN 38110365e5aSMatt Jacob * duples. 38210365e5aSMatt Jacob * 38310365e5aSMatt Jacob * + There can never be two non-NIL entries with the same handle. 38410365e5aSMatt Jacob * 3852df76c16SMatt Jacob * + There can never be two non-NIL entries which have the same dev_map_idx 38610365e5aSMatt Jacob * value. 38710365e5aSMatt Jacob */ 3886054c3f6SMatt Jacob typedef struct { 389f7c631bcSMatt Jacob /* 390f7c631bcSMatt Jacob * This is the handle that the firmware needs in order for us to 391f7c631bcSMatt Jacob * send commands to the device. For pre-24XX cards, this would be 392f7c631bcSMatt Jacob * the 'loopid'. 393f7c631bcSMatt Jacob */ 39410365e5aSMatt Jacob uint16_t handle; 3952df76c16SMatt Jacob 396f7c631bcSMatt Jacob /* 3972df76c16SMatt Jacob * The dev_map_idx, if nonzero, is the system virtual target ID (+1) 3982df76c16SMatt Jacob * as a cross-reference with the isp_dev_map. 399f7c631bcSMatt Jacob * 400f7c631bcSMatt Jacob * A device is 'autologin' if the firmware automatically logs into 401f7c631bcSMatt Jacob * it (re-logins as needed). Basically, local private loop devices. 402f7c631bcSMatt Jacob * 4032df76c16SMatt Jacob * The state is the current state of this entry. 404f7c631bcSMatt Jacob * 405f7c631bcSMatt Jacob * Role is Initiator, Target, Both 406f7c631bcSMatt Jacob * 4072df76c16SMatt Jacob * Portid is obvious, as are node && port WWNs. The new_role and 408f7c631bcSMatt Jacob * new_portid is for when we are pending a change. 4092df76c16SMatt Jacob * 4102df76c16SMatt Jacob * The 'target_mode' tag means that this entry arrived via a 4112df76c16SMatt Jacob * target mode command and is immune from normal flushing rules. 4122df76c16SMatt Jacob * You should also never see anything with an initiator role 4132df76c16SMatt Jacob * with this set. 414f7c631bcSMatt Jacob */ 4152df76c16SMatt Jacob uint16_t dev_map_idx : 12, 41610365e5aSMatt Jacob autologin : 1, /* F/W does PLOGI/PLOGO */ 41710365e5aSMatt Jacob state : 3; 4182df76c16SMatt Jacob uint32_t reserved : 5, 4192df76c16SMatt Jacob target_mode : 1, 42010365e5aSMatt Jacob roles : 2, 42110365e5aSMatt Jacob portid : 24; 4222df76c16SMatt Jacob uint32_t 4232df76c16SMatt Jacob dirty : 1, /* commands have been run */ 4242df76c16SMatt Jacob new_reserved : 5, 42510365e5aSMatt Jacob new_roles : 2, 42610365e5aSMatt Jacob new_portid : 24; 42710365e5aSMatt Jacob uint64_t node_wwn; 42810365e5aSMatt Jacob uint64_t port_wwn; 429427fa8f9SMatt Jacob uint32_t gone_timer; 43010365e5aSMatt Jacob } fcportdb_t; 43110365e5aSMatt Jacob 43210365e5aSMatt Jacob #define FC_PORTDB_STATE_NIL 0 43310365e5aSMatt Jacob #define FC_PORTDB_STATE_PROBATIONAL 1 43410365e5aSMatt Jacob #define FC_PORTDB_STATE_DEAD 2 43510365e5aSMatt Jacob #define FC_PORTDB_STATE_CHANGED 3 43610365e5aSMatt Jacob #define FC_PORTDB_STATE_NEW 4 43710365e5aSMatt Jacob #define FC_PORTDB_STATE_PENDING_VALID 5 438f7c631bcSMatt Jacob #define FC_PORTDB_STATE_ZOMBIE 6 43910365e5aSMatt Jacob #define FC_PORTDB_STATE_VALID 7 44010365e5aSMatt Jacob 44110365e5aSMatt Jacob /* 44210365e5aSMatt Jacob * FC card specific information 4432df76c16SMatt Jacob * 4442df76c16SMatt Jacob * This structure is replicated across multiple channels for multi-id 4452df76c16SMatt Jacob * capapble chipsets, with some entities different on a per-channel basis. 44610365e5aSMatt Jacob */ 4472df76c16SMatt Jacob 44810365e5aSMatt Jacob typedef struct { 4492df76c16SMatt Jacob uint32_t 4502df76c16SMatt Jacob link_active : 1, 4512df76c16SMatt Jacob npiv_fabric : 1, 4522df76c16SMatt Jacob inorder : 1, 4532df76c16SMatt Jacob sendmarker : 1, 4542df76c16SMatt Jacob role : 2, 4552df76c16SMatt Jacob isp_gbspeed : 4, 4566a23026cSMatt Jacob isp_loopstate : 4, /* Current Loop State */ 4578a97c03aSMatt Jacob isp_fwstate : 4, /* ISP F/W state */ 4582df76c16SMatt Jacob isp_topo : 3, /* Connection Type */ 45910365e5aSMatt Jacob loop_seen_once : 1; 4602df76c16SMatt Jacob 4611dae40ebSMatt Jacob uint32_t : 8, 462e5265237SMatt Jacob isp_portid : 24; /* S_ID */ 4632df76c16SMatt Jacob 4642df76c16SMatt Jacob 4651dae40ebSMatt Jacob uint16_t isp_fwoptions; 4668a97c03aSMatt Jacob uint16_t isp_xfwoptions; 4678a97c03aSMatt Jacob uint16_t isp_zfwoptions; 4681dae40ebSMatt Jacob uint16_t isp_loopid; /* hard loop id */ 4692df76c16SMatt Jacob uint16_t isp_sns_hdl; /* N-port handle for SNS */ 4702df76c16SMatt Jacob uint16_t isp_lasthdl; /* only valid for channel 0 */ 4712df76c16SMatt Jacob uint16_t isp_maxalloc; 4721dae40ebSMatt Jacob uint8_t isp_retry_delay; 4731dae40ebSMatt Jacob uint8_t isp_retry_count; 4742df76c16SMatt Jacob 4752df76c16SMatt Jacob /* 4762df76c16SMatt Jacob * Current active WWNN/WWPN 4772df76c16SMatt Jacob */ 4782df76c16SMatt Jacob uint64_t isp_wwnn; 4792df76c16SMatt Jacob uint64_t isp_wwpn; 4802df76c16SMatt Jacob 4812df76c16SMatt Jacob /* 4822df76c16SMatt Jacob * NVRAM WWNN/WWPN 4832df76c16SMatt Jacob */ 4846c81a0aeSMatt Jacob uint64_t isp_wwnn_nvram; 4856c81a0aeSMatt Jacob uint64_t isp_wwpn_nvram; 486f7c631bcSMatt Jacob 487f7c631bcSMatt Jacob /* 488f7c631bcSMatt Jacob * Our Port Data Base 489f7c631bcSMatt Jacob */ 49010365e5aSMatt Jacob fcportdb_t portdb[MAX_FC_TARG]; 491f7c631bcSMatt Jacob 492f7c631bcSMatt Jacob /* 493f7c631bcSMatt Jacob * This maps system virtual 'target' id to a portdb entry. 494f7c631bcSMatt Jacob * 495f7c631bcSMatt Jacob * The mapping function is to take any non-zero entry and 496f7c631bcSMatt Jacob * subtract one to get the portdb index. This means that 497f7c631bcSMatt Jacob * entries which are zero are unmapped (i.e., don't exist). 498f7c631bcSMatt Jacob */ 4992df76c16SMatt Jacob uint16_t isp_dev_map[MAX_FC_TARG]; 5002df76c16SMatt Jacob 5012df76c16SMatt Jacob #ifdef ISP_TARGET_MODE 5022df76c16SMatt Jacob /* 5032df76c16SMatt Jacob * This maps N-Port Handle to portdb entry so we 5042df76c16SMatt Jacob * don't have to search for every incoming command. 5052df76c16SMatt Jacob * 5062df76c16SMatt Jacob * The mapping function is to take any non-zero entry and 5072df76c16SMatt Jacob * subtract one to get the portdb index. This means that 5082df76c16SMatt Jacob * entries which are zero are unmapped (i.e., don't exist). 5092df76c16SMatt Jacob */ 5102df76c16SMatt Jacob uint16_t isp_tgt_map[MAX_NPORT_HANDLE]; 5112df76c16SMatt Jacob #endif 512f7c631bcSMatt Jacob 51357c801f5SMatt Jacob /* 5146054c3f6SMatt Jacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 5156054c3f6SMatt Jacob */ 5161dae40ebSMatt Jacob void * isp_scratch; 5171dae40ebSMatt Jacob XS_DMA_ADDR_T isp_scdma; 5186054c3f6SMatt Jacob } fcparam; 5196054c3f6SMatt Jacob 52077d4e836SMatt Jacob #define FW_CONFIG_WAIT 0 52177d4e836SMatt Jacob #define FW_WAIT_AL_PA 1 52277d4e836SMatt Jacob #define FW_WAIT_LOGIN 2 52377d4e836SMatt Jacob #define FW_READY 3 52477d4e836SMatt Jacob #define FW_LOSS_OF_SYNC 4 52577d4e836SMatt Jacob #define FW_ERROR 5 52677d4e836SMatt Jacob #define FW_REINIT 6 52777d4e836SMatt Jacob #define FW_NON_PART 7 5286054c3f6SMatt Jacob 52977d4e836SMatt Jacob #define LOOP_NIL 0 53077d4e836SMatt Jacob #define LOOP_LIP_RCVD 1 53177d4e836SMatt Jacob #define LOOP_PDB_RCVD 2 53210365e5aSMatt Jacob #define LOOP_SCANNING_LOOP 3 53310365e5aSMatt Jacob #define LOOP_LSCAN_DONE 4 53410365e5aSMatt Jacob #define LOOP_SCANNING_FABRIC 5 53510365e5aSMatt Jacob #define LOOP_FSCAN_DONE 6 5366a23026cSMatt Jacob #define LOOP_SYNCING_PDB 7 5376a23026cSMatt Jacob #define LOOP_READY 8 53877d4e836SMatt Jacob 539d465588aSMatt Jacob #define TOPO_NL_PORT 0 540d465588aSMatt Jacob #define TOPO_FL_PORT 1 541d465588aSMatt Jacob #define TOPO_N_PORT 2 542d465588aSMatt Jacob #define TOPO_F_PORT 3 543d465588aSMatt Jacob #define TOPO_PTP_STUB 4 544d465588aSMatt Jacob 5456054c3f6SMatt Jacob /* 5466054c3f6SMatt Jacob * Soft Structure per host adapter 5476054c3f6SMatt Jacob */ 5481dae40ebSMatt Jacob struct ispsoftc { 5496054c3f6SMatt Jacob /* 5506054c3f6SMatt Jacob * Platform (OS) specific data 5516054c3f6SMatt Jacob */ 5526054c3f6SMatt Jacob struct isposinfo isp_osinfo; 5536054c3f6SMatt Jacob 5546054c3f6SMatt Jacob /* 55580ae5655SMatt Jacob * Pointer to bus specific functions and data 5566054c3f6SMatt Jacob */ 5576054c3f6SMatt Jacob struct ispmdvec * isp_mdvec; 5586054c3f6SMatt Jacob 5596054c3f6SMatt Jacob /* 56080ae5655SMatt Jacob * (Mostly) nonvolatile state. Board specific parameters 56180ae5655SMatt Jacob * may contain some volatile state (e.g., current loop state). 5626054c3f6SMatt Jacob */ 5636054c3f6SMatt Jacob 56480ae5655SMatt Jacob void * isp_param; /* type specific */ 5651dae40ebSMatt Jacob uint16_t isp_fwrev[3]; /* Loaded F/W revision */ 5661dae40ebSMatt Jacob uint16_t isp_maxcmds; /* max possible I/O cmds */ 5671dae40ebSMatt Jacob uint8_t isp_type; /* HBA Chip Type */ 5681dae40ebSMatt Jacob uint8_t isp_revision; /* HBA Chip H/W Revision */ 5691dae40ebSMatt Jacob uint32_t isp_maxluns; /* maximum luns supported */ 5706054c3f6SMatt Jacob 5711dae40ebSMatt Jacob uint32_t isp_clock : 8, /* input clock */ 57275c1e828SMatt Jacob : 4, 57310365e5aSMatt Jacob isp_port : 1, /* 23XX/24XX only */ 5744fd13c1bSMatt Jacob isp_open : 1, /* opened (ioctl) */ 575b6b6ad2fSMatt Jacob isp_bustype : 1, /* SBus or PCI */ 576b6b6ad2fSMatt Jacob isp_loaded_fw : 1, /* loaded firmware */ 5772df76c16SMatt Jacob isp_dblev : 16; /* debug log mask */ 5782df76c16SMatt Jacob 5792df76c16SMatt Jacob uint16_t isp_fwattr; /* firmware attributes */ 5802df76c16SMatt Jacob uint16_t isp_nchan; /* number of channels */ 5817afb656fSMatt Jacob 5821dae40ebSMatt Jacob uint32_t isp_confopts; /* config options */ 5837afb656fSMatt Jacob 58410365e5aSMatt Jacob uint32_t isp_rqstinrp; /* register for REQINP */ 58510365e5aSMatt Jacob uint32_t isp_rqstoutrp; /* register for REQOUTP */ 58610365e5aSMatt Jacob uint32_t isp_respinrp; /* register for RESINP */ 58710365e5aSMatt Jacob uint32_t isp_respoutrp; /* register for RESOUTP */ 588126ec864SMatt Jacob 58967afe757SMatt Jacob /* 59067afe757SMatt Jacob * Instrumentation 59167afe757SMatt Jacob */ 5921dae40ebSMatt Jacob uint64_t isp_intcnt; /* total int count */ 5931dae40ebSMatt Jacob uint64_t isp_intbogus; /* spurious int count */ 5941dae40ebSMatt Jacob uint64_t isp_intmboxc; /* mbox completions */ 5951dae40ebSMatt Jacob uint64_t isp_intoasync; /* other async */ 5961dae40ebSMatt Jacob uint64_t isp_rsltccmplt; /* CMDs on result q */ 5971dae40ebSMatt Jacob uint64_t isp_fphccmplt; /* CMDs via fastpost */ 5981dae40ebSMatt Jacob uint16_t isp_rscchiwater; 5991dae40ebSMatt Jacob uint16_t isp_fpcchiwater; 6002df76c16SMatt Jacob NANOTIME_T isp_init_time; /* time were last initialized */ 6016054c3f6SMatt Jacob 6026054c3f6SMatt Jacob /* 603478f8a96SJustin T. Gibbs * Volatile state 6046054c3f6SMatt Jacob */ 605478f8a96SJustin T. Gibbs 6068a97c03aSMatt Jacob volatile uint32_t : 8, 6072df76c16SMatt Jacob : 2, 6082df76c16SMatt Jacob isp_dead : 1, 6092df76c16SMatt Jacob : 1, 6104fd13c1bSMatt Jacob isp_mboxbsy : 1, /* mailbox command active */ 611478f8a96SJustin T. Gibbs isp_state : 3, 6127e90346eSMatt Jacob isp_nactive : 16; /* how many commands active */ 613c8b8a2c4SMatt Jacob volatile mbreg_t isp_curmbx; /* currently active mailbox command */ 61410365e5aSMatt Jacob volatile uint32_t isp_reqodx; /* index of last ISP pickup */ 61510365e5aSMatt Jacob volatile uint32_t isp_reqidx; /* index of next request */ 61610365e5aSMatt Jacob volatile uint32_t isp_residx; /* index of next result */ 61710365e5aSMatt Jacob volatile uint32_t isp_resodx; /* index of next result */ 61810365e5aSMatt Jacob volatile uint32_t isp_obits; /* mailbox command output */ 6192df76c16SMatt Jacob volatile uint32_t isp_serno; /* rolling serial number */ 6201dae40ebSMatt Jacob volatile uint16_t isp_mboxtmp[MAILBOX_STORAGE]; 6211dae40ebSMatt Jacob volatile uint16_t isp_lastmbxcmd; /* last mbox command sent */ 6221dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk0; 6231dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk1; 6241dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk2; 6258a97c03aSMatt Jacob volatile uint16_t isp_mbxwrk8; 626c8b8a2c4SMatt Jacob volatile uint16_t isp_seqno; /* running sequence number */ 62775c1e828SMatt Jacob void * isp_mbxworkp; 628478f8a96SJustin T. Gibbs 629478f8a96SJustin T. Gibbs /* 63080ae5655SMatt Jacob * Active commands are stored here, indexed by handle functions. 631478f8a96SJustin T. Gibbs */ 632c8b8a2c4SMatt Jacob isp_hdl_t *isp_xflist; 633c8b8a2c4SMatt Jacob isp_hdl_t *isp_xffree; 6346054c3f6SMatt Jacob 63551e23558SNate Lawson #ifdef ISP_TARGET_MODE 63651e23558SNate Lawson /* 6372df76c16SMatt Jacob * Active target commands are stored here, indexed by handle functions. 63851e23558SNate Lawson */ 639c8b8a2c4SMatt Jacob isp_hdl_t *isp_tgtlist; 640c8b8a2c4SMatt Jacob isp_hdl_t *isp_tgtfree; 64151e23558SNate Lawson #endif 64251e23558SNate Lawson 6436054c3f6SMatt Jacob /* 6444b39f27dSMatt Jacob * request/result queue pointers and DMA handles for them. 6456054c3f6SMatt Jacob */ 6461dae40ebSMatt Jacob void * isp_rquest; 6471dae40ebSMatt Jacob void * isp_result; 6481dae40ebSMatt Jacob XS_DMA_ADDR_T isp_rquest_dma; 6491dae40ebSMatt Jacob XS_DMA_ADDR_T isp_result_dma; 65010365e5aSMatt Jacob #ifdef ISP_TARGET_MODE 65110365e5aSMatt Jacob /* for 24XX only */ 65210365e5aSMatt Jacob void * isp_atioq; 65310365e5aSMatt Jacob XS_DMA_ADDR_T isp_atioq_dma; 65410365e5aSMatt Jacob #endif 6551dae40ebSMatt Jacob }; 6566054c3f6SMatt Jacob 6572df76c16SMatt Jacob #define SDPARAM(isp, chan) (&((sdparam *)(isp)->isp_param)[(chan)]) 6582df76c16SMatt Jacob #define FCPARAM(isp, chan) (&((fcparam *)(isp)->isp_param)[(chan)]) 6592df76c16SMatt Jacob 6602df76c16SMatt Jacob #define ISP_SET_SENDMARKER(isp, chan, val) \ 6612df76c16SMatt Jacob if (IS_FC(isp)) { \ 6622df76c16SMatt Jacob FCPARAM(isp, chan)->sendmarker = val; \ 6632df76c16SMatt Jacob } else { \ 6642df76c16SMatt Jacob SDPARAM(isp, chan)->sendmarker = val; \ 6652df76c16SMatt Jacob } 6662df76c16SMatt Jacob 6672df76c16SMatt Jacob #define ISP_TST_SENDMARKER(isp, chan) \ 6682df76c16SMatt Jacob (IS_FC(isp)? \ 6692df76c16SMatt Jacob FCPARAM(isp, chan)->sendmarker != 0 : \ 6702df76c16SMatt Jacob SDPARAM(isp, chan)->sendmarker != 0) 6710f747d72SMatt Jacob 6726054c3f6SMatt Jacob /* 67353cff3bbSMatt Jacob * ISP Driver Run States 6746054c3f6SMatt Jacob */ 6756054c3f6SMatt Jacob #define ISP_NILSTATE 0 6768a97c03aSMatt Jacob #define ISP_CRASHED 1 6778a97c03aSMatt Jacob #define ISP_RESETSTATE 2 6788a97c03aSMatt Jacob #define ISP_INITSTATE 3 6798a97c03aSMatt Jacob #define ISP_RUNSTATE 4 6806054c3f6SMatt Jacob 6816054c3f6SMatt Jacob /* 6826054c3f6SMatt Jacob * ISP Configuration Options 6836054c3f6SMatt Jacob */ 6846054c3f6SMatt Jacob #define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 68510f20e40SMatt Jacob #define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 686c507669aSMatt Jacob #define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ 687c507669aSMatt Jacob #define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ 68880ae5655SMatt Jacob #define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 68967afe757SMatt Jacob #define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ 69067afe757SMatt Jacob #define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ 69167afe757SMatt Jacob #define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ 69267afe757SMatt Jacob #define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ 69367afe757SMatt Jacob #define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ 6940499ae00SMatt Jacob #define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */ 6950499ae00SMatt Jacob #define ISP_CFG_OWNLOOPID 0x800 /* override NVRAM loopid */ 6960499ae00SMatt Jacob #define ISP_CFG_OWNEXCTHROTTLE 0x1000 /* override NVRAM execution throttle */ 69710365e5aSMatt Jacob #define ISP_CFG_FOURGB 0x2000 /* force 4GB connection (24XX only) */ 6986054c3f6SMatt Jacob 69953cff3bbSMatt Jacob /* 7002df76c16SMatt Jacob * For each channel, the outer layers should know what role that channel 7012df76c16SMatt Jacob * will take: ISP_ROLE_NONE, ISP_ROLE_INITIATOR, ISP_ROLE_TARGET, 7022df76c16SMatt Jacob * ISP_ROLE_BOTH. 7037afb656fSMatt Jacob * 7047afb656fSMatt Jacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, 7057afb656fSMatt Jacob * NVRAM read, and defaults set, but any further initialization (e.g. 7067afb656fSMatt Jacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. 7077afb656fSMatt Jacob * 7087afb656fSMatt Jacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped 7092df76c16SMatt Jacob * at isp_start and completed with the equivalent of SELECTION TIMEOUT. 7107afb656fSMatt Jacob * 7117afb656fSMatt Jacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support 7127afb656fSMatt Jacob * needs to be enabled, or will even work. What happens with the 2X00 cards 7137afb656fSMatt Jacob * here is that if you have enabled it with TARGET MODE as part of the ICB 7147afb656fSMatt Jacob * options, but you haven't given the f/w any ram resources for ATIOs or 7157afb656fSMatt Jacob * Immediate Notifies, the f/w just handles what it can and you never see 7167afb656fSMatt Jacob * anything. Basically, it sends a single byte of data (the first byte, 7177afb656fSMatt Jacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for 7187afb656fSMatt Jacob * INQUIRY, and sends back QUEUE FULL status for any other command. 7197afb656fSMatt Jacob * 7207afb656fSMatt Jacob */ 7217afb656fSMatt Jacob #define ISP_ROLE_NONE 0x0 722e0d3cfb7SMatt Jacob #define ISP_ROLE_TARGET 0x1 723e0d3cfb7SMatt Jacob #define ISP_ROLE_INITIATOR 0x2 7247afb656fSMatt Jacob #define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) 7257afb656fSMatt Jacob #define ISP_ROLE_EITHER ISP_ROLE_BOTH 7267afb656fSMatt Jacob #ifndef ISP_DEFAULT_ROLES 7277afb656fSMatt Jacob #define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR 7287afb656fSMatt Jacob #endif 7297afb656fSMatt Jacob 7307afb656fSMatt Jacob 7317afb656fSMatt Jacob /* 73253cff3bbSMatt Jacob * Firmware related defines 73353cff3bbSMatt Jacob */ 73453cff3bbSMatt Jacob #define ISP_CODE_ORG 0x1000 /* default f/w code start */ 735126ec864SMatt Jacob #define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ 73610365e5aSMatt Jacob #define ISP_CODE_ORG_2400 0x100000 /* ..and 2400s */ 73712b36e2dSMatt Jacob #define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 738f8597b62SMatt Jacob #define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) 739f8597b62SMatt Jacob #define ISP_FW_MINOR(code) ((code >> 16) & 0xff) 740f8597b62SMatt Jacob #define ISP_FW_MICRO(code) ((code >> 8) & 0xff) 74112b36e2dSMatt Jacob #define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 742f8597b62SMatt Jacob #define ISP_FW_MAJORX(xp) (xp[0]) 743f8597b62SMatt Jacob #define ISP_FW_MINORX(xp) (xp[1]) 744f8597b62SMatt Jacob #define ISP_FW_MICROX(xp) (xp[2]) 745e347e2c9SMatt Jacob #define ISP_FW_NEWER_THAN(i, major, minor, micro) \ 746e347e2c9SMatt Jacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro)) 74710365e5aSMatt Jacob #define ISP_FW_OLDER_THAN(i, major, minor, micro) \ 74810365e5aSMatt Jacob (ISP_FW_REVX((i)->isp_fwrev) < ISP_FW_REV(major, minor, micro)) 74912b36e2dSMatt Jacob 7506054c3f6SMatt Jacob /* 751478f8a96SJustin T. Gibbs * Bus (implementation) types 752478f8a96SJustin T. Gibbs */ 753478f8a96SJustin T. Gibbs #define ISP_BT_PCI 0 /* PCI Implementations */ 754478f8a96SJustin T. Gibbs #define ISP_BT_SBUS 1 /* SBus Implementations */ 755478f8a96SJustin T. Gibbs 756478f8a96SJustin T. Gibbs /* 7574fd13c1bSMatt Jacob * If we have not otherwise defined SBus support away make sure 7584fd13c1bSMatt Jacob * it is defined here such that the code is included as default 7594fd13c1bSMatt Jacob */ 7604fd13c1bSMatt Jacob #ifndef ISP_SBUS_SUPPORTED 7614fd13c1bSMatt Jacob #define ISP_SBUS_SUPPORTED 1 7624fd13c1bSMatt Jacob #endif 7634fd13c1bSMatt Jacob 7644fd13c1bSMatt Jacob /* 765478f8a96SJustin T. Gibbs * Chip Types 7666054c3f6SMatt Jacob */ 7676054c3f6SMatt Jacob #define ISP_HA_SCSI 0xf 768478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_UNKNOWN 0x1 769478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020 0x2 770478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020A 0x3 771478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040 0x4 772478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040A 0x5 773478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040B 0x6 77412b36e2dSMatt Jacob #define ISP_HA_SCSI_1040C 0x7 77522e1dc85SMatt Jacob #define ISP_HA_SCSI_1240 0x8 77622e1dc85SMatt Jacob #define ISP_HA_SCSI_1080 0x9 77722e1dc85SMatt Jacob #define ISP_HA_SCSI_1280 0xa 778f556e83bSMatt Jacob #define ISP_HA_SCSI_10160 0xb 779f556e83bSMatt Jacob #define ISP_HA_SCSI_12160 0xc 7806054c3f6SMatt Jacob #define ISP_HA_FC 0xf0 7816054c3f6SMatt Jacob #define ISP_HA_FC_2100 0x10 78277d4e836SMatt Jacob #define ISP_HA_FC_2200 0x20 7835d571944SMatt Jacob #define ISP_HA_FC_2300 0x30 7842903b272SMatt Jacob #define ISP_HA_FC_2312 0x40 785e5265237SMatt Jacob #define ISP_HA_FC_2322 0x50 786e5265237SMatt Jacob #define ISP_HA_FC_2400 0x60 7872df76c16SMatt Jacob #define ISP_HA_FC_2500 0x70 7886054c3f6SMatt Jacob 78957c801f5SMatt Jacob #define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 7902df76c16SMatt Jacob #define IS_1020(isp) (isp->isp_type < ISP_HA_SCSI_1240) 79122e1dc85SMatt Jacob #define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 79257c801f5SMatt Jacob #define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 79322e1dc85SMatt Jacob #define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 794f556e83bSMatt Jacob #define IS_10160(isp) (isp->isp_type == ISP_HA_SCSI_10160) 79583fbc566SMatt Jacob #define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 79683fbc566SMatt Jacob 79783fbc566SMatt Jacob #define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 798f556e83bSMatt Jacob #define IS_1X160(isp) (IS_10160(isp) || IS_12160(isp)) 79983fbc566SMatt Jacob #define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 800f556e83bSMatt Jacob #define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_1X160(isp)) 801f556e83bSMatt Jacob #define IS_ULTRA3(isp) (IS_1X160(isp)) 80283fbc566SMatt Jacob 8035d571944SMatt Jacob #define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) 8045d571944SMatt Jacob #define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) 8055d571944SMatt Jacob #define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) 80610365e5aSMatt Jacob #define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300 && \ 80710365e5aSMatt Jacob (isp)->isp_type < ISP_HA_FC_2400) 8082903b272SMatt Jacob #define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) 8092903b272SMatt Jacob #define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) 810e5265237SMatt Jacob #define IS_2322(isp) ((isp)->isp_type == ISP_HA_FC_2322) 811e5265237SMatt Jacob #define IS_24XX(isp) ((isp)->isp_type >= ISP_HA_FC_2400) 8122df76c16SMatt Jacob #define IS_25XX(isp) ((isp)->isp_type >= ISP_HA_FC_2500) 81383fbc566SMatt Jacob 81453cff3bbSMatt Jacob /* 8151dae40ebSMatt Jacob * DMA related macros 81653cff3bbSMatt Jacob */ 81710365e5aSMatt Jacob #define DMA_WD3(x) (((uint16_t)(((uint64_t)x) >> 48)) & 0xffff) 81810365e5aSMatt Jacob #define DMA_WD2(x) (((uint16_t)(((uint64_t)x) >> 32)) & 0xffff) 81910365e5aSMatt Jacob #define DMA_WD1(x) ((uint16_t)((x) >> 16) & 0xffff) 82010365e5aSMatt Jacob #define DMA_WD0(x) ((uint16_t)((x) & 0xffff)) 82157c801f5SMatt Jacob 8221dae40ebSMatt Jacob #define DMA_LO32(x) ((uint32_t) (x)) 8231dae40ebSMatt Jacob #define DMA_HI32(x) ((uint32_t)(((uint64_t)x) >> 32)) 8241dae40ebSMatt Jacob 8256054c3f6SMatt Jacob /* 82653cff3bbSMatt Jacob * Core System Function Prototypes 8276054c3f6SMatt Jacob */ 8286054c3f6SMatt Jacob 8296054c3f6SMatt Jacob /* 8302df76c16SMatt Jacob * Reset Hardware. Totally. Assumes that you'll follow this with a call to isp_init. 8316054c3f6SMatt Jacob */ 8322df76c16SMatt Jacob void isp_reset(ispsoftc_t *, int); 8336054c3f6SMatt Jacob 8346054c3f6SMatt Jacob /* 8356054c3f6SMatt Jacob * Initialize Hardware to known state 8366054c3f6SMatt Jacob */ 8371dae40ebSMatt Jacob void isp_init(ispsoftc_t *); 8386054c3f6SMatt Jacob 8396054c3f6SMatt Jacob /* 840478f8a96SJustin T. Gibbs * Reset the ISP and call completion for any orphaned commands. 841478f8a96SJustin T. Gibbs */ 8422df76c16SMatt Jacob void isp_reinit(ispsoftc_t *, int); 84301ff579dSMatt Jacob 844478f8a96SJustin T. Gibbs /* 845126ec864SMatt Jacob * Internal Interrupt Service Routine 846126ec864SMatt Jacob * 847126ec864SMatt Jacob * The outer layers do the spade work to get the appropriate status register, 848126ec864SMatt Jacob * semaphore register and first mailbox register (if appropriate). This also 849126ec864SMatt Jacob * means that most spurious/bogus interrupts not for us can be filtered first. 8506054c3f6SMatt Jacob */ 85110365e5aSMatt Jacob void isp_intr(ispsoftc_t *, uint32_t, uint16_t, uint16_t); 852126ec864SMatt Jacob 8536054c3f6SMatt Jacob 8546054c3f6SMatt Jacob /* 85553cff3bbSMatt Jacob * Command Entry Point- Platform Dependent layers call into this 8566054c3f6SMatt Jacob */ 857e2ec5cf0SMatt Jacob int isp_start(XS_T *); 8581dae40ebSMatt Jacob 85953cff3bbSMatt Jacob /* these values are what isp_start returns */ 86053cff3bbSMatt Jacob #define CMD_COMPLETE 101 /* command completed */ 86153cff3bbSMatt Jacob #define CMD_EAGAIN 102 /* busy- maybe retry later */ 86253cff3bbSMatt Jacob #define CMD_QUEUED 103 /* command has been queued for execution */ 86353cff3bbSMatt Jacob #define CMD_RQLATER 104 /* requeue this command later */ 86453cff3bbSMatt Jacob 86553cff3bbSMatt Jacob /* 86653cff3bbSMatt Jacob * Command Completion Point- Core layers call out from this with completed cmds 86753cff3bbSMatt Jacob */ 868e2ec5cf0SMatt Jacob void isp_done(XS_T *); 869478f8a96SJustin T. Gibbs 870478f8a96SJustin T. Gibbs /* 871cbf57b47SMatt Jacob * Platform Dependent to External to Internal Control Function 872478f8a96SJustin T. Gibbs * 873410b5567SMatt Jacob * Assumes locks are held on entry. You should note that with many of 8742df76c16SMatt Jacob * these commands locks may be released while this function is called. 875478f8a96SJustin T. Gibbs * 8762df76c16SMatt Jacob * ... ISPCTL_RESET_BUS, int channel); 8772df76c16SMatt Jacob * Reset BUS on this channel 8782df76c16SMatt Jacob * ... ISPCTL_RESET_DEV, int channel, int target); 8792df76c16SMatt Jacob * Reset Device on this channel at this target. 8802df76c16SMatt Jacob * ... ISPCTL_ABORT_CMD, XS_T *xs); 8812df76c16SMatt Jacob * Abort active transaction described by xs. 8822df76c16SMatt Jacob * ... IPCTL_UPDATE_PARAMS); 8832df76c16SMatt Jacob * Update any operating parameters (speed, etc.) 8842df76c16SMatt Jacob * ... ISPCTL_FCLINK_TEST, int channel); 8852df76c16SMatt Jacob * Test FC link status on this channel 8862df76c16SMatt Jacob * ... ISPCTL_SCAN_FABRIC, int channel); 8872df76c16SMatt Jacob * Scan fabric on this channel 8882df76c16SMatt Jacob * ... ISPCTL_SCAN_LOOP, int channel); 8892df76c16SMatt Jacob * Scan local loop on this channel 8902df76c16SMatt Jacob * ... ISPCTL_PDB_SYNC, int channel); 8912df76c16SMatt Jacob * Synchronize port database on this channel 8922df76c16SMatt Jacob * ... ISPCTL_SEND_LIP, int channel); 8932df76c16SMatt Jacob * Send a LIP on this channel 8942df76c16SMatt Jacob * ... ISPCTL_GET_NAMES, int channel, int np, uint64_t *wwnn, uint64_t *wwpn) 8952df76c16SMatt Jacob * Get a WWNN/WWPN for this N-port handle on this channel 8962df76c16SMatt Jacob * ... ISPCTL_RUN_MBOXCMD, mbreg_t *mbp) 8972df76c16SMatt Jacob * Run this mailbox command 8982df76c16SMatt Jacob * ... ISPCTL_GET_PDB, int channel, int nphandle, isp_pdb_t *pdb) 8992df76c16SMatt Jacob * Get PDB on this channel for this N-port handle 9002df76c16SMatt Jacob * ... ISPCTL_PLOGX, isp_plcmd_t *) 9012df76c16SMatt Jacob * Performa a port login/logout 902410b5567SMatt Jacob * 903410b5567SMatt Jacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in 904410b5567SMatt Jacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. 905410b5567SMatt Jacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging 906410b5567SMatt Jacob * and logging out of fabric devices (if one is on a fabric) and then marking 907410b5567SMatt Jacob * the 'loop state' as being ready to now be used for sending commands to 908410b5567SMatt Jacob * devices. Originally fabric name server and local loop scanning were 909561e7bb9SMatt Jacob * part of this function. It's now been separated to allow for finer control. 910478f8a96SJustin T. Gibbs */ 911478f8a96SJustin T. Gibbs typedef enum { 9122df76c16SMatt Jacob ISPCTL_RESET_BUS, 9132df76c16SMatt Jacob ISPCTL_RESET_DEV, 9142df76c16SMatt Jacob ISPCTL_ABORT_CMD, 9152df76c16SMatt Jacob ISPCTL_UPDATE_PARAMS, 9162df76c16SMatt Jacob ISPCTL_FCLINK_TEST, 9172df76c16SMatt Jacob ISPCTL_SCAN_FABRIC, 9182df76c16SMatt Jacob ISPCTL_SCAN_LOOP, 9192df76c16SMatt Jacob ISPCTL_PDB_SYNC, 9202df76c16SMatt Jacob ISPCTL_SEND_LIP, 9212df76c16SMatt Jacob ISPCTL_GET_NAMES, 9222df76c16SMatt Jacob ISPCTL_RUN_MBOXCMD, 9232df76c16SMatt Jacob ISPCTL_GET_PDB, 9242df76c16SMatt Jacob ISPCTL_PLOGX 925478f8a96SJustin T. Gibbs } ispctl_t; 9262df76c16SMatt Jacob int isp_control(ispsoftc_t *, ispctl_t, ...); 927cbf57b47SMatt Jacob 928cbf57b47SMatt Jacob /* 929cbf57b47SMatt Jacob * Platform Dependent to Internal to External Control Function 930cbf57b47SMatt Jacob */ 931cbf57b47SMatt Jacob 932cbf57b47SMatt Jacob typedef enum { 9332df76c16SMatt Jacob ISPASYNC_NEW_TGT_PARAMS, /* SPI New Target Parameters */ 9342df76c16SMatt Jacob ISPASYNC_BUS_RESET, /* All Bus Was Reset */ 93577d4e836SMatt Jacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 93677d4e836SMatt Jacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 9372df76c16SMatt Jacob ISPASYNC_LIP, /* FC LIP Received */ 9382df76c16SMatt Jacob ISPASYNC_LOOP_RESET, /* FC Loop Reset Received */ 939410b5567SMatt Jacob ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ 9402df76c16SMatt Jacob ISPASYNC_DEV_ARRIVED, /* FC Device Arrived */ 9412df76c16SMatt Jacob ISPASYNC_DEV_CHANGED, /* FC Device Changed */ 9422df76c16SMatt Jacob ISPASYNC_DEV_STAYED, /* FC Device Stayed */ 9432df76c16SMatt Jacob ISPASYNC_DEV_GONE, /* FC Device Departure */ 9442df76c16SMatt Jacob ISPASYNC_TARGET_NOTIFY, /* All target async notification */ 9452df76c16SMatt Jacob ISPASYNC_TARGET_ACTION, /* All target action requested */ 9462df76c16SMatt Jacob ISPASYNC_FW_CRASH, /* All Firmware has crashed */ 9472df76c16SMatt Jacob ISPASYNC_FW_RESTARTED /* All Firmware has been restarted */ 948cbf57b47SMatt Jacob } ispasync_t; 9492df76c16SMatt Jacob void isp_async(ispsoftc_t *, ispasync_t, ...); 950cbf57b47SMatt Jacob 9512df76c16SMatt Jacob #define ISPASYNC_CHANGE_PDB 0 9522df76c16SMatt Jacob #define ISPASYNC_CHANGE_SNS 1 9532df76c16SMatt Jacob #define ISPASYNC_CHANGE_OTHER 2 954410b5567SMatt Jacob 955478f8a96SJustin T. Gibbs /* 95653cff3bbSMatt Jacob * Platform Dependent Error and Debug Printout 957547725beSMatt Jacob * 958670508b1SMatt Jacob * Two required functions for each platform must be provided: 959547725beSMatt Jacob * 9601dae40ebSMatt Jacob * void isp_prt(ispsoftc_t *, int level, const char *, ...) 961670508b1SMatt Jacob * void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...) 962547725beSMatt Jacob * 963547725beSMatt Jacob * but due to compiler differences on different platforms this won't be 964670508b1SMatt Jacob * formally defined here. Instead, they go in each platform definition file. 965478f8a96SJustin T. Gibbs */ 966e9423e21SMatt Jacob 96753cff3bbSMatt Jacob #define ISP_LOGALL 0x0 /* log always */ 96853cff3bbSMatt Jacob #define ISP_LOGCONFIG 0x1 /* log configuration messages */ 96953cff3bbSMatt Jacob #define ISP_LOGINFO 0x2 /* log informational messages */ 97053cff3bbSMatt Jacob #define ISP_LOGWARN 0x4 /* log warning messages */ 97153cff3bbSMatt Jacob #define ISP_LOGERR 0x8 /* log error messages */ 97253cff3bbSMatt Jacob #define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 97353cff3bbSMatt Jacob #define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 97453cff3bbSMatt Jacob #define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 975b91862efSMatt Jacob #define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ 976f7c631bcSMatt Jacob #define ISP_LOGSANCFG 0x100 /* log SAN configuration */ 977670508b1SMatt Jacob #define ISP_LOG_CWARN 0x200 /* log SCSI command "warnings" (e.g., check conditions) */ 9782df76c16SMatt Jacob #define ISP_LOGTINFO 0x1000 /* log informational messages (target mode) */ 9792df76c16SMatt Jacob #define ISP_LOGTDEBUG0 0x2000 /* log simple debug messages (target mode) */ 9802df76c16SMatt Jacob #define ISP_LOGTDEBUG1 0x4000 /* log intermediate debug messages (target) */ 9812df76c16SMatt Jacob #define ISP_LOGTDEBUG2 0x8000 /* log all debug messages (target) */ 982478f8a96SJustin T. Gibbs 98353cff3bbSMatt Jacob /* 98453cff3bbSMatt Jacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 98553cff3bbSMatt Jacob * defined above. 98653cff3bbSMatt Jacob * 98753cff3bbSMatt Jacob * Each platform must also provide the following macros/defines: 98853cff3bbSMatt Jacob * 98953cff3bbSMatt Jacob * 9902df76c16SMatt Jacob * ISP_FC_SCRLEN FC scratch area DMA length 99153cff3bbSMatt Jacob * 9922df76c16SMatt Jacob * ISP_MEMZERO(dst, src) platform zeroing function 9932df76c16SMatt Jacob * ISP_MEMCPY(dst, src, count) platform copying function 9942df76c16SMatt Jacob * ISP_SNPRINTF(buf, bufsize, fmt, ...) snprintf 9952df76c16SMatt Jacob * ISP_DELAY(usecs) microsecond spindelay function 9962df76c16SMatt Jacob * ISP_SLEEP(isp, usecs) microsecond sleep function 9972df76c16SMatt Jacob * 9982df76c16SMatt Jacob * ISP_INLINE ___inline or not- depending on how 9992df76c16SMatt Jacob * good your debugger is 1000*898899d9SMatt Jacob * ISP_MIN shorthand for ((a) < (b))? (a) : (b) 100153cff3bbSMatt Jacob * 100253cff3bbSMatt Jacob * NANOTIME_T nanosecond time type 100353cff3bbSMatt Jacob * 100453cff3bbSMatt Jacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 100553cff3bbSMatt Jacob * 10061dae40ebSMatt Jacob * GET_NANOSEC(NANOTIME_T *) get uint64_t from NANOTIME_T 100753cff3bbSMatt Jacob * 100853cff3bbSMatt Jacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 100953cff3bbSMatt Jacob * subtract two NANOTIME_T values 101053cff3bbSMatt Jacob * 10111dae40ebSMatt Jacob * MAXISPREQUEST(ispsoftc_t *) maximum request queue size 101253cff3bbSMatt Jacob * for this particular board type 101353cff3bbSMatt Jacob * 101437bb79f1SMarius Strobl * MEMORYBARRIER(ispsoftc_t *, barrier_type, offset, size, chan) 101553cff3bbSMatt Jacob * 101653cff3bbSMatt Jacob * Function/Macro the provides memory synchronization on 101753cff3bbSMatt Jacob * various objects so that the ISP's and the system's view 101853cff3bbSMatt Jacob * of the same object is consistent. 101953cff3bbSMatt Jacob * 10201dae40ebSMatt Jacob * MBOX_ACQUIRE(ispsoftc_t *) acquire lock on mailbox regs 102110365e5aSMatt Jacob * MBOX_WAIT_COMPLETE(ispsoftc_t *, mbreg_t *) wait for cmd to be done 10221dae40ebSMatt Jacob * MBOX_NOTIFY_COMPLETE(ispsoftc_t *) notification of mbox cmd donee 10231dae40ebSMatt Jacob * MBOX_RELEASE(ispsoftc_t *) release lock on mailbox regs 102453cff3bbSMatt Jacob * 10252df76c16SMatt Jacob * FC_SCRATCH_ACQUIRE(ispsoftc_t *, chan) acquire lock on FC scratch area 10262df76c16SMatt Jacob * return -1 if you cannot 10272df76c16SMatt Jacob * FC_SCRATCH_RELEASE(ispsoftc_t *, chan) acquire lock on FC scratch area 102853cff3bbSMatt Jacob * 102953cff3bbSMatt Jacob * SCSI_GOOD SCSI 'Good' Status 103053cff3bbSMatt Jacob * SCSI_CHECK SCSI 'Check Condition' Status 103153cff3bbSMatt Jacob * SCSI_BUSY SCSI 'Busy' Status 103253cff3bbSMatt Jacob * SCSI_QFULL SCSI 'Queue Full' Status 103353cff3bbSMatt Jacob * 103453cff3bbSMatt Jacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 10351dae40ebSMatt Jacob * XS_DMA_ADDR_T Platform PCI DMA Address Type 10362df76c16SMatt Jacob * XS_GET_DMA_SEG(..) Get 32 bit dma segment list value 10372df76c16SMatt Jacob * XS_GET_DMA64_SEG(..) Get 64 bit dma segment list value 103853cff3bbSMatt Jacob * XS_ISP(xs) gets an instance out of an XS_T 103953cff3bbSMatt Jacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 104053cff3bbSMatt Jacob * XS_TGT(xs) gets the target "" 104153cff3bbSMatt Jacob * XS_LUN(xs) gets the lun "" 104253cff3bbSMatt Jacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 104353cff3bbSMatt Jacob * XS_CDBLEN(xs) gets the CDB's length "" 104453cff3bbSMatt Jacob * XS_XFRLEN(xs) gets the associated data transfer length "" 104553cff3bbSMatt Jacob * XS_TIME(xs) gets the time (in milliseconds) for this command 10462df76c16SMatt Jacob * XS_GET_RESID(xs) gets the current residual count 10472df76c16SMatt Jacob * XS_GET_RESID(xs, resid) sets the current residual count 104853cff3bbSMatt Jacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 104953cff3bbSMatt Jacob * XS_SNSP(xs) gets a pointer to the associate sense data 105053cff3bbSMatt Jacob * XS_SNSLEN(xs) gets the length of sense data storage 105153cff3bbSMatt Jacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 1052670508b1SMatt Jacob * XS_SNSASC(xs) dereferences XS_SNSP to get the current stored Additional Sense Code 1053670508b1SMatt Jacob * XS_SNSASCQ(xs) dereferences XS_SNSP to get the current stored Additional Sense Code Qualifier 105453cff3bbSMatt Jacob * XS_TAG_P(xs) predicate of whether this command should be tagged 105553cff3bbSMatt Jacob * XS_TAG_TYPE(xs) which type of tag to use 105653cff3bbSMatt Jacob * XS_SETERR(xs) set error state 105753cff3bbSMatt Jacob * 105853cff3bbSMatt Jacob * HBA_NOERROR command has no erros 105953cff3bbSMatt Jacob * HBA_BOTCH hba botched something 106053cff3bbSMatt Jacob * HBA_CMDTIMEOUT command timed out 106153cff3bbSMatt Jacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 106253cff3bbSMatt Jacob * HBA_TGTBSY target returned a BUSY status 106353cff3bbSMatt Jacob * HBA_BUSRESET bus reset destroyed command 106453cff3bbSMatt Jacob * HBA_ABORTED command was aborted (by request) 106553cff3bbSMatt Jacob * HBA_DATAOVR a data overrun was detected 106653cff3bbSMatt Jacob * HBA_ARQFAIL Automatic Request Sense failed 106753cff3bbSMatt Jacob * 106853cff3bbSMatt Jacob * XS_ERR(xs) return current error state 106953cff3bbSMatt Jacob * XS_NOERR(xs) there is no error currently set 107053cff3bbSMatt Jacob * XS_INITERR(xs) initialize error state 107153cff3bbSMatt Jacob * 1072f7c631bcSMatt Jacob * XS_SAVE_SENSE(xs, sp, len) save sense data 107353cff3bbSMatt Jacob * 1074670508b1SMatt Jacob * XS_SENSE_VALID(xs) indicates whether sense is valid 1075670508b1SMatt Jacob * 10761dae40ebSMatt Jacob * DEFAULT_FRAMESIZE(ispsoftc_t *) Default Frame Size 10771dae40ebSMatt Jacob * DEFAULT_EXEC_THROTTLE(ispsoftc_t *) Default Execution Throttle 10782df76c16SMatt Jacob * 10792df76c16SMatt Jacob * GET_DEFAULT_ROLE(ispsoftc_t *, int) Get Default Role for a channel 10802df76c16SMatt Jacob * SET_DEFAULT_ROLE(ispsoftc_t *, int, int) Set Default Role for a channel 10812df76c16SMatt Jacob * DEFAULT_IID(ispsoftc_t *, int) Default SCSI initiator ID 10822df76c16SMatt Jacob * DEFAULT_LOOPID(ispsoftc_t *, int) Default FC Loop ID 10832df76c16SMatt Jacob * 10849cf43b97SMatt Jacob * These establish reasonable defaults for each platform. 10859cf43b97SMatt Jacob * These must be available independent of card NVRAM and are 10869cf43b97SMatt Jacob * to be used should NVRAM not be readable. 108753cff3bbSMatt Jacob * 10882df76c16SMatt Jacob * DEFAULT_NODEWWN(ispsoftc_t *, chan) Default FC Node WWN to use 10892df76c16SMatt Jacob * DEFAULT_PORTWWN(ispsoftc_t *, chan) Default FC Port WWN to use 109053cff3bbSMatt Jacob * 10912df76c16SMatt Jacob * These defines are hooks to allow the setting of node and 10922df76c16SMatt Jacob * port WWNs when NVRAM cannot be read or is to be overriden. 109353cff3bbSMatt Jacob * 10942df76c16SMatt Jacob * ACTIVE_NODEWWN(ispsoftc_t *, chan) FC Node WWN to use 10952df76c16SMatt Jacob * ACTIVE_PORTWWN(ispsoftc_t *, chan) FC Port WWN to use 10962df76c16SMatt Jacob * 10972df76c16SMatt Jacob * After NVRAM is read, these will be invoked to get the 10982df76c16SMatt Jacob * node and port WWNs that will actually be used for this 10992df76c16SMatt Jacob * channel. 11002df76c16SMatt Jacob * 11014fd13c1bSMatt Jacob * 11021dae40ebSMatt Jacob * ISP_IOXPUT_8(ispsoftc_t *, uint8_t srcval, uint8_t *dstptr) 11031dae40ebSMatt Jacob * ISP_IOXPUT_16(ispsoftc_t *, uint16_t srcval, uint16_t *dstptr) 11041dae40ebSMatt Jacob * ISP_IOXPUT_32(ispsoftc_t *, uint32_t srcval, uint32_t *dstptr) 11054fd13c1bSMatt Jacob * 11061dae40ebSMatt Jacob * ISP_IOXGET_8(ispsoftc_t *, uint8_t *srcptr, uint8_t dstrval) 11071dae40ebSMatt Jacob * ISP_IOXGET_16(ispsoftc_t *, uint16_t *srcptr, uint16_t dstrval) 11081dae40ebSMatt Jacob * ISP_IOXGET_32(ispsoftc_t *, uint32_t *srcptr, uint32_t dstrval) 11094fd13c1bSMatt Jacob * 11101dae40ebSMatt Jacob * ISP_SWIZZLE_NVRAM_WORD(ispsoftc_t *, uint16_t *) 11114607e8eeSMatt Jacob * ISP_SWIZZLE_NVRAM_LONG(ispsoftc_t *, uint32_t *) 11124607e8eeSMatt Jacob * ISP_SWAP16(ispsoftc_t *, uint16_t srcval) 11134607e8eeSMatt Jacob * ISP_SWAP32(ispsoftc_t *, uint32_t srcval) 111453cff3bbSMatt Jacob */ 11155d571944SMatt Jacob 11162df76c16SMatt Jacob #ifdef ISP_TARGET_MODE 11172df76c16SMatt Jacob /* 11182df76c16SMatt Jacob * The functions below are for the publicly available 11192df76c16SMatt Jacob * target mode functions that are internal to the Qlogic driver. 11202df76c16SMatt Jacob */ 11212df76c16SMatt Jacob 11222df76c16SMatt Jacob /* 11232df76c16SMatt Jacob * This function handles new response queue entry appropriate for target mode. 11242df76c16SMatt Jacob */ 11252df76c16SMatt Jacob int isp_target_notify(ispsoftc_t *, void *, uint32_t *); 11262df76c16SMatt Jacob 11272df76c16SMatt Jacob /* 11282df76c16SMatt Jacob * This function externalizes the ability to acknowledge an Immediate Notify request. 11292df76c16SMatt Jacob */ 11302df76c16SMatt Jacob int isp_notify_ack(ispsoftc_t *, void *); 11312df76c16SMatt Jacob 11322df76c16SMatt Jacob /* 11332df76c16SMatt Jacob * This function externalized acknowledging (success/fail) an ABTS frame 11342df76c16SMatt Jacob */ 11352df76c16SMatt Jacob int isp_acknak_abts(ispsoftc_t *, void *, int); 11362df76c16SMatt Jacob 11372df76c16SMatt Jacob /* 11382df76c16SMatt Jacob * Enable/Disable/Modify a logical unit. 11392df76c16SMatt Jacob * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt) 11402df76c16SMatt Jacob */ 11412df76c16SMatt Jacob #define DFLT_CMND_CNT 0xfe /* unmonitored */ 11422df76c16SMatt Jacob #define DFLT_INOT_CNT 0xfe /* unmonitored */ 11432df76c16SMatt Jacob int isp_lun_cmd(ispsoftc_t *, int, int, int, int, int); 11442df76c16SMatt Jacob 11452df76c16SMatt Jacob /* 11462df76c16SMatt Jacob * General request queue 'put' routine for target mode entries. 11472df76c16SMatt Jacob */ 11482df76c16SMatt Jacob int isp_target_put_entry(ispsoftc_t *isp, void *); 11492df76c16SMatt Jacob 11502df76c16SMatt Jacob /* 11512df76c16SMatt Jacob * General routine to put back an ATIO entry- 11522df76c16SMatt Jacob * used for replenishing f/w resource counts. 11532df76c16SMatt Jacob * The argument is a pointer to a source ATIO 11542df76c16SMatt Jacob * or ATIO2. 11552df76c16SMatt Jacob */ 11562df76c16SMatt Jacob int isp_target_put_atio(ispsoftc_t *, void *); 11572df76c16SMatt Jacob 11582df76c16SMatt Jacob /* 11592df76c16SMatt Jacob * General routine to send a final CTIO for a command- used mostly for 11602df76c16SMatt Jacob * local responses. 11612df76c16SMatt Jacob */ 11622df76c16SMatt Jacob int isp_endcmd(ispsoftc_t *, ...); 11632df76c16SMatt Jacob #define ECMD_SVALID 0x100 11642df76c16SMatt Jacob #define ECMD_TERMINATE 0x200 11652df76c16SMatt Jacob 11662df76c16SMatt Jacob /* 11672df76c16SMatt Jacob * Handle an asynchronous event 11682df76c16SMatt Jacob * 11692df76c16SMatt Jacob * Return nonzero if the interrupt that generated this event has been dismissed. 11702df76c16SMatt Jacob */ 11712df76c16SMatt Jacob int isp_target_async(ispsoftc_t *, int, int); 11722df76c16SMatt Jacob #endif 11736054c3f6SMatt Jacob #endif /* _ISPVAR_H */ 1174