ispvar.h revision 102012
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 102012 2002-08-17 17:19:09Z 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 5798281Smjacob#define ISP_CORE_VERSION_MINOR 7 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, 29098281Smjacob loopid : 8, 29193837Smjacob fc4_type : 4, 29293837Smjacob last_fabric_dev : 1, 29398281Smjacob : 2, 29498281Smjacob relogin : 1, 29577776Smjacob force_logout : 1, 29671079Smjacob was_fabric_dev : 1, 29771079Smjacob fabric_dev : 1, 29860221Smjacob loggedin : 1, 29960221Smjacob roles : 2, 30060221Smjacob valid : 1; 30152347Smjacob u_int32_t portid; 30248484Smjacob u_int64_t node_wwn; 30348484Smjacob u_int64_t port_wwn; 30472355Smjacob } portdb[MAX_FC_TARG], tport[FC_PORT_ID]; 30544819Smjacob 30644819Smjacob /* 30735388Smjacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 30835388Smjacob */ 30948195Smjacob caddr_t isp_scratch; 31082689Smjacob ISP_DMA_ADDR_T isp_scdma; 31190752Smjacob#ifdef ISP_FW_CRASH_DUMP 31290752Smjacob u_int16_t *isp_dump_data; 31390752Smjacob#endif 31435388Smjacob} fcparam; 31535388Smjacob 31648484Smjacob#define FW_CONFIG_WAIT 0 31748484Smjacob#define FW_WAIT_AL_PA 1 31848484Smjacob#define FW_WAIT_LOGIN 2 31948484Smjacob#define FW_READY 3 32048484Smjacob#define FW_LOSS_OF_SYNC 4 32148484Smjacob#define FW_ERROR 5 32248484Smjacob#define FW_REINIT 6 32348484Smjacob#define FW_NON_PART 7 32435388Smjacob 32548484Smjacob#define LOOP_NIL 0 32648484Smjacob#define LOOP_LIP_RCVD 1 32748484Smjacob#define LOOP_PDB_RCVD 2 32872355Smjacob#define LOOP_SCANNING_FABRIC 3 32972355Smjacob#define LOOP_FSCAN_DONE 4 33072355Smjacob#define LOOP_SCANNING_LOOP 5 33177776Smjacob#define LOOP_LSCAN_DONE 6 33277776Smjacob#define LOOP_SYNCING_PDB 7 33377776Smjacob#define LOOP_READY 8 33435388Smjacob 33559454Smjacob#define TOPO_NL_PORT 0 33659454Smjacob#define TOPO_FL_PORT 1 33759454Smjacob#define TOPO_N_PORT 2 33859454Smjacob#define TOPO_F_PORT 3 33959454Smjacob#define TOPO_PTP_STUB 4 34059454Smjacob 34142131Smjacob/* 34235388Smjacob * Soft Structure per host adapter 34335388Smjacob */ 34465140Smjacobtypedef struct ispsoftc { 34535388Smjacob /* 34635388Smjacob * Platform (OS) specific data 34735388Smjacob */ 34835388Smjacob struct isposinfo isp_osinfo; 34935388Smjacob 35035388Smjacob /* 35153487Smjacob * Pointer to bus specific functions and data 35235388Smjacob */ 35335388Smjacob struct ispmdvec * isp_mdvec; 35435388Smjacob 35535388Smjacob /* 35653487Smjacob * (Mostly) nonvolatile state. Board specific parameters 35753487Smjacob * may contain some volatile state (e.g., current loop state). 35835388Smjacob */ 35935388Smjacob 36053487Smjacob void * isp_param; /* type specific */ 36153487Smjacob u_int16_t isp_fwrev[3]; /* Loaded F/W revision */ 36253487Smjacob u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */ 36353487Smjacob u_int16_t isp_maxcmds; /* max possible I/O cmds */ 36453487Smjacob u_int8_t isp_type; /* HBA Chip Type */ 36553487Smjacob u_int8_t isp_revision; /* HBA Chip H/W Revision */ 36661772Smjacob u_int32_t isp_maxluns; /* maximum luns supported */ 36735388Smjacob 36871079Smjacob u_int32_t isp_clock : 8, /* input clock */ 36990224Smjacob : 4, 37090224Smjacob isp_port : 1, /* 23XX only */ 37187635Smjacob isp_failed : 1, /* board failed */ 37287635Smjacob isp_open : 1, /* opened (ioctl) */ 37353487Smjacob isp_touched : 1, /* board ever seen? */ 37453487Smjacob isp_bustype : 1, /* SBus or PCI */ 37565140Smjacob isp_loaded_fw : 1, /* loaded firmware */ 37687635Smjacob isp_role : 2, /* roles supported */ 37771079Smjacob isp_dblev : 12; /* debug log mask */ 37871079Smjacob 37971079Smjacob u_int32_t isp_confopts; /* config options */ 38071079Smjacob 38182689Smjacob u_int16_t isp_rqstinrp; /* register for REQINP */ 38282689Smjacob u_int16_t isp_rqstoutrp; /* register for REQOUTP */ 38382689Smjacob u_int16_t isp_respinrp; /* register for RESINP */ 38482689Smjacob u_int16_t isp_respoutrp; /* register for RESOUTP */ 38582689Smjacob 38669522Smjacob /* 38769522Smjacob * Instrumentation 38869522Smjacob */ 38969522Smjacob u_int64_t isp_intcnt; /* total int count */ 39069522Smjacob u_int64_t isp_intbogus; /* spurious int count */ 39188855Smjacob u_int64_t isp_intmboxc; /* mbox completions */ 39288855Smjacob u_int64_t isp_intoasync; /* other async */ 39388855Smjacob u_int64_t isp_rsltccmplt; /* CMDs on result q */ 39488855Smjacob u_int64_t isp_fphccmplt; /* CMDs via fastpost */ 39588855Smjacob u_int16_t isp_rscchiwater; 39688855Smjacob u_int16_t isp_fpcchiwater; 39739235Sgibbs 39835388Smjacob /* 39939235Sgibbs * Volatile state 40035388Smjacob */ 40135388Smjacob 40262171Smjacob volatile u_int32_t 40387635Smjacob isp_obits : 8, /* mailbox command output */ 40487635Smjacob isp_mboxbsy : 1, /* mailbox command active */ 40539235Sgibbs isp_state : 3, 40646968Smjacob isp_sendmarker : 2, /* send a marker entry */ 40746968Smjacob isp_update : 2, /* update parameters */ 40852347Smjacob isp_nactive : 16; /* how many commands active */ 40952347Smjacob volatile u_int16_t isp_reqodx; /* index of last ISP pickup */ 41052347Smjacob volatile u_int16_t isp_reqidx; /* index of next request */ 41152347Smjacob volatile u_int16_t isp_residx; /* index of next result */ 41292893Smjacob volatile u_int16_t isp_resodx; /* index of next result */ 41392893Smjacob volatile u_int16_t isp_rspbsy; 41452347Smjacob volatile u_int16_t isp_lasthdls; /* last handle seed */ 41562171Smjacob volatile u_int16_t isp_mboxtmp[MAX_MAILBOX]; 41671079Smjacob volatile u_int16_t isp_lastmbxcmd; /* last mbox command sent */ 41790224Smjacob volatile u_int16_t isp_mbxwrk0; 41890224Smjacob volatile u_int16_t isp_mbxwrk1; 41990224Smjacob volatile u_int16_t isp_mbxwrk2; 42090224Smjacob void * isp_mbxworkp; 42135388Smjacob 42235388Smjacob /* 42353487Smjacob * Active commands are stored here, indexed by handle functions. 42435388Smjacob */ 42564087Smjacob XS_T **isp_xflist; 42635388Smjacob 42735388Smjacob /* 42852347Smjacob * request/result queue pointers and dma handles for them. 42935388Smjacob */ 43048195Smjacob caddr_t isp_rquest; 43148195Smjacob caddr_t isp_result; 43282689Smjacob ISP_DMA_ADDR_T isp_rquest_dma; 43382689Smjacob ISP_DMA_ADDR_T isp_result_dma; 43465140Smjacob} ispsoftc_t; 43535388Smjacob 43649909Smjacob#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) 43749909Smjacob#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) 43849909Smjacob 43935388Smjacob/* 44064087Smjacob * ISP Driver Run States 44135388Smjacob */ 44235388Smjacob#define ISP_NILSTATE 0 44335388Smjacob#define ISP_RESETSTATE 1 44435388Smjacob#define ISP_INITSTATE 2 44535388Smjacob#define ISP_RUNSTATE 3 44635388Smjacob 44735388Smjacob/* 44835388Smjacob * ISP Configuration Options 44935388Smjacob */ 45035388Smjacob#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 45143793Smjacob#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 45284241Smjacob#define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ 45384241Smjacob#define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ 45453487Smjacob#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 45569522Smjacob#define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ 45669522Smjacob#define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ 45769522Smjacob#define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ 45869522Smjacob#define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ 45969522Smjacob#define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ 46090752Smjacob#define ISP_CFG_OWNWWPN 0x100 /* override NVRAM wwpn */ 46190752Smjacob#define ISP_CFG_OWNWWNN 0x200 /* override NVRAM wwnn */ 46298281Smjacob#define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */ 46398281Smjacob#define ISP_CFG_OWNLOOPID 0x800 /* override NVRAM loopid */ 46498281Smjacob#define ISP_CFG_OWNEXCTHROTTLE 0x1000 /* override NVRAM execution throttle */ 46535388Smjacob 46664087Smjacob/* 46771079Smjacob * Prior to calling isp_reset for the first time, the outer layer 46871079Smjacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH. 46971079Smjacob * 47071079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, 47171079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g. 47271079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. 47371079Smjacob * 47471079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped 47571079Smjacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT. 47671079Smjacob * 47771079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support 47871079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards 47971079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB 48071079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or 48171079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see 48271079Smjacob * anything. Basically, it sends a single byte of data (the first byte, 48371079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for 48471079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command. 48579235Smjacob * 48671079Smjacob */ 48771079Smjacob#define ISP_ROLE_NONE 0x0 48871079Smjacob#define ISP_ROLE_INITIATOR 0x1 48971079Smjacob#define ISP_ROLE_TARGET 0x2 49071079Smjacob#define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) 49171079Smjacob#define ISP_ROLE_EITHER ISP_ROLE_BOTH 49271079Smjacob#ifndef ISP_DEFAULT_ROLES 49371079Smjacob#define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR 49471079Smjacob#endif 49571079Smjacob 49671079Smjacob 49771079Smjacob/* 49864087Smjacob * Firmware related defines 49964087Smjacob */ 50071079Smjacob#define ISP_CODE_ORG 0x1000 /* default f/w code start */ 50182689Smjacob#define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ 50245282Smjacob#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 50382841Smjacob#define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) 50482841Smjacob#define ISP_FW_MINOR(code) ((code >> 16) & 0xff) 50582841Smjacob#define ISP_FW_MICRO(code) ((code >> 8) & 0xff) 50671079Smjacob#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 50782841Smjacob#define ISP_FW_MAJORX(xp) (xp[0]) 50882841Smjacob#define ISP_FW_MINORX(xp) (xp[1]) 50982841Smjacob#define ISP_FW_MICROX(xp) (xp[2]) 510102012Smjacob#define ISP_FW_NEWER_THAN(i, major, minor, micro) \ 511102012Smjacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro)) 51239235Sgibbs 51335388Smjacob/* 51439235Sgibbs * Bus (implementation) types 51535388Smjacob */ 51639235Sgibbs#define ISP_BT_PCI 0 /* PCI Implementations */ 51739235Sgibbs#define ISP_BT_SBUS 1 /* SBus Implementations */ 51839235Sgibbs 51939235Sgibbs/* 52087635Smjacob * If we have not otherwise defined SBus support away make sure 52187635Smjacob * it is defined here such that the code is included as default 52287635Smjacob */ 52387635Smjacob#ifndef ISP_SBUS_SUPPORTED 52487635Smjacob#define ISP_SBUS_SUPPORTED 1 52587635Smjacob#endif 52687635Smjacob 52787635Smjacob/* 52839235Sgibbs * Chip Types 52939235Sgibbs */ 53035388Smjacob#define ISP_HA_SCSI 0xf 53139235Sgibbs#define ISP_HA_SCSI_UNKNOWN 0x1 53239235Sgibbs#define ISP_HA_SCSI_1020 0x2 53339235Sgibbs#define ISP_HA_SCSI_1020A 0x3 53439235Sgibbs#define ISP_HA_SCSI_1040 0x4 53539235Sgibbs#define ISP_HA_SCSI_1040A 0x5 53639235Sgibbs#define ISP_HA_SCSI_1040B 0x6 53745282Smjacob#define ISP_HA_SCSI_1040C 0x7 53854671Smjacob#define ISP_HA_SCSI_1240 0x8 53954671Smjacob#define ISP_HA_SCSI_1080 0x9 54054671Smjacob#define ISP_HA_SCSI_1280 0xa 54157145Smjacob#define ISP_HA_SCSI_12160 0xb 54235388Smjacob#define ISP_HA_FC 0xf0 54335388Smjacob#define ISP_HA_FC_2100 0x10 54448484Smjacob#define ISP_HA_FC_2200 0x20 54577365Smjacob#define ISP_HA_FC_2300 0x30 54688855Smjacob#define ISP_HA_FC_2312 0x40 54735388Smjacob 54844819Smjacob#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 54954671Smjacob#define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 55044819Smjacob#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 55154671Smjacob#define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 55257145Smjacob#define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 55357145Smjacob 55457145Smjacob#define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 55557145Smjacob#define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 55657145Smjacob#define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_12160(isp)) 55757145Smjacob#define IS_ULTRA3(isp) (IS_12160(isp)) 55857145Smjacob 55977365Smjacob#define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) 56077365Smjacob#define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) 56177365Smjacob#define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) 56288855Smjacob#define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300) 56388855Smjacob#define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) 56488855Smjacob#define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) 56544819Smjacob 56664087Smjacob/* 56764087Smjacob * DMA cookie macros 56864087Smjacob */ 56982689Smjacob#define DMA_WD3(x) 0 57082689Smjacob#define DMA_WD2(x) 0 57182689Smjacob#define DMA_WD1(x) (((x) >> 16) & 0xffff) 57282689Smjacob#define DMA_WD0(x) (((x) & 0xffff)) 57357145Smjacob 57435388Smjacob/* 57564087Smjacob * Core System Function Prototypes 57635388Smjacob */ 57735388Smjacob 57835388Smjacob/* 57939235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with 58039235Sgibbs * a call to isp_init. 58135388Smjacob */ 58274229Smjacobvoid isp_reset(struct ispsoftc *); 58335388Smjacob 58435388Smjacob/* 58535388Smjacob * Initialize Hardware to known state 58635388Smjacob */ 58774229Smjacobvoid isp_init(struct ispsoftc *); 58835388Smjacob 58935388Smjacob/* 59039235Sgibbs * Reset the ISP and call completion for any orphaned commands. 59139235Sgibbs */ 59274229Smjacobvoid isp_reinit(struct ispsoftc *); 59339235Sgibbs 59490752Smjacob#ifdef ISP_FW_CRASH_DUMP 59539235Sgibbs/* 59690752Smjacob * Dump firmware entry point. 59790752Smjacob */ 59890752Smjacobvoid isp_fw_dump(struct ispsoftc *isp); 59990752Smjacob#endif 60090752Smjacob 60190752Smjacob/* 60282689Smjacob * Internal Interrupt Service Routine 60382689Smjacob * 60482689Smjacob * The outer layers do the spade work to get the appropriate status register, 60582689Smjacob * semaphore register and first mailbox register (if appropriate). This also 60682689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first. 60735388Smjacob */ 60882689Smjacobvoid isp_intr(struct ispsoftc *, u_int16_t, u_int16_t, u_int16_t); 60935388Smjacob 61082689Smjacob 61135388Smjacob/* 61264087Smjacob * Command Entry Point- Platform Dependent layers call into this 61335388Smjacob */ 61474229Smjacobint isp_start(XS_T *); 61564087Smjacob/* these values are what isp_start returns */ 61664087Smjacob#define CMD_COMPLETE 101 /* command completed */ 61764087Smjacob#define CMD_EAGAIN 102 /* busy- maybe retry later */ 61864087Smjacob#define CMD_QUEUED 103 /* command has been queued for execution */ 61964087Smjacob#define CMD_RQLATER 104 /* requeue this command later */ 62035388Smjacob 62139235Sgibbs/* 62264087Smjacob * Command Completion Point- Core layers call out from this with completed cmds 62364087Smjacob */ 62474229Smjacobvoid isp_done(XS_T *); 62564087Smjacob 62664087Smjacob/* 62743420Smjacob * Platform Dependent to External to Internal Control Function 62839235Sgibbs * 62972355Smjacob * Assumes locks are held on entry. You should note that with many of 63072355Smjacob * these commands and locks may be released while this is occurring. 63139235Sgibbs * 63272355Smjacob * A few notes about some of these functions: 63372355Smjacob * 63472355Smjacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link. 63572355Smjacob * The argument is a pointer to an integer which is the time, in microseconds, 63672355Smjacob * we should wait to see whether we have good link. This test, if successful, 63772355Smjacob * lets us know our connection topology and our Loop ID/AL_PA and so on. 63872355Smjacob * You can't get anywhere without this. 63972355Smjacob * 64072355Smjacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for 64172355Smjacob * all entities using the FC Generic Services subcommand GET ALL NEXT. 64272355Smjacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see 64372355Smjacob * below). 64472355Smjacob * 64572355Smjacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection 64672355Smjacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w 64772355Smjacob * 'automatically' manages local loop connections, this function essentially 64872355Smjacob * notes the arrival, departure, and possible shuffling around of local loop 64972355Smjacob * entities. Thus for each arrival and departure this generates an isp_async 65072355Smjacob * event of ISPASYNC_PROMENADE (see below). 65172355Smjacob * 65272355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in 65372355Smjacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. 65472355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging 65572355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking 65672355Smjacob * the 'loop state' as being ready to now be used for sending commands to 65772355Smjacob * devices. Originally fabric name server and local loop scanning were 65881794Smjacob * part of this function. It's now been separated to allow for finer control. 65939235Sgibbs */ 66039235Sgibbstypedef enum { 66148484Smjacob ISPCTL_RESET_BUS, /* Reset Bus */ 66248484Smjacob ISPCTL_RESET_DEV, /* Reset Device */ 66348484Smjacob ISPCTL_ABORT_CMD, /* Abort Command */ 66472355Smjacob ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters (SCSI) */ 66555364Smjacob ISPCTL_FCLINK_TEST, /* Test FC Link Status */ 66672355Smjacob ISPCTL_SCAN_FABRIC, /* (Re)scan Fabric Name Server */ 66772355Smjacob ISPCTL_SCAN_LOOP, /* (Re)scan Local Loop */ 66855364Smjacob ISPCTL_PDB_SYNC, /* Synchronize Port Database */ 66972355Smjacob ISPCTL_SEND_LIP, /* Send a LIP */ 67072355Smjacob ISPCTL_GET_POSMAP, /* Get FC-AL position map */ 67172938Smjacob ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ 67255364Smjacob ISPCTL_TOGGLE_TMODE /* toggle target mode */ 67339235Sgibbs} ispctl_t; 67474229Smjacobint isp_control(struct ispsoftc *, ispctl_t, void *); 67539235Sgibbs 67643420Smjacob 67739235Sgibbs/* 67843420Smjacob * Platform Dependent to Internal to External Control Function 67943420Smjacob * (each platform must provide such a function) 68043420Smjacob * 68172355Smjacob * Assumes locks are held. 68272355Smjacob * 68372355Smjacob * A few notes about some of these functions: 68472355Smjacob * 68572355Smjacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has 68672355Smjacob * occurred that invalidates the list of fabric devices known and/or 68772355Smjacob * the list of known loop devices. The argument passed is a pointer 68872355Smjacob * whose values are defined below (local loop change, name server 68972355Smjacob * change, other). 'Other' may simply be a LIP, or a change in 69072355Smjacob * connection topology. 69172355Smjacob * 69272355Smjacob * ISPASYNC_FABRIC_DEV announces the next element in a list of 69372355Smjacob * fabric device names we're getting out of the name server. The 69472355Smjacob * argument points to a GET ALL NEXT response structure. The list 69572355Smjacob * is known to terminate with an entry that refers to ourselves. 69672355Smjacob * One of the main purposes of this function is to allow outer 69772355Smjacob * layers, which are OS dependent, to set policy as to which fabric 69872355Smjacob * devices might actually be logged into (and made visible) later 69972355Smjacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric 70072355Smjacob * devices that we can log into (256 less 3 'reserved' for F-port 70172355Smjacob * topologies), and fabrics can grow up to 8 million or so entries 70272355Smjacob * (24 bits of Port Address, less a wad of reserved spaces), clearly 70372355Smjacob * we had better let the OS determine login policy. 70472355Smjacob * 70572355Smjacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which 70672355Smjacob * is an index into the portdb in the softc ('target'). Whether that entrie's 70772355Smjacob * valid tag is set or not says whether something has arrived or departed. 70872355Smjacob * The name refers to a favorite pastime of many city dwellers- watching 70972355Smjacob * people come and go, talking of Michaelangelo, and so on.. 71072938Smjacob * 71172938Smjacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a 71272938Smjacob * response queue entry not otherwise handled. The outer layer should 71387635Smjacob * return non-zero if it handled it. The 'arg' points to an unmassaged 71487635Smjacob * response queue entry. 71543420Smjacob */ 71643420Smjacob 71743420Smjacobtypedef enum { 71872355Smjacob ISPASYNC_NEW_TGT_PARAMS, /* New Target Parameters Negotiated */ 71948484Smjacob ISPASYNC_BUS_RESET, /* Bus Was Reset */ 72048484Smjacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 72148484Smjacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 72277365Smjacob ISPASYNC_LIP, /* LIP Received */ 72377365Smjacob ISPASYNC_LOOP_RESET, /* Loop Reset Received */ 72472355Smjacob ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ 72572355Smjacob ISPASYNC_FABRIC_DEV, /* FC Fabric Device Arrival */ 72672355Smjacob ISPASYNC_PROMENADE, /* FC Objects coming && going */ 72755364Smjacob ISPASYNC_TARGET_MESSAGE, /* target message */ 72855364Smjacob ISPASYNC_TARGET_EVENT, /* target asynchronous event */ 72972355Smjacob ISPASYNC_TARGET_ACTION, /* other target command action */ 73072938Smjacob ISPASYNC_CONF_CHANGE, /* Platform Configuration Change */ 73179235Smjacob ISPASYNC_UNHANDLED_RESPONSE, /* Unhandled Response Entry */ 73298281Smjacob ISPASYNC_FW_CRASH, /* Firmware has crashed */ 733102012Smjacob ISPASYNC_FW_DUMPED, /* Firmware crashdump taken */ 73498281Smjacob ISPASYNC_FW_RESTARTED /* Firmware has been restarted */ 73543420Smjacob} ispasync_t; 73674229Smjacobint isp_async(struct ispsoftc *, ispasync_t, void *); 73743420Smjacob 73872355Smjacob#define ISPASYNC_CHANGE_PDB ((void *) 0) 73972355Smjacob#define ISPASYNC_CHANGE_SNS ((void *) 1) 74072355Smjacob#define ISPASYNC_CHANGE_OTHER ((void *) 2) 74172355Smjacob 74243420Smjacob/* 74364087Smjacob * Platform Dependent Error and Debug Printout 74439235Sgibbs */ 74570490Smjacob#ifdef __GNUC__ 74674229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...) 74770490Smjacob __attribute__((__format__(__printf__,3,4))); 74870490Smjacob#else 74974229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...); 75070490Smjacob#endif 75170490Smjacob 75264087Smjacob#define ISP_LOGALL 0x0 /* log always */ 75364087Smjacob#define ISP_LOGCONFIG 0x1 /* log configuration messages */ 75464087Smjacob#define ISP_LOGINFO 0x2 /* log informational messages */ 75564087Smjacob#define ISP_LOGWARN 0x4 /* log warning messages */ 75664087Smjacob#define ISP_LOGERR 0x8 /* log error messages */ 75764087Smjacob#define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 75864087Smjacob#define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 75964087Smjacob#define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 76079235Smjacob#define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ 76179235Smjacob#define ISP_LOGDEBUG4 0x100 /* log high frequency debug messages */ 76264087Smjacob#define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ 76364087Smjacob#define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ 76464087Smjacob#define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ 76539235Sgibbs 76664087Smjacob/* 76764087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 76864087Smjacob * defined above. 76964087Smjacob * 77064087Smjacob * Each platform must also provide the following macros/defines: 77164087Smjacob * 77264087Smjacob * 77364087Smjacob * INLINE - platform specific define for 'inline' functions 77464087Smjacob * 77582689Smjacob * ISP_DMA_ADDR_T - platform specific dma address coookie- basically 77682689Smjacob * the largest integer that can hold the 32 or 77782689Smjacob * 64 bit value appropriate for the QLogic's DMA 77882689Smjacob * addressing. Defaults to u_int32_t. 77982689Smjacob * 78064087Smjacob * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area 78164087Smjacob * 78264087Smjacob * MEMZERO(dst, src) platform zeroing function 78364087Smjacob * MEMCPY(dst, src, count) platform copying function 78464087Smjacob * SNPRINTF(buf, bufsize, fmt, ...) snprintf 78564087Smjacob * STRNCAT(dstbuf, size, srcbuf) strncat 78664087Smjacob * USEC_DELAY(usecs) microsecond spindelay function 78769522Smjacob * USEC_SLEEP(isp, usecs) microsecond sleep function 78864087Smjacob * 78964087Smjacob * NANOTIME_T nanosecond time type 79064087Smjacob * 79164087Smjacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 79264087Smjacob * 79364087Smjacob * GET_NANOSEC(NANOTIME_T *) get u_int64_t from NANOTIME_T 79464087Smjacob * 79564087Smjacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 79664087Smjacob * subtract two NANOTIME_T values 79764087Smjacob * 79864087Smjacob * 79964087Smjacob * MAXISPREQUEST(struct ispsoftc *) maximum request queue size 80064087Smjacob * for this particular board type 80164087Smjacob * 80264087Smjacob * MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size) 80364087Smjacob * 80464087Smjacob * Function/Macro the provides memory synchronization on 80564087Smjacob * various objects so that the ISP's and the system's view 80664087Smjacob * of the same object is consistent. 80764087Smjacob * 80864087Smjacob * MBOX_ACQUIRE(struct ispsoftc *) acquire lock on mailbox regs 80964087Smjacob * MBOX_WAIT_COMPLETE(struct ispsoftc *) wait for mailbox cmd to be done 81064087Smjacob * MBOX_NOTIFY_COMPLETE(struct ispsoftc *) notification of mbox cmd donee 81164087Smjacob * MBOX_RELEASE(struct ispsoftc *) release lock on mailbox regs 81264087Smjacob * 81390224Smjacob * FC_SCRATCH_ACQUIRE(struct ispsoftc *) acquire lock on FC scratch area 81490224Smjacob * FC_SCRATCH_RELEASE(struct ispsoftc *) acquire lock on FC scratch area 81572355Smjacob * 81664087Smjacob * SCSI_GOOD SCSI 'Good' Status 81764087Smjacob * SCSI_CHECK SCSI 'Check Condition' Status 81864087Smjacob * SCSI_BUSY SCSI 'Busy' Status 81964087Smjacob * SCSI_QFULL SCSI 'Queue Full' Status 82064087Smjacob * 82164087Smjacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 82264087Smjacob * XS_ISP(xs) gets an instance out of an XS_T 82364087Smjacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 82464087Smjacob * XS_TGT(xs) gets the target "" 82564087Smjacob * XS_LUN(xs) gets the lun "" 82664087Smjacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 82764087Smjacob * XS_CDBLEN(xs) gets the CDB's length "" 82864087Smjacob * XS_XFRLEN(xs) gets the associated data transfer length "" 82964087Smjacob * XS_TIME(xs) gets the time (in milliseconds) for this command 83064087Smjacob * XS_RESID(xs) gets the current residual count 83164087Smjacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 83264087Smjacob * XS_SNSP(xs) gets a pointer to the associate sense data 83364087Smjacob * XS_SNSLEN(xs) gets the length of sense data storage 83464087Smjacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 83564087Smjacob * XS_TAG_P(xs) predicate of whether this command should be tagged 83664087Smjacob * XS_TAG_TYPE(xs) which type of tag to use 83764087Smjacob * XS_SETERR(xs) set error state 83864087Smjacob * 83964087Smjacob * HBA_NOERROR command has no erros 84064087Smjacob * HBA_BOTCH hba botched something 84164087Smjacob * HBA_CMDTIMEOUT command timed out 84264087Smjacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 84364087Smjacob * HBA_TGTBSY target returned a BUSY status 84464087Smjacob * HBA_BUSRESET bus reset destroyed command 84564087Smjacob * HBA_ABORTED command was aborted (by request) 84664087Smjacob * HBA_DATAOVR a data overrun was detected 84764087Smjacob * HBA_ARQFAIL Automatic Request Sense failed 84864087Smjacob * 84964087Smjacob * XS_ERR(xs) return current error state 85064087Smjacob * XS_NOERR(xs) there is no error currently set 85164087Smjacob * XS_INITERR(xs) initialize error state 85264087Smjacob * 85364087Smjacob * XS_SAVE_SENSE(xs, sp) save sense data 85464087Smjacob * 85564087Smjacob * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of 85664087Smjacob * response queue entry status bits 85764087Smjacob * 85864087Smjacob * 85964087Smjacob * DEFAULT_IID(struct ispsoftc *) Default SCSI initiator ID 86064087Smjacob * DEFAULT_LOOPID(struct ispsoftc *) Default FC Loop ID 86167047Smjacob * DEFAULT_NODEWWN(struct ispsoftc *) Default Node WWN 86267047Smjacob * DEFAULT_PORTWWN(struct ispsoftc *) Default Port WWN 86398281Smjacob * DEFAULT_FRAMESIZE(struct ispsoftc *) Default Frame Size 86498281Smjacob * DEFAULT_EXEC_THROTTLE(struct ispsoftc *) Default Execution Throttle 86567047Smjacob * These establish reasonable defaults for each platform. 86667047Smjacob * These must be available independent of card NVRAM and are 86767047Smjacob * to be used should NVRAM not be readable. 86864087Smjacob * 86967047Smjacob * ISP_NODEWWN(struct ispsoftc *) FC Node WWN to use 87067047Smjacob * ISP_PORTWWN(struct ispsoftc *) FC Port WWN to use 87164087Smjacob * 87267047Smjacob * These are to be used after NVRAM is read. The tags 87367047Smjacob * in fcparam.isp_{node,port}wwn reflect the values 87467047Smjacob * read from NVRAM (possibly corrected for card botches). 87567047Smjacob * Each platform can take that information and override 87667047Smjacob * it or ignore and return the Node and Port WWNs to be 87767047Smjacob * used when sending the Qlogic f/w the Initialization Control 87867047Smjacob * Block. 87964087Smjacob * 88064087Smjacob * (XXX these do endian specific transformations- in transition XXX) 88187635Smjacob * 88287635Smjacob * ISP_IOXPUT_8(struct ispsoftc *, u_int8_t srcval, u_int8_t *dstptr) 88387635Smjacob * ISP_IOXPUT_16(struct ispsoftc *, u_int16_t srcval, u_int16_t *dstptr) 88487635Smjacob * ISP_IOXPUT_32(struct ispsoftc *, u_int32_t srcval, u_int32_t *dstptr) 88587635Smjacob * 88687635Smjacob * ISP_IOXGET_8(struct ispsoftc *, u_int8_t *srcptr, u_int8_t dstrval) 88787635Smjacob * ISP_IOXGET_16(struct ispsoftc *, u_int16_t *srcptr, u_int16_t dstrval) 88887635Smjacob * ISP_IOXGET_32(struct ispsoftc *, u_int32_t *srcptr, u_int32_t dstrval) 88987635Smjacob * 89087635Smjacob * ISP_SWIZZLE_NVRAM_WORD(struct ispsoftc *, u_int16_t *) 89164087Smjacob */ 89277365Smjacob 89335388Smjacob#endif /* _ISPVAR_H */ 894