ispvar.h revision 163899
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 163899 2006-11-02 03:21:32Z mjacob $ */ 2139749Simp/*- 335388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters. 435388Smjacob * 5154704Smjacob * Copyright (c) 1997-2006 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#ifndef _ISPVAR_H 3135388Smjacob#define _ISPVAR_H 3235388Smjacob 3344819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__) 34163899Smjacob#include <dev/ic/isp_stds.h> 3535388Smjacob#include <dev/ic/ispmbox.h> 3635388Smjacob#endif 3735388Smjacob#ifdef __FreeBSD__ 38163899Smjacob#include <dev/isp/isp_stds.h> 3935388Smjacob#include <dev/isp/ispmbox.h> 4035388Smjacob#endif 4135388Smjacob#ifdef __linux__ 42163899Smjacob#include "isp_stds.h" 4342131Smjacob#include "ispmbox.h" 4435388Smjacob#endif 45155704Smjacob#ifdef __svr4__ 46163899Smjacob#include "isp_stds.h" 47155704Smjacob#include "ispmbox.h" 4853487Smjacob#endif 4935388Smjacob 50163899Smjacob#define ISP_CORE_VERSION_MAJOR 3 51163899Smjacob#define ISP_CORE_VERSION_MINOR 0 5239235Sgibbs 5335388Smjacob/* 5443420Smjacob * Vector for bus specific code to provide specific services. 5535388Smjacob */ 56155704Smjacobtypedef struct ispsoftc ispsoftc_t; 5735388Smjacobstruct ispmdvec { 5882689Smjacob int (*dv_rd_isr) 59163899Smjacob (ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); 60163899Smjacob uint32_t (*dv_rd_reg) (ispsoftc_t *, int); 61163899Smjacob void (*dv_wr_reg) (ispsoftc_t *, int, uint32_t); 62155704Smjacob int (*dv_mbxdma) (ispsoftc_t *); 63155704Smjacob int (*dv_dmaset) 64163899Smjacob (ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t); 65163899Smjacob void (*dv_dmaclr) (ispsoftc_t *, XS_T *, uint32_t); 66155704Smjacob void (*dv_reset0) (ispsoftc_t *); 67155704Smjacob void (*dv_reset1) (ispsoftc_t *); 68155704Smjacob void (*dv_dregs) (ispsoftc_t *, const char *); 69163899Smjacob void * dv_ispfw; /* ptr to f/w */ 70155704Smjacob uint16_t dv_conf1; 71155704Smjacob uint16_t dv_clock; /* clock frequency */ 7235388Smjacob}; 7335388Smjacob 7464087Smjacob/* 7564087Smjacob * Overall parameters 7664087Smjacob */ 7782689Smjacob#define MAX_TARGETS 16 7882689Smjacob#define MAX_FC_TARG 256 7949909Smjacob#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) 8061772Smjacob#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns 8149909Smjacob 8282689Smjacob/* 8364087Smjacob * Macros to access ISP registers through bus specific layers- 8464087Smjacob * mostly wrappers to vector through the mdvec structure. 8553487Smjacob */ 8682689Smjacob#define ISP_READ_ISR(isp, isrp, semap, mbox0p) \ 8782689Smjacob (*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p) 8853487Smjacob 8953487Smjacob#define ISP_READ(isp, reg) \ 9053487Smjacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 9153487Smjacob 9253487Smjacob#define ISP_WRITE(isp, reg, val) \ 9353487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 9453487Smjacob 9553487Smjacob#define ISP_MBOXDMASETUP(isp) \ 9653487Smjacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 9753487Smjacob 9853487Smjacob#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ 9953487Smjacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) 10053487Smjacob 101155704Smjacob#define ISP_DMAFREE(isp, xs, hndl) \ 102155704Smjacob if ((isp)->isp_mdvec->dv_dmaclr) \ 10353487Smjacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) 10453487Smjacob 10553487Smjacob#define ISP_RESET0(isp) \ 10653487Smjacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 10753487Smjacob#define ISP_RESET1(isp) \ 10853487Smjacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 10964087Smjacob#define ISP_DUMPREGS(isp, m) \ 11064087Smjacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) 11153487Smjacob 11253487Smjacob#define ISP_SETBITS(isp, reg, val) \ 11353487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 11453487Smjacob 11553487Smjacob#define ISP_CLRBITS(isp, reg, val) \ 11653487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 11753487Smjacob 11864087Smjacob/* 11964087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization 12064087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers) 12164087Smjacob * 12264087Smjacob * Defined Memory Barrier Synchronization Types 12364087Smjacob */ 12464087Smjacob#define SYNC_REQUEST 0 /* request queue synchronization */ 12564087Smjacob#define SYNC_RESULT 1 /* result queue synchronization */ 12664087Smjacob#define SYNC_SFORDEV 2 /* scratch, sync for ISP */ 12764087Smjacob#define SYNC_SFORCPU 3 /* scratch, sync for CPU */ 12864087Smjacob#define SYNC_REG 4 /* for registers */ 129163899Smjacob#define SYNC_ATIOQ 5 /* atio result queue (24xx) */ 13064087Smjacob 13164087Smjacob/* 13264087Smjacob * Request/Response Queue defines and macros. 13364087Smjacob * The maximum is defined per platform (and can be based on board type). 13464087Smjacob */ 13564087Smjacob/* This is the size of a queue entry (request and response) */ 13639235Sgibbs#define QENTRY_LEN 64 13764087Smjacob/* Both request and result queue length must be a power of two */ 13864087Smjacob#define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) 13993706Smjacob#ifdef ISP_TARGET_MODE 14093706Smjacob#define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) 14193706Smjacob#else 14264087Smjacob#define RESULT_QUEUE_LEN(x) \ 14364087Smjacob (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) 14493706Smjacob#endif 145155704Smjacob#define ISP_QUEUE_ENTRY(q, idx) (((uint8_t *)q) + ((idx) * QENTRY_LEN)) 14639235Sgibbs#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 14739235Sgibbs#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 14865140Smjacob#define ISP_QFREE(in, out, qlen) \ 14939235Sgibbs ((in == out)? (qlen - 1) : ((in > out)? \ 15052347Smjacob ((qlen - 1) - (in - out)) : (out - in - 1))) 15165140Smjacob#define ISP_QAVAIL(isp) \ 15265140Smjacob ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) 15353487Smjacob 15487635Smjacob#define ISP_ADD_REQUEST(isp, nxti) \ 15587635Smjacob MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN); \ 156163899Smjacob ISP_WRITE(isp, isp->isp_rqstinrp, nxti); \ 15787635Smjacob isp->isp_reqidx = nxti 15853487Smjacob 15935388Smjacob/* 16046968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target 16135388Smjacob */ 16235388Smjacobtypedef struct { 163155704Smjacob uint32_t isp_gotdparms : 1, 16452347Smjacob isp_req_ack_active_neg : 1, 16552347Smjacob isp_data_line_active_neg: 1, 16635388Smjacob isp_cmd_dma_burst_enable: 1, 16735388Smjacob isp_data_dma_burst_enabl: 1, 16842461Smjacob isp_fifo_threshold : 3, 169163899Smjacob isp_ptisp : 1, 17043420Smjacob isp_ultramode : 1, 17135388Smjacob isp_diffmode : 1, 17245040Smjacob isp_lvdmode : 1, 17365140Smjacob isp_fast_mttr : 1, /* fast sram */ 17435388Smjacob isp_initiator_id : 4, 17552347Smjacob isp_async_data_setup : 4; 176155704Smjacob uint16_t isp_selection_timeout; 177155704Smjacob uint16_t isp_max_queue_depth; 178155704Smjacob uint8_t isp_tag_aging; 179155704Smjacob uint8_t isp_bus_reset_delay; 180155704Smjacob uint8_t isp_retry_count; 181155704Smjacob uint8_t isp_retry_delay; 18235388Smjacob struct { 183155704Smjacob uint32_t 18480582Smjacob exc_throttle : 8, 18546968Smjacob : 1, 18680582Smjacob dev_enable : 1, /* ignored */ 18743420Smjacob dev_update : 1, 18843420Smjacob dev_refresh : 1, 18980582Smjacob actv_offset : 4, 19080582Smjacob goal_offset : 4, 19180582Smjacob nvrm_offset : 4; 192155704Smjacob uint8_t actv_period; /* current sync period */ 193155704Smjacob uint8_t goal_period; /* goal sync period */ 194155704Smjacob uint8_t nvrm_period; /* nvram sync period */ 195155704Smjacob uint16_t actv_flags; /* current device flags */ 196155704Smjacob uint16_t goal_flags; /* goal device flags */ 197155704Smjacob uint16_t nvrm_flags; /* nvram 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 21845040Smjacob/* technically, not really correct, as they need to be rated based upon clock */ 21965140Smjacob#define ISP_80M_SYNCPARMS 0x0c09 22065140Smjacob#define ISP_40M_SYNCPARMS 0x0c0a 22165140Smjacob#define ISP_20M_SYNCPARMS 0x0c0c 22265140Smjacob#define ISP_20M_SYNCPARMS_1040 0x080c 22352347Smjacob#define ISP_10M_SYNCPARMS 0x0c19 22452347Smjacob#define ISP_08M_SYNCPARMS 0x0c25 22552347Smjacob#define ISP_05M_SYNCPARMS 0x0c32 22652347Smjacob#define ISP_04M_SYNCPARMS 0x0c41 22735388Smjacob 22835388Smjacob/* 22935388Smjacob * Fibre Channel Specifics 23035388Smjacob */ 231163899Smjacob/* These are for 2100/2200/2300 cards */ 232163899Smjacob#define FL_ID 0x7e /* FL_Port Special ID */ 233163899Smjacob#define SNS_ID 0x80 /* SNS Server Special ID */ 234163899Smjacob#define NPH_MAX 0xfe 23552347Smjacob 236163899Smjacob/* These are for 24XX cards */ 237163899Smjacob#define NPH_RESERVED 0x7F0 /* begin of reserved N-port handles */ 238163899Smjacob#define NPH_MGT_ID 0x7FA /* Management Server Special ID */ 239163899Smjacob#define NPH_SNS_ID 0x7FC /* SNS Server Special ID */ 240163899Smjacob#define NPH_FL_ID 0x7FE /* FL Port Special ID */ 241163899Smjacob#define NPH_MAX_24XX 0x800 24293837Smjacob 243163899Smjacob/* 244163899Smjacob * Limit for devices on an arbitrated loop. 245163899Smjacob */ 246163899Smjacob#define LOCAL_LOOP_LIM 126 247163899Smjacob 248163899Smjacob/* 249163899Smjacob * Special Port IDs 250163899Smjacob */ 251163899Smjacob#define MANAGEMENT_PORT_ID 0xFFFFFA 252163899Smjacob#define SNS_PORT_ID 0xFFFFFC 253163899Smjacob#define FABRIC_PORT_ID 0xFFFFFE 254163899Smjacob 255163899Smjacob 256163899Smjacob/* 257163899Smjacob * FC Port Database entry. 258163899Smjacob * 259163899Smjacob * It has a handle that the f/w uses to address commands to a device. 260163899Smjacob * This handle's value may be assigned by the firmware (e.g., for local loop 261163899Smjacob * devices) or by the driver (e.g., for fabric devices). 262163899Smjacob * 263163899Smjacob * It has a state. If the state if VALID, that means that we've logged into 264163899Smjacob * the device. We also *may* have a initiator map index entry. This is a value 265163899Smjacob * from 0..MAX_FC_TARG that is used to index into the isp_ini_map array. If 266163899Smjacob * the value therein is non-zero, then that value minus one is used to index 267163899Smjacob * into the Port Database to find the handle for forming commands. There is 268163899Smjacob * back-index minus one value within to Port Database entry that tells us 269163899Smjacob * which entry in isp_ini_map points to us (to avoid searching). 270163899Smjacob * 271163899Smjacob * Local loop devices the firmware automatically performs PLOGI on for us 272163899Smjacob * (which is why that handle is imposed upon us). Fabric devices we assign 273163899Smjacob * a handle to and perform the PLOGI on. 274163899Smjacob * 275163899Smjacob * When a PORT DATABASE CHANGED asynchronous event occurs, we mark all VALID 276163899Smjacob * entries as PROBATIONAL. This allows us, if policy says to, just keep track 277163899Smjacob * of devices whose handles change but are otherwise the same device (and 278163899Smjacob * thus keep 'target' constant). 279163899Smjacob * 280163899Smjacob * In any case, we search all possible local loop handles. For each one that 281163899Smjacob * has a port database entity returned, we search for any PROBATIONAL entry 282163899Smjacob * that matches it and update as appropriate. Otherwise, as a new entry, we 283163899Smjacob * find room for it in the Port Database. We *try* and use the handle as the 284163899Smjacob * index to put it into the Database, but that's just an optimization. We mark 285163899Smjacob * the entry VALID and make sure that the target index is updated and correct. 286163899Smjacob * 287163899Smjacob * When we get done searching the local loop, we then search similarily for 288163899Smjacob * a list of devices we've gotten from the fabric name controller (if we're 289163899Smjacob * on a fabric). VALID marking is also done similarily. 290163899Smjacob * 291163899Smjacob * When all of this is done, we can march through the database and clean up 292163899Smjacob * any entry that is still PROBATIONAL (these represent devices which have 293163899Smjacob * departed). Then we're done and can resume normal operations. 294163899Smjacob * 295163899Smjacob * Negative invariants that we try and test for are: 296163899Smjacob * 297163899Smjacob * + There can never be two non-NIL entries with the same { Port, Node } WWN 298163899Smjacob * duples. 299163899Smjacob * 300163899Smjacob * + There can never be two non-NIL entries with the same handle. 301163899Smjacob * 302163899Smjacob * + There can never be two non-NIL entries which have the same ini_map_idx 303163899Smjacob * value. 304163899Smjacob */ 30535388Smjacobtypedef struct { 306163899Smjacob uint16_t handle; 307163899Smjacob uint16_t ini_map_idx : 12, 308163899Smjacob autologin : 1, /* F/W does PLOGI/PLOGO */ 309163899Smjacob state : 3; 310163899Smjacob uint32_t : 6, 311163899Smjacob roles : 2, 312163899Smjacob portid : 24; 313163899Smjacob uint32_t : 6, 314163899Smjacob new_roles : 2, 315163899Smjacob new_portid : 24; 316163899Smjacob uint64_t node_wwn; 317163899Smjacob uint64_t port_wwn; 318163899Smjacob} fcportdb_t; 319163899Smjacob 320163899Smjacob#define FC_PORTDB_STATE_NIL 0 321163899Smjacob#define FC_PORTDB_STATE_PROBATIONAL 1 322163899Smjacob#define FC_PORTDB_STATE_DEAD 2 323163899Smjacob#define FC_PORTDB_STATE_CHANGED 3 324163899Smjacob#define FC_PORTDB_STATE_NEW 4 325163899Smjacob#define FC_PORTDB_STATE_PENDING_VALID 5 326163899Smjacob#define FC_PORTDB_STATE_VALID 7 327163899Smjacob 328163899Smjacob/* 329163899Smjacob * FC card specific information 330163899Smjacob */ 331163899Smjacobtypedef struct { 332163899Smjacob uint32_t : 10, 333163899Smjacob isp_tmode : 1, 334163899Smjacob isp_2klogin : 1, 335163899Smjacob isp_sccfw : 1, 336154704Smjacob isp_gbspeed : 3, 337160080Smjacob : 1, 338163899Smjacob : 1, 339163899Smjacob : 1, 34077776Smjacob isp_loopstate : 4, /* Current Loop State */ 341160080Smjacob isp_fwstate : 4, /* ISP F/W state */ 34248484Smjacob isp_gotdparms : 1, 34359454Smjacob isp_topo : 3, 344163899Smjacob loop_seen_once : 1; 345155704Smjacob uint32_t : 8, 346154704Smjacob isp_portid : 24; /* S_ID */ 347155704Smjacob uint16_t isp_fwoptions; 348160080Smjacob uint16_t isp_xfwoptions; 349160080Smjacob uint16_t isp_zfwoptions; 350155704Smjacob uint16_t isp_loopid; /* hard loop id */ 351155704Smjacob uint16_t isp_fwattr; /* firmware attributes */ 352158813Smjacob uint16_t isp_execthrottle; 353155704Smjacob uint8_t isp_retry_delay; 354155704Smjacob uint8_t isp_retry_count; 355155704Smjacob uint8_t isp_reserved; 356155704Smjacob uint16_t isp_maxalloc; 357155704Smjacob uint16_t isp_maxfrmlen; 358155704Smjacob uint64_t isp_nodewwn; 359155704Smjacob uint64_t isp_portwwn; 360163899Smjacob fcportdb_t portdb[MAX_FC_TARG]; 361163899Smjacob uint16_t isp_ini_map[MAX_FC_TARG]; 36235388Smjacob /* 36335388Smjacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 36435388Smjacob */ 365155704Smjacob void * isp_scratch; 366155704Smjacob XS_DMA_ADDR_T isp_scdma; 36790752Smjacob#ifdef ISP_FW_CRASH_DUMP 368155704Smjacob uint16_t * isp_dump_data; 36990752Smjacob#endif 37035388Smjacob} fcparam; 37135388Smjacob 37248484Smjacob#define FW_CONFIG_WAIT 0 37348484Smjacob#define FW_WAIT_AL_PA 1 37448484Smjacob#define FW_WAIT_LOGIN 2 37548484Smjacob#define FW_READY 3 37648484Smjacob#define FW_LOSS_OF_SYNC 4 37748484Smjacob#define FW_ERROR 5 37848484Smjacob#define FW_REINIT 6 37948484Smjacob#define FW_NON_PART 7 38035388Smjacob 38148484Smjacob#define LOOP_NIL 0 38248484Smjacob#define LOOP_LIP_RCVD 1 38348484Smjacob#define LOOP_PDB_RCVD 2 384163899Smjacob#define LOOP_SCANNING_LOOP 3 385163899Smjacob#define LOOP_LSCAN_DONE 4 386163899Smjacob#define LOOP_SCANNING_FABRIC 5 387163899Smjacob#define LOOP_FSCAN_DONE 6 38877776Smjacob#define LOOP_SYNCING_PDB 7 38977776Smjacob#define LOOP_READY 8 39035388Smjacob 39159454Smjacob#define TOPO_NL_PORT 0 39259454Smjacob#define TOPO_FL_PORT 1 39359454Smjacob#define TOPO_N_PORT 2 39459454Smjacob#define TOPO_F_PORT 3 39559454Smjacob#define TOPO_PTP_STUB 4 39659454Smjacob 39742131Smjacob/* 39835388Smjacob * Soft Structure per host adapter 39935388Smjacob */ 400155704Smjacobstruct ispsoftc { 40135388Smjacob /* 40235388Smjacob * Platform (OS) specific data 40335388Smjacob */ 40435388Smjacob struct isposinfo isp_osinfo; 40535388Smjacob 40635388Smjacob /* 40753487Smjacob * Pointer to bus specific functions and data 40835388Smjacob */ 40935388Smjacob struct ispmdvec * isp_mdvec; 41035388Smjacob 41135388Smjacob /* 41253487Smjacob * (Mostly) nonvolatile state. Board specific parameters 41353487Smjacob * may contain some volatile state (e.g., current loop state). 41435388Smjacob */ 41535388Smjacob 41653487Smjacob void * isp_param; /* type specific */ 417155704Smjacob uint16_t isp_fwrev[3]; /* Loaded F/W revision */ 418155704Smjacob uint16_t isp_romfw_rev[3]; /* PROM F/W revision */ 419155704Smjacob uint16_t isp_maxcmds; /* max possible I/O cmds */ 420155704Smjacob uint8_t isp_type; /* HBA Chip Type */ 421155704Smjacob uint8_t isp_revision; /* HBA Chip H/W Revision */ 422155704Smjacob uint32_t isp_maxluns; /* maximum luns supported */ 42335388Smjacob 424155704Smjacob uint32_t isp_clock : 8, /* input clock */ 42590224Smjacob : 4, 426163899Smjacob isp_port : 1, /* 23XX/24XX only */ 42787635Smjacob isp_failed : 1, /* board failed */ 42887635Smjacob isp_open : 1, /* opened (ioctl) */ 42953487Smjacob isp_touched : 1, /* board ever seen? */ 43053487Smjacob isp_bustype : 1, /* SBus or PCI */ 43165140Smjacob isp_loaded_fw : 1, /* loaded firmware */ 43287635Smjacob isp_role : 2, /* roles supported */ 43371079Smjacob isp_dblev : 12; /* debug log mask */ 43471079Smjacob 435155704Smjacob uint32_t isp_confopts; /* config options */ 43671079Smjacob 437163899Smjacob uint32_t isp_rqstinrp; /* register for REQINP */ 438163899Smjacob uint32_t isp_rqstoutrp; /* register for REQOUTP */ 439163899Smjacob uint32_t isp_respinrp; /* register for RESINP */ 440163899Smjacob uint32_t isp_respoutrp; /* register for RESOUTP */ 441163899Smjacob uint32_t isp_atioinrp; /* register for ATIOINP */ 442163899Smjacob uint32_t isp_atiooutrp; /* register for ATIOOUTP */ 44382689Smjacob 44469522Smjacob /* 44569522Smjacob * Instrumentation 44669522Smjacob */ 447155704Smjacob uint64_t isp_intcnt; /* total int count */ 448155704Smjacob uint64_t isp_intbogus; /* spurious int count */ 449155704Smjacob uint64_t isp_intmboxc; /* mbox completions */ 450155704Smjacob uint64_t isp_intoasync; /* other async */ 451155704Smjacob uint64_t isp_rsltccmplt; /* CMDs on result q */ 452155704Smjacob uint64_t isp_fphccmplt; /* CMDs via fastpost */ 453155704Smjacob uint16_t isp_rscchiwater; 454155704Smjacob uint16_t isp_fpcchiwater; 45539235Sgibbs 45635388Smjacob /* 45739235Sgibbs * Volatile state 45835388Smjacob */ 45935388Smjacob 460160080Smjacob volatile uint32_t : 8, 46187635Smjacob isp_mboxbsy : 1, /* mailbox command active */ 46239235Sgibbs isp_state : 3, 46346968Smjacob isp_sendmarker : 2, /* send a marker entry */ 46446968Smjacob isp_update : 2, /* update parameters */ 46552347Smjacob isp_nactive : 16; /* how many commands active */ 466163899Smjacob volatile uint32_t isp_reqodx; /* index of last ISP pickup */ 467163899Smjacob volatile uint32_t isp_reqidx; /* index of next request */ 468163899Smjacob volatile uint32_t isp_residx; /* index of next result */ 469163899Smjacob volatile uint32_t isp_resodx; /* index of next result */ 470163899Smjacob volatile uint32_t isp_rspbsy; 471163899Smjacob volatile uint32_t isp_lasthdls; /* last handle seed */ 472163899Smjacob volatile uint32_t isp_obits; /* mailbox command output */ 473155704Smjacob volatile uint16_t isp_mboxtmp[MAILBOX_STORAGE]; 474155704Smjacob volatile uint16_t isp_lastmbxcmd; /* last mbox command sent */ 475155704Smjacob volatile uint16_t isp_mbxwrk0; 476155704Smjacob volatile uint16_t isp_mbxwrk1; 477155704Smjacob volatile uint16_t isp_mbxwrk2; 478160080Smjacob volatile uint16_t isp_mbxwrk8; 47990224Smjacob void * isp_mbxworkp; 48035388Smjacob 48135388Smjacob /* 48253487Smjacob * Active commands are stored here, indexed by handle functions. 48335388Smjacob */ 48464087Smjacob XS_T **isp_xflist; 48535388Smjacob 486129643Snjl#ifdef ISP_TARGET_MODE 48735388Smjacob /* 488129643Snjl * Active target commands are stored here, indexed by handle function. 489129643Snjl */ 490129643Snjl void **isp_tgtlist; 491129643Snjl#endif 492129643Snjl 493129643Snjl /* 494120018Smjacob * request/result queue pointers and DMA handles for them. 49535388Smjacob */ 496155704Smjacob void * isp_rquest; 497155704Smjacob void * isp_result; 498155704Smjacob XS_DMA_ADDR_T isp_rquest_dma; 499155704Smjacob XS_DMA_ADDR_T isp_result_dma; 500163899Smjacob#ifdef ISP_TARGET_MODE 501163899Smjacob /* for 24XX only */ 502163899Smjacob void * isp_atioq; 503163899Smjacob XS_DMA_ADDR_T isp_atioq_dma; 504163899Smjacob#endif 505155704Smjacob}; 50635388Smjacob 50749909Smjacob#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) 50849909Smjacob#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) 50949909Smjacob 51035388Smjacob/* 51164087Smjacob * ISP Driver Run States 51235388Smjacob */ 51335388Smjacob#define ISP_NILSTATE 0 514160080Smjacob#define ISP_CRASHED 1 515160080Smjacob#define ISP_RESETSTATE 2 516160080Smjacob#define ISP_INITSTATE 3 517160080Smjacob#define ISP_RUNSTATE 4 51835388Smjacob 51935388Smjacob/* 52035388Smjacob * ISP Configuration Options 52135388Smjacob */ 52235388Smjacob#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 52343793Smjacob#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 52484241Smjacob#define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ 52584241Smjacob#define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ 52653487Smjacob#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 52769522Smjacob#define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ 52869522Smjacob#define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ 52969522Smjacob#define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ 53069522Smjacob#define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ 53169522Smjacob#define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ 53290752Smjacob#define ISP_CFG_OWNWWPN 0x100 /* override NVRAM wwpn */ 53390752Smjacob#define ISP_CFG_OWNWWNN 0x200 /* override NVRAM wwnn */ 53498281Smjacob#define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */ 53598281Smjacob#define ISP_CFG_OWNLOOPID 0x800 /* override NVRAM loopid */ 53698281Smjacob#define ISP_CFG_OWNEXCTHROTTLE 0x1000 /* override NVRAM execution throttle */ 537163899Smjacob#define ISP_CFG_FOURGB 0x2000 /* force 4GB connection (24XX only) */ 53835388Smjacob 53964087Smjacob/* 54071079Smjacob * Prior to calling isp_reset for the first time, the outer layer 54171079Smjacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH. 54271079Smjacob * 54371079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, 54471079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g. 54571079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. 54671079Smjacob * 54771079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped 54871079Smjacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT. 54971079Smjacob * 55071079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support 55171079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards 55271079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB 55371079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or 55471079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see 55571079Smjacob * anything. Basically, it sends a single byte of data (the first byte, 55671079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for 55771079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command. 55879235Smjacob * 55971079Smjacob */ 56071079Smjacob#define ISP_ROLE_NONE 0x0 561125544Smjacob#define ISP_ROLE_TARGET 0x1 562125544Smjacob#define ISP_ROLE_INITIATOR 0x2 56371079Smjacob#define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) 56471079Smjacob#define ISP_ROLE_EITHER ISP_ROLE_BOTH 56571079Smjacob#ifndef ISP_DEFAULT_ROLES 56671079Smjacob#define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR 56771079Smjacob#endif 56871079Smjacob 56971079Smjacob 57071079Smjacob/* 57164087Smjacob * Firmware related defines 57264087Smjacob */ 57371079Smjacob#define ISP_CODE_ORG 0x1000 /* default f/w code start */ 57482689Smjacob#define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ 575163899Smjacob#define ISP_CODE_ORG_2400 0x100000 /* ..and 2400s */ 57645282Smjacob#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 57782841Smjacob#define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) 57882841Smjacob#define ISP_FW_MINOR(code) ((code >> 16) & 0xff) 57982841Smjacob#define ISP_FW_MICRO(code) ((code >> 8) & 0xff) 58071079Smjacob#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 58182841Smjacob#define ISP_FW_MAJORX(xp) (xp[0]) 58282841Smjacob#define ISP_FW_MINORX(xp) (xp[1]) 58382841Smjacob#define ISP_FW_MICROX(xp) (xp[2]) 584102012Smjacob#define ISP_FW_NEWER_THAN(i, major, minor, micro) \ 585102012Smjacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro)) 586163899Smjacob#define ISP_FW_OLDER_THAN(i, major, minor, micro) \ 587163899Smjacob (ISP_FW_REVX((i)->isp_fwrev) < ISP_FW_REV(major, minor, micro)) 58839235Sgibbs 58935388Smjacob/* 59039235Sgibbs * Bus (implementation) types 59135388Smjacob */ 59239235Sgibbs#define ISP_BT_PCI 0 /* PCI Implementations */ 59339235Sgibbs#define ISP_BT_SBUS 1 /* SBus Implementations */ 59439235Sgibbs 59539235Sgibbs/* 59687635Smjacob * If we have not otherwise defined SBus support away make sure 59787635Smjacob * it is defined here such that the code is included as default 59887635Smjacob */ 59987635Smjacob#ifndef ISP_SBUS_SUPPORTED 60087635Smjacob#define ISP_SBUS_SUPPORTED 1 60187635Smjacob#endif 60287635Smjacob 60387635Smjacob/* 60439235Sgibbs * Chip Types 60539235Sgibbs */ 60635388Smjacob#define ISP_HA_SCSI 0xf 60739235Sgibbs#define ISP_HA_SCSI_UNKNOWN 0x1 60839235Sgibbs#define ISP_HA_SCSI_1020 0x2 60939235Sgibbs#define ISP_HA_SCSI_1020A 0x3 61039235Sgibbs#define ISP_HA_SCSI_1040 0x4 61139235Sgibbs#define ISP_HA_SCSI_1040A 0x5 61239235Sgibbs#define ISP_HA_SCSI_1040B 0x6 61345282Smjacob#define ISP_HA_SCSI_1040C 0x7 61454671Smjacob#define ISP_HA_SCSI_1240 0x8 61554671Smjacob#define ISP_HA_SCSI_1080 0x9 61654671Smjacob#define ISP_HA_SCSI_1280 0xa 617104916Smjacob#define ISP_HA_SCSI_10160 0xb 618104916Smjacob#define ISP_HA_SCSI_12160 0xc 61935388Smjacob#define ISP_HA_FC 0xf0 62035388Smjacob#define ISP_HA_FC_2100 0x10 62148484Smjacob#define ISP_HA_FC_2200 0x20 62277365Smjacob#define ISP_HA_FC_2300 0x30 62388855Smjacob#define ISP_HA_FC_2312 0x40 624154704Smjacob#define ISP_HA_FC_2322 0x50 625154704Smjacob#define ISP_HA_FC_2400 0x60 62635388Smjacob 62744819Smjacob#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 62854671Smjacob#define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 62944819Smjacob#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 63054671Smjacob#define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 631104916Smjacob#define IS_10160(isp) (isp->isp_type == ISP_HA_SCSI_10160) 63257145Smjacob#define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 63357145Smjacob 63457145Smjacob#define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 635104916Smjacob#define IS_1X160(isp) (IS_10160(isp) || IS_12160(isp)) 63657145Smjacob#define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 637104916Smjacob#define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_1X160(isp)) 638104916Smjacob#define IS_ULTRA3(isp) (IS_1X160(isp)) 63957145Smjacob 64077365Smjacob#define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) 64177365Smjacob#define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) 64277365Smjacob#define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) 643163899Smjacob#define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300 && \ 644163899Smjacob (isp)->isp_type < ISP_HA_FC_2400) 64588855Smjacob#define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) 64688855Smjacob#define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) 647154704Smjacob#define IS_2322(isp) ((isp)->isp_type == ISP_HA_FC_2322) 648154704Smjacob#define IS_24XX(isp) ((isp)->isp_type >= ISP_HA_FC_2400) 64944819Smjacob 65064087Smjacob/* 651155704Smjacob * DMA related macros 65264087Smjacob */ 653163899Smjacob#define DMA_WD3(x) (((uint16_t)(((uint64_t)x) >> 48)) & 0xffff) 654163899Smjacob#define DMA_WD2(x) (((uint16_t)(((uint64_t)x) >> 32)) & 0xffff) 655163899Smjacob#define DMA_WD1(x) ((uint16_t)((x) >> 16) & 0xffff) 656163899Smjacob#define DMA_WD0(x) ((uint16_t)((x) & 0xffff)) 65757145Smjacob 658155704Smjacob#define DMA_LO32(x) ((uint32_t) (x)) 659155704Smjacob#define DMA_HI32(x) ((uint32_t)(((uint64_t)x) >> 32)) 660155704Smjacob 66135388Smjacob/* 66264087Smjacob * Core System Function Prototypes 66335388Smjacob */ 66435388Smjacob 66535388Smjacob/* 66639235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with 66739235Sgibbs * a call to isp_init. 66835388Smjacob */ 669155704Smjacobvoid isp_reset(ispsoftc_t *); 67035388Smjacob 67135388Smjacob/* 67235388Smjacob * Initialize Hardware to known state 67335388Smjacob */ 674155704Smjacobvoid isp_init(ispsoftc_t *); 67535388Smjacob 67635388Smjacob/* 67739235Sgibbs * Reset the ISP and call completion for any orphaned commands. 67839235Sgibbs */ 679155704Smjacobvoid isp_reinit(ispsoftc_t *); 68039235Sgibbs 68190752Smjacob#ifdef ISP_FW_CRASH_DUMP 68239235Sgibbs/* 68390752Smjacob * Dump firmware entry point. 68490752Smjacob */ 685155704Smjacobvoid isp_fw_dump(ispsoftc_t *isp); 68690752Smjacob#endif 68790752Smjacob 68890752Smjacob/* 68982689Smjacob * Internal Interrupt Service Routine 69082689Smjacob * 69182689Smjacob * The outer layers do the spade work to get the appropriate status register, 69282689Smjacob * semaphore register and first mailbox register (if appropriate). This also 69382689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first. 69435388Smjacob */ 695163899Smjacobvoid isp_intr(ispsoftc_t *, uint32_t, uint16_t, uint16_t); 69635388Smjacob 69782689Smjacob 69835388Smjacob/* 69964087Smjacob * Command Entry Point- Platform Dependent layers call into this 70035388Smjacob */ 70174229Smjacobint isp_start(XS_T *); 702155704Smjacob 70364087Smjacob/* these values are what isp_start returns */ 70464087Smjacob#define CMD_COMPLETE 101 /* command completed */ 70564087Smjacob#define CMD_EAGAIN 102 /* busy- maybe retry later */ 70664087Smjacob#define CMD_QUEUED 103 /* command has been queued for execution */ 70764087Smjacob#define CMD_RQLATER 104 /* requeue this command later */ 70835388Smjacob 70939235Sgibbs/* 71064087Smjacob * Command Completion Point- Core layers call out from this with completed cmds 71164087Smjacob */ 71274229Smjacobvoid isp_done(XS_T *); 71364087Smjacob 71464087Smjacob/* 71543420Smjacob * Platform Dependent to External to Internal Control Function 71639235Sgibbs * 71772355Smjacob * Assumes locks are held on entry. You should note that with many of 71872355Smjacob * these commands and locks may be released while this is occurring. 71939235Sgibbs * 72072355Smjacob * A few notes about some of these functions: 72172355Smjacob * 72272355Smjacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link. 72372355Smjacob * The argument is a pointer to an integer which is the time, in microseconds, 72472355Smjacob * we should wait to see whether we have good link. This test, if successful, 72572355Smjacob * lets us know our connection topology and our Loop ID/AL_PA and so on. 72672355Smjacob * You can't get anywhere without this. 72772355Smjacob * 72872355Smjacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for 72972355Smjacob * all entities using the FC Generic Services subcommand GET ALL NEXT. 73072355Smjacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see 73172355Smjacob * below). 73272355Smjacob * 73372355Smjacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection 73472355Smjacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w 73572355Smjacob * 'automatically' manages local loop connections, this function essentially 73672355Smjacob * notes the arrival, departure, and possible shuffling around of local loop 73772355Smjacob * entities. Thus for each arrival and departure this generates an isp_async 73872355Smjacob * event of ISPASYNC_PROMENADE (see below). 73972355Smjacob * 74072355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in 74172355Smjacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. 74272355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging 74372355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking 74472355Smjacob * the 'loop state' as being ready to now be used for sending commands to 74572355Smjacob * devices. Originally fabric name server and local loop scanning were 74681794Smjacob * part of this function. It's now been separated to allow for finer control. 74739235Sgibbs */ 74839235Sgibbstypedef enum { 74948484Smjacob ISPCTL_RESET_BUS, /* Reset Bus */ 75048484Smjacob ISPCTL_RESET_DEV, /* Reset Device */ 75148484Smjacob ISPCTL_ABORT_CMD, /* Abort Command */ 75272355Smjacob ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters (SCSI) */ 75355364Smjacob ISPCTL_FCLINK_TEST, /* Test FC Link Status */ 75472355Smjacob ISPCTL_SCAN_FABRIC, /* (Re)scan Fabric Name Server */ 75572355Smjacob ISPCTL_SCAN_LOOP, /* (Re)scan Local Loop */ 75655364Smjacob ISPCTL_PDB_SYNC, /* Synchronize Port Database */ 75772355Smjacob ISPCTL_SEND_LIP, /* Send a LIP */ 758163899Smjacob ISPCTL_GET_PORTNAME, /* get portname from an N-port handle */ 75972938Smjacob ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ 760125544Smjacob ISPCTL_TOGGLE_TMODE, /* toggle target mode */ 761125544Smjacob ISPCTL_GET_PDB /* get a single port database entry */ 76239235Sgibbs} ispctl_t; 763155704Smjacobint isp_control(ispsoftc_t *, ispctl_t, void *); 76439235Sgibbs 76543420Smjacob 76639235Sgibbs/* 76743420Smjacob * Platform Dependent to Internal to External Control Function 76843420Smjacob * (each platform must provide such a function) 76943420Smjacob * 77072355Smjacob * Assumes locks are held. 77172355Smjacob * 77272355Smjacob * A few notes about some of these functions: 77372355Smjacob * 77472355Smjacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has 77572355Smjacob * occurred that invalidates the list of fabric devices known and/or 77672355Smjacob * the list of known loop devices. The argument passed is a pointer 77772355Smjacob * whose values are defined below (local loop change, name server 77872355Smjacob * change, other). 'Other' may simply be a LIP, or a change in 77972355Smjacob * connection topology. 78072355Smjacob * 78172355Smjacob * ISPASYNC_FABRIC_DEV announces the next element in a list of 78272355Smjacob * fabric device names we're getting out of the name server. The 78372355Smjacob * argument points to a GET ALL NEXT response structure. The list 78472355Smjacob * is known to terminate with an entry that refers to ourselves. 78572355Smjacob * One of the main purposes of this function is to allow outer 78672355Smjacob * layers, which are OS dependent, to set policy as to which fabric 78772355Smjacob * devices might actually be logged into (and made visible) later 78872355Smjacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric 78972355Smjacob * devices that we can log into (256 less 3 'reserved' for F-port 79072355Smjacob * topologies), and fabrics can grow up to 8 million or so entries 79172355Smjacob * (24 bits of Port Address, less a wad of reserved spaces), clearly 79272355Smjacob * we had better let the OS determine login policy. 79372355Smjacob * 79472355Smjacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which 795103826Smjacob * is an index into the portdb in the softc ('target'). Whether that entry's 79672355Smjacob * valid tag is set or not says whether something has arrived or departed. 79772355Smjacob * The name refers to a favorite pastime of many city dwellers- watching 79872355Smjacob * people come and go, talking of Michaelangelo, and so on.. 79972938Smjacob * 80072938Smjacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a 80172938Smjacob * response queue entry not otherwise handled. The outer layer should 80287635Smjacob * return non-zero if it handled it. The 'arg' points to an unmassaged 80387635Smjacob * response queue entry. 80443420Smjacob */ 80543420Smjacob 80643420Smjacobtypedef enum { 80772355Smjacob ISPASYNC_NEW_TGT_PARAMS, /* New Target Parameters Negotiated */ 80848484Smjacob ISPASYNC_BUS_RESET, /* Bus Was Reset */ 80948484Smjacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 81048484Smjacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 81177365Smjacob ISPASYNC_LIP, /* LIP Received */ 81277365Smjacob ISPASYNC_LOOP_RESET, /* Loop Reset Received */ 81372355Smjacob ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ 814163899Smjacob ISPASYNC_DEV_ARRIVED, /* FC Device Arrival */ 815163899Smjacob ISPASYNC_DEV_CHANGED, /* FC Device Change */ 816163899Smjacob ISPASYNC_DEV_STAYED, /* FC Device Stayed the Same */ 817163899Smjacob ISPASYNC_DEV_GONE, /* FC Device Depart */ 818154704Smjacob ISPASYNC_TARGET_NOTIFY, /* target asynchronous notification event */ 819154704Smjacob ISPASYNC_TARGET_ACTION, /* target action requested */ 82072938Smjacob ISPASYNC_CONF_CHANGE, /* Platform Configuration Change */ 82179235Smjacob ISPASYNC_UNHANDLED_RESPONSE, /* Unhandled Response Entry */ 82298281Smjacob ISPASYNC_FW_CRASH, /* Firmware has crashed */ 823102012Smjacob ISPASYNC_FW_DUMPED, /* Firmware crashdump taken */ 82498281Smjacob ISPASYNC_FW_RESTARTED /* Firmware has been restarted */ 82543420Smjacob} ispasync_t; 826155704Smjacobint isp_async(ispsoftc_t *, ispasync_t, void *); 82743420Smjacob 82872355Smjacob#define ISPASYNC_CHANGE_PDB ((void *) 0) 82972355Smjacob#define ISPASYNC_CHANGE_SNS ((void *) 1) 83072355Smjacob#define ISPASYNC_CHANGE_OTHER ((void *) 2) 83172355Smjacob 83243420Smjacob/* 83364087Smjacob * Platform Dependent Error and Debug Printout 834146073Smjacob * 835146073Smjacob * Generally this is: 836146073Smjacob * 837155704Smjacob * void isp_prt(ispsoftc_t *, int level, const char *, ...) 838146073Smjacob * 839146073Smjacob * but due to compiler differences on different platforms this won't be 840146073Smjacob * formally done here. Instead, it goes in each platform definition file. 84139235Sgibbs */ 84270490Smjacob 84364087Smjacob#define ISP_LOGALL 0x0 /* log always */ 84464087Smjacob#define ISP_LOGCONFIG 0x1 /* log configuration messages */ 84564087Smjacob#define ISP_LOGINFO 0x2 /* log informational messages */ 84664087Smjacob#define ISP_LOGWARN 0x4 /* log warning messages */ 84764087Smjacob#define ISP_LOGERR 0x8 /* log error messages */ 84864087Smjacob#define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 84964087Smjacob#define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 85064087Smjacob#define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 85179235Smjacob#define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ 85279235Smjacob#define ISP_LOGDEBUG4 0x100 /* log high frequency debug messages */ 85364087Smjacob#define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ 85464087Smjacob#define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ 85564087Smjacob#define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ 85639235Sgibbs 85764087Smjacob/* 85864087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 85964087Smjacob * defined above. 86064087Smjacob * 86164087Smjacob * Each platform must also provide the following macros/defines: 86264087Smjacob * 86364087Smjacob * 86464087Smjacob * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area 86564087Smjacob * 86664087Smjacob * MEMZERO(dst, src) platform zeroing function 86764087Smjacob * MEMCPY(dst, src, count) platform copying function 86864087Smjacob * SNPRINTF(buf, bufsize, fmt, ...) snprintf 86964087Smjacob * USEC_DELAY(usecs) microsecond spindelay function 87069522Smjacob * USEC_SLEEP(isp, usecs) microsecond sleep function 87164087Smjacob * 87264087Smjacob * NANOTIME_T nanosecond time type 87364087Smjacob * 87464087Smjacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 87564087Smjacob * 876155704Smjacob * GET_NANOSEC(NANOTIME_T *) get uint64_t from NANOTIME_T 87764087Smjacob * 87864087Smjacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 87964087Smjacob * subtract two NANOTIME_T values 88064087Smjacob * 88164087Smjacob * 882155704Smjacob * MAXISPREQUEST(ispsoftc_t *) maximum request queue size 88364087Smjacob * for this particular board type 88464087Smjacob * 885155704Smjacob * MEMORYBARRIER(ispsoftc_t *, barrier_type, offset, size) 88664087Smjacob * 88764087Smjacob * Function/Macro the provides memory synchronization on 88864087Smjacob * various objects so that the ISP's and the system's view 88964087Smjacob * of the same object is consistent. 89064087Smjacob * 891155704Smjacob * MBOX_ACQUIRE(ispsoftc_t *) acquire lock on mailbox regs 892163899Smjacob * MBOX_WAIT_COMPLETE(ispsoftc_t *, mbreg_t *) wait for cmd to be done 893155704Smjacob * MBOX_NOTIFY_COMPLETE(ispsoftc_t *) notification of mbox cmd donee 894155704Smjacob * MBOX_RELEASE(ispsoftc_t *) release lock on mailbox regs 89564087Smjacob * 896155704Smjacob * FC_SCRATCH_ACQUIRE(ispsoftc_t *) acquire lock on FC scratch area 897155704Smjacob * FC_SCRATCH_RELEASE(ispsoftc_t *) acquire lock on FC scratch area 89872355Smjacob * 89964087Smjacob * SCSI_GOOD SCSI 'Good' Status 90064087Smjacob * SCSI_CHECK SCSI 'Check Condition' Status 90164087Smjacob * SCSI_BUSY SCSI 'Busy' Status 90264087Smjacob * SCSI_QFULL SCSI 'Queue Full' Status 90364087Smjacob * 90464087Smjacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 905155704Smjacob * XS_DMA_ADDR_T Platform PCI DMA Address Type 90664087Smjacob * XS_ISP(xs) gets an instance out of an XS_T 90764087Smjacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 90864087Smjacob * XS_TGT(xs) gets the target "" 90964087Smjacob * XS_LUN(xs) gets the lun "" 91064087Smjacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 91164087Smjacob * XS_CDBLEN(xs) gets the CDB's length "" 91264087Smjacob * XS_XFRLEN(xs) gets the associated data transfer length "" 91364087Smjacob * XS_TIME(xs) gets the time (in milliseconds) for this command 91464087Smjacob * XS_RESID(xs) gets the current residual count 91564087Smjacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 91664087Smjacob * XS_SNSP(xs) gets a pointer to the associate sense data 91764087Smjacob * XS_SNSLEN(xs) gets the length of sense data storage 91864087Smjacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 91964087Smjacob * XS_TAG_P(xs) predicate of whether this command should be tagged 92064087Smjacob * XS_TAG_TYPE(xs) which type of tag to use 92164087Smjacob * XS_SETERR(xs) set error state 92264087Smjacob * 92364087Smjacob * HBA_NOERROR command has no erros 92464087Smjacob * HBA_BOTCH hba botched something 92564087Smjacob * HBA_CMDTIMEOUT command timed out 92664087Smjacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 92764087Smjacob * HBA_TGTBSY target returned a BUSY status 92864087Smjacob * HBA_BUSRESET bus reset destroyed command 92964087Smjacob * HBA_ABORTED command was aborted (by request) 93064087Smjacob * HBA_DATAOVR a data overrun was detected 93164087Smjacob * HBA_ARQFAIL Automatic Request Sense failed 93264087Smjacob * 93364087Smjacob * XS_ERR(xs) return current error state 93464087Smjacob * XS_NOERR(xs) there is no error currently set 93564087Smjacob * XS_INITERR(xs) initialize error state 93664087Smjacob * 93764087Smjacob * XS_SAVE_SENSE(xs, sp) save sense data 93864087Smjacob * 93964087Smjacob * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of 94064087Smjacob * response queue entry status bits 94164087Smjacob * 94264087Smjacob * 943155704Smjacob * DEFAULT_IID(ispsoftc_t *) Default SCSI initiator ID 944155704Smjacob * DEFAULT_LOOPID(ispsoftc_t *) Default FC Loop ID 945155704Smjacob * DEFAULT_NODEWWN(ispsoftc_t *) Default Node WWN 946155704Smjacob * DEFAULT_PORTWWN(ispsoftc_t *) Default Port WWN 947155704Smjacob * DEFAULT_FRAMESIZE(ispsoftc_t *) Default Frame Size 948155704Smjacob * DEFAULT_EXEC_THROTTLE(ispsoftc_t *) Default Execution Throttle 94967047Smjacob * These establish reasonable defaults for each platform. 95067047Smjacob * These must be available independent of card NVRAM and are 95167047Smjacob * to be used should NVRAM not be readable. 95264087Smjacob * 953155704Smjacob * ISP_NODEWWN(ispsoftc_t *) FC Node WWN to use 954155704Smjacob * ISP_PORTWWN(ispsoftc_t *) FC Port WWN to use 95564087Smjacob * 95667047Smjacob * These are to be used after NVRAM is read. The tags 95767047Smjacob * in fcparam.isp_{node,port}wwn reflect the values 95867047Smjacob * read from NVRAM (possibly corrected for card botches). 95967047Smjacob * Each platform can take that information and override 96067047Smjacob * it or ignore and return the Node and Port WWNs to be 96167047Smjacob * used when sending the Qlogic f/w the Initialization Control 96267047Smjacob * Block. 96364087Smjacob * 96464087Smjacob * (XXX these do endian specific transformations- in transition XXX) 96587635Smjacob * 966155704Smjacob * ISP_IOXPUT_8(ispsoftc_t *, uint8_t srcval, uint8_t *dstptr) 967155704Smjacob * ISP_IOXPUT_16(ispsoftc_t *, uint16_t srcval, uint16_t *dstptr) 968155704Smjacob * ISP_IOXPUT_32(ispsoftc_t *, uint32_t srcval, uint32_t *dstptr) 96987635Smjacob * 970155704Smjacob * ISP_IOXGET_8(ispsoftc_t *, uint8_t *srcptr, uint8_t dstrval) 971155704Smjacob * ISP_IOXGET_16(ispsoftc_t *, uint16_t *srcptr, uint16_t dstrval) 972155704Smjacob * ISP_IOXGET_32(ispsoftc_t *, uint32_t *srcptr, uint32_t dstrval) 97387635Smjacob * 974155704Smjacob * ISP_SWIZZLE_NVRAM_WORD(ispsoftc_t *, uint16_t *) 97564087Smjacob */ 97677365Smjacob 97735388Smjacob#endif /* _ISPVAR_H */ 978