ispvar.h revision 93837
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 93837 2002-04-04 23:46:01Z mjacob $ */ 235388Smjacob/* 335388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters. 435388Smjacob * 566189Smjacob * Copyright (c) 1997, 1998, 1999, 2000 by Matthew Jacob 635388Smjacob * All rights reserved. 752347Smjacob * 835388Smjacob * Redistribution and use in source and binary forms, with or without 935388Smjacob * modification, are permitted provided that the following conditions 1035388Smjacob * are met: 1135388Smjacob * 1. Redistributions of source code must retain the above copyright 1235388Smjacob * notice immediately at the beginning of the file, without modification, 1335388Smjacob * this list of conditions, and the following disclaimer. 1466189Smjacob * 2. The name of the author may not be used to endorse or promote products 1535388Smjacob * derived from this software without specific prior written permission. 1635388Smjacob * 1735388Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1835388Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1935388Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2035388Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 2135388Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2235388Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2335388Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2435388Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2535388Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2635388Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2735388Smjacob * SUCH DAMAGE. 2835388Smjacob * 2935388Smjacob */ 3035388Smjacob 3135388Smjacob#ifndef _ISPVAR_H 3235388Smjacob#define _ISPVAR_H 3335388Smjacob 3444819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__) 3535388Smjacob#include <dev/ic/ispmbox.h> 3653487Smjacob#ifdef ISP_TARGET_MODE 3753487Smjacob#include <dev/ic/isp_target.h> 3856004Smjacob#include <dev/ic/isp_tpublic.h> 3935388Smjacob#endif 4053487Smjacob#endif 4135388Smjacob#ifdef __FreeBSD__ 4235388Smjacob#include <dev/isp/ispmbox.h> 4353487Smjacob#ifdef ISP_TARGET_MODE 4453487Smjacob#include <dev/isp/isp_target.h> 4556004Smjacob#include <dev/isp/isp_tpublic.h> 4635388Smjacob#endif 4753487Smjacob#endif 4835388Smjacob#ifdef __linux__ 4942131Smjacob#include "ispmbox.h" 5053487Smjacob#ifdef ISP_TARGET_MODE 5153487Smjacob#include "isp_target.h" 5256004Smjacob#include "isp_tpublic.h" 5335388Smjacob#endif 5453487Smjacob#endif 5535388Smjacob 5664087Smjacob#define ISP_CORE_VERSION_MAJOR 2 5793837Smjacob#define ISP_CORE_VERSION_MINOR 6 5839235Sgibbs 5935388Smjacob/* 6043420Smjacob * Vector for bus specific code to provide specific services. 6135388Smjacob */ 6235388Smjacobstruct ispsoftc; 6335388Smjacobstruct ispmdvec { 6482689Smjacob int (*dv_rd_isr) 6582689Smjacob (struct ispsoftc *, u_int16_t *, u_int16_t *, u_int16_t *); 6674229Smjacob u_int16_t (*dv_rd_reg) (struct ispsoftc *, int); 6774229Smjacob void (*dv_wr_reg) (struct ispsoftc *, int, u_int16_t); 6874229Smjacob int (*dv_mbxdma) (struct ispsoftc *); 6974229Smjacob int (*dv_dmaset) (struct ispsoftc *, 7082689Smjacob XS_T *, ispreq_t *, u_int16_t *, u_int16_t); 7135388Smjacob void (*dv_dmaclr) 7282689Smjacob (struct ispsoftc *, XS_T *, u_int16_t); 7374229Smjacob void (*dv_reset0) (struct ispsoftc *); 7474229Smjacob void (*dv_reset1) (struct ispsoftc *); 7574229Smjacob void (*dv_dregs) (struct ispsoftc *, const char *); 7692893Smjacob u_int16_t *dv_ispfw; /* ptr to f/w */ 7735388Smjacob u_int16_t dv_conf1; 7835388Smjacob u_int16_t dv_clock; /* clock frequency */ 7935388Smjacob}; 8035388Smjacob 8164087Smjacob/* 8264087Smjacob * Overall parameters 8364087Smjacob */ 8482689Smjacob#define MAX_TARGETS 16 8582689Smjacob#define MAX_FC_TARG 256 8649909Smjacob#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) 8761772Smjacob#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns 8849909Smjacob 8982689Smjacob/* 9082689Smjacob * 'Types' 9182689Smjacob */ 9282689Smjacob#ifndef ISP_DMA_ADDR_T 9382689Smjacob#define ISP_DMA_ADDR_T u_int32_t 9482689Smjacob#endif 9553487Smjacob 9653487Smjacob/* 9764087Smjacob * Macros to access ISP registers through bus specific layers- 9864087Smjacob * mostly wrappers to vector through the mdvec structure. 9953487Smjacob */ 10082689Smjacob#define ISP_READ_ISR(isp, isrp, semap, mbox0p) \ 10182689Smjacob (*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p) 10253487Smjacob 10353487Smjacob#define ISP_READ(isp, reg) \ 10453487Smjacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 10553487Smjacob 10653487Smjacob#define ISP_WRITE(isp, reg, val) \ 10753487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 10853487Smjacob 10953487Smjacob#define ISP_MBOXDMASETUP(isp) \ 11053487Smjacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 11153487Smjacob 11253487Smjacob#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ 11353487Smjacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) 11453487Smjacob 11553487Smjacob#define ISP_DMAFREE(isp, xs, hndl) \ 11653487Smjacob if ((isp)->isp_mdvec->dv_dmaclr) \ 11753487Smjacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) 11853487Smjacob 11953487Smjacob#define ISP_RESET0(isp) \ 12053487Smjacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 12153487Smjacob#define ISP_RESET1(isp) \ 12253487Smjacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 12364087Smjacob#define ISP_DUMPREGS(isp, m) \ 12464087Smjacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) 12553487Smjacob 12653487Smjacob#define ISP_SETBITS(isp, reg, val) \ 12753487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 12853487Smjacob 12953487Smjacob#define ISP_CLRBITS(isp, reg, val) \ 13053487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 13153487Smjacob 13264087Smjacob/* 13364087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization 13464087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers) 13564087Smjacob * 13664087Smjacob * Defined Memory Barrier Synchronization Types 13764087Smjacob */ 13864087Smjacob#define SYNC_REQUEST 0 /* request queue synchronization */ 13964087Smjacob#define SYNC_RESULT 1 /* result queue synchronization */ 14064087Smjacob#define SYNC_SFORDEV 2 /* scratch, sync for ISP */ 14164087Smjacob#define SYNC_SFORCPU 3 /* scratch, sync for CPU */ 14264087Smjacob#define SYNC_REG 4 /* for registers */ 14364087Smjacob 14464087Smjacob/* 14564087Smjacob * Request/Response Queue defines and macros. 14664087Smjacob * The maximum is defined per platform (and can be based on board type). 14764087Smjacob */ 14864087Smjacob/* This is the size of a queue entry (request and response) */ 14939235Sgibbs#define QENTRY_LEN 64 15064087Smjacob/* Both request and result queue length must be a power of two */ 15164087Smjacob#define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) 15293706Smjacob#ifdef ISP_TARGET_MODE 15393706Smjacob#define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) 15493706Smjacob#else 15564087Smjacob#define RESULT_QUEUE_LEN(x) \ 15664087Smjacob (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) 15793706Smjacob#endif 15839235Sgibbs#define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN)) 15939235Sgibbs#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 16039235Sgibbs#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 16165140Smjacob#define ISP_QFREE(in, out, qlen) \ 16239235Sgibbs ((in == out)? (qlen - 1) : ((in > out)? \ 16352347Smjacob ((qlen - 1) - (in - out)) : (out - in - 1))) 16465140Smjacob#define ISP_QAVAIL(isp) \ 16565140Smjacob ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) 16653487Smjacob 16787635Smjacob#define ISP_ADD_REQUEST(isp, nxti) \ 16887635Smjacob MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN); \ 16987635Smjacob WRITE_REQUEST_QUEUE_IN_POINTER(isp, nxti); \ 17087635Smjacob isp->isp_reqidx = nxti 17153487Smjacob 17235388Smjacob/* 17346968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target 17435388Smjacob */ 17535388Smjacob 17635388Smjacobtypedef struct { 17746968Smjacob u_int isp_gotdparms : 1, 17852347Smjacob isp_req_ack_active_neg : 1, 17952347Smjacob isp_data_line_active_neg: 1, 18035388Smjacob isp_cmd_dma_burst_enable: 1, 18135388Smjacob isp_data_dma_burst_enabl: 1, 18242461Smjacob isp_fifo_threshold : 3, 18343420Smjacob isp_ultramode : 1, 18435388Smjacob isp_diffmode : 1, 18545040Smjacob isp_lvdmode : 1, 18665140Smjacob isp_fast_mttr : 1, /* fast sram */ 18735388Smjacob isp_initiator_id : 4, 18852347Smjacob isp_async_data_setup : 4; 18952347Smjacob u_int16_t isp_selection_timeout; 19052347Smjacob u_int16_t isp_max_queue_depth; 19135388Smjacob u_int8_t isp_tag_aging; 19252347Smjacob u_int8_t isp_bus_reset_delay; 19352347Smjacob u_int8_t isp_retry_count; 19452347Smjacob u_int8_t isp_retry_delay; 19535388Smjacob struct { 19680582Smjacob u_int32_t 19780582Smjacob exc_throttle : 8, 19846968Smjacob : 1, 19980582Smjacob dev_enable : 1, /* ignored */ 20043420Smjacob dev_update : 1, 20143420Smjacob dev_refresh : 1, 20280582Smjacob actv_offset : 4, 20380582Smjacob goal_offset : 4, 20480582Smjacob nvrm_offset : 4; 20580582Smjacob u_int8_t actv_period; /* current sync period */ 20680582Smjacob u_int8_t goal_period; /* goal sync period */ 20780582Smjacob u_int8_t nvrm_period; /* nvram sync period */ 20880582Smjacob u_int16_t actv_flags; /* current device flags */ 20980582Smjacob u_int16_t goal_flags; /* goal device flags */ 21080582Smjacob u_int16_t nvrm_flags; /* nvram device flags */ 21135388Smjacob } isp_devparam[MAX_TARGETS]; 21246968Smjacob} sdparam; 21335388Smjacob 21435388Smjacob/* 21535388Smjacob * Device Flags 21635388Smjacob */ 21739235Sgibbs#define DPARM_DISC 0x8000 21839235Sgibbs#define DPARM_PARITY 0x4000 21939235Sgibbs#define DPARM_WIDE 0x2000 22039235Sgibbs#define DPARM_SYNC 0x1000 22139235Sgibbs#define DPARM_TQING 0x0800 22239235Sgibbs#define DPARM_ARQ 0x0400 22339235Sgibbs#define DPARM_QFRZ 0x0200 22439235Sgibbs#define DPARM_RENEG 0x0100 22565140Smjacob#define DPARM_NARROW 0x0080 22665140Smjacob#define DPARM_ASYNC 0x0040 22765140Smjacob#define DPARM_PPR 0x0020 22843793Smjacob#define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) 22939235Sgibbs#define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) 23035388Smjacob 23139235Sgibbs 23245040Smjacob/* technically, not really correct, as they need to be rated based upon clock */ 23365140Smjacob#define ISP_80M_SYNCPARMS 0x0c09 23465140Smjacob#define ISP_40M_SYNCPARMS 0x0c0a 23565140Smjacob#define ISP_20M_SYNCPARMS 0x0c0c 23665140Smjacob#define ISP_20M_SYNCPARMS_1040 0x080c 23752347Smjacob#define ISP_10M_SYNCPARMS 0x0c19 23852347Smjacob#define ISP_08M_SYNCPARMS 0x0c25 23952347Smjacob#define ISP_05M_SYNCPARMS 0x0c32 24052347Smjacob#define ISP_04M_SYNCPARMS 0x0c41 24135388Smjacob 24235388Smjacob/* 24335388Smjacob * Fibre Channel Specifics 24435388Smjacob */ 24552347Smjacob#define FL_PORT_ID 0x7e /* FL_Port Special ID */ 24652347Smjacob#define FC_PORT_ID 0x7f /* Fabric Controller Special ID */ 24752347Smjacob#define FC_SNS_ID 0x80 /* SNS Server Special ID */ 24852347Smjacob 24993837Smjacob/* #define ISP_USE_GA_NXT 1 */ /* Use GA_NXT with switches */ 25093837Smjacob#ifndef GA_NXT_MAX 25193837Smjacob#define GA_NXT_MAX 256 25293837Smjacob#endif 25393837Smjacob 25435388Smjacobtypedef struct { 25552347Smjacob u_int32_t isp_fwoptions : 16, 25684241Smjacob isp_gbspeed : 2, 25772355Smjacob isp_iid_set : 1, 25848484Smjacob loop_seen_once : 1, 25977776Smjacob isp_loopstate : 4, /* Current Loop State */ 26048484Smjacob isp_fwstate : 3, /* ISP F/W state */ 26148484Smjacob isp_gotdparms : 1, 26259454Smjacob isp_topo : 3, 26348484Smjacob isp_onfabric : 1; 26472355Smjacob u_int8_t isp_iid; /* 'initiator' id */ 26539235Sgibbs u_int8_t isp_loopid; /* hard loop id */ 26639235Sgibbs u_int8_t isp_alpa; /* ALPA */ 26772355Smjacob u_int32_t isp_portid; 26852347Smjacob volatile u_int16_t isp_lipseq; /* LIP sequence # */ 26982841Smjacob u_int16_t isp_fwattr; /* firmware attributes */ 27039235Sgibbs u_int8_t isp_execthrottle; 27152347Smjacob u_int8_t isp_retry_delay; 27252347Smjacob u_int8_t isp_retry_count; 27352347Smjacob u_int8_t isp_reserved; 27439235Sgibbs u_int16_t isp_maxalloc; 27539235Sgibbs u_int16_t isp_maxfrmlen; 27648484Smjacob u_int64_t isp_nodewwn; 27748484Smjacob u_int64_t isp_portwwn; 27835388Smjacob /* 27948484Smjacob * Port Data Base. This is indexed by 'target', which is invariate. 28048484Smjacob * However, elements within can move around due to loop changes, 28148484Smjacob * so the actual loop ID passed to the F/W is in this structure. 28248484Smjacob * The first time the loop is seen up, loopid will match the index 28348484Smjacob * (except for fabric nodes which are above mapped above FC_SNS_ID 28448484Smjacob * and are completely virtual), but subsequent LIPs can cause things 28548484Smjacob * to move around. 28644819Smjacob */ 28748484Smjacob struct lportdb { 28893837Smjacob u_int32_t 28993837Smjacob port_type : 8, 29093837Smjacob : 4, 29193837Smjacob fc4_type : 4, 29260221Smjacob loopid : 8, 29393837Smjacob last_fabric_dev : 1, 29477776Smjacob force_logout : 1, 29571079Smjacob was_fabric_dev : 1, 29671079Smjacob fabric_dev : 1, 29760221Smjacob loggedin : 1, 29860221Smjacob roles : 2, 29960221Smjacob valid : 1; 30052347Smjacob u_int32_t portid; 30148484Smjacob u_int64_t node_wwn; 30248484Smjacob u_int64_t port_wwn; 30372355Smjacob } portdb[MAX_FC_TARG], tport[FC_PORT_ID]; 30444819Smjacob 30544819Smjacob /* 30635388Smjacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 30735388Smjacob */ 30848195Smjacob caddr_t isp_scratch; 30982689Smjacob ISP_DMA_ADDR_T isp_scdma; 31090752Smjacob#ifdef ISP_FW_CRASH_DUMP 31190752Smjacob u_int16_t *isp_dump_data; 31290752Smjacob#endif 31335388Smjacob} fcparam; 31435388Smjacob 31548484Smjacob#define FW_CONFIG_WAIT 0 31648484Smjacob#define FW_WAIT_AL_PA 1 31748484Smjacob#define FW_WAIT_LOGIN 2 31848484Smjacob#define FW_READY 3 31948484Smjacob#define FW_LOSS_OF_SYNC 4 32048484Smjacob#define FW_ERROR 5 32148484Smjacob#define FW_REINIT 6 32248484Smjacob#define FW_NON_PART 7 32335388Smjacob 32448484Smjacob#define LOOP_NIL 0 32548484Smjacob#define LOOP_LIP_RCVD 1 32648484Smjacob#define LOOP_PDB_RCVD 2 32772355Smjacob#define LOOP_SCANNING_FABRIC 3 32872355Smjacob#define LOOP_FSCAN_DONE 4 32972355Smjacob#define LOOP_SCANNING_LOOP 5 33077776Smjacob#define LOOP_LSCAN_DONE 6 33177776Smjacob#define LOOP_SYNCING_PDB 7 33277776Smjacob#define LOOP_READY 8 33335388Smjacob 33459454Smjacob#define TOPO_NL_PORT 0 33559454Smjacob#define TOPO_FL_PORT 1 33659454Smjacob#define TOPO_N_PORT 2 33759454Smjacob#define TOPO_F_PORT 3 33859454Smjacob#define TOPO_PTP_STUB 4 33959454Smjacob 34042131Smjacob/* 34135388Smjacob * Soft Structure per host adapter 34235388Smjacob */ 34365140Smjacobtypedef struct ispsoftc { 34435388Smjacob /* 34535388Smjacob * Platform (OS) specific data 34635388Smjacob */ 34735388Smjacob struct isposinfo isp_osinfo; 34835388Smjacob 34935388Smjacob /* 35053487Smjacob * Pointer to bus specific functions and data 35135388Smjacob */ 35235388Smjacob struct ispmdvec * isp_mdvec; 35335388Smjacob 35435388Smjacob /* 35553487Smjacob * (Mostly) nonvolatile state. Board specific parameters 35653487Smjacob * may contain some volatile state (e.g., current loop state). 35735388Smjacob */ 35835388Smjacob 35953487Smjacob void * isp_param; /* type specific */ 36053487Smjacob u_int16_t isp_fwrev[3]; /* Loaded F/W revision */ 36153487Smjacob u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */ 36253487Smjacob u_int16_t isp_maxcmds; /* max possible I/O cmds */ 36353487Smjacob u_int8_t isp_type; /* HBA Chip Type */ 36453487Smjacob u_int8_t isp_revision; /* HBA Chip H/W Revision */ 36561772Smjacob u_int32_t isp_maxluns; /* maximum luns supported */ 36635388Smjacob 36771079Smjacob u_int32_t isp_clock : 8, /* input clock */ 36890224Smjacob : 4, 36990224Smjacob isp_port : 1, /* 23XX only */ 37087635Smjacob isp_failed : 1, /* board failed */ 37187635Smjacob isp_open : 1, /* opened (ioctl) */ 37253487Smjacob isp_touched : 1, /* board ever seen? */ 37353487Smjacob isp_bustype : 1, /* SBus or PCI */ 37465140Smjacob isp_loaded_fw : 1, /* loaded firmware */ 37587635Smjacob isp_role : 2, /* roles supported */ 37671079Smjacob isp_dblev : 12; /* debug log mask */ 37771079Smjacob 37871079Smjacob u_int32_t isp_confopts; /* config options */ 37971079Smjacob 38082689Smjacob u_int16_t isp_rqstinrp; /* register for REQINP */ 38182689Smjacob u_int16_t isp_rqstoutrp; /* register for REQOUTP */ 38282689Smjacob u_int16_t isp_respinrp; /* register for RESINP */ 38382689Smjacob u_int16_t isp_respoutrp; /* register for RESOUTP */ 38482689Smjacob 38569522Smjacob /* 38669522Smjacob * Instrumentation 38769522Smjacob */ 38869522Smjacob u_int64_t isp_intcnt; /* total int count */ 38969522Smjacob u_int64_t isp_intbogus; /* spurious int count */ 39088855Smjacob u_int64_t isp_intmboxc; /* mbox completions */ 39188855Smjacob u_int64_t isp_intoasync; /* other async */ 39288855Smjacob u_int64_t isp_rsltccmplt; /* CMDs on result q */ 39388855Smjacob u_int64_t isp_fphccmplt; /* CMDs via fastpost */ 39488855Smjacob u_int16_t isp_rscchiwater; 39588855Smjacob u_int16_t isp_fpcchiwater; 39639235Sgibbs 39735388Smjacob /* 39839235Sgibbs * Volatile state 39935388Smjacob */ 40035388Smjacob 40162171Smjacob volatile u_int32_t 40287635Smjacob isp_obits : 8, /* mailbox command output */ 40387635Smjacob isp_mboxbsy : 1, /* mailbox command active */ 40439235Sgibbs isp_state : 3, 40546968Smjacob isp_sendmarker : 2, /* send a marker entry */ 40646968Smjacob isp_update : 2, /* update parameters */ 40752347Smjacob isp_nactive : 16; /* how many commands active */ 40852347Smjacob volatile u_int16_t isp_reqodx; /* index of last ISP pickup */ 40952347Smjacob volatile u_int16_t isp_reqidx; /* index of next request */ 41052347Smjacob volatile u_int16_t isp_residx; /* index of next result */ 41192893Smjacob volatile u_int16_t isp_resodx; /* index of next result */ 41292893Smjacob volatile u_int16_t isp_rspbsy; 41352347Smjacob volatile u_int16_t isp_lasthdls; /* last handle seed */ 41462171Smjacob volatile u_int16_t isp_mboxtmp[MAX_MAILBOX]; 41571079Smjacob volatile u_int16_t isp_lastmbxcmd; /* last mbox command sent */ 41690224Smjacob volatile u_int16_t isp_mbxwrk0; 41790224Smjacob volatile u_int16_t isp_mbxwrk1; 41890224Smjacob volatile u_int16_t isp_mbxwrk2; 41990224Smjacob void * isp_mbxworkp; 42035388Smjacob 42135388Smjacob /* 42253487Smjacob * Active commands are stored here, indexed by handle functions. 42335388Smjacob */ 42464087Smjacob XS_T **isp_xflist; 42535388Smjacob 42635388Smjacob /* 42752347Smjacob * request/result queue pointers and dma handles for them. 42835388Smjacob */ 42948195Smjacob caddr_t isp_rquest; 43048195Smjacob caddr_t isp_result; 43182689Smjacob ISP_DMA_ADDR_T isp_rquest_dma; 43282689Smjacob ISP_DMA_ADDR_T isp_result_dma; 43365140Smjacob} ispsoftc_t; 43435388Smjacob 43549909Smjacob#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) 43649909Smjacob#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) 43749909Smjacob 43835388Smjacob/* 43964087Smjacob * ISP Driver Run States 44035388Smjacob */ 44135388Smjacob#define ISP_NILSTATE 0 44235388Smjacob#define ISP_RESETSTATE 1 44335388Smjacob#define ISP_INITSTATE 2 44435388Smjacob#define ISP_RUNSTATE 3 44535388Smjacob 44635388Smjacob/* 44735388Smjacob * ISP Configuration Options 44835388Smjacob */ 44935388Smjacob#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 45043793Smjacob#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 45184241Smjacob#define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ 45284241Smjacob#define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ 45353487Smjacob#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 45469522Smjacob#define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ 45569522Smjacob#define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ 45669522Smjacob#define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ 45769522Smjacob#define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ 45869522Smjacob#define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ 45990752Smjacob#define ISP_CFG_OWNWWPN 0x100 /* override NVRAM wwpn */ 46090752Smjacob#define ISP_CFG_OWNWWNN 0x200 /* override NVRAM wwnn */ 46135388Smjacob 46264087Smjacob/* 46371079Smjacob * Prior to calling isp_reset for the first time, the outer layer 46471079Smjacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH. 46571079Smjacob * 46671079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, 46771079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g. 46871079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. 46971079Smjacob * 47071079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped 47171079Smjacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT. 47271079Smjacob * 47371079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support 47471079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards 47571079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB 47671079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or 47771079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see 47871079Smjacob * anything. Basically, it sends a single byte of data (the first byte, 47971079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for 48071079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command. 48179235Smjacob * 48271079Smjacob */ 48371079Smjacob#define ISP_ROLE_NONE 0x0 48471079Smjacob#define ISP_ROLE_INITIATOR 0x1 48571079Smjacob#define ISP_ROLE_TARGET 0x2 48671079Smjacob#define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) 48771079Smjacob#define ISP_ROLE_EITHER ISP_ROLE_BOTH 48871079Smjacob#ifndef ISP_DEFAULT_ROLES 48971079Smjacob#define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR 49071079Smjacob#endif 49171079Smjacob 49271079Smjacob 49371079Smjacob/* 49464087Smjacob * Firmware related defines 49564087Smjacob */ 49671079Smjacob#define ISP_CODE_ORG 0x1000 /* default f/w code start */ 49782689Smjacob#define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ 49845282Smjacob#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 49982841Smjacob#define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) 50082841Smjacob#define ISP_FW_MINOR(code) ((code >> 16) & 0xff) 50182841Smjacob#define ISP_FW_MICRO(code) ((code >> 8) & 0xff) 50271079Smjacob#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 50382841Smjacob#define ISP_FW_MAJORX(xp) (xp[0]) 50482841Smjacob#define ISP_FW_MINORX(xp) (xp[1]) 50582841Smjacob#define ISP_FW_MICROX(xp) (xp[2]) 50639235Sgibbs 50735388Smjacob/* 50839235Sgibbs * Bus (implementation) types 50935388Smjacob */ 51039235Sgibbs#define ISP_BT_PCI 0 /* PCI Implementations */ 51139235Sgibbs#define ISP_BT_SBUS 1 /* SBus Implementations */ 51239235Sgibbs 51339235Sgibbs/* 51487635Smjacob * If we have not otherwise defined SBus support away make sure 51587635Smjacob * it is defined here such that the code is included as default 51687635Smjacob */ 51787635Smjacob#ifndef ISP_SBUS_SUPPORTED 51887635Smjacob#define ISP_SBUS_SUPPORTED 1 51987635Smjacob#endif 52087635Smjacob 52187635Smjacob/* 52239235Sgibbs * Chip Types 52339235Sgibbs */ 52435388Smjacob#define ISP_HA_SCSI 0xf 52539235Sgibbs#define ISP_HA_SCSI_UNKNOWN 0x1 52639235Sgibbs#define ISP_HA_SCSI_1020 0x2 52739235Sgibbs#define ISP_HA_SCSI_1020A 0x3 52839235Sgibbs#define ISP_HA_SCSI_1040 0x4 52939235Sgibbs#define ISP_HA_SCSI_1040A 0x5 53039235Sgibbs#define ISP_HA_SCSI_1040B 0x6 53145282Smjacob#define ISP_HA_SCSI_1040C 0x7 53254671Smjacob#define ISP_HA_SCSI_1240 0x8 53354671Smjacob#define ISP_HA_SCSI_1080 0x9 53454671Smjacob#define ISP_HA_SCSI_1280 0xa 53557145Smjacob#define ISP_HA_SCSI_12160 0xb 53635388Smjacob#define ISP_HA_FC 0xf0 53735388Smjacob#define ISP_HA_FC_2100 0x10 53848484Smjacob#define ISP_HA_FC_2200 0x20 53977365Smjacob#define ISP_HA_FC_2300 0x30 54088855Smjacob#define ISP_HA_FC_2312 0x40 54135388Smjacob 54244819Smjacob#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 54354671Smjacob#define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 54444819Smjacob#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 54554671Smjacob#define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 54657145Smjacob#define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 54757145Smjacob 54857145Smjacob#define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 54957145Smjacob#define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 55057145Smjacob#define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_12160(isp)) 55157145Smjacob#define IS_ULTRA3(isp) (IS_12160(isp)) 55257145Smjacob 55377365Smjacob#define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) 55477365Smjacob#define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) 55577365Smjacob#define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) 55688855Smjacob#define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300) 55788855Smjacob#define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) 55888855Smjacob#define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) 55944819Smjacob 56064087Smjacob/* 56164087Smjacob * DMA cookie macros 56264087Smjacob */ 56382689Smjacob#define DMA_WD3(x) 0 56482689Smjacob#define DMA_WD2(x) 0 56582689Smjacob#define DMA_WD1(x) (((x) >> 16) & 0xffff) 56682689Smjacob#define DMA_WD0(x) (((x) & 0xffff)) 56757145Smjacob 56835388Smjacob/* 56964087Smjacob * Core System Function Prototypes 57035388Smjacob */ 57135388Smjacob 57235388Smjacob/* 57339235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with 57439235Sgibbs * a call to isp_init. 57535388Smjacob */ 57674229Smjacobvoid isp_reset(struct ispsoftc *); 57735388Smjacob 57835388Smjacob/* 57935388Smjacob * Initialize Hardware to known state 58035388Smjacob */ 58174229Smjacobvoid isp_init(struct ispsoftc *); 58235388Smjacob 58335388Smjacob/* 58439235Sgibbs * Reset the ISP and call completion for any orphaned commands. 58539235Sgibbs */ 58674229Smjacobvoid isp_reinit(struct ispsoftc *); 58739235Sgibbs 58890752Smjacob#ifdef ISP_FW_CRASH_DUMP 58939235Sgibbs/* 59090752Smjacob * Dump firmware entry point. 59190752Smjacob */ 59290752Smjacobvoid isp_fw_dump(struct ispsoftc *isp); 59390752Smjacob#endif 59490752Smjacob 59590752Smjacob/* 59682689Smjacob * Internal Interrupt Service Routine 59782689Smjacob * 59882689Smjacob * The outer layers do the spade work to get the appropriate status register, 59982689Smjacob * semaphore register and first mailbox register (if appropriate). This also 60082689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first. 60135388Smjacob */ 60282689Smjacobvoid isp_intr(struct ispsoftc *, u_int16_t, u_int16_t, u_int16_t); 60335388Smjacob 60482689Smjacob 60535388Smjacob/* 60664087Smjacob * Command Entry Point- Platform Dependent layers call into this 60735388Smjacob */ 60874229Smjacobint isp_start(XS_T *); 60964087Smjacob/* these values are what isp_start returns */ 61064087Smjacob#define CMD_COMPLETE 101 /* command completed */ 61164087Smjacob#define CMD_EAGAIN 102 /* busy- maybe retry later */ 61264087Smjacob#define CMD_QUEUED 103 /* command has been queued for execution */ 61364087Smjacob#define CMD_RQLATER 104 /* requeue this command later */ 61435388Smjacob 61539235Sgibbs/* 61664087Smjacob * Command Completion Point- Core layers call out from this with completed cmds 61764087Smjacob */ 61874229Smjacobvoid isp_done(XS_T *); 61964087Smjacob 62064087Smjacob/* 62143420Smjacob * Platform Dependent to External to Internal Control Function 62239235Sgibbs * 62372355Smjacob * Assumes locks are held on entry. You should note that with many of 62472355Smjacob * these commands and locks may be released while this is occurring. 62539235Sgibbs * 62672355Smjacob * A few notes about some of these functions: 62772355Smjacob * 62872355Smjacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link. 62972355Smjacob * The argument is a pointer to an integer which is the time, in microseconds, 63072355Smjacob * we should wait to see whether we have good link. This test, if successful, 63172355Smjacob * lets us know our connection topology and our Loop ID/AL_PA and so on. 63272355Smjacob * You can't get anywhere without this. 63372355Smjacob * 63472355Smjacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for 63572355Smjacob * all entities using the FC Generic Services subcommand GET ALL NEXT. 63672355Smjacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see 63772355Smjacob * below). 63872355Smjacob * 63972355Smjacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection 64072355Smjacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w 64172355Smjacob * 'automatically' manages local loop connections, this function essentially 64272355Smjacob * notes the arrival, departure, and possible shuffling around of local loop 64372355Smjacob * entities. Thus for each arrival and departure this generates an isp_async 64472355Smjacob * event of ISPASYNC_PROMENADE (see below). 64572355Smjacob * 64672355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in 64772355Smjacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. 64872355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging 64972355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking 65072355Smjacob * the 'loop state' as being ready to now be used for sending commands to 65172355Smjacob * devices. Originally fabric name server and local loop scanning were 65281794Smjacob * part of this function. It's now been separated to allow for finer control. 65339235Sgibbs */ 65439235Sgibbstypedef enum { 65548484Smjacob ISPCTL_RESET_BUS, /* Reset Bus */ 65648484Smjacob ISPCTL_RESET_DEV, /* Reset Device */ 65748484Smjacob ISPCTL_ABORT_CMD, /* Abort Command */ 65872355Smjacob ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters (SCSI) */ 65955364Smjacob ISPCTL_FCLINK_TEST, /* Test FC Link Status */ 66072355Smjacob ISPCTL_SCAN_FABRIC, /* (Re)scan Fabric Name Server */ 66172355Smjacob ISPCTL_SCAN_LOOP, /* (Re)scan Local Loop */ 66255364Smjacob ISPCTL_PDB_SYNC, /* Synchronize Port Database */ 66372355Smjacob ISPCTL_SEND_LIP, /* Send a LIP */ 66472355Smjacob ISPCTL_GET_POSMAP, /* Get FC-AL position map */ 66572938Smjacob ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ 66655364Smjacob ISPCTL_TOGGLE_TMODE /* toggle target mode */ 66739235Sgibbs} ispctl_t; 66874229Smjacobint isp_control(struct ispsoftc *, ispctl_t, void *); 66939235Sgibbs 67043420Smjacob 67139235Sgibbs/* 67243420Smjacob * Platform Dependent to Internal to External Control Function 67343420Smjacob * (each platform must provide such a function) 67443420Smjacob * 67572355Smjacob * Assumes locks are held. 67672355Smjacob * 67772355Smjacob * A few notes about some of these functions: 67872355Smjacob * 67972355Smjacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has 68072355Smjacob * occurred that invalidates the list of fabric devices known and/or 68172355Smjacob * the list of known loop devices. The argument passed is a pointer 68272355Smjacob * whose values are defined below (local loop change, name server 68372355Smjacob * change, other). 'Other' may simply be a LIP, or a change in 68472355Smjacob * connection topology. 68572355Smjacob * 68672355Smjacob * ISPASYNC_FABRIC_DEV announces the next element in a list of 68772355Smjacob * fabric device names we're getting out of the name server. The 68872355Smjacob * argument points to a GET ALL NEXT response structure. The list 68972355Smjacob * is known to terminate with an entry that refers to ourselves. 69072355Smjacob * One of the main purposes of this function is to allow outer 69172355Smjacob * layers, which are OS dependent, to set policy as to which fabric 69272355Smjacob * devices might actually be logged into (and made visible) later 69372355Smjacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric 69472355Smjacob * devices that we can log into (256 less 3 'reserved' for F-port 69572355Smjacob * topologies), and fabrics can grow up to 8 million or so entries 69672355Smjacob * (24 bits of Port Address, less a wad of reserved spaces), clearly 69772355Smjacob * we had better let the OS determine login policy. 69872355Smjacob * 69972355Smjacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which 70072355Smjacob * is an index into the portdb in the softc ('target'). Whether that entrie's 70172355Smjacob * valid tag is set or not says whether something has arrived or departed. 70272355Smjacob * The name refers to a favorite pastime of many city dwellers- watching 70372355Smjacob * people come and go, talking of Michaelangelo, and so on.. 70472938Smjacob * 70572938Smjacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a 70672938Smjacob * response queue entry not otherwise handled. The outer layer should 70787635Smjacob * return non-zero if it handled it. The 'arg' points to an unmassaged 70887635Smjacob * response queue entry. 70943420Smjacob */ 71043420Smjacob 71143420Smjacobtypedef enum { 71272355Smjacob ISPASYNC_NEW_TGT_PARAMS, /* New Target Parameters Negotiated */ 71348484Smjacob ISPASYNC_BUS_RESET, /* Bus Was Reset */ 71448484Smjacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 71548484Smjacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 71677365Smjacob ISPASYNC_LIP, /* LIP Received */ 71777365Smjacob ISPASYNC_LOOP_RESET, /* Loop Reset Received */ 71872355Smjacob ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ 71972355Smjacob ISPASYNC_FABRIC_DEV, /* FC Fabric Device Arrival */ 72072355Smjacob ISPASYNC_PROMENADE, /* FC Objects coming && going */ 72155364Smjacob ISPASYNC_TARGET_MESSAGE, /* target message */ 72255364Smjacob ISPASYNC_TARGET_EVENT, /* target asynchronous event */ 72372355Smjacob ISPASYNC_TARGET_ACTION, /* other target command action */ 72472938Smjacob ISPASYNC_CONF_CHANGE, /* Platform Configuration Change */ 72579235Smjacob ISPASYNC_UNHANDLED_RESPONSE, /* Unhandled Response Entry */ 72679235Smjacob ISPASYNC_FW_CRASH /* Firmware has crashed */ 72743420Smjacob} ispasync_t; 72874229Smjacobint isp_async(struct ispsoftc *, ispasync_t, void *); 72943420Smjacob 73072355Smjacob#define ISPASYNC_CHANGE_PDB ((void *) 0) 73172355Smjacob#define ISPASYNC_CHANGE_SNS ((void *) 1) 73272355Smjacob#define ISPASYNC_CHANGE_OTHER ((void *) 2) 73372355Smjacob 73443420Smjacob/* 73564087Smjacob * Platform Dependent Error and Debug Printout 73639235Sgibbs */ 73770490Smjacob#ifdef __GNUC__ 73874229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...) 73970490Smjacob __attribute__((__format__(__printf__,3,4))); 74070490Smjacob#else 74174229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...); 74270490Smjacob#endif 74370490Smjacob 74464087Smjacob#define ISP_LOGALL 0x0 /* log always */ 74564087Smjacob#define ISP_LOGCONFIG 0x1 /* log configuration messages */ 74664087Smjacob#define ISP_LOGINFO 0x2 /* log informational messages */ 74764087Smjacob#define ISP_LOGWARN 0x4 /* log warning messages */ 74864087Smjacob#define ISP_LOGERR 0x8 /* log error messages */ 74964087Smjacob#define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 75064087Smjacob#define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 75164087Smjacob#define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 75279235Smjacob#define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ 75379235Smjacob#define ISP_LOGDEBUG4 0x100 /* log high frequency debug messages */ 75464087Smjacob#define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ 75564087Smjacob#define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ 75664087Smjacob#define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ 75739235Sgibbs 75864087Smjacob/* 75964087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 76064087Smjacob * defined above. 76164087Smjacob * 76264087Smjacob * Each platform must also provide the following macros/defines: 76364087Smjacob * 76464087Smjacob * 76564087Smjacob * INLINE - platform specific define for 'inline' functions 76664087Smjacob * 76782689Smjacob * ISP_DMA_ADDR_T - platform specific dma address coookie- basically 76882689Smjacob * the largest integer that can hold the 32 or 76982689Smjacob * 64 bit value appropriate for the QLogic's DMA 77082689Smjacob * addressing. Defaults to u_int32_t. 77182689Smjacob * 77264087Smjacob * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area 77364087Smjacob * 77464087Smjacob * MEMZERO(dst, src) platform zeroing function 77564087Smjacob * MEMCPY(dst, src, count) platform copying function 77664087Smjacob * SNPRINTF(buf, bufsize, fmt, ...) snprintf 77764087Smjacob * STRNCAT(dstbuf, size, srcbuf) strncat 77864087Smjacob * USEC_DELAY(usecs) microsecond spindelay function 77969522Smjacob * USEC_SLEEP(isp, usecs) microsecond sleep function 78064087Smjacob * 78164087Smjacob * NANOTIME_T nanosecond time type 78264087Smjacob * 78364087Smjacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 78464087Smjacob * 78564087Smjacob * GET_NANOSEC(NANOTIME_T *) get u_int64_t from NANOTIME_T 78664087Smjacob * 78764087Smjacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 78864087Smjacob * subtract two NANOTIME_T values 78964087Smjacob * 79064087Smjacob * 79164087Smjacob * MAXISPREQUEST(struct ispsoftc *) maximum request queue size 79264087Smjacob * for this particular board type 79364087Smjacob * 79464087Smjacob * MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size) 79564087Smjacob * 79664087Smjacob * Function/Macro the provides memory synchronization on 79764087Smjacob * various objects so that the ISP's and the system's view 79864087Smjacob * of the same object is consistent. 79964087Smjacob * 80064087Smjacob * MBOX_ACQUIRE(struct ispsoftc *) acquire lock on mailbox regs 80164087Smjacob * MBOX_WAIT_COMPLETE(struct ispsoftc *) wait for mailbox cmd to be done 80264087Smjacob * MBOX_NOTIFY_COMPLETE(struct ispsoftc *) notification of mbox cmd donee 80364087Smjacob * MBOX_RELEASE(struct ispsoftc *) release lock on mailbox regs 80464087Smjacob * 80590224Smjacob * FC_SCRATCH_ACQUIRE(struct ispsoftc *) acquire lock on FC scratch area 80690224Smjacob * FC_SCRATCH_RELEASE(struct ispsoftc *) acquire lock on FC scratch area 80772355Smjacob * 80864087Smjacob * SCSI_GOOD SCSI 'Good' Status 80964087Smjacob * SCSI_CHECK SCSI 'Check Condition' Status 81064087Smjacob * SCSI_BUSY SCSI 'Busy' Status 81164087Smjacob * SCSI_QFULL SCSI 'Queue Full' Status 81264087Smjacob * 81364087Smjacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 81464087Smjacob * XS_ISP(xs) gets an instance out of an XS_T 81564087Smjacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 81664087Smjacob * XS_TGT(xs) gets the target "" 81764087Smjacob * XS_LUN(xs) gets the lun "" 81864087Smjacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 81964087Smjacob * XS_CDBLEN(xs) gets the CDB's length "" 82064087Smjacob * XS_XFRLEN(xs) gets the associated data transfer length "" 82164087Smjacob * XS_TIME(xs) gets the time (in milliseconds) for this command 82264087Smjacob * XS_RESID(xs) gets the current residual count 82364087Smjacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 82464087Smjacob * XS_SNSP(xs) gets a pointer to the associate sense data 82564087Smjacob * XS_SNSLEN(xs) gets the length of sense data storage 82664087Smjacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 82764087Smjacob * XS_TAG_P(xs) predicate of whether this command should be tagged 82864087Smjacob * XS_TAG_TYPE(xs) which type of tag to use 82964087Smjacob * XS_SETERR(xs) set error state 83064087Smjacob * 83164087Smjacob * HBA_NOERROR command has no erros 83264087Smjacob * HBA_BOTCH hba botched something 83364087Smjacob * HBA_CMDTIMEOUT command timed out 83464087Smjacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 83564087Smjacob * HBA_TGTBSY target returned a BUSY status 83664087Smjacob * HBA_BUSRESET bus reset destroyed command 83764087Smjacob * HBA_ABORTED command was aborted (by request) 83864087Smjacob * HBA_DATAOVR a data overrun was detected 83964087Smjacob * HBA_ARQFAIL Automatic Request Sense failed 84064087Smjacob * 84164087Smjacob * XS_ERR(xs) return current error state 84264087Smjacob * XS_NOERR(xs) there is no error currently set 84364087Smjacob * XS_INITERR(xs) initialize error state 84464087Smjacob * 84564087Smjacob * XS_SAVE_SENSE(xs, sp) save sense data 84664087Smjacob * 84764087Smjacob * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of 84864087Smjacob * response queue entry status bits 84964087Smjacob * 85064087Smjacob * 85164087Smjacob * DEFAULT_IID(struct ispsoftc *) Default SCSI initiator ID 85264087Smjacob * DEFAULT_LOOPID(struct ispsoftc *) Default FC Loop ID 85367047Smjacob * DEFAULT_NODEWWN(struct ispsoftc *) Default Node WWN 85467047Smjacob * DEFAULT_PORTWWN(struct ispsoftc *) Default Port WWN 85567047Smjacob * These establish reasonable defaults for each platform. 85667047Smjacob * These must be available independent of card NVRAM and are 85767047Smjacob * to be used should NVRAM not be readable. 85864087Smjacob * 85967047Smjacob * ISP_NODEWWN(struct ispsoftc *) FC Node WWN to use 86067047Smjacob * ISP_PORTWWN(struct ispsoftc *) FC Port WWN to use 86164087Smjacob * 86267047Smjacob * These are to be used after NVRAM is read. The tags 86367047Smjacob * in fcparam.isp_{node,port}wwn reflect the values 86467047Smjacob * read from NVRAM (possibly corrected for card botches). 86567047Smjacob * Each platform can take that information and override 86667047Smjacob * it or ignore and return the Node and Port WWNs to be 86767047Smjacob * used when sending the Qlogic f/w the Initialization Control 86867047Smjacob * Block. 86964087Smjacob * 87064087Smjacob * (XXX these do endian specific transformations- in transition XXX) 87187635Smjacob * 87287635Smjacob * ISP_IOXPUT_8(struct ispsoftc *, u_int8_t srcval, u_int8_t *dstptr) 87387635Smjacob * ISP_IOXPUT_16(struct ispsoftc *, u_int16_t srcval, u_int16_t *dstptr) 87487635Smjacob * ISP_IOXPUT_32(struct ispsoftc *, u_int32_t srcval, u_int32_t *dstptr) 87587635Smjacob * 87687635Smjacob * ISP_IOXGET_8(struct ispsoftc *, u_int8_t *srcptr, u_int8_t dstrval) 87787635Smjacob * ISP_IOXGET_16(struct ispsoftc *, u_int16_t *srcptr, u_int16_t dstrval) 87887635Smjacob * ISP_IOXGET_32(struct ispsoftc *, u_int32_t *srcptr, u_int32_t dstrval) 87987635Smjacob * 88087635Smjacob * ISP_SWIZZLE_NVRAM_WORD(struct ispsoftc *, u_int16_t *) 88164087Smjacob */ 88277365Smjacob 88335388Smjacob#endif /* _ISPVAR_H */ 884