ispvar.h revision 66189
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 66189 2000-09-21 20:16:04Z 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 5764087Smjacob#define ISP_CORE_VERSION_MINOR 0 5839235Sgibbs 5935388Smjacob/* 6043420Smjacob * Vector for bus specific code to provide specific services. 6135388Smjacob */ 6235388Smjacobstruct ispsoftc; 6335388Smjacobstruct ispmdvec { 6435388Smjacob u_int16_t (*dv_rd_reg) __P((struct ispsoftc *, int)); 6535388Smjacob void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t)); 6635388Smjacob int (*dv_mbxdma) __P((struct ispsoftc *)); 6735388Smjacob int (*dv_dmaset) __P((struct ispsoftc *, 6864087Smjacob XS_T *, ispreq_t *, u_int16_t *, u_int16_t)); 6935388Smjacob void (*dv_dmaclr) 7064087Smjacob __P((struct ispsoftc *, XS_T *, u_int32_t)); 7135388Smjacob void (*dv_reset0) __P((struct ispsoftc *)); 7235388Smjacob void (*dv_reset1) __P((struct ispsoftc *)); 7364087Smjacob void (*dv_dregs) __P((struct ispsoftc *, const char *)); 7461772Smjacob const u_int16_t *dv_ispfw; /* ptr to f/w */ 7535388Smjacob u_int16_t dv_conf1; 7635388Smjacob u_int16_t dv_clock; /* clock frequency */ 7735388Smjacob}; 7835388Smjacob 7964087Smjacob/* 8064087Smjacob * Overall parameters 8164087Smjacob */ 8235388Smjacob#define MAX_TARGETS 16 8344819Smjacob#ifdef ISP2100_FABRIC 8444819Smjacob#define MAX_FC_TARG 256 8544819Smjacob#else 8635388Smjacob#define MAX_FC_TARG 126 8744819Smjacob#endif 8835388Smjacob 8949909Smjacob#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) 9061772Smjacob#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns 9149909Smjacob 9253487Smjacob 9353487Smjacob/* 9464087Smjacob * Macros to access ISP registers through bus specific layers- 9564087Smjacob * mostly wrappers to vector through the mdvec structure. 9653487Smjacob */ 9753487Smjacob 9853487Smjacob#define ISP_READ(isp, reg) \ 9953487Smjacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 10053487Smjacob 10153487Smjacob#define ISP_WRITE(isp, reg, val) \ 10253487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 10353487Smjacob 10453487Smjacob#define ISP_MBOXDMASETUP(isp) \ 10553487Smjacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 10653487Smjacob 10753487Smjacob#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ 10853487Smjacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) 10953487Smjacob 11053487Smjacob#define ISP_DMAFREE(isp, xs, hndl) \ 11153487Smjacob if ((isp)->isp_mdvec->dv_dmaclr) \ 11253487Smjacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) 11353487Smjacob 11453487Smjacob#define ISP_RESET0(isp) \ 11553487Smjacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 11653487Smjacob#define ISP_RESET1(isp) \ 11753487Smjacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 11864087Smjacob#define ISP_DUMPREGS(isp, m) \ 11964087Smjacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) 12053487Smjacob 12153487Smjacob#define ISP_SETBITS(isp, reg, val) \ 12253487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 12353487Smjacob 12453487Smjacob#define ISP_CLRBITS(isp, reg, val) \ 12553487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 12653487Smjacob 12764087Smjacob/* 12864087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization 12964087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers) 13064087Smjacob * 13164087Smjacob * Defined Memory Barrier Synchronization Types 13264087Smjacob */ 13364087Smjacob#define SYNC_REQUEST 0 /* request queue synchronization */ 13464087Smjacob#define SYNC_RESULT 1 /* result queue synchronization */ 13564087Smjacob#define SYNC_SFORDEV 2 /* scratch, sync for ISP */ 13664087Smjacob#define SYNC_SFORCPU 3 /* scratch, sync for CPU */ 13764087Smjacob#define SYNC_REG 4 /* for registers */ 13864087Smjacob 13964087Smjacob/* 14064087Smjacob * Request/Response Queue defines and macros. 14164087Smjacob * The maximum is defined per platform (and can be based on board type). 14264087Smjacob */ 14364087Smjacob/* This is the size of a queue entry (request and response) */ 14439235Sgibbs#define QENTRY_LEN 64 14564087Smjacob/* Both request and result queue length must be a power of two */ 14664087Smjacob#define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) 14764087Smjacob#define RESULT_QUEUE_LEN(x) \ 14864087Smjacob (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) 14939235Sgibbs#define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN)) 15039235Sgibbs#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 15139235Sgibbs#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 15265140Smjacob#define ISP_QFREE(in, out, qlen) \ 15339235Sgibbs ((in == out)? (qlen - 1) : ((in > out)? \ 15452347Smjacob ((qlen - 1) - (in - out)) : (out - in - 1))) 15565140Smjacob#define ISP_QAVAIL(isp) \ 15665140Smjacob ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) 15753487Smjacob 15853487Smjacob#define ISP_ADD_REQUEST(isp, iptr) \ 15964087Smjacob MEMORYBARRIER(isp, SYNC_REQUEST, iptr, QENTRY_LEN); \ 16064087Smjacob ISP_WRITE(isp, INMAILBOX4, iptr); \ 16164087Smjacob isp->isp_reqidx = iptr 16253487Smjacob 16335388Smjacob/* 16446968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target 16535388Smjacob */ 16635388Smjacob 16735388Smjacobtypedef struct { 16846968Smjacob u_int isp_gotdparms : 1, 16952347Smjacob isp_req_ack_active_neg : 1, 17052347Smjacob isp_data_line_active_neg: 1, 17135388Smjacob isp_cmd_dma_burst_enable: 1, 17235388Smjacob isp_data_dma_burst_enabl: 1, 17342461Smjacob isp_fifo_threshold : 3, 17443420Smjacob isp_ultramode : 1, 17535388Smjacob isp_diffmode : 1, 17645040Smjacob isp_lvdmode : 1, 17765140Smjacob isp_fast_mttr : 1, /* fast sram */ 17835388Smjacob isp_initiator_id : 4, 17952347Smjacob isp_async_data_setup : 4; 18052347Smjacob u_int16_t isp_selection_timeout; 18152347Smjacob u_int16_t isp_max_queue_depth; 18235388Smjacob u_int8_t isp_tag_aging; 18352347Smjacob u_int8_t isp_bus_reset_delay; 18452347Smjacob u_int8_t isp_retry_count; 18552347Smjacob u_int8_t isp_retry_delay; 18635388Smjacob struct { 18746968Smjacob u_int dev_enable : 1, /* ignored */ 18846968Smjacob : 1, 18943420Smjacob dev_update : 1, 19043420Smjacob dev_refresh : 1, 19145040Smjacob exc_throttle : 8, 19245040Smjacob cur_offset : 4, 19345040Smjacob sync_offset : 4; 19445040Smjacob u_int8_t cur_period; /* current sync period */ 19545040Smjacob u_int8_t sync_period; /* goal sync period */ 19645040Smjacob u_int16_t dev_flags; /* goal device flags */ 19745040Smjacob u_int16_t cur_dflags; /* current device flags */ 19835388Smjacob } isp_devparam[MAX_TARGETS]; 19946968Smjacob} sdparam; 20035388Smjacob 20135388Smjacob/* 20235388Smjacob * Device Flags 20335388Smjacob */ 20439235Sgibbs#define DPARM_DISC 0x8000 20539235Sgibbs#define DPARM_PARITY 0x4000 20639235Sgibbs#define DPARM_WIDE 0x2000 20739235Sgibbs#define DPARM_SYNC 0x1000 20839235Sgibbs#define DPARM_TQING 0x0800 20939235Sgibbs#define DPARM_ARQ 0x0400 21039235Sgibbs#define DPARM_QFRZ 0x0200 21139235Sgibbs#define DPARM_RENEG 0x0100 21265140Smjacob#define DPARM_NARROW 0x0080 21365140Smjacob#define DPARM_ASYNC 0x0040 21465140Smjacob#define DPARM_PPR 0x0020 21543793Smjacob#define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) 21639235Sgibbs#define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) 21735388Smjacob 21839235Sgibbs 21945040Smjacob/* technically, not really correct, as they need to be rated based upon clock */ 22065140Smjacob#define ISP_80M_SYNCPARMS 0x0c09 22165140Smjacob#define ISP_40M_SYNCPARMS 0x0c0a 22265140Smjacob#define ISP_20M_SYNCPARMS 0x0c0c 22365140Smjacob#define ISP_20M_SYNCPARMS_1040 0x080c 22452347Smjacob#define ISP_10M_SYNCPARMS 0x0c19 22552347Smjacob#define ISP_08M_SYNCPARMS 0x0c25 22652347Smjacob#define ISP_05M_SYNCPARMS 0x0c32 22752347Smjacob#define ISP_04M_SYNCPARMS 0x0c41 22835388Smjacob 22935388Smjacob/* 23035388Smjacob * Fibre Channel Specifics 23135388Smjacob */ 23252347Smjacob#define FL_PORT_ID 0x7e /* FL_Port Special ID */ 23352347Smjacob#define FC_PORT_ID 0x7f /* Fabric Controller Special ID */ 23452347Smjacob#define FC_SNS_ID 0x80 /* SNS Server Special ID */ 23552347Smjacob 23635388Smjacobtypedef struct { 23752347Smjacob u_int32_t isp_fwoptions : 16, 23859454Smjacob : 4, 23948484Smjacob loop_seen_once : 1, 24048484Smjacob isp_loopstate : 3, /* Current Loop State */ 24148484Smjacob isp_fwstate : 3, /* ISP F/W state */ 24248484Smjacob isp_gotdparms : 1, 24359454Smjacob isp_topo : 3, 24448484Smjacob isp_onfabric : 1; 24539235Sgibbs u_int8_t isp_loopid; /* hard loop id */ 24639235Sgibbs u_int8_t isp_alpa; /* ALPA */ 24752347Smjacob volatile u_int16_t isp_lipseq; /* LIP sequence # */ 24848484Smjacob u_int32_t isp_portid; 24939235Sgibbs u_int8_t isp_execthrottle; 25052347Smjacob u_int8_t isp_retry_delay; 25152347Smjacob u_int8_t isp_retry_count; 25252347Smjacob u_int8_t isp_reserved; 25339235Sgibbs u_int16_t isp_maxalloc; 25439235Sgibbs u_int16_t isp_maxfrmlen; 25548484Smjacob u_int64_t isp_nodewwn; 25648484Smjacob u_int64_t isp_portwwn; 25735388Smjacob /* 25848484Smjacob * Port Data Base. This is indexed by 'target', which is invariate. 25948484Smjacob * However, elements within can move around due to loop changes, 26048484Smjacob * so the actual loop ID passed to the F/W is in this structure. 26148484Smjacob * The first time the loop is seen up, loopid will match the index 26248484Smjacob * (except for fabric nodes which are above mapped above FC_SNS_ID 26348484Smjacob * and are completely virtual), but subsequent LIPs can cause things 26448484Smjacob * to move around. 26544819Smjacob */ 26648484Smjacob struct lportdb { 26752347Smjacob u_int 26860221Smjacob loopid : 8, 26960221Smjacob : 4, 27060221Smjacob loggedin : 1, 27160221Smjacob roles : 2, 27260221Smjacob valid : 1; 27352347Smjacob u_int32_t portid; 27448484Smjacob u_int64_t node_wwn; 27548484Smjacob u_int64_t port_wwn; 27652347Smjacob } portdb[MAX_FC_TARG], tport[FL_PORT_ID]; 27744819Smjacob 27844819Smjacob /* 27935388Smjacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 28035388Smjacob */ 28148195Smjacob caddr_t isp_scratch; 28235388Smjacob u_int32_t isp_scdma; 28335388Smjacob} fcparam; 28435388Smjacob 28548484Smjacob#define FW_CONFIG_WAIT 0 28648484Smjacob#define FW_WAIT_AL_PA 1 28748484Smjacob#define FW_WAIT_LOGIN 2 28848484Smjacob#define FW_READY 3 28948484Smjacob#define FW_LOSS_OF_SYNC 4 29048484Smjacob#define FW_ERROR 5 29148484Smjacob#define FW_REINIT 6 29248484Smjacob#define FW_NON_PART 7 29335388Smjacob 29448484Smjacob#define LOOP_NIL 0 29548484Smjacob#define LOOP_LIP_RCVD 1 29648484Smjacob#define LOOP_PDB_RCVD 2 29748484Smjacob#define LOOP_READY 7 29835388Smjacob 29959454Smjacob#define TOPO_NL_PORT 0 30059454Smjacob#define TOPO_FL_PORT 1 30159454Smjacob#define TOPO_N_PORT 2 30259454Smjacob#define TOPO_F_PORT 3 30359454Smjacob#define TOPO_PTP_STUB 4 30459454Smjacob 30542131Smjacob/* 30635388Smjacob * Soft Structure per host adapter 30735388Smjacob */ 30865140Smjacobtypedef struct ispsoftc { 30935388Smjacob /* 31035388Smjacob * Platform (OS) specific data 31135388Smjacob */ 31235388Smjacob struct isposinfo isp_osinfo; 31335388Smjacob 31435388Smjacob /* 31553487Smjacob * Pointer to bus specific functions and data 31635388Smjacob */ 31735388Smjacob struct ispmdvec * isp_mdvec; 31835388Smjacob 31935388Smjacob /* 32053487Smjacob * (Mostly) nonvolatile state. Board specific parameters 32153487Smjacob * may contain some volatile state (e.g., current loop state). 32235388Smjacob */ 32335388Smjacob 32453487Smjacob void * isp_param; /* type specific */ 32553487Smjacob u_int16_t isp_fwrev[3]; /* Loaded F/W revision */ 32653487Smjacob u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */ 32753487Smjacob u_int16_t isp_maxcmds; /* max possible I/O cmds */ 32853487Smjacob u_int8_t isp_type; /* HBA Chip Type */ 32953487Smjacob u_int8_t isp_revision; /* HBA Chip H/W Revision */ 33061772Smjacob u_int32_t isp_maxluns; /* maximum luns supported */ 33135388Smjacob 33264087Smjacob u_int32_t 33353487Smjacob isp_touched : 1, /* board ever seen? */ 33465140Smjacob : 1, 33553487Smjacob isp_bustype : 1, /* SBus or PCI */ 33665140Smjacob isp_loaded_fw : 1, /* loaded firmware */ 33764087Smjacob isp_dblev : 12, /* debug log mask */ 33853487Smjacob isp_clock : 8, /* input clock */ 33953487Smjacob isp_confopts : 8; /* config options */ 34039235Sgibbs 34135388Smjacob /* 34239235Sgibbs * Volatile state 34335388Smjacob */ 34435388Smjacob 34562171Smjacob volatile u_int32_t 34662171Smjacob isp_mboxbsy : 8, /* mailbox command active */ 34762171Smjacob : 1, 34839235Sgibbs isp_state : 3, 34946968Smjacob isp_sendmarker : 2, /* send a marker entry */ 35046968Smjacob isp_update : 2, /* update parameters */ 35152347Smjacob isp_nactive : 16; /* how many commands active */ 35252347Smjacob volatile u_int16_t isp_reqodx; /* index of last ISP pickup */ 35352347Smjacob volatile u_int16_t isp_reqidx; /* index of next request */ 35452347Smjacob volatile u_int16_t isp_residx; /* index of next result */ 35552347Smjacob volatile u_int16_t isp_lasthdls; /* last handle seed */ 35662171Smjacob volatile u_int16_t isp_mboxtmp[MAX_MAILBOX]; 35735388Smjacob 35835388Smjacob /* 35953487Smjacob * Active commands are stored here, indexed by handle functions. 36035388Smjacob */ 36164087Smjacob XS_T **isp_xflist; 36235388Smjacob 36335388Smjacob /* 36452347Smjacob * request/result queue pointers and dma handles for them. 36535388Smjacob */ 36648195Smjacob caddr_t isp_rquest; 36748195Smjacob caddr_t isp_result; 36835388Smjacob u_int32_t isp_rquest_dma; 36935388Smjacob u_int32_t isp_result_dma; 37065140Smjacob} ispsoftc_t; 37135388Smjacob 37249909Smjacob#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) 37349909Smjacob#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) 37449909Smjacob 37535388Smjacob/* 37664087Smjacob * ISP Driver Run States 37735388Smjacob */ 37835388Smjacob#define ISP_NILSTATE 0 37935388Smjacob#define ISP_RESETSTATE 1 38035388Smjacob#define ISP_INITSTATE 2 38135388Smjacob#define ISP_RUNSTATE 3 38235388Smjacob 38335388Smjacob/* 38435388Smjacob * ISP Configuration Options 38535388Smjacob */ 38635388Smjacob#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 38743793Smjacob#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 38853487Smjacob#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 38953487Smjacob#define ISP_CFG_OWNWWN 0x02 /* override NVRAM wwn */ 39057145Smjacob#define ISP_CFG_NPORT 0x04 /* try to force N- instead of L-Port */ 39135388Smjacob 39264087Smjacob/* 39364087Smjacob * Firmware related defines 39464087Smjacob */ 39564087Smjacob#define ISP_CODE_ORG 0x1000 /* default f/w code start */ 39645282Smjacob#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 39746968Smjacob#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 39839235Sgibbs 39935388Smjacob/* 40039235Sgibbs * Bus (implementation) types 40135388Smjacob */ 40239235Sgibbs#define ISP_BT_PCI 0 /* PCI Implementations */ 40339235Sgibbs#define ISP_BT_SBUS 1 /* SBus Implementations */ 40439235Sgibbs 40539235Sgibbs/* 40639235Sgibbs * Chip Types 40739235Sgibbs */ 40835388Smjacob#define ISP_HA_SCSI 0xf 40939235Sgibbs#define ISP_HA_SCSI_UNKNOWN 0x1 41039235Sgibbs#define ISP_HA_SCSI_1020 0x2 41139235Sgibbs#define ISP_HA_SCSI_1020A 0x3 41239235Sgibbs#define ISP_HA_SCSI_1040 0x4 41339235Sgibbs#define ISP_HA_SCSI_1040A 0x5 41439235Sgibbs#define ISP_HA_SCSI_1040B 0x6 41545282Smjacob#define ISP_HA_SCSI_1040C 0x7 41654671Smjacob#define ISP_HA_SCSI_1240 0x8 41754671Smjacob#define ISP_HA_SCSI_1080 0x9 41854671Smjacob#define ISP_HA_SCSI_1280 0xa 41957145Smjacob#define ISP_HA_SCSI_12160 0xb 42035388Smjacob#define ISP_HA_FC 0xf0 42135388Smjacob#define ISP_HA_FC_2100 0x10 42248484Smjacob#define ISP_HA_FC_2200 0x20 42335388Smjacob 42444819Smjacob#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 42554671Smjacob#define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 42644819Smjacob#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 42754671Smjacob#define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 42857145Smjacob#define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 42957145Smjacob 43057145Smjacob#define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 43157145Smjacob#define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 43257145Smjacob#define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_12160(isp)) 43357145Smjacob#define IS_ULTRA3(isp) (IS_12160(isp)) 43457145Smjacob 43544819Smjacob#define IS_FC(isp) (isp->isp_type & ISP_HA_FC) 43657145Smjacob#define IS_2100(isp) (isp->isp_type == ISP_HA_FC_2100) 43757145Smjacob#define IS_2200(isp) (isp->isp_type == ISP_HA_FC_2200) 43844819Smjacob 43964087Smjacob/* 44064087Smjacob * DMA cookie macros 44164087Smjacob */ 44264087Smjacob#define DMA_MSW(x) (((x) >> 16) & 0xffff) 44364087Smjacob#define DMA_LSW(x) (((x) & 0xffff)) 44457145Smjacob 44535388Smjacob/* 44664087Smjacob * Core System Function Prototypes 44735388Smjacob */ 44835388Smjacob 44935388Smjacob/* 45039235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with 45139235Sgibbs * a call to isp_init. 45235388Smjacob */ 45335388Smjacobvoid isp_reset __P((struct ispsoftc *)); 45435388Smjacob 45535388Smjacob/* 45635388Smjacob * Initialize Hardware to known state 45735388Smjacob */ 45835388Smjacobvoid isp_init __P((struct ispsoftc *)); 45935388Smjacob 46035388Smjacob/* 46139235Sgibbs * Reset the ISP and call completion for any orphaned commands. 46239235Sgibbs */ 46364087Smjacobvoid isp_reinit __P((struct ispsoftc *)); 46439235Sgibbs 46539235Sgibbs/* 46635388Smjacob * Interrupt Service Routine 46735388Smjacob */ 46835388Smjacobint isp_intr __P((void *)); 46935388Smjacob 47035388Smjacob/* 47164087Smjacob * Command Entry Point- Platform Dependent layers call into this 47235388Smjacob */ 47364087Smjacobint isp_start __P((XS_T *)); 47464087Smjacob/* these values are what isp_start returns */ 47564087Smjacob#define CMD_COMPLETE 101 /* command completed */ 47664087Smjacob#define CMD_EAGAIN 102 /* busy- maybe retry later */ 47764087Smjacob#define CMD_QUEUED 103 /* command has been queued for execution */ 47864087Smjacob#define CMD_RQLATER 104 /* requeue this command later */ 47935388Smjacob 48039235Sgibbs/* 48164087Smjacob * Command Completion Point- Core layers call out from this with completed cmds 48264087Smjacob */ 48364087Smjacobvoid isp_done __P((XS_T *)); 48464087Smjacob 48564087Smjacob/* 48643420Smjacob * Platform Dependent to External to Internal Control Function 48739235Sgibbs * 48848484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with. 48939235Sgibbs * 49039235Sgibbs */ 49139235Sgibbstypedef enum { 49248484Smjacob ISPCTL_RESET_BUS, /* Reset Bus */ 49348484Smjacob ISPCTL_RESET_DEV, /* Reset Device */ 49448484Smjacob ISPCTL_ABORT_CMD, /* Abort Command */ 49548484Smjacob ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters */ 49655364Smjacob ISPCTL_FCLINK_TEST, /* Test FC Link Status */ 49755364Smjacob ISPCTL_PDB_SYNC, /* Synchronize Port Database */ 49855364Smjacob ISPCTL_TOGGLE_TMODE /* toggle target mode */ 49939235Sgibbs} ispctl_t; 50039235Sgibbsint isp_control __P((struct ispsoftc *, ispctl_t, void *)); 50139235Sgibbs 50243420Smjacob 50339235Sgibbs/* 50443420Smjacob * Platform Dependent to Internal to External Control Function 50543420Smjacob * (each platform must provide such a function) 50643420Smjacob * 50748484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with. 50843420Smjacob * 50943420Smjacob */ 51043420Smjacob 51143420Smjacobtypedef enum { 51243793Smjacob ISPASYNC_NEW_TGT_PARAMS, 51348484Smjacob ISPASYNC_BUS_RESET, /* Bus Was Reset */ 51448484Smjacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 51548484Smjacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 51648484Smjacob ISPASYNC_PDB_CHANGED, /* FC Port Data Base Changed */ 51748484Smjacob ISPASYNC_CHANGE_NOTIFY, /* FC SNS Change Notification */ 51848484Smjacob ISPASYNC_FABRIC_DEV, /* FC New Fabric Device */ 51955364Smjacob ISPASYNC_TARGET_MESSAGE, /* target message */ 52055364Smjacob ISPASYNC_TARGET_EVENT, /* target asynchronous event */ 52155364Smjacob ISPASYNC_TARGET_ACTION /* other target command action */ 52243420Smjacob} ispasync_t; 52343420Smjacobint isp_async __P((struct ispsoftc *, ispasync_t, void *)); 52443420Smjacob 52543420Smjacob/* 52664087Smjacob * Platform Dependent Error and Debug Printout 52739235Sgibbs */ 52864087Smjacobvoid isp_prt __P((struct ispsoftc *, int level, const char *, ...)); 52964087Smjacob#define ISP_LOGALL 0x0 /* log always */ 53064087Smjacob#define ISP_LOGCONFIG 0x1 /* log configuration messages */ 53164087Smjacob#define ISP_LOGINFO 0x2 /* log informational messages */ 53264087Smjacob#define ISP_LOGWARN 0x4 /* log warning messages */ 53364087Smjacob#define ISP_LOGERR 0x8 /* log error messages */ 53464087Smjacob#define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 53564087Smjacob#define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 53664087Smjacob#define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 53764087Smjacob#define ISP_LOGDEBUG3 0x100 /* log high frequency debug messages */ 53864087Smjacob#define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ 53964087Smjacob#define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ 54064087Smjacob#define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ 54139235Sgibbs 54264087Smjacob/* 54364087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 54464087Smjacob * defined above. 54564087Smjacob * 54664087Smjacob * Each platform must also provide the following macros/defines: 54764087Smjacob * 54864087Smjacob * 54964087Smjacob * INLINE - platform specific define for 'inline' functions 55064087Smjacob * 55164087Smjacob * ISP2100_FABRIC - defines whether FABRIC support is enabled 55264087Smjacob * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area 55364087Smjacob * 55464087Smjacob * MEMZERO(dst, src) platform zeroing function 55564087Smjacob * MEMCPY(dst, src, count) platform copying function 55664087Smjacob * SNPRINTF(buf, bufsize, fmt, ...) snprintf 55764087Smjacob * STRNCAT(dstbuf, size, srcbuf) strncat 55864087Smjacob * USEC_DELAY(usecs) microsecond spindelay function 55964087Smjacob * 56064087Smjacob * NANOTIME_T nanosecond time type 56164087Smjacob * 56264087Smjacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 56364087Smjacob * 56464087Smjacob * GET_NANOSEC(NANOTIME_T *) get u_int64_t from NANOTIME_T 56564087Smjacob * 56664087Smjacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 56764087Smjacob * subtract two NANOTIME_T values 56864087Smjacob * 56964087Smjacob * 57064087Smjacob * MAXISPREQUEST(struct ispsoftc *) maximum request queue size 57164087Smjacob * for this particular board type 57264087Smjacob * 57364087Smjacob * MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size) 57464087Smjacob * 57564087Smjacob * Function/Macro the provides memory synchronization on 57664087Smjacob * various objects so that the ISP's and the system's view 57764087Smjacob * of the same object is consistent. 57864087Smjacob * 57964087Smjacob * MBOX_ACQUIRE(struct ispsoftc *) acquire lock on mailbox regs 58064087Smjacob * MBOX_WAIT_COMPLETE(struct ispsoftc *) wait for mailbox cmd to be done 58164087Smjacob * MBOX_NOTIFY_COMPLETE(struct ispsoftc *) notification of mbox cmd donee 58264087Smjacob * MBOX_RELEASE(struct ispsoftc *) release lock on mailbox regs 58364087Smjacob * 58464087Smjacob * 58564087Smjacob * SCSI_GOOD SCSI 'Good' Status 58664087Smjacob * SCSI_CHECK SCSI 'Check Condition' Status 58764087Smjacob * SCSI_BUSY SCSI 'Busy' Status 58864087Smjacob * SCSI_QFULL SCSI 'Queue Full' Status 58964087Smjacob * 59064087Smjacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 59164087Smjacob * XS_ISP(xs) gets an instance out of an XS_T 59264087Smjacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 59364087Smjacob * XS_TGT(xs) gets the target "" 59464087Smjacob * XS_LUN(xs) gets the lun "" 59564087Smjacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 59664087Smjacob * XS_CDBLEN(xs) gets the CDB's length "" 59764087Smjacob * XS_XFRLEN(xs) gets the associated data transfer length "" 59864087Smjacob * XS_TIME(xs) gets the time (in milliseconds) for this command 59964087Smjacob * XS_RESID(xs) gets the current residual count 60064087Smjacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 60164087Smjacob * XS_SNSP(xs) gets a pointer to the associate sense data 60264087Smjacob * XS_SNSLEN(xs) gets the length of sense data storage 60364087Smjacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 60464087Smjacob * XS_TAG_P(xs) predicate of whether this command should be tagged 60564087Smjacob * XS_TAG_TYPE(xs) which type of tag to use 60664087Smjacob * XS_SETERR(xs) set error state 60764087Smjacob * 60864087Smjacob * HBA_NOERROR command has no erros 60964087Smjacob * HBA_BOTCH hba botched something 61064087Smjacob * HBA_CMDTIMEOUT command timed out 61164087Smjacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 61264087Smjacob * HBA_TGTBSY target returned a BUSY status 61364087Smjacob * HBA_BUSRESET bus reset destroyed command 61464087Smjacob * HBA_ABORTED command was aborted (by request) 61564087Smjacob * HBA_DATAOVR a data overrun was detected 61664087Smjacob * HBA_ARQFAIL Automatic Request Sense failed 61764087Smjacob * 61864087Smjacob * XS_ERR(xs) return current error state 61964087Smjacob * XS_NOERR(xs) there is no error currently set 62064087Smjacob * XS_INITERR(xs) initialize error state 62164087Smjacob * 62264087Smjacob * XS_SAVE_SENSE(xs, sp) save sense data 62364087Smjacob * 62464087Smjacob * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of 62564087Smjacob * response queue entry status bits 62664087Smjacob * 62764087Smjacob * 62864087Smjacob * DEFAULT_IID(struct ispsoftc *) Default SCSI initiator ID 62964087Smjacob * 63064087Smjacob * DEFAULT_LOOPID(struct ispsoftc *) Default FC Loop ID 63164087Smjacob * DEFAULT_NODEWWN(struct ispsoftc *) Default FC Node WWN 63264087Smjacob * DEFAULT_PORTWWN(struct ispsoftc *) Default FC Port WWN 63364087Smjacob * 63464087Smjacob * PORT_FROM_NODE_WWN(struct ispsoftc *, u_int64_t nwwn) 63564087Smjacob * 63664087Smjacob * Node to Port WWN generator- this needs to be platform 63764087Smjacob * specific so that given a NAA=2 WWN dragged from the Qlogic 63864087Smjacob * card's NVRAM, a Port WWN can be generated that has the 63964087Smjacob * appropriate bits set in bits 48..60 that are likely to be 64064087Smjacob * based on the device instance number. 64164087Smjacob * 64264087Smjacob * (XXX these do endian specific transformations- in transition XXX) 64364087Smjacob * ISP_SWIZZLE_ICB 64464087Smjacob * ISP_UNSWIZZLE_AND_COPY_PDBP 64564087Smjacob * ISP_SWIZZLE_CONTINUATION 64664087Smjacob * ISP_SWIZZLE_REQUEST 64764087Smjacob * ISP_UNSWIZZLE_RESPONSE 64864087Smjacob * ISP_SWIZZLE_SNS_REQ 64964087Smjacob * ISP_UNSWIZZLE_SNS_RSP 65064087Smjacob * ISP_SWIZZLE_NVRAM_WORD 65164087Smjacob * 65264087Smjacob * 65364087Smjacob */ 65435388Smjacob#endif /* _ISPVAR_H */ 655