1c3aac50fSPeter Wemm /* $FreeBSD$ */ 2098ca2bdSWarner Losh /*- 36054c3f6SMatt Jacob * Soft Definitions for for Qlogic ISP SCSI adapters. 46054c3f6SMatt Jacob * 5e5265237SMatt Jacob * Copyright (c) 1997-2006 by Matthew Jacob 66054c3f6SMatt Jacob * All rights reserved. 77e90346eSMatt Jacob * 86054c3f6SMatt Jacob * Redistribution and use in source and binary forms, with or without 96054c3f6SMatt Jacob * modification, are permitted provided that the following conditions 106054c3f6SMatt Jacob * are met: 116054c3f6SMatt Jacob * 1. Redistributions of source code must retain the above copyright 126054c3f6SMatt Jacob * notice immediately at the beginning of the file, without modification, 136054c3f6SMatt Jacob * this list of conditions, and the following disclaimer. 14aa57fd6fSMatt Jacob * 2. The name of the author may not be used to endorse or promote products 156054c3f6SMatt Jacob * derived from this software without specific prior written permission. 166054c3f6SMatt Jacob * 176054c3f6SMatt Jacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 186054c3f6SMatt Jacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 196054c3f6SMatt Jacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 206054c3f6SMatt Jacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 216054c3f6SMatt Jacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 226054c3f6SMatt Jacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 236054c3f6SMatt Jacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 246054c3f6SMatt Jacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 256054c3f6SMatt Jacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 266054c3f6SMatt Jacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 276054c3f6SMatt Jacob * SUCH DAMAGE. 286054c3f6SMatt Jacob */ 296054c3f6SMatt Jacob 306054c3f6SMatt Jacob #ifndef _ISPVAR_H 316054c3f6SMatt Jacob #define _ISPVAR_H 326054c3f6SMatt Jacob 3357c801f5SMatt Jacob #if defined(__NetBSD__) || defined(__OpenBSD__) 346054c3f6SMatt Jacob #include <dev/ic/ispmbox.h> 356054c3f6SMatt Jacob #endif 366054c3f6SMatt Jacob #ifdef __FreeBSD__ 376054c3f6SMatt Jacob #include <dev/isp/ispmbox.h> 386054c3f6SMatt Jacob #endif 396054c3f6SMatt Jacob #ifdef __linux__ 40c3055363SMatt Jacob #include "ispmbox.h" 4180ae5655SMatt Jacob #endif 421dae40ebSMatt Jacob #ifdef __svr4__ 431dae40ebSMatt Jacob #include "ispmbox.h" 446054c3f6SMatt Jacob #endif 456054c3f6SMatt Jacob 4653cff3bbSMatt Jacob #define ISP_CORE_VERSION_MAJOR 2 471dae40ebSMatt Jacob #define ISP_CORE_VERSION_MINOR 11 48478f8a96SJustin T. Gibbs 496054c3f6SMatt Jacob /* 50cbf57b47SMatt Jacob * Vector for bus specific code to provide specific services. 516054c3f6SMatt Jacob */ 521dae40ebSMatt Jacob typedef struct ispsoftc ispsoftc_t; 536054c3f6SMatt Jacob struct ispmdvec { 54126ec864SMatt Jacob int (*dv_rd_isr) 551dae40ebSMatt Jacob (ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *); 561dae40ebSMatt Jacob uint16_t (*dv_rd_reg) (ispsoftc_t *, int); 571dae40ebSMatt Jacob void (*dv_wr_reg) (ispsoftc_t *, int, uint16_t); 581dae40ebSMatt Jacob int (*dv_mbxdma) (ispsoftc_t *); 591dae40ebSMatt Jacob int (*dv_dmaset) 601dae40ebSMatt Jacob (ispsoftc_t *, XS_T *, ispreq_t *, uint16_t *, uint16_t); 611dae40ebSMatt Jacob void (*dv_dmaclr) (ispsoftc_t *, XS_T *, uint16_t); 621dae40ebSMatt Jacob void (*dv_reset0) (ispsoftc_t *); 631dae40ebSMatt Jacob void (*dv_reset1) (ispsoftc_t *); 641dae40ebSMatt Jacob void (*dv_dregs) (ispsoftc_t *, const char *); 651dae40ebSMatt Jacob uint16_t *dv_ispfw; /* ptr to f/w */ 661dae40ebSMatt Jacob uint16_t dv_conf1; 671dae40ebSMatt Jacob uint16_t dv_clock; /* clock frequency */ 686054c3f6SMatt Jacob }; 696054c3f6SMatt Jacob 7053cff3bbSMatt Jacob /* 7153cff3bbSMatt Jacob * Overall parameters 7253cff3bbSMatt Jacob */ 736054c3f6SMatt Jacob #define MAX_TARGETS 16 7457c801f5SMatt Jacob #define MAX_FC_TARG 256 750f747d72SMatt Jacob #define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) 765e09512cSMatt Jacob #define ISP_MAX_LUNS(isp) (isp)->isp_maxluns 770f747d72SMatt Jacob 78126ec864SMatt Jacob /* 7953cff3bbSMatt Jacob * Macros to access ISP registers through bus specific layers- 8053cff3bbSMatt Jacob * mostly wrappers to vector through the mdvec structure. 8180ae5655SMatt Jacob */ 82126ec864SMatt Jacob #define ISP_READ_ISR(isp, isrp, semap, mbox0p) \ 83126ec864SMatt Jacob (*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p) 8480ae5655SMatt Jacob 8580ae5655SMatt Jacob #define ISP_READ(isp, reg) \ 8680ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 8780ae5655SMatt Jacob 8880ae5655SMatt Jacob #define ISP_WRITE(isp, reg, val) \ 8980ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 9080ae5655SMatt Jacob 9180ae5655SMatt Jacob #define ISP_MBOXDMASETUP(isp) \ 9280ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 9380ae5655SMatt Jacob 9480ae5655SMatt Jacob #define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ 9580ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) 9680ae5655SMatt Jacob 9780ae5655SMatt Jacob #define ISP_DMAFREE(isp, xs, hndl) \ 9880ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_dmaclr) \ 9980ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) 10080ae5655SMatt Jacob 10180ae5655SMatt Jacob #define ISP_RESET0(isp) \ 10280ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 10380ae5655SMatt Jacob #define ISP_RESET1(isp) \ 10480ae5655SMatt Jacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 10553cff3bbSMatt Jacob #define ISP_DUMPREGS(isp, m) \ 10653cff3bbSMatt Jacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) 10780ae5655SMatt Jacob 10880ae5655SMatt Jacob #define ISP_SETBITS(isp, reg, val) \ 10980ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 11080ae5655SMatt Jacob 11180ae5655SMatt Jacob #define ISP_CLRBITS(isp, reg, val) \ 11280ae5655SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 11380ae5655SMatt Jacob 11453cff3bbSMatt Jacob /* 11553cff3bbSMatt Jacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization 11653cff3bbSMatt Jacob * on Request and Response Queues, Scratch DMA areas, and Registers) 11753cff3bbSMatt Jacob * 11853cff3bbSMatt Jacob * Defined Memory Barrier Synchronization Types 11953cff3bbSMatt Jacob */ 12053cff3bbSMatt Jacob #define SYNC_REQUEST 0 /* request queue synchronization */ 12153cff3bbSMatt Jacob #define SYNC_RESULT 1 /* result queue synchronization */ 12253cff3bbSMatt Jacob #define SYNC_SFORDEV 2 /* scratch, sync for ISP */ 12353cff3bbSMatt Jacob #define SYNC_SFORCPU 3 /* scratch, sync for CPU */ 12453cff3bbSMatt Jacob #define SYNC_REG 4 /* for registers */ 12553cff3bbSMatt Jacob 12653cff3bbSMatt Jacob /* 12753cff3bbSMatt Jacob * Request/Response Queue defines and macros. 12853cff3bbSMatt Jacob * The maximum is defined per platform (and can be based on board type). 12953cff3bbSMatt Jacob */ 13053cff3bbSMatt Jacob /* This is the size of a queue entry (request and response) */ 1316054c3f6SMatt Jacob #define QENTRY_LEN 64 13253cff3bbSMatt Jacob /* Both request and result queue length must be a power of two */ 13353cff3bbSMatt Jacob #define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) 1341923f739SMatt Jacob #ifdef ISP_TARGET_MODE 1351923f739SMatt Jacob #define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) 1361923f739SMatt Jacob #else 13753cff3bbSMatt Jacob #define RESULT_QUEUE_LEN(x) \ 13853cff3bbSMatt Jacob (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) 1391923f739SMatt Jacob #endif 1401dae40ebSMatt Jacob #define ISP_QUEUE_ENTRY(q, idx) (((uint8_t *)q) + ((idx) * QENTRY_LEN)) 1416054c3f6SMatt Jacob #define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 142478f8a96SJustin T. Gibbs #define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 143b6b6ad2fSMatt Jacob #define ISP_QFREE(in, out, qlen) \ 144478f8a96SJustin T. Gibbs ((in == out)? (qlen - 1) : ((in > out)? \ 145478f8a96SJustin T. Gibbs ((qlen - 1) - (in - out)) : (out - in - 1))) 146b6b6ad2fSMatt Jacob #define ISP_QAVAIL(isp) \ 147b6b6ad2fSMatt Jacob ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) 14880ae5655SMatt Jacob 1494fd13c1bSMatt Jacob #define ISP_ADD_REQUEST(isp, nxti) \ 1504fd13c1bSMatt Jacob MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN); \ 1514fd13c1bSMatt Jacob WRITE_REQUEST_QUEUE_IN_POINTER(isp, nxti); \ 1524fd13c1bSMatt Jacob isp->isp_reqidx = nxti 15380ae5655SMatt Jacob 1546054c3f6SMatt Jacob /* 1558259d081SMatt Jacob * SCSI Specific Host Adapter Parameters- per bus, per target 1566054c3f6SMatt Jacob */ 1576054c3f6SMatt Jacob typedef struct { 1581dae40ebSMatt Jacob uint32_t isp_gotdparms : 1, 1598259d081SMatt Jacob isp_req_ack_active_neg : 1, 1606054c3f6SMatt Jacob isp_data_line_active_neg: 1, 1616054c3f6SMatt Jacob isp_cmd_dma_burst_enable: 1, 1626054c3f6SMatt Jacob isp_data_dma_burst_enabl: 1, 163128101f3SMatt Jacob isp_fifo_threshold : 3, 164cbf57b47SMatt Jacob isp_ultramode : 1, 1656054c3f6SMatt Jacob isp_diffmode : 1, 1664394c92fSMatt Jacob isp_lvdmode : 1, 167b6b6ad2fSMatt Jacob isp_fast_mttr : 1, /* fast sram */ 1686054c3f6SMatt Jacob isp_initiator_id : 4, 1696054c3f6SMatt Jacob isp_async_data_setup : 4; 1701dae40ebSMatt Jacob uint16_t isp_selection_timeout; 1711dae40ebSMatt Jacob uint16_t isp_max_queue_depth; 1721dae40ebSMatt Jacob uint8_t isp_tag_aging; 1731dae40ebSMatt Jacob uint8_t isp_bus_reset_delay; 1741dae40ebSMatt Jacob uint8_t isp_retry_count; 1751dae40ebSMatt Jacob uint8_t isp_retry_delay; 1766054c3f6SMatt Jacob struct { 1771dae40ebSMatt Jacob uint32_t 178d9c272f3SMatt Jacob exc_throttle : 8, 1798259d081SMatt Jacob : 1, 180d9c272f3SMatt Jacob dev_enable : 1, /* ignored */ 181cbf57b47SMatt Jacob dev_update : 1, 182cbf57b47SMatt Jacob dev_refresh : 1, 183d9c272f3SMatt Jacob actv_offset : 4, 184d9c272f3SMatt Jacob goal_offset : 4, 185d9c272f3SMatt Jacob nvrm_offset : 4; 1861dae40ebSMatt Jacob uint8_t actv_period; /* current sync period */ 1871dae40ebSMatt Jacob uint8_t goal_period; /* goal sync period */ 1881dae40ebSMatt Jacob uint8_t nvrm_period; /* nvram sync period */ 1891dae40ebSMatt Jacob uint16_t actv_flags; /* current device flags */ 1901dae40ebSMatt Jacob uint16_t goal_flags; /* goal device flags */ 1911dae40ebSMatt Jacob uint16_t nvrm_flags; /* nvram device flags */ 1926054c3f6SMatt Jacob } isp_devparam[MAX_TARGETS]; 1938259d081SMatt Jacob } sdparam; 1946054c3f6SMatt Jacob 1956054c3f6SMatt Jacob /* 1966054c3f6SMatt Jacob * Device Flags 1976054c3f6SMatt Jacob */ 198478f8a96SJustin T. Gibbs #define DPARM_DISC 0x8000 199478f8a96SJustin T. Gibbs #define DPARM_PARITY 0x4000 200478f8a96SJustin T. Gibbs #define DPARM_WIDE 0x2000 201478f8a96SJustin T. Gibbs #define DPARM_SYNC 0x1000 202478f8a96SJustin T. Gibbs #define DPARM_TQING 0x0800 203478f8a96SJustin T. Gibbs #define DPARM_ARQ 0x0400 204478f8a96SJustin T. Gibbs #define DPARM_QFRZ 0x0200 205478f8a96SJustin T. Gibbs #define DPARM_RENEG 0x0100 206b6b6ad2fSMatt Jacob #define DPARM_NARROW 0x0080 207b6b6ad2fSMatt Jacob #define DPARM_ASYNC 0x0040 208b6b6ad2fSMatt Jacob #define DPARM_PPR 0x0020 20910f20e40SMatt Jacob #define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) 210478f8a96SJustin T. Gibbs #define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) 211478f8a96SJustin T. Gibbs 2124394c92fSMatt Jacob /* technically, not really correct, as they need to be rated based upon clock */ 213b6b6ad2fSMatt Jacob #define ISP_80M_SYNCPARMS 0x0c09 214b6b6ad2fSMatt Jacob #define ISP_40M_SYNCPARMS 0x0c0a 215b6b6ad2fSMatt Jacob #define ISP_20M_SYNCPARMS 0x0c0c 216b6b6ad2fSMatt Jacob #define ISP_20M_SYNCPARMS_1040 0x080c 2176054c3f6SMatt Jacob #define ISP_10M_SYNCPARMS 0x0c19 2186054c3f6SMatt Jacob #define ISP_08M_SYNCPARMS 0x0c25 2196054c3f6SMatt Jacob #define ISP_05M_SYNCPARMS 0x0c32 2206054c3f6SMatt Jacob #define ISP_04M_SYNCPARMS 0x0c41 2216054c3f6SMatt Jacob 2226054c3f6SMatt Jacob /* 2236054c3f6SMatt Jacob * Fibre Channel Specifics 2246054c3f6SMatt Jacob */ 2257e90346eSMatt Jacob #define FL_PORT_ID 0x7e /* FL_Port Special ID */ 2267e90346eSMatt Jacob #define FC_PORT_ID 0x7f /* Fabric Controller Special ID */ 2277e90346eSMatt Jacob #define FC_SNS_ID 0x80 /* SNS Server Special ID */ 2287e90346eSMatt Jacob 229029f13c6SMatt Jacob /* #define ISP_USE_GA_NXT 1 */ /* Use GA_NXT with switches */ 230029f13c6SMatt Jacob #ifndef GA_NXT_MAX 231029f13c6SMatt Jacob #define GA_NXT_MAX 256 232029f13c6SMatt Jacob #endif 233029f13c6SMatt Jacob 2346054c3f6SMatt Jacob typedef struct { 2351dae40ebSMatt Jacob uint32_t : 13, 236e5265237SMatt Jacob isp_gbspeed : 3, 237e5265237SMatt Jacob : 2, 238410b5567SMatt Jacob isp_iid_set : 1, 23977d4e836SMatt Jacob loop_seen_once : 1, 2406a23026cSMatt Jacob isp_loopstate : 4, /* Current Loop State */ 24177d4e836SMatt Jacob isp_fwstate : 3, /* ISP F/W state */ 24277d4e836SMatt Jacob isp_gotdparms : 1, 243d465588aSMatt Jacob isp_topo : 3, 24477d4e836SMatt Jacob isp_onfabric : 1; 2451dae40ebSMatt Jacob uint32_t : 8, 246e5265237SMatt Jacob isp_portid : 24; /* S_ID */ 2471dae40ebSMatt Jacob uint16_t isp_fwoptions; 2481dae40ebSMatt Jacob uint16_t isp_iid; /* 'initiator' id */ 2491dae40ebSMatt Jacob uint16_t isp_loopid; /* hard loop id */ 2501dae40ebSMatt Jacob uint16_t isp_fwattr; /* firmware attributes */ 2511dae40ebSMatt Jacob uint8_t isp_execthrottle; 2521dae40ebSMatt Jacob uint8_t isp_retry_delay; 2531dae40ebSMatt Jacob uint8_t isp_retry_count; 2541dae40ebSMatt Jacob uint8_t isp_reserved; 2551dae40ebSMatt Jacob uint16_t isp_maxalloc; 2561dae40ebSMatt Jacob uint16_t isp_maxfrmlen; 2571dae40ebSMatt Jacob uint64_t isp_nodewwn; 2581dae40ebSMatt Jacob uint64_t isp_portwwn; 2596054c3f6SMatt Jacob /* 26077d4e836SMatt Jacob * Port Data Base. This is indexed by 'target', which is invariate. 26177d4e836SMatt Jacob * However, elements within can move around due to loop changes, 26277d4e836SMatt Jacob * so the actual loop ID passed to the F/W is in this structure. 26377d4e836SMatt Jacob * The first time the loop is seen up, loopid will match the index 26477d4e836SMatt Jacob * (except for fabric nodes which are above mapped above FC_SNS_ID 26577d4e836SMatt Jacob * and are completely virtual), but subsequent LIPs can cause things 26677d4e836SMatt Jacob * to move around. 26757c801f5SMatt Jacob */ 26877d4e836SMatt Jacob struct lportdb { 2691dae40ebSMatt Jacob uint32_t loopid : 16, 270e5265237SMatt Jacob : 2, 2710499ae00SMatt Jacob fc4_type : 4, 272029f13c6SMatt Jacob last_fabric_dev : 1, 2730499ae00SMatt Jacob relogin : 1, 2746a23026cSMatt Jacob force_logout : 1, 2757afb656fSMatt Jacob was_fabric_dev : 1, 2767afb656fSMatt Jacob fabric_dev : 1, 277686f419dSMatt Jacob loggedin : 1, 27877d4e836SMatt Jacob roles : 2, 279e5265237SMatt Jacob tvalid : 1, 28077d4e836SMatt Jacob valid : 1; 2811dae40ebSMatt Jacob uint32_t port_type : 8, 282e5265237SMatt Jacob portid : 24; 2831dae40ebSMatt Jacob uint64_t node_wwn; 2841dae40ebSMatt Jacob uint64_t port_wwn; 285410b5567SMatt Jacob } portdb[MAX_FC_TARG], tport[FC_PORT_ID]; 28657c801f5SMatt Jacob 28757c801f5SMatt Jacob /* 2886054c3f6SMatt Jacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 2896054c3f6SMatt Jacob */ 2901dae40ebSMatt Jacob void * isp_scratch; 2911dae40ebSMatt Jacob XS_DMA_ADDR_T isp_scdma; 29201ff579dSMatt Jacob #ifdef ISP_FW_CRASH_DUMP 2931dae40ebSMatt Jacob uint16_t * isp_dump_data; 29401ff579dSMatt Jacob #endif 2956054c3f6SMatt Jacob } fcparam; 2966054c3f6SMatt Jacob 29777d4e836SMatt Jacob #define FW_CONFIG_WAIT 0 29877d4e836SMatt Jacob #define FW_WAIT_AL_PA 1 29977d4e836SMatt Jacob #define FW_WAIT_LOGIN 2 30077d4e836SMatt Jacob #define FW_READY 3 30177d4e836SMatt Jacob #define FW_LOSS_OF_SYNC 4 30277d4e836SMatt Jacob #define FW_ERROR 5 30377d4e836SMatt Jacob #define FW_REINIT 6 30477d4e836SMatt Jacob #define FW_NON_PART 7 3056054c3f6SMatt Jacob 30677d4e836SMatt Jacob #define LOOP_NIL 0 30777d4e836SMatt Jacob #define LOOP_LIP_RCVD 1 30877d4e836SMatt Jacob #define LOOP_PDB_RCVD 2 309410b5567SMatt Jacob #define LOOP_SCANNING_FABRIC 3 310410b5567SMatt Jacob #define LOOP_FSCAN_DONE 4 311410b5567SMatt Jacob #define LOOP_SCANNING_LOOP 5 3126a23026cSMatt Jacob #define LOOP_LSCAN_DONE 6 3136a23026cSMatt Jacob #define LOOP_SYNCING_PDB 7 3146a23026cSMatt Jacob #define LOOP_READY 8 31577d4e836SMatt Jacob 316d465588aSMatt Jacob #define TOPO_NL_PORT 0 317d465588aSMatt Jacob #define TOPO_FL_PORT 1 318d465588aSMatt Jacob #define TOPO_N_PORT 2 319d465588aSMatt Jacob #define TOPO_F_PORT 3 320d465588aSMatt Jacob #define TOPO_PTP_STUB 4 321d465588aSMatt Jacob 3226054c3f6SMatt Jacob /* 3236054c3f6SMatt Jacob * Soft Structure per host adapter 3246054c3f6SMatt Jacob */ 3251dae40ebSMatt Jacob struct ispsoftc { 3266054c3f6SMatt Jacob /* 3276054c3f6SMatt Jacob * Platform (OS) specific data 3286054c3f6SMatt Jacob */ 3296054c3f6SMatt Jacob struct isposinfo isp_osinfo; 3306054c3f6SMatt Jacob 3316054c3f6SMatt Jacob /* 33280ae5655SMatt Jacob * Pointer to bus specific functions and data 3336054c3f6SMatt Jacob */ 3346054c3f6SMatt Jacob struct ispmdvec * isp_mdvec; 3356054c3f6SMatt Jacob 3366054c3f6SMatt Jacob /* 33780ae5655SMatt Jacob * (Mostly) nonvolatile state. Board specific parameters 33880ae5655SMatt Jacob * may contain some volatile state (e.g., current loop state). 3396054c3f6SMatt Jacob */ 3406054c3f6SMatt Jacob 34180ae5655SMatt Jacob void * isp_param; /* type specific */ 3421dae40ebSMatt Jacob uint16_t isp_fwrev[3]; /* Loaded F/W revision */ 3431dae40ebSMatt Jacob uint16_t isp_romfw_rev[3]; /* PROM F/W revision */ 3441dae40ebSMatt Jacob uint16_t isp_maxcmds; /* max possible I/O cmds */ 3451dae40ebSMatt Jacob uint8_t isp_type; /* HBA Chip Type */ 3461dae40ebSMatt Jacob uint8_t isp_revision; /* HBA Chip H/W Revision */ 3471dae40ebSMatt Jacob uint32_t isp_maxluns; /* maximum luns supported */ 3486054c3f6SMatt Jacob 3491dae40ebSMatt Jacob uint32_t isp_clock : 8, /* input clock */ 35075c1e828SMatt Jacob : 4, 35175c1e828SMatt Jacob isp_port : 1, /* 23XX only */ 3524fd13c1bSMatt Jacob isp_failed : 1, /* board failed */ 3534fd13c1bSMatt Jacob isp_open : 1, /* opened (ioctl) */ 3547afb656fSMatt Jacob isp_touched : 1, /* board ever seen? */ 355b6b6ad2fSMatt Jacob isp_bustype : 1, /* SBus or PCI */ 356b6b6ad2fSMatt Jacob isp_loaded_fw : 1, /* loaded firmware */ 3574fd13c1bSMatt Jacob isp_role : 2, /* roles supported */ 3587afb656fSMatt Jacob isp_dblev : 12; /* debug log mask */ 3597afb656fSMatt Jacob 3601dae40ebSMatt Jacob uint32_t isp_confopts; /* config options */ 3617afb656fSMatt Jacob 3621dae40ebSMatt Jacob uint16_t isp_rqstinrp; /* register for REQINP */ 3631dae40ebSMatt Jacob uint16_t isp_rqstoutrp; /* register for REQOUTP */ 3641dae40ebSMatt Jacob uint16_t isp_respinrp; /* register for RESINP */ 3651dae40ebSMatt Jacob uint16_t isp_respoutrp; /* register for RESOUTP */ 366126ec864SMatt Jacob 36767afe757SMatt Jacob /* 36867afe757SMatt Jacob * Instrumentation 36967afe757SMatt Jacob */ 3701dae40ebSMatt Jacob uint64_t isp_intcnt; /* total int count */ 3711dae40ebSMatt Jacob uint64_t isp_intbogus; /* spurious int count */ 3721dae40ebSMatt Jacob uint64_t isp_intmboxc; /* mbox completions */ 3731dae40ebSMatt Jacob uint64_t isp_intoasync; /* other async */ 3741dae40ebSMatt Jacob uint64_t isp_rsltccmplt; /* CMDs on result q */ 3751dae40ebSMatt Jacob uint64_t isp_fphccmplt; /* CMDs via fastpost */ 3761dae40ebSMatt Jacob uint16_t isp_rscchiwater; 3771dae40ebSMatt Jacob uint16_t isp_fpcchiwater; 3786054c3f6SMatt Jacob 3796054c3f6SMatt Jacob /* 380478f8a96SJustin T. Gibbs * Volatile state 3816054c3f6SMatt Jacob */ 382478f8a96SJustin T. Gibbs 3831dae40ebSMatt Jacob volatile uint32_t 3844fd13c1bSMatt Jacob isp_obits : 8, /* mailbox command output */ 3854fd13c1bSMatt Jacob isp_mboxbsy : 1, /* mailbox command active */ 386478f8a96SJustin T. Gibbs isp_state : 3, 3878259d081SMatt Jacob isp_sendmarker : 2, /* send a marker entry */ 3888259d081SMatt Jacob isp_update : 2, /* update parameters */ 3897e90346eSMatt Jacob isp_nactive : 16; /* how many commands active */ 3901dae40ebSMatt Jacob volatile uint16_t isp_reqodx; /* index of last ISP pickup */ 3911dae40ebSMatt Jacob volatile uint16_t isp_reqidx; /* index of next request */ 3921dae40ebSMatt Jacob volatile uint16_t isp_residx; /* index of next result */ 3931dae40ebSMatt Jacob volatile uint16_t isp_resodx; /* index of next result */ 3941dae40ebSMatt Jacob volatile uint16_t isp_rspbsy; 3951dae40ebSMatt Jacob volatile uint16_t isp_lasthdls; /* last handle seed */ 3961dae40ebSMatt Jacob volatile uint16_t isp_mboxtmp[MAILBOX_STORAGE]; 3971dae40ebSMatt Jacob volatile uint16_t isp_lastmbxcmd; /* last mbox command sent */ 3981dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk0; 3991dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk1; 4001dae40ebSMatt Jacob volatile uint16_t isp_mbxwrk2; 40175c1e828SMatt Jacob void * isp_mbxworkp; 402478f8a96SJustin T. Gibbs 403478f8a96SJustin T. Gibbs /* 40480ae5655SMatt Jacob * Active commands are stored here, indexed by handle functions. 405478f8a96SJustin T. Gibbs */ 40653cff3bbSMatt Jacob XS_T **isp_xflist; 4076054c3f6SMatt Jacob 40851e23558SNate Lawson #ifdef ISP_TARGET_MODE 40951e23558SNate Lawson /* 41051e23558SNate Lawson * Active target commands are stored here, indexed by handle function. 41151e23558SNate Lawson */ 41251e23558SNate Lawson void **isp_tgtlist; 41351e23558SNate Lawson #endif 41451e23558SNate Lawson 4156054c3f6SMatt Jacob /* 4164b39f27dSMatt Jacob * request/result queue pointers and DMA handles for them. 4176054c3f6SMatt Jacob */ 4181dae40ebSMatt Jacob void * isp_rquest; 4191dae40ebSMatt Jacob void * isp_result; 4201dae40ebSMatt Jacob XS_DMA_ADDR_T isp_rquest_dma; 4211dae40ebSMatt Jacob XS_DMA_ADDR_T isp_result_dma; 4221dae40ebSMatt Jacob }; 4236054c3f6SMatt Jacob 4240f747d72SMatt Jacob #define SDPARAM(isp) ((sdparam *) (isp)->isp_param) 4250f747d72SMatt Jacob #define FCPARAM(isp) ((fcparam *) (isp)->isp_param) 4260f747d72SMatt Jacob 4276054c3f6SMatt Jacob /* 42853cff3bbSMatt Jacob * ISP Driver Run States 4296054c3f6SMatt Jacob */ 4306054c3f6SMatt Jacob #define ISP_NILSTATE 0 4316054c3f6SMatt Jacob #define ISP_RESETSTATE 1 4326054c3f6SMatt Jacob #define ISP_INITSTATE 2 4336054c3f6SMatt Jacob #define ISP_RUNSTATE 3 4346054c3f6SMatt Jacob 4356054c3f6SMatt Jacob /* 4366054c3f6SMatt Jacob * ISP Configuration Options 4376054c3f6SMatt Jacob */ 4386054c3f6SMatt Jacob #define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 43910f20e40SMatt Jacob #define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 440c507669aSMatt Jacob #define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ 441c507669aSMatt Jacob #define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ 44280ae5655SMatt Jacob #define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ 44367afe757SMatt Jacob #define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ 44467afe757SMatt Jacob #define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ 44567afe757SMatt Jacob #define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ 44667afe757SMatt Jacob #define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ 44767afe757SMatt Jacob #define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ 44801ff579dSMatt Jacob #define ISP_CFG_OWNWWPN 0x100 /* override NVRAM wwpn */ 44901ff579dSMatt Jacob #define ISP_CFG_OWNWWNN 0x200 /* override NVRAM wwnn */ 4500499ae00SMatt Jacob #define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */ 4510499ae00SMatt Jacob #define ISP_CFG_OWNLOOPID 0x800 /* override NVRAM loopid */ 4520499ae00SMatt Jacob #define ISP_CFG_OWNEXCTHROTTLE 0x1000 /* override NVRAM execution throttle */ 4536054c3f6SMatt Jacob 45453cff3bbSMatt Jacob /* 4557afb656fSMatt Jacob * Prior to calling isp_reset for the first time, the outer layer 4567afb656fSMatt Jacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH. 4577afb656fSMatt Jacob * 4587afb656fSMatt Jacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, 4597afb656fSMatt Jacob * NVRAM read, and defaults set, but any further initialization (e.g. 4607afb656fSMatt Jacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. 4617afb656fSMatt Jacob * 4627afb656fSMatt Jacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped 4637afb656fSMatt Jacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT. 4647afb656fSMatt Jacob * 4657afb656fSMatt Jacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support 4667afb656fSMatt Jacob * needs to be enabled, or will even work. What happens with the 2X00 cards 4677afb656fSMatt Jacob * here is that if you have enabled it with TARGET MODE as part of the ICB 4687afb656fSMatt Jacob * options, but you haven't given the f/w any ram resources for ATIOs or 4697afb656fSMatt Jacob * Immediate Notifies, the f/w just handles what it can and you never see 4707afb656fSMatt Jacob * anything. Basically, it sends a single byte of data (the first byte, 4717afb656fSMatt Jacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for 4727afb656fSMatt Jacob * INQUIRY, and sends back QUEUE FULL status for any other command. 4737afb656fSMatt Jacob * 4747afb656fSMatt Jacob */ 4757afb656fSMatt Jacob #define ISP_ROLE_NONE 0x0 476e0d3cfb7SMatt Jacob #define ISP_ROLE_TARGET 0x1 477e0d3cfb7SMatt Jacob #define ISP_ROLE_INITIATOR 0x2 4787afb656fSMatt Jacob #define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) 4797afb656fSMatt Jacob #define ISP_ROLE_EITHER ISP_ROLE_BOTH 4807afb656fSMatt Jacob #ifndef ISP_DEFAULT_ROLES 4817afb656fSMatt Jacob #define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR 4827afb656fSMatt Jacob #endif 4837afb656fSMatt Jacob 4847afb656fSMatt Jacob 4857afb656fSMatt Jacob /* 48653cff3bbSMatt Jacob * Firmware related defines 48753cff3bbSMatt Jacob */ 48853cff3bbSMatt Jacob #define ISP_CODE_ORG 0x1000 /* default f/w code start */ 489126ec864SMatt Jacob #define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ 49012b36e2dSMatt Jacob #define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) 491f8597b62SMatt Jacob #define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) 492f8597b62SMatt Jacob #define ISP_FW_MINOR(code) ((code >> 16) & 0xff) 493f8597b62SMatt Jacob #define ISP_FW_MICRO(code) ((code >> 8) & 0xff) 49412b36e2dSMatt Jacob #define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) 495f8597b62SMatt Jacob #define ISP_FW_MAJORX(xp) (xp[0]) 496f8597b62SMatt Jacob #define ISP_FW_MINORX(xp) (xp[1]) 497f8597b62SMatt Jacob #define ISP_FW_MICROX(xp) (xp[2]) 498e347e2c9SMatt Jacob #define ISP_FW_NEWER_THAN(i, major, minor, micro) \ 499e347e2c9SMatt Jacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro)) 50012b36e2dSMatt Jacob 5016054c3f6SMatt Jacob /* 502478f8a96SJustin T. Gibbs * Bus (implementation) types 503478f8a96SJustin T. Gibbs */ 504478f8a96SJustin T. Gibbs #define ISP_BT_PCI 0 /* PCI Implementations */ 505478f8a96SJustin T. Gibbs #define ISP_BT_SBUS 1 /* SBus Implementations */ 506478f8a96SJustin T. Gibbs 507478f8a96SJustin T. Gibbs /* 5084fd13c1bSMatt Jacob * If we have not otherwise defined SBus support away make sure 5094fd13c1bSMatt Jacob * it is defined here such that the code is included as default 5104fd13c1bSMatt Jacob */ 5114fd13c1bSMatt Jacob #ifndef ISP_SBUS_SUPPORTED 5124fd13c1bSMatt Jacob #define ISP_SBUS_SUPPORTED 1 5134fd13c1bSMatt Jacob #endif 5144fd13c1bSMatt Jacob 5154fd13c1bSMatt Jacob /* 516478f8a96SJustin T. Gibbs * Chip Types 5176054c3f6SMatt Jacob */ 5186054c3f6SMatt Jacob #define ISP_HA_SCSI 0xf 519478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_UNKNOWN 0x1 520478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020 0x2 521478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020A 0x3 522478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040 0x4 523478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040A 0x5 524478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040B 0x6 52512b36e2dSMatt Jacob #define ISP_HA_SCSI_1040C 0x7 52622e1dc85SMatt Jacob #define ISP_HA_SCSI_1240 0x8 52722e1dc85SMatt Jacob #define ISP_HA_SCSI_1080 0x9 52822e1dc85SMatt Jacob #define ISP_HA_SCSI_1280 0xa 529f556e83bSMatt Jacob #define ISP_HA_SCSI_10160 0xb 530f556e83bSMatt Jacob #define ISP_HA_SCSI_12160 0xc 5316054c3f6SMatt Jacob #define ISP_HA_FC 0xf0 5326054c3f6SMatt Jacob #define ISP_HA_FC_2100 0x10 53377d4e836SMatt Jacob #define ISP_HA_FC_2200 0x20 5345d571944SMatt Jacob #define ISP_HA_FC_2300 0x30 5352903b272SMatt Jacob #define ISP_HA_FC_2312 0x40 536e5265237SMatt Jacob #define ISP_HA_FC_2322 0x50 537e5265237SMatt Jacob #define ISP_HA_FC_2400 0x60 538e5265237SMatt Jacob #define ISP_HA_FC_2422 0x61 5396054c3f6SMatt Jacob 54057c801f5SMatt Jacob #define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 54122e1dc85SMatt Jacob #define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) 54257c801f5SMatt Jacob #define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 54322e1dc85SMatt Jacob #define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) 544f556e83bSMatt Jacob #define IS_10160(isp) (isp->isp_type == ISP_HA_SCSI_10160) 54583fbc566SMatt Jacob #define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) 54683fbc566SMatt Jacob 54783fbc566SMatt Jacob #define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) 548f556e83bSMatt Jacob #define IS_1X160(isp) (IS_10160(isp) || IS_12160(isp)) 54983fbc566SMatt Jacob #define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) 550f556e83bSMatt Jacob #define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_1X160(isp)) 551f556e83bSMatt Jacob #define IS_ULTRA3(isp) (IS_1X160(isp)) 55283fbc566SMatt Jacob 5535d571944SMatt Jacob #define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) 5545d571944SMatt Jacob #define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) 5555d571944SMatt Jacob #define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) 5562903b272SMatt Jacob #define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300) 5572903b272SMatt Jacob #define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) 5582903b272SMatt Jacob #define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) 559e5265237SMatt Jacob #define IS_2322(isp) ((isp)->isp_type == ISP_HA_FC_2322) 560e5265237SMatt Jacob #define IS_24XX(isp) ((isp)->isp_type >= ISP_HA_FC_2400) 56183fbc566SMatt Jacob 56253cff3bbSMatt Jacob /* 5631dae40ebSMatt Jacob * DMA related macros 56453cff3bbSMatt Jacob */ 5651dae40ebSMatt Jacob #define DMA_WD3(x) ((((uint64_t)x) >> 48) & 0xffff) 5661dae40ebSMatt Jacob #define DMA_WD2(x) ((((uint64_t)x) >> 32) & 0xffff) 567126ec864SMatt Jacob #define DMA_WD1(x) (((x) >> 16) & 0xffff) 568126ec864SMatt Jacob #define DMA_WD0(x) (((x) & 0xffff)) 56957c801f5SMatt Jacob 5701dae40ebSMatt Jacob #define DMA_LO32(x) ((uint32_t) (x)) 5711dae40ebSMatt Jacob #define DMA_HI32(x) ((uint32_t)(((uint64_t)x) >> 32)) 5721dae40ebSMatt Jacob 5736054c3f6SMatt Jacob /* 57453cff3bbSMatt Jacob * Core System Function Prototypes 5756054c3f6SMatt Jacob */ 5766054c3f6SMatt Jacob 5776054c3f6SMatt Jacob /* 578478f8a96SJustin T. Gibbs * Reset Hardware. Totally. Assumes that you'll follow this with 579478f8a96SJustin T. Gibbs * a call to isp_init. 5806054c3f6SMatt Jacob */ 5811dae40ebSMatt Jacob void isp_reset(ispsoftc_t *); 5826054c3f6SMatt Jacob 5836054c3f6SMatt Jacob /* 5846054c3f6SMatt Jacob * Initialize Hardware to known state 5856054c3f6SMatt Jacob */ 5861dae40ebSMatt Jacob void isp_init(ispsoftc_t *); 5876054c3f6SMatt Jacob 5886054c3f6SMatt Jacob /* 589478f8a96SJustin T. Gibbs * Reset the ISP and call completion for any orphaned commands. 590478f8a96SJustin T. Gibbs */ 5911dae40ebSMatt Jacob void isp_reinit(ispsoftc_t *); 592478f8a96SJustin T. Gibbs 59301ff579dSMatt Jacob #ifdef ISP_FW_CRASH_DUMP 59401ff579dSMatt Jacob /* 59501ff579dSMatt Jacob * Dump firmware entry point. 59601ff579dSMatt Jacob */ 5971dae40ebSMatt Jacob void isp_fw_dump(ispsoftc_t *isp); 59801ff579dSMatt Jacob #endif 59901ff579dSMatt Jacob 600478f8a96SJustin T. Gibbs /* 601126ec864SMatt Jacob * Internal Interrupt Service Routine 602126ec864SMatt Jacob * 603126ec864SMatt Jacob * The outer layers do the spade work to get the appropriate status register, 604126ec864SMatt Jacob * semaphore register and first mailbox register (if appropriate). This also 605126ec864SMatt Jacob * means that most spurious/bogus interrupts not for us can be filtered first. 6066054c3f6SMatt Jacob */ 6071dae40ebSMatt Jacob void isp_intr(ispsoftc_t *, uint16_t, uint16_t, uint16_t); 608126ec864SMatt Jacob 6096054c3f6SMatt Jacob 6106054c3f6SMatt Jacob /* 61153cff3bbSMatt Jacob * Command Entry Point- Platform Dependent layers call into this 6126054c3f6SMatt Jacob */ 613e2ec5cf0SMatt Jacob int isp_start(XS_T *); 6141dae40ebSMatt Jacob 61553cff3bbSMatt Jacob /* these values are what isp_start returns */ 61653cff3bbSMatt Jacob #define CMD_COMPLETE 101 /* command completed */ 61753cff3bbSMatt Jacob #define CMD_EAGAIN 102 /* busy- maybe retry later */ 61853cff3bbSMatt Jacob #define CMD_QUEUED 103 /* command has been queued for execution */ 61953cff3bbSMatt Jacob #define CMD_RQLATER 104 /* requeue this command later */ 62053cff3bbSMatt Jacob 62153cff3bbSMatt Jacob /* 62253cff3bbSMatt Jacob * Command Completion Point- Core layers call out from this with completed cmds 62353cff3bbSMatt Jacob */ 624e2ec5cf0SMatt Jacob void isp_done(XS_T *); 625478f8a96SJustin T. Gibbs 626478f8a96SJustin T. Gibbs /* 627cbf57b47SMatt Jacob * Platform Dependent to External to Internal Control Function 628478f8a96SJustin T. Gibbs * 629410b5567SMatt Jacob * Assumes locks are held on entry. You should note that with many of 630410b5567SMatt Jacob * these commands and locks may be released while this is occurring. 631478f8a96SJustin T. Gibbs * 632410b5567SMatt Jacob * A few notes about some of these functions: 633410b5567SMatt Jacob * 634410b5567SMatt Jacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link. 635410b5567SMatt Jacob * The argument is a pointer to an integer which is the time, in microseconds, 636410b5567SMatt Jacob * we should wait to see whether we have good link. This test, if successful, 637410b5567SMatt Jacob * lets us know our connection topology and our Loop ID/AL_PA and so on. 638410b5567SMatt Jacob * You can't get anywhere without this. 639410b5567SMatt Jacob * 640410b5567SMatt Jacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for 641410b5567SMatt Jacob * all entities using the FC Generic Services subcommand GET ALL NEXT. 642410b5567SMatt Jacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see 643410b5567SMatt Jacob * below). 644410b5567SMatt Jacob * 645410b5567SMatt Jacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection 646410b5567SMatt Jacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w 647410b5567SMatt Jacob * 'automatically' manages local loop connections, this function essentially 648410b5567SMatt Jacob * notes the arrival, departure, and possible shuffling around of local loop 649410b5567SMatt Jacob * entities. Thus for each arrival and departure this generates an isp_async 650410b5567SMatt Jacob * event of ISPASYNC_PROMENADE (see below). 651410b5567SMatt Jacob * 652410b5567SMatt Jacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in 653410b5567SMatt Jacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. 654410b5567SMatt Jacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging 655410b5567SMatt Jacob * and logging out of fabric devices (if one is on a fabric) and then marking 656410b5567SMatt Jacob * the 'loop state' as being ready to now be used for sending commands to 657410b5567SMatt Jacob * devices. Originally fabric name server and local loop scanning were 658561e7bb9SMatt Jacob * part of this function. It's now been separated to allow for finer control. 659478f8a96SJustin T. Gibbs */ 660478f8a96SJustin T. Gibbs typedef enum { 66177d4e836SMatt Jacob ISPCTL_RESET_BUS, /* Reset Bus */ 66277d4e836SMatt Jacob ISPCTL_RESET_DEV, /* Reset Device */ 66377d4e836SMatt Jacob ISPCTL_ABORT_CMD, /* Abort Command */ 664410b5567SMatt Jacob ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters (SCSI) */ 66541593b25SMatt Jacob ISPCTL_FCLINK_TEST, /* Test FC Link Status */ 666410b5567SMatt Jacob ISPCTL_SCAN_FABRIC, /* (Re)scan Fabric Name Server */ 667410b5567SMatt Jacob ISPCTL_SCAN_LOOP, /* (Re)scan Local Loop */ 66841593b25SMatt Jacob ISPCTL_PDB_SYNC, /* Synchronize Port Database */ 669410b5567SMatt Jacob ISPCTL_SEND_LIP, /* Send a LIP */ 670410b5567SMatt Jacob ISPCTL_GET_POSMAP, /* Get FC-AL position map */ 6714102f2f6SMatt Jacob ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ 672e0d3cfb7SMatt Jacob ISPCTL_TOGGLE_TMODE, /* toggle target mode */ 673e0d3cfb7SMatt Jacob ISPCTL_GET_PDB /* get a single port database entry */ 674478f8a96SJustin T. Gibbs } ispctl_t; 6751dae40ebSMatt Jacob int isp_control(ispsoftc_t *, ispctl_t, void *); 676478f8a96SJustin T. Gibbs 677cbf57b47SMatt Jacob 678cbf57b47SMatt Jacob /* 679cbf57b47SMatt Jacob * Platform Dependent to Internal to External Control Function 680cbf57b47SMatt Jacob * (each platform must provide such a function) 681cbf57b47SMatt Jacob * 682410b5567SMatt Jacob * Assumes locks are held. 683410b5567SMatt Jacob * 684410b5567SMatt Jacob * A few notes about some of these functions: 685410b5567SMatt Jacob * 686410b5567SMatt Jacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has 687410b5567SMatt Jacob * occurred that invalidates the list of fabric devices known and/or 688410b5567SMatt Jacob * the list of known loop devices. The argument passed is a pointer 689410b5567SMatt Jacob * whose values are defined below (local loop change, name server 690410b5567SMatt Jacob * change, other). 'Other' may simply be a LIP, or a change in 691410b5567SMatt Jacob * connection topology. 692410b5567SMatt Jacob * 693410b5567SMatt Jacob * ISPASYNC_FABRIC_DEV announces the next element in a list of 694410b5567SMatt Jacob * fabric device names we're getting out of the name server. The 695410b5567SMatt Jacob * argument points to a GET ALL NEXT response structure. The list 696410b5567SMatt Jacob * is known to terminate with an entry that refers to ourselves. 697410b5567SMatt Jacob * One of the main purposes of this function is to allow outer 698410b5567SMatt Jacob * layers, which are OS dependent, to set policy as to which fabric 699410b5567SMatt Jacob * devices might actually be logged into (and made visible) later 700410b5567SMatt Jacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric 701410b5567SMatt Jacob * devices that we can log into (256 less 3 'reserved' for F-port 702410b5567SMatt Jacob * topologies), and fabrics can grow up to 8 million or so entries 703410b5567SMatt Jacob * (24 bits of Port Address, less a wad of reserved spaces), clearly 704410b5567SMatt Jacob * we had better let the OS determine login policy. 705410b5567SMatt Jacob * 706410b5567SMatt Jacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which 70766cbe912SMatt Jacob * is an index into the portdb in the softc ('target'). Whether that entry's 708410b5567SMatt Jacob * valid tag is set or not says whether something has arrived or departed. 709410b5567SMatt Jacob * The name refers to a favorite pastime of many city dwellers- watching 710410b5567SMatt Jacob * people come and go, talking of Michaelangelo, and so on.. 7114102f2f6SMatt Jacob * 7124102f2f6SMatt Jacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a 7134102f2f6SMatt Jacob * response queue entry not otherwise handled. The outer layer should 7144fd13c1bSMatt Jacob * return non-zero if it handled it. The 'arg' points to an unmassaged 7154fd13c1bSMatt Jacob * response queue entry. 716cbf57b47SMatt Jacob */ 717cbf57b47SMatt Jacob 718cbf57b47SMatt Jacob typedef enum { 719410b5567SMatt Jacob ISPASYNC_NEW_TGT_PARAMS, /* New Target Parameters Negotiated */ 72077d4e836SMatt Jacob ISPASYNC_BUS_RESET, /* Bus Was Reset */ 72177d4e836SMatt Jacob ISPASYNC_LOOP_DOWN, /* FC Loop Down */ 72277d4e836SMatt Jacob ISPASYNC_LOOP_UP, /* FC Loop Up */ 7235d571944SMatt Jacob ISPASYNC_LIP, /* LIP Received */ 7245d571944SMatt Jacob ISPASYNC_LOOP_RESET, /* Loop Reset Received */ 725410b5567SMatt Jacob ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ 726410b5567SMatt Jacob ISPASYNC_FABRIC_DEV, /* FC Fabric Device Arrival */ 727410b5567SMatt Jacob ISPASYNC_PROMENADE, /* FC Objects coming && going */ 728e5265237SMatt Jacob ISPASYNC_TARGET_NOTIFY, /* target asynchronous notification event */ 729e5265237SMatt Jacob ISPASYNC_TARGET_ACTION, /* target action requested */ 7304102f2f6SMatt Jacob ISPASYNC_CONF_CHANGE, /* Platform Configuration Change */ 731b91862efSMatt Jacob ISPASYNC_UNHANDLED_RESPONSE, /* Unhandled Response Entry */ 7320499ae00SMatt Jacob ISPASYNC_FW_CRASH, /* Firmware has crashed */ 733e347e2c9SMatt Jacob ISPASYNC_FW_DUMPED, /* Firmware crashdump taken */ 7340499ae00SMatt Jacob ISPASYNC_FW_RESTARTED /* Firmware has been restarted */ 735cbf57b47SMatt Jacob } ispasync_t; 7361dae40ebSMatt Jacob int isp_async(ispsoftc_t *, ispasync_t, void *); 737cbf57b47SMatt Jacob 738410b5567SMatt Jacob #define ISPASYNC_CHANGE_PDB ((void *) 0) 739410b5567SMatt Jacob #define ISPASYNC_CHANGE_SNS ((void *) 1) 740410b5567SMatt Jacob #define ISPASYNC_CHANGE_OTHER ((void *) 2) 741410b5567SMatt Jacob 742478f8a96SJustin T. Gibbs /* 74353cff3bbSMatt Jacob * Platform Dependent Error and Debug Printout 744547725beSMatt Jacob * 745547725beSMatt Jacob * Generally this is: 746547725beSMatt Jacob * 7471dae40ebSMatt Jacob * void isp_prt(ispsoftc_t *, int level, const char *, ...) 748547725beSMatt Jacob * 749547725beSMatt Jacob * but due to compiler differences on different platforms this won't be 750547725beSMatt Jacob * formally done here. Instead, it goes in each platform definition file. 751478f8a96SJustin T. Gibbs */ 752e9423e21SMatt Jacob 75353cff3bbSMatt Jacob #define ISP_LOGALL 0x0 /* log always */ 75453cff3bbSMatt Jacob #define ISP_LOGCONFIG 0x1 /* log configuration messages */ 75553cff3bbSMatt Jacob #define ISP_LOGINFO 0x2 /* log informational messages */ 75653cff3bbSMatt Jacob #define ISP_LOGWARN 0x4 /* log warning messages */ 75753cff3bbSMatt Jacob #define ISP_LOGERR 0x8 /* log error messages */ 75853cff3bbSMatt Jacob #define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ 75953cff3bbSMatt Jacob #define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ 76053cff3bbSMatt Jacob #define ISP_LOGDEBUG2 0x40 /* log most debug messages */ 761b91862efSMatt Jacob #define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ 762b91862efSMatt Jacob #define ISP_LOGDEBUG4 0x100 /* log high frequency debug messages */ 76353cff3bbSMatt Jacob #define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ 76453cff3bbSMatt Jacob #define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ 76553cff3bbSMatt Jacob #define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ 766478f8a96SJustin T. Gibbs 76753cff3bbSMatt Jacob /* 76853cff3bbSMatt Jacob * Each Platform provides it's own isposinfo substructure of the ispsoftc 76953cff3bbSMatt Jacob * defined above. 77053cff3bbSMatt Jacob * 77153cff3bbSMatt Jacob * Each platform must also provide the following macros/defines: 77253cff3bbSMatt Jacob * 77353cff3bbSMatt Jacob * 77453cff3bbSMatt Jacob * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area 77553cff3bbSMatt Jacob * 77653cff3bbSMatt Jacob * MEMZERO(dst, src) platform zeroing function 77753cff3bbSMatt Jacob * MEMCPY(dst, src, count) platform copying function 77853cff3bbSMatt Jacob * SNPRINTF(buf, bufsize, fmt, ...) snprintf 77953cff3bbSMatt Jacob * USEC_DELAY(usecs) microsecond spindelay function 78067afe757SMatt Jacob * USEC_SLEEP(isp, usecs) microsecond sleep function 78153cff3bbSMatt Jacob * 78253cff3bbSMatt Jacob * NANOTIME_T nanosecond time type 78353cff3bbSMatt Jacob * 78453cff3bbSMatt Jacob * GET_NANOTIME(NANOTIME_T *) get current nanotime. 78553cff3bbSMatt Jacob * 7861dae40ebSMatt Jacob * GET_NANOSEC(NANOTIME_T *) get uint64_t from NANOTIME_T 78753cff3bbSMatt Jacob * 78853cff3bbSMatt Jacob * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) 78953cff3bbSMatt Jacob * subtract two NANOTIME_T values 79053cff3bbSMatt Jacob * 79153cff3bbSMatt Jacob * 7921dae40ebSMatt Jacob * MAXISPREQUEST(ispsoftc_t *) maximum request queue size 79353cff3bbSMatt Jacob * for this particular board type 79453cff3bbSMatt Jacob * 7951dae40ebSMatt Jacob * MEMORYBARRIER(ispsoftc_t *, barrier_type, offset, size) 79653cff3bbSMatt Jacob * 79753cff3bbSMatt Jacob * Function/Macro the provides memory synchronization on 79853cff3bbSMatt Jacob * various objects so that the ISP's and the system's view 79953cff3bbSMatt Jacob * of the same object is consistent. 80053cff3bbSMatt Jacob * 8011dae40ebSMatt Jacob * MBOX_ACQUIRE(ispsoftc_t *) acquire lock on mailbox regs 8021dae40ebSMatt Jacob * MBOX_WAIT_COMPLETE(ispsoftc_t *) wait for mailbox cmd to be done 8031dae40ebSMatt Jacob * MBOX_NOTIFY_COMPLETE(ispsoftc_t *) notification of mbox cmd donee 8041dae40ebSMatt Jacob * MBOX_RELEASE(ispsoftc_t *) release lock on mailbox regs 80553cff3bbSMatt Jacob * 8061dae40ebSMatt Jacob * FC_SCRATCH_ACQUIRE(ispsoftc_t *) acquire lock on FC scratch area 8071dae40ebSMatt Jacob * FC_SCRATCH_RELEASE(ispsoftc_t *) acquire lock on FC scratch area 80853cff3bbSMatt Jacob * 80953cff3bbSMatt Jacob * SCSI_GOOD SCSI 'Good' Status 81053cff3bbSMatt Jacob * SCSI_CHECK SCSI 'Check Condition' Status 81153cff3bbSMatt Jacob * SCSI_BUSY SCSI 'Busy' Status 81253cff3bbSMatt Jacob * SCSI_QFULL SCSI 'Queue Full' Status 81353cff3bbSMatt Jacob * 81453cff3bbSMatt Jacob * XS_T Platform SCSI transaction type (i.e., command for HBA) 8151dae40ebSMatt Jacob * XS_DMA_ADDR_T Platform PCI DMA Address Type 81653cff3bbSMatt Jacob * XS_ISP(xs) gets an instance out of an XS_T 81753cff3bbSMatt Jacob * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" 81853cff3bbSMatt Jacob * XS_TGT(xs) gets the target "" 81953cff3bbSMatt Jacob * XS_LUN(xs) gets the lun "" 82053cff3bbSMatt Jacob * XS_CDBP(xs) gets a pointer to the scsi CDB "" 82153cff3bbSMatt Jacob * XS_CDBLEN(xs) gets the CDB's length "" 82253cff3bbSMatt Jacob * XS_XFRLEN(xs) gets the associated data transfer length "" 82353cff3bbSMatt Jacob * XS_TIME(xs) gets the time (in milliseconds) for this command 82453cff3bbSMatt Jacob * XS_RESID(xs) gets the current residual count 82553cff3bbSMatt Jacob * XS_STSP(xs) gets a pointer to the SCSI status byte "" 82653cff3bbSMatt Jacob * XS_SNSP(xs) gets a pointer to the associate sense data 82753cff3bbSMatt Jacob * XS_SNSLEN(xs) gets the length of sense data storage 82853cff3bbSMatt Jacob * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key 82953cff3bbSMatt Jacob * XS_TAG_P(xs) predicate of whether this command should be tagged 83053cff3bbSMatt Jacob * XS_TAG_TYPE(xs) which type of tag to use 83153cff3bbSMatt Jacob * XS_SETERR(xs) set error state 83253cff3bbSMatt Jacob * 83353cff3bbSMatt Jacob * HBA_NOERROR command has no erros 83453cff3bbSMatt Jacob * HBA_BOTCH hba botched something 83553cff3bbSMatt Jacob * HBA_CMDTIMEOUT command timed out 83653cff3bbSMatt Jacob * HBA_SELTIMEOUT selection timed out (also port logouts for FC) 83753cff3bbSMatt Jacob * HBA_TGTBSY target returned a BUSY status 83853cff3bbSMatt Jacob * HBA_BUSRESET bus reset destroyed command 83953cff3bbSMatt Jacob * HBA_ABORTED command was aborted (by request) 84053cff3bbSMatt Jacob * HBA_DATAOVR a data overrun was detected 84153cff3bbSMatt Jacob * HBA_ARQFAIL Automatic Request Sense failed 84253cff3bbSMatt Jacob * 84353cff3bbSMatt Jacob * XS_ERR(xs) return current error state 84453cff3bbSMatt Jacob * XS_NOERR(xs) there is no error currently set 84553cff3bbSMatt Jacob * XS_INITERR(xs) initialize error state 84653cff3bbSMatt Jacob * 84753cff3bbSMatt Jacob * XS_SAVE_SENSE(xs, sp) save sense data 84853cff3bbSMatt Jacob * 84953cff3bbSMatt Jacob * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of 85053cff3bbSMatt Jacob * response queue entry status bits 85153cff3bbSMatt Jacob * 85253cff3bbSMatt Jacob * 8531dae40ebSMatt Jacob * DEFAULT_IID(ispsoftc_t *) Default SCSI initiator ID 8541dae40ebSMatt Jacob * DEFAULT_LOOPID(ispsoftc_t *) Default FC Loop ID 8551dae40ebSMatt Jacob * DEFAULT_NODEWWN(ispsoftc_t *) Default Node WWN 8561dae40ebSMatt Jacob * DEFAULT_PORTWWN(ispsoftc_t *) Default Port WWN 8571dae40ebSMatt Jacob * DEFAULT_FRAMESIZE(ispsoftc_t *) Default Frame Size 8581dae40ebSMatt Jacob * DEFAULT_EXEC_THROTTLE(ispsoftc_t *) Default Execution Throttle 8599cf43b97SMatt Jacob * These establish reasonable defaults for each platform. 8609cf43b97SMatt Jacob * These must be available independent of card NVRAM and are 8619cf43b97SMatt Jacob * to be used should NVRAM not be readable. 86253cff3bbSMatt Jacob * 8631dae40ebSMatt Jacob * ISP_NODEWWN(ispsoftc_t *) FC Node WWN to use 8641dae40ebSMatt Jacob * ISP_PORTWWN(ispsoftc_t *) FC Port WWN to use 86553cff3bbSMatt Jacob * 8669cf43b97SMatt Jacob * These are to be used after NVRAM is read. The tags 8679cf43b97SMatt Jacob * in fcparam.isp_{node,port}wwn reflect the values 8689cf43b97SMatt Jacob * read from NVRAM (possibly corrected for card botches). 8699cf43b97SMatt Jacob * Each platform can take that information and override 8709cf43b97SMatt Jacob * it or ignore and return the Node and Port WWNs to be 8719cf43b97SMatt Jacob * used when sending the Qlogic f/w the Initialization Control 8729cf43b97SMatt Jacob * Block. 87353cff3bbSMatt Jacob * 87453cff3bbSMatt Jacob * (XXX these do endian specific transformations- in transition XXX) 8754fd13c1bSMatt Jacob * 8761dae40ebSMatt Jacob * ISP_IOXPUT_8(ispsoftc_t *, uint8_t srcval, uint8_t *dstptr) 8771dae40ebSMatt Jacob * ISP_IOXPUT_16(ispsoftc_t *, uint16_t srcval, uint16_t *dstptr) 8781dae40ebSMatt Jacob * ISP_IOXPUT_32(ispsoftc_t *, uint32_t srcval, uint32_t *dstptr) 8794fd13c1bSMatt Jacob * 8801dae40ebSMatt Jacob * ISP_IOXGET_8(ispsoftc_t *, uint8_t *srcptr, uint8_t dstrval) 8811dae40ebSMatt Jacob * ISP_IOXGET_16(ispsoftc_t *, uint16_t *srcptr, uint16_t dstrval) 8821dae40ebSMatt Jacob * ISP_IOXGET_32(ispsoftc_t *, uint32_t *srcptr, uint32_t dstrval) 8834fd13c1bSMatt Jacob * 8841dae40ebSMatt Jacob * ISP_SWIZZLE_NVRAM_WORD(ispsoftc_t *, uint16_t *) 88553cff3bbSMatt Jacob */ 8865d571944SMatt Jacob 8876054c3f6SMatt Jacob #endif /* _ISPVAR_H */ 888