15678Spl196000 /* 2*12408SZhongyan.Gu@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 35678Spl196000 */ 45678Spl196000 55678Spl196000 /* 65678Spl196000 * Copyright 2005-06 Adaptec, Inc. 75678Spl196000 * Copyright (c) 2005-06 Adaptec Inc., Achim Leubner 85678Spl196000 * Copyright (c) 2000 Michael Smith 95678Spl196000 * Copyright (c) 2001 Scott Long 105678Spl196000 * Copyright (c) 2000 BSDi 115678Spl196000 * All rights reserved. 125678Spl196000 * 135678Spl196000 * Redistribution and use in source and binary forms, with or without 145678Spl196000 * modification, are permitted provided that the following conditions 155678Spl196000 * are met: 165678Spl196000 * 1. Redistributions of source code must retain the above copyright 175678Spl196000 * notice, this list of conditions and the following disclaimer. 185678Spl196000 * 2. Redistributions in binary form must reproduce the above copyright 195678Spl196000 * notice, this list of conditions and the following disclaimer in the 205678Spl196000 * documentation and/or other materials provided with the distribution. 215678Spl196000 * 225678Spl196000 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 235678Spl196000 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 245678Spl196000 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 255678Spl196000 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 265678Spl196000 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 275678Spl196000 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 285678Spl196000 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 295678Spl196000 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 305678Spl196000 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 315678Spl196000 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 325678Spl196000 * SUCH DAMAGE. 335678Spl196000 * 345678Spl196000 * $FreeBSD: src/sys/dev/aac/aacvar.h,v 1.47 2005/10/08 15:55:09 scottl Exp $ 355678Spl196000 */ 365678Spl196000 375678Spl196000 #ifndef _AAC_H_ 385678Spl196000 #define _AAC_H_ 395678Spl196000 405678Spl196000 #ifdef __cplusplus 415678Spl196000 extern "C" { 425678Spl196000 #endif 435678Spl196000 445678Spl196000 #define AAC_ROUNDUP(x, y) (((x) + (y) - 1) / (y) * (y)) 455678Spl196000 465678Spl196000 #define AAC_TYPE_DEVO 1 475678Spl196000 #define AAC_TYPE_ALPHA 2 485678Spl196000 #define AAC_TYPE_BETA 3 495678Spl196000 #define AAC_TYPE_RELEASE 4 505678Spl196000 515678Spl196000 #ifndef AAC_DRIVER_BUILD 525678Spl196000 #define AAC_DRIVER_BUILD 1 535678Spl196000 #endif 545678Spl196000 555678Spl196000 #define AAC_DRIVER_MAJOR_VERSION 2 565678Spl196000 #define AAC_DRIVER_MINOR_VERSION 2 57*12408SZhongyan.Gu@Sun.COM #define AAC_DRIVER_BUGFIX_LEVEL 11 585678Spl196000 #define AAC_DRIVER_TYPE AAC_TYPE_RELEASE 595678Spl196000 605678Spl196000 #define STR(s) # s 615678Spl196000 #define AAC_VERSION(a, b, c) STR(a.b.c) 625678Spl196000 #define AAC_DRIVER_VERSION AAC_VERSION(AAC_DRIVER_MAJOR_VERSION, \ 635678Spl196000 AAC_DRIVER_MINOR_VERSION, \ 645678Spl196000 AAC_DRIVER_BUGFIX_LEVEL) 655678Spl196000 665678Spl196000 #define AACOK 0 675678Spl196000 #define AACERR -1 685678Spl196000 695678Spl196000 #define AAC_MAX_ADAPTERS 64 705678Spl196000 715678Spl196000 /* Definitions for mode sense */ 725678Spl196000 #ifndef SD_MODE_SENSE_PAGE3_CODE 735678Spl196000 #define SD_MODE_SENSE_PAGE3_CODE 0x03 745678Spl196000 #endif 755678Spl196000 765678Spl196000 #ifndef SD_MODE_SENSE_PAGE4_CODE 775678Spl196000 #define SD_MODE_SENSE_PAGE4_CODE 0x04 785678Spl196000 #endif 795678Spl196000 805678Spl196000 #ifndef SCMD_SYNCHRONIZE_CACHE 815678Spl196000 #define SCMD_SYNCHRONIZE_CACHE 0x35 825678Spl196000 #endif 835678Spl196000 845678Spl196000 /* 855678Spl196000 * The controller reports status events in AIFs. We hang on to a number of 865678Spl196000 * these in order to pass them out to user-space management tools. 875678Spl196000 */ 885678Spl196000 #define AAC_AIFQ_LENGTH 64 895678Spl196000 905678Spl196000 #ifdef __x86 915678Spl196000 #define AAC_IMMEDIATE_TIMEOUT 30 /* seconds */ 925678Spl196000 #else 935678Spl196000 #define AAC_IMMEDIATE_TIMEOUT 60 /* seconds */ 945678Spl196000 #endif 955678Spl196000 #define AAC_FWUP_TIMEOUT 180 /* wait up to 3 minutes */ 967567SXin.Chen@Sun.COM #define AAC_IOCTL_TIMEOUT 900 /* wait up to 15 minutes */ 9711348SZhongyan.Gu@Sun.COM #define AAC_SYNC_TIMEOUT 900 /* wait up to 15 minutes */ 985678Spl196000 995678Spl196000 /* Adapter hardware interface types */ 1005678Spl196000 #define AAC_HWIF_UNKNOWN 0 1015678Spl196000 #define AAC_HWIF_I960RX 1 1025678Spl196000 #define AAC_HWIF_RKT 2 1035678Spl196000 1045678Spl196000 #define AAC_TYPE_UNKNOWN 0 1055678Spl196000 #define AAC_TYPE_SCSI 1 1065678Spl196000 #define AAC_TYPE_SATA 2 1075678Spl196000 #define AAC_TYPE_SAS 3 1085678Spl196000 1095678Spl196000 #define AAC_LS32(d) ((uint32_t)((d) & 0xffffffffull)) 1105678Spl196000 #define AAC_MS32(d) ((uint32_t)((d) >> 32)) 1115678Spl196000 #define AAC_LO32(p64) ((uint32_t *)(p64)) 1125678Spl196000 #define AAC_HI32(p64) ((uint32_t *)(p64) + 1) 1135678Spl196000 1145678Spl196000 /* 11511964SXin.Chen@Sun.COM * Internal events that will be handled serially by aac_event_thread() 11611964SXin.Chen@Sun.COM */ 11711964SXin.Chen@Sun.COM #define AAC_EVENT_AIF (1 << 0) 11811964SXin.Chen@Sun.COM #define AAC_EVENT_TIMEOUT (1 << 1) 11911964SXin.Chen@Sun.COM #define AAC_EVENT_SYNCTICK (1 << 2) 12011964SXin.Chen@Sun.COM 12111964SXin.Chen@Sun.COM /* 1225678Spl196000 * AAC_CMDQ_SYNC should be 0 and AAC_CMDQ_ASYNC be 1 for Sync FIB io 1235678Spl196000 * to be served before async FIB io, see aac_start_waiting_io(). 1245678Spl196000 * So that io requests sent by interactive userland commands get 1255678Spl196000 * responded asap. 1265678Spl196000 */ 1275678Spl196000 enum aac_cmdq { 1285678Spl196000 AAC_CMDQ_SYNC, /* sync FIB queue */ 1295678Spl196000 AAC_CMDQ_ASYNC, /* async FIB queue */ 1305678Spl196000 AAC_CMDQ_NUM 1315678Spl196000 }; 1325678Spl196000 1335678Spl196000 /* 1345678Spl196000 * IO command flags 1355678Spl196000 */ 1365678Spl196000 #define AAC_IOCMD_SYNC (1 << AAC_CMDQ_SYNC) 1375678Spl196000 #define AAC_IOCMD_ASYNC (1 << AAC_CMDQ_ASYNC) 1385678Spl196000 #define AAC_IOCMD_OUTSTANDING (1 << AAC_CMDQ_NUM) 1395678Spl196000 #define AAC_IOCMD_ALL (AAC_IOCMD_SYNC | AAC_IOCMD_ASYNC | \ 1405678Spl196000 AAC_IOCMD_OUTSTANDING) 1415678Spl196000 1425678Spl196000 struct aac_cmd_queue { 1435678Spl196000 struct aac_cmd *q_head; /* also as the header of aac_cmd */ 1445678Spl196000 struct aac_cmd *q_tail; 1455678Spl196000 }; 1465678Spl196000 1475678Spl196000 struct aac_card_type { 1485678Spl196000 uint16_t vendor; /* PCI Vendor ID */ 1495678Spl196000 uint16_t device; /* PCI Device ID */ 1505678Spl196000 uint16_t subvendor; /* PCI Subsystem Vendor ID */ 1515678Spl196000 uint16_t subsys; /* PCI Subsystem ID */ 1525678Spl196000 uint16_t hwif; /* card chip type: i960 or Rocket */ 1535678Spl196000 uint16_t quirks; /* card odd limits */ 1545678Spl196000 uint16_t type; /* hard drive type */ 1555678Spl196000 char *vid; /* ASCII data for INQUIRY command vendor id */ 1565678Spl196000 char *desc; /* ASCII data for INQUIRY command product id */ 1575678Spl196000 }; 1585678Spl196000 1597567SXin.Chen@Sun.COM /* Device types */ 1607567SXin.Chen@Sun.COM #define AAC_DEV_LD 0 /* logical device */ 1617567SXin.Chen@Sun.COM #define AAC_DEV_PD 1 /* physical device */ 1627567SXin.Chen@Sun.COM 1637567SXin.Chen@Sun.COM /* Device flags */ 1647567SXin.Chen@Sun.COM #define AAC_DFLAG_VALID (1 << 0) 1657567SXin.Chen@Sun.COM #define AAC_DFLAG_CONFIGURING (1 << 1) 1667567SXin.Chen@Sun.COM 1677567SXin.Chen@Sun.COM #define AAC_DEV_IS_VALID(dvp) ((dvp)->flags & AAC_DFLAG_VALID) 168*12408SZhongyan.Gu@Sun.COM #define AAC_P2VTGT(softs, bus, tgt) \ 169*12408SZhongyan.Gu@Sun.COM ((softs)->tgt_max * (bus) + (tgt) + AAC_MAX_LD) 1707567SXin.Chen@Sun.COM 17111964SXin.Chen@Sun.COM /* 17211964SXin.Chen@Sun.COM * Device config change events 17311964SXin.Chen@Sun.COM */ 17411964SXin.Chen@Sun.COM enum aac_cfg_event { 17511964SXin.Chen@Sun.COM AAC_CFG_NULL_NOEXIST = 0, /* No change with no device */ 17611964SXin.Chen@Sun.COM AAC_CFG_NULL_EXIST, /* No change but have device */ 17711964SXin.Chen@Sun.COM AAC_CFG_ADD, /* Device added */ 17811964SXin.Chen@Sun.COM AAC_CFG_DELETE, /* Device deleted */ 17911964SXin.Chen@Sun.COM AAC_CFG_CHANGE /* Device changed */ 18011964SXin.Chen@Sun.COM }; 18111964SXin.Chen@Sun.COM 1827567SXin.Chen@Sun.COM struct aac_device { 1837567SXin.Chen@Sun.COM int flags; 1847567SXin.Chen@Sun.COM 1857567SXin.Chen@Sun.COM uint8_t type; 1867567SXin.Chen@Sun.COM dev_info_t *dip; 1877567SXin.Chen@Sun.COM int ncmds[AAC_CMDQ_NUM]; /* outstanding cmds of the device */ 1887567SXin.Chen@Sun.COM int throttle[AAC_CMDQ_NUM]; /* hold IO cmds for the device */ 1897567SXin.Chen@Sun.COM }; 1907567SXin.Chen@Sun.COM 1915678Spl196000 /* Array description */ 1925678Spl196000 struct aac_container { 1937567SXin.Chen@Sun.COM struct aac_device dev; 1947567SXin.Chen@Sun.COM 1955678Spl196000 uint32_t cid; /* container id */ 1965678Spl196000 uint32_t uid; /* container uid */ 1975678Spl196000 uint64_t size; /* in block */ 1985678Spl196000 uint8_t locked; 1995678Spl196000 uint8_t deleted; 2007567SXin.Chen@Sun.COM uint8_t reset; /* container is being reseted */ 2017567SXin.Chen@Sun.COM }; 2027567SXin.Chen@Sun.COM 2037567SXin.Chen@Sun.COM /* Non-DASD phys. device descrption, eg. CDROM or tape */ 2047567SXin.Chen@Sun.COM struct aac_nondasd { 2057567SXin.Chen@Sun.COM struct aac_device dev; 2067567SXin.Chen@Sun.COM 2077567SXin.Chen@Sun.COM uint32_t bus; 2087567SXin.Chen@Sun.COM uint32_t tid; 2095678Spl196000 }; 2105678Spl196000 2115678Spl196000 /* 2125678Spl196000 * The firmware can support a lot of outstanding commands. Each aac_slot 2135678Spl196000 * is corresponding to one of such commands. It records the command and 2145678Spl196000 * associated DMA resource for FIB command. 2155678Spl196000 */ 2165678Spl196000 struct aac_slot { 2175678Spl196000 struct aac_slot *next; /* next slot in the free slot list */ 2185678Spl196000 int index; /* index of this slot */ 2195678Spl196000 ddi_acc_handle_t fib_acc_handle; 2205678Spl196000 ddi_dma_handle_t fib_dma_handle; 2215678Spl196000 uint64_t fib_phyaddr; /* physical address of FIB memory */ 2225678Spl196000 struct aac_cmd *acp; /* command using this slot */ 2235678Spl196000 struct aac_fib *fibp; /* virtual address of FIB memory */ 2245678Spl196000 }; 2255678Spl196000 22611348SZhongyan.Gu@Sun.COM /* 22711348SZhongyan.Gu@Sun.COM * Scatter-gather list structure defined by HBA hardware 22811348SZhongyan.Gu@Sun.COM */ 22911348SZhongyan.Gu@Sun.COM struct aac_sge { 23011348SZhongyan.Gu@Sun.COM uint32_t bcount; /* byte count */ 23111348SZhongyan.Gu@Sun.COM union { 23211348SZhongyan.Gu@Sun.COM uint32_t ad32; /* 32 bit address */ 23311348SZhongyan.Gu@Sun.COM struct { 23411348SZhongyan.Gu@Sun.COM uint32_t lo; 23511348SZhongyan.Gu@Sun.COM uint32_t hi; 23611348SZhongyan.Gu@Sun.COM } ad64; /* 64 bit address */ 23711348SZhongyan.Gu@Sun.COM } addr; 23811348SZhongyan.Gu@Sun.COM }; 23911348SZhongyan.Gu@Sun.COM 24011348SZhongyan.Gu@Sun.COM /* aac_cmd flags */ 24111348SZhongyan.Gu@Sun.COM #define AAC_CMD_CONSISTENT (1 << 0) 24211348SZhongyan.Gu@Sun.COM #define AAC_CMD_DMA_PARTIAL (1 << 1) 24311348SZhongyan.Gu@Sun.COM #define AAC_CMD_DMA_VALID (1 << 2) 24411348SZhongyan.Gu@Sun.COM #define AAC_CMD_BUF_READ (1 << 3) 24511348SZhongyan.Gu@Sun.COM #define AAC_CMD_BUF_WRITE (1 << 4) 24611348SZhongyan.Gu@Sun.COM #define AAC_CMD_SYNC (1 << 5) /* use sync FIB */ 24711348SZhongyan.Gu@Sun.COM #define AAC_CMD_NO_INTR (1 << 6) /* poll IO, no intr */ 24811348SZhongyan.Gu@Sun.COM #define AAC_CMD_NO_CB (1 << 7) /* sync IO, no callback */ 24911348SZhongyan.Gu@Sun.COM #define AAC_CMD_NTAG (1 << 8) 25011348SZhongyan.Gu@Sun.COM #define AAC_CMD_CMPLT (1 << 9) /* cmd exec'ed by driver/fw */ 25111348SZhongyan.Gu@Sun.COM #define AAC_CMD_ABORT (1 << 10) 25211348SZhongyan.Gu@Sun.COM #define AAC_CMD_TIMEOUT (1 << 11) 25311348SZhongyan.Gu@Sun.COM #define AAC_CMD_ERR (1 << 12) 25411348SZhongyan.Gu@Sun.COM #define AAC_CMD_IN_SYNC_SLOT (1 << 13) 25511348SZhongyan.Gu@Sun.COM 25611348SZhongyan.Gu@Sun.COM struct aac_softstate; 25711348SZhongyan.Gu@Sun.COM typedef void (*aac_cmd_fib_t)(struct aac_softstate *, struct aac_cmd *); 25811348SZhongyan.Gu@Sun.COM 25911348SZhongyan.Gu@Sun.COM struct aac_cmd { 26011348SZhongyan.Gu@Sun.COM /* 26111348SZhongyan.Gu@Sun.COM * Note: should be the first member for aac_cmd_queue to work 26211348SZhongyan.Gu@Sun.COM * correctly. 26311348SZhongyan.Gu@Sun.COM */ 26411348SZhongyan.Gu@Sun.COM struct aac_cmd *next; 26511348SZhongyan.Gu@Sun.COM struct aac_cmd *prev; 26611348SZhongyan.Gu@Sun.COM 26711348SZhongyan.Gu@Sun.COM struct scsi_pkt *pkt; 26811348SZhongyan.Gu@Sun.COM int cmdlen; 26911348SZhongyan.Gu@Sun.COM int flags; 27011348SZhongyan.Gu@Sun.COM uint32_t timeout; /* time when the cmd should have completed */ 27111348SZhongyan.Gu@Sun.COM struct buf *bp; 27211348SZhongyan.Gu@Sun.COM ddi_dma_handle_t buf_dma_handle; 27311348SZhongyan.Gu@Sun.COM 27411348SZhongyan.Gu@Sun.COM /* For non-aligned buffer and SRB */ 27511348SZhongyan.Gu@Sun.COM caddr_t abp; 27611348SZhongyan.Gu@Sun.COM ddi_acc_handle_t abh; 27711348SZhongyan.Gu@Sun.COM 27811348SZhongyan.Gu@Sun.COM /* Data transfer state */ 27911348SZhongyan.Gu@Sun.COM ddi_dma_cookie_t cookie; 28011348SZhongyan.Gu@Sun.COM uint_t left_cookien; 28111348SZhongyan.Gu@Sun.COM uint_t cur_win; 28211348SZhongyan.Gu@Sun.COM uint_t total_nwin; 28311348SZhongyan.Gu@Sun.COM size_t total_xfer; 28411348SZhongyan.Gu@Sun.COM uint64_t blkno; 28511348SZhongyan.Gu@Sun.COM uint32_t bcount; /* buffer size in byte */ 28611348SZhongyan.Gu@Sun.COM struct aac_sge *sgt; /* sg table */ 28711348SZhongyan.Gu@Sun.COM 28811348SZhongyan.Gu@Sun.COM /* FIB construct function */ 28911348SZhongyan.Gu@Sun.COM aac_cmd_fib_t aac_cmd_fib; 29011348SZhongyan.Gu@Sun.COM /* Call back function for completed command */ 29111348SZhongyan.Gu@Sun.COM void (*ac_comp)(struct aac_softstate *, struct aac_cmd *); 29211348SZhongyan.Gu@Sun.COM 29311348SZhongyan.Gu@Sun.COM struct aac_slot *slotp; /* slot used by this command */ 29411348SZhongyan.Gu@Sun.COM struct aac_device *dvp; /* target device */ 29511348SZhongyan.Gu@Sun.COM 29611348SZhongyan.Gu@Sun.COM /* FIB for this IO command */ 29711348SZhongyan.Gu@Sun.COM int fib_size; /* size of the FIB xferred to/from the card */ 29811348SZhongyan.Gu@Sun.COM struct aac_fib *fibp; 29911348SZhongyan.Gu@Sun.COM 30011348SZhongyan.Gu@Sun.COM #ifdef DEBUG 30111348SZhongyan.Gu@Sun.COM uint32_t fib_flags; 30211348SZhongyan.Gu@Sun.COM #endif 30311348SZhongyan.Gu@Sun.COM }; 30411348SZhongyan.Gu@Sun.COM 3055678Spl196000 /* Flags for attach tracking */ 3065678Spl196000 #define AAC_ATTACH_SOFTSTATE_ALLOCED (1 << 0) 3075678Spl196000 #define AAC_ATTACH_CARD_DETECTED (1 << 1) 3085678Spl196000 #define AAC_ATTACH_PCI_MEM_MAPPED (1 << 2) 3095678Spl196000 #define AAC_ATTACH_KMUTEX_INITED (1 << 3) 31011348SZhongyan.Gu@Sun.COM #define AAC_ATTACH_SCSI_TRAN_SETUP (1 << 4) 31111348SZhongyan.Gu@Sun.COM #define AAC_ATTACH_COMM_SPACE_SETUP (1 << 5) 31211348SZhongyan.Gu@Sun.COM #define AAC_ATTACH_CREATE_DEVCTL (1 << 6) 31311348SZhongyan.Gu@Sun.COM #define AAC_ATTACH_CREATE_SCSI (1 << 7) 3145678Spl196000 3155678Spl196000 /* Driver running states */ 3165678Spl196000 #define AAC_STATE_STOPPED 0 3175678Spl196000 #define AAC_STATE_RUN (1 << 0) 3185678Spl196000 #define AAC_STATE_RESET (1 << 1) 3195678Spl196000 #define AAC_STATE_QUIESCED (1 << 2) 3205678Spl196000 #define AAC_STATE_DEAD (1 << 3) 32111636SXin.Chen@Sun.COM #define AAC_STATE_INTR (1 << 4) 3225678Spl196000 3235678Spl196000 /* 3245678Spl196000 * Flags for aac firmware 3255678Spl196000 * Note: Quirks are only valid for the older cards. These cards only supported 3265678Spl196000 * old comm. Thus they are not valid for any cards that support new comm. 3275678Spl196000 */ 3285678Spl196000 #define AAC_FLAGS_SG_64BIT (1 << 0) /* Use 64-bit S/G addresses */ 3295678Spl196000 #define AAC_FLAGS_4GB_WINDOW (1 << 1) /* Can access host mem 2-4GB range */ 3305678Spl196000 #define AAC_FLAGS_NO4GB (1 << 2) /* quirk: FIB addresses must reside */ 3315678Spl196000 /* between 0x2000 & 0x7FFFFFFF */ 3325678Spl196000 #define AAC_FLAGS_256FIBS (1 << 3) /* quirk: Can only do 256 commands */ 3335678Spl196000 #define AAC_FLAGS_NEW_COMM (1 << 4) /* New comm. interface supported */ 3345678Spl196000 #define AAC_FLAGS_RAW_IO (1 << 5) /* Raw I/O interface */ 3355678Spl196000 #define AAC_FLAGS_ARRAY_64BIT (1 << 6) /* 64-bit array size */ 3365678Spl196000 #define AAC_FLAGS_LBA_64BIT (1 << 7) /* 64-bit LBA supported */ 3375678Spl196000 #define AAC_FLAGS_17SG (1 << 8) /* quirk: 17 scatter gather maximum */ 3385678Spl196000 #define AAC_FLAGS_34SG (1 << 9) /* quirk: 34 scatter gather maximum */ 3397567SXin.Chen@Sun.COM #define AAC_FLAGS_NONDASD (1 << 10) /* non-DASD device supported */ 3408551SPeng.L@Sun.COM #define AAC_FLAGS_BRKUP (1 << 11) /* pkt breakup support */ 341*12408SZhongyan.Gu@Sun.COM #define AAC_FLAGS_JBOD (1 << 12) /* JBOD mode support */ 3425678Spl196000 3435678Spl196000 struct aac_softstate; 3445678Spl196000 struct aac_interface { 3455678Spl196000 int (*aif_get_fwstatus)(struct aac_softstate *); 3465678Spl196000 int (*aif_get_mailbox)(struct aac_softstate *, int); 3475678Spl196000 void (*aif_set_mailbox)(struct aac_softstate *, uint32_t, 3485678Spl196000 uint32_t, uint32_t, uint32_t, uint32_t); 3495678Spl196000 }; 3505678Spl196000 35111964SXin.Chen@Sun.COM #define AAC_CTXFLAG_FILLED 0x01 /* aifq's full for this ctx */ 35211964SXin.Chen@Sun.COM #define AAC_CTXFLAG_RESETED 0x02 35311964SXin.Chen@Sun.COM 3545678Spl196000 struct aac_fib_context { 3555678Spl196000 uint32_t unique; 3565678Spl196000 int ctx_idx; 3575678Spl196000 int ctx_filled; /* aifq is full for this fib context */ 35811964SXin.Chen@Sun.COM int ctx_flags; 35911964SXin.Chen@Sun.COM int ctx_overrun; 3605678Spl196000 struct aac_fib_context *next, *prev; 3615678Spl196000 }; 3625678Spl196000 3635678Spl196000 #define AAC_VENDOR_LEN 8 3645678Spl196000 #define AAC_PRODUCT_LEN 16 3655678Spl196000 3665678Spl196000 struct aac_softstate { 3675678Spl196000 int card; /* index to aac_cards */ 3685678Spl196000 uint16_t hwif; /* card chip type: i960 or Rocket */ 3695678Spl196000 uint16_t vendid; /* vendor id */ 3705678Spl196000 uint16_t subvendid; /* sub vendor id */ 3715678Spl196000 uint16_t devid; /* device id */ 3725678Spl196000 uint16_t subsysid; /* sub system id */ 3735678Spl196000 char vendor_name[AAC_VENDOR_LEN + 1]; 3745678Spl196000 char product_name[AAC_PRODUCT_LEN + 1]; 3755678Spl196000 uint32_t support_opt; /* firmware features */ 37610976SZhongyan.Gu@Sun.COM uint32_t support_opt2; 37710976SZhongyan.Gu@Sun.COM uint32_t feature_bits; 3785678Spl196000 uint32_t atu_size; /* actual size of PCI mem space */ 3795678Spl196000 uint32_t map_size; /* mapped PCI mem space size */ 3805678Spl196000 uint32_t map_size_min; /* minimum size of PCI mem that must be */ 3815678Spl196000 /* mapped to address the card */ 3825678Spl196000 int flags; /* firmware features enabled */ 3835678Spl196000 int instance; 3845678Spl196000 dev_info_t *devinfo_p; 3857567SXin.Chen@Sun.COM scsi_hba_tran_t *hba_tran; 3865678Spl196000 int slen; 3877567SXin.Chen@Sun.COM int legacy; /* legacy device naming */ 3888551SPeng.L@Sun.COM uint32_t dma_max; /* for buf breakup */ 3895678Spl196000 3905678Spl196000 /* DMA attributes */ 3915678Spl196000 ddi_dma_attr_t buf_dma_attr; 3925678Spl196000 ddi_dma_attr_t addr_dma_attr; 3935678Spl196000 3945678Spl196000 /* PCI spaces */ 3957567SXin.Chen@Sun.COM ddi_device_acc_attr_t acc_attr; 39611236SStephen.Hanson@Sun.COM ddi_device_acc_attr_t reg_attr; 3975678Spl196000 ddi_acc_handle_t pci_mem_handle; 3987100Spl196000 uint8_t *pci_mem_base_vaddr; 3995678Spl196000 uint32_t pci_mem_base_paddr; 4005678Spl196000 4015678Spl196000 struct aac_interface aac_if; /* adapter hardware interface */ 4025678Spl196000 40311348SZhongyan.Gu@Sun.COM struct aac_cmd sync_ac; /* sync FIB */ 4045678Spl196000 4055678Spl196000 /* Communication space */ 4065678Spl196000 struct aac_comm_space *comm_space; 4075678Spl196000 ddi_acc_handle_t comm_space_acc_handle; 4085678Spl196000 ddi_dma_handle_t comm_space_dma_handle; 4095678Spl196000 uint32_t comm_space_phyaddr; 4105678Spl196000 4115678Spl196000 /* Old Comm. interface: message queues */ 4125678Spl196000 struct aac_queue_table *qtablep; 4135678Spl196000 struct aac_queue_entry *qentries[AAC_QUEUE_COUNT]; 4145678Spl196000 4155678Spl196000 /* New Comm. interface */ 4165678Spl196000 uint32_t aac_max_fibs; /* max. FIB count */ 4175678Spl196000 uint32_t aac_max_fib_size; /* max. FIB size */ 4185678Spl196000 uint32_t aac_sg_tablesize; /* max. sg count from host */ 4195678Spl196000 uint32_t aac_max_sectors; /* max. I/O size from host (blocks) */ 4205678Spl196000 4215678Spl196000 aac_cmd_fib_t aac_cmd_fib; /* IO cmd FIB construct function */ 4225678Spl196000 aac_cmd_fib_t aac_cmd_fib_scsi; /* SRB construct function */ 4235678Spl196000 4245678Spl196000 ddi_softintr_t softint_id; /* soft intr */ 4255678Spl196000 4265678Spl196000 kmutex_t io_lock; 4275678Spl196000 int state; /* driver state */ 4285678Spl196000 4295678Spl196000 struct aac_container containers[AAC_MAX_LD]; 4305678Spl196000 int container_count; /* max container id + 1 */ 4317567SXin.Chen@Sun.COM struct aac_nondasd *nondasds; 4327567SXin.Chen@Sun.COM uint32_t bus_max; /* max FW buses exposed */ 4337567SXin.Chen@Sun.COM uint32_t tgt_max; /* max FW target per bus */ 4345678Spl196000 4355678Spl196000 /* 4365678Spl196000 * Command queues 4375678Spl196000 * Each aac command flows through wait(or wait_sync) queue, 4385678Spl196000 * busy queue, and complete queue sequentially. 4395678Spl196000 */ 4405678Spl196000 struct aac_cmd_queue q_wait[AAC_CMDQ_NUM]; 4415678Spl196000 struct aac_cmd_queue q_busy; /* outstanding cmd queue */ 4425678Spl196000 kmutex_t q_comp_mutex; 4435678Spl196000 struct aac_cmd_queue q_comp; /* completed io requests */ 4445678Spl196000 4455678Spl196000 /* I/O slots and FIBs */ 4465678Spl196000 int total_slots; /* total slots allocated */ 4475678Spl196000 int total_fibs; /* total FIBs allocated */ 4485678Spl196000 struct aac_slot *io_slot; /* static list for allocated slots */ 4495678Spl196000 struct aac_slot *free_io_slot_head; 4505678Spl196000 4515678Spl196000 kcondvar_t event; /* for ioctl_send_fib() and sync IO */ 45211636SXin.Chen@Sun.COM kcondvar_t sync_fib_cv; /* for sync_fib_slot_bind/release */ 4535678Spl196000 4545678Spl196000 int bus_ncmds[AAC_CMDQ_NUM]; /* total outstanding async cmds */ 4555678Spl196000 int bus_throttle[AAC_CMDQ_NUM]; /* hold IO cmds for the bus */ 4565678Spl196000 int ndrains; /* number of draining threads */ 4575678Spl196000 timeout_id_t drain_timeid; /* for outstanding cmd drain */ 4585678Spl196000 kcondvar_t drain_cv; /* for quiesce drain */ 4595678Spl196000 46011964SXin.Chen@Sun.COM /* Internal timer */ 46111964SXin.Chen@Sun.COM kmutex_t time_mutex; 46211964SXin.Chen@Sun.COM timeout_id_t timeout_id; /* for timeout daemon */ 46311964SXin.Chen@Sun.COM uint32_t timebase; /* internal timer in seconds */ 46411964SXin.Chen@Sun.COM uint32_t time_sync; /* next time to sync with firmware */ 46511964SXin.Chen@Sun.COM uint32_t time_out; /* next time to check timeout */ 46611964SXin.Chen@Sun.COM uint32_t time_throttle; /* next time to restore throttle */ 46711964SXin.Chen@Sun.COM 46811964SXin.Chen@Sun.COM /* Internal events handling */ 46911964SXin.Chen@Sun.COM kmutex_t ev_lock; 47011964SXin.Chen@Sun.COM int events; 47111964SXin.Chen@Sun.COM kthread_t *event_thread; /* for AIF & timeout */ 47211964SXin.Chen@Sun.COM kcondvar_t event_wait_cv; 47311964SXin.Chen@Sun.COM kcondvar_t event_disp_cv; 47411964SXin.Chen@Sun.COM 4755678Spl196000 /* AIF */ 4765678Spl196000 kmutex_t aifq_mutex; /* for AIF queue aifq */ 47711964SXin.Chen@Sun.COM kcondvar_t aifq_cv; 4785678Spl196000 union aac_fib_align aifq[AAC_AIFQ_LENGTH]; 4795678Spl196000 int aifq_idx; /* slot for next new AIF */ 4805678Spl196000 int aifq_wrap; /* AIF queue has ever been wrapped */ 48111964SXin.Chen@Sun.COM struct aac_fib_context aifctx; /* sys aif ctx */ 48211964SXin.Chen@Sun.COM struct aac_fib_context *fibctx_p; 4835678Spl196000 int devcfg_wait_on; /* AIF event waited for rescan */ 4845678Spl196000 4855678Spl196000 int fm_capabilities; 4865678Spl196000 4877000Sjd218194 /* MSI specific fields */ 4887000Sjd218194 ddi_intr_handle_t *htable; /* For array of interrupts */ 4897000Sjd218194 int intr_type; /* What type of interrupt */ 4907000Sjd218194 int intr_cnt; /* # of intrs count returned */ 49111348SZhongyan.Gu@Sun.COM int intr_size; 4927000Sjd218194 uint_t intr_pri; /* Interrupt priority */ 4937000Sjd218194 int intr_cap; /* Interrupt capabilities */ 4947000Sjd218194 4955678Spl196000 #ifdef DEBUG 4965678Spl196000 /* UART trace printf variables */ 4975678Spl196000 uint32_t debug_flags; /* debug print flags bitmap */ 4987567SXin.Chen@Sun.COM uint32_t debug_fib_flags; /* debug FIB print flags bitmap */ 4995678Spl196000 uint32_t debug_fw_flags; /* FW debug flags */ 5005678Spl196000 uint32_t debug_buf_offset; /* offset from DPMEM start */ 5015678Spl196000 uint32_t debug_buf_size; /* FW debug buffer size in bytes */ 5025678Spl196000 uint32_t debug_header_size; /* size of debug header */ 5035678Spl196000 #endif 5045678Spl196000 }; 5055678Spl196000 5065678Spl196000 /* 5075678Spl196000 * The following data are kept stable because they are only written at driver 5085678Spl196000 * initialization, and we do not allow them changed otherwise even at driver 5095678Spl196000 * re-initialization. 5105678Spl196000 */ 5115678Spl196000 _NOTE(SCHEME_PROTECTS_DATA("stable data", aac_softstate::{flags slen \ 5125678Spl196000 buf_dma_attr pci_mem_handle pci_mem_base_vaddr \ 5135678Spl196000 comm_space_acc_handle comm_space_dma_handle aac_max_fib_size \ 5147567SXin.Chen@Sun.COM aac_sg_tablesize aac_cmd_fib aac_cmd_fib_scsi debug_flags bus_max tgt_max})) 5155678Spl196000 5165678Spl196000 #ifdef DEBUG 5175678Spl196000 5185678Spl196000 #define AACDB_FLAGS_MASK 0x0000ffff 5195678Spl196000 #define AACDB_FLAGS_KERNEL_PRINT 0x00000001 5205678Spl196000 #define AACDB_FLAGS_FW_PRINT 0x00000002 5215678Spl196000 #define AACDB_FLAGS_NO_HEADERS 0x00000004 5225678Spl196000 5235678Spl196000 #define AACDB_FLAGS_MISC 0x00000010 5245678Spl196000 #define AACDB_FLAGS_FUNC1 0x00000020 5255678Spl196000 #define AACDB_FLAGS_FUNC2 0x00000040 5265678Spl196000 #define AACDB_FLAGS_SCMD 0x00000080 5275678Spl196000 #define AACDB_FLAGS_AIF 0x00000100 5285678Spl196000 #define AACDB_FLAGS_FIB 0x00000200 5295678Spl196000 #define AACDB_FLAGS_IOCTL 0x00000400 5305678Spl196000 5317567SXin.Chen@Sun.COM /* 5327567SXin.Chen@Sun.COM * Flags for FIB print 5337567SXin.Chen@Sun.COM */ 5347567SXin.Chen@Sun.COM /* FIB sources */ 5357567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_SCMD 0x00000001 5367567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_IOCTL 0x00000002 5377567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_SRB 0x00000004 5387567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_SYNC 0x00000008 5397567SXin.Chen@Sun.COM /* FIB components */ 5407567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_HEADER 0x00000010 5417567SXin.Chen@Sun.COM /* FIB states */ 5427567SXin.Chen@Sun.COM #define AACDB_FLAGS_FIB_TIMEOUT 0x00000100 5437567SXin.Chen@Sun.COM 5445678Spl196000 extern uint32_t aac_debug_flags; 5455678Spl196000 extern int aac_dbflag_on(struct aac_softstate *, int); 5465678Spl196000 extern void aac_printf(struct aac_softstate *, uint_t, const char *, ...); 5477567SXin.Chen@Sun.COM extern void aac_print_fib(struct aac_softstate *, struct aac_slot *); 5485678Spl196000 5495678Spl196000 #define AACDB_PRINT(s, lev, ...) { \ 5505678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_MISC)) \ 5515678Spl196000 aac_printf((s), (lev), __VA_ARGS__); } 5525678Spl196000 5535678Spl196000 #define AACDB_PRINT_IOCTL(s, ...) { \ 5545678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_IOCTL)) \ 5555678Spl196000 aac_printf((s), CE_NOTE, __VA_ARGS__); } 5565678Spl196000 5575678Spl196000 #define AACDB_PRINT_TRAN(s, ...) { \ 5585678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_SCMD)) \ 5595678Spl196000 aac_printf((s), CE_NOTE, __VA_ARGS__); } 5605678Spl196000 5615678Spl196000 #define DBCALLED(s, n) { \ 5625678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_FUNC ## n)) \ 5635678Spl196000 aac_printf((s), CE_NOTE, "--- %s() called ---", __func__); } 5645678Spl196000 5655678Spl196000 #define AACDB_PRINT_SCMD(s, x) { \ 5665678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_SCMD)) aac_print_scmd((s), (x)); } 5675678Spl196000 5685678Spl196000 #define AACDB_PRINT_AIF(s, x) { \ 5695678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_AIF)) aac_print_aif((s), (x)); } 5705678Spl196000 5715678Spl196000 #define AACDB_PRINT_FIB(s, x) { \ 5725678Spl196000 if (aac_dbflag_on((s), AACDB_FLAGS_FIB)) aac_print_fib((s), (x)); } 5735678Spl196000 5745678Spl196000 #else /* DEBUG */ 5755678Spl196000 5765678Spl196000 #define AACDB_PRINT(s, lev, ...) 5775678Spl196000 #define AACDB_PRINT_IOCTL(s, ...) 5785678Spl196000 #define AACDB_PRINT_TRAN(s, ...) 5795678Spl196000 #define AACDB_PRINT_FIB(s, x) 5805678Spl196000 #define AACDB_PRINT_SCMD(s, x) 5815678Spl196000 #define AACDB_PRINT_AIF(s, x) 5825678Spl196000 #define DBCALLED(s, n) 5835678Spl196000 5845678Spl196000 #endif /* DEBUG */ 5855678Spl196000 5865678Spl196000 #ifdef __cplusplus 5875678Spl196000 } 5885678Spl196000 #endif 5895678Spl196000 5905678Spl196000 #endif /* _AAC_H_ */ 591