/*-1* Core definitions and data structures shareable across OS platforms.2*3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright (c) 1994-2001 Justin T. Gibbs.6* Copyright (c) 2000-2001 Adaptec Inc.7* All rights reserved.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions, and the following disclaimer,14* without modification.15* 2. Redistributions in binary form must reproduce at minimum a disclaimer16* substantially similar to the "NO WARRANTY" disclaimer below17* ("Disclaimer") and any redistribution must be conditioned upon18* including a substantially similar Disclaimer requirement for further19* binary redistribution.20* 3. Neither the names of the above-listed copyright holders nor the names21* of any contributors may be used to endorse or promote products derived22* from this software without specific prior written permission.23*24* Alternatively, this software may be distributed under the terms of the25* GNU General Public License ("GPL") version 2 as published by the Free26* Software Foundation.27*28* NO WARRANTY29* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS30* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT31* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR32* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT33* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS35* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,37* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING38* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE39* POSSIBILITY OF SUCH DAMAGES.40*41* $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#85 $42*/4344#ifndef _AIC7XXX_H_45#define _AIC7XXX_H_4647/* Register Definitions */48#include "aic7xxx_reg.h"4950/************************* Forward Declarations *******************************/51struct ahc_platform_data;52struct scb_platform_data;53struct seeprom_descriptor;5455/****************************** Useful Macros *********************************/56#ifndef MAX57#define MAX(a,b) (((a) > (b)) ? (a) : (b))58#endif5960#ifndef MIN61#define MIN(a,b) (((a) < (b)) ? (a) : (b))62#endif6364#ifndef TRUE65#define TRUE 166#endif67#ifndef FALSE68#define FALSE 069#endif7071#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))7273#define ALL_CHANNELS '\0'74#define ALL_TARGETS_MASK 0xFFFF75#define INITIATOR_WILDCARD (~0)7677#define SCSIID_TARGET(ahc, scsiid) \78(((scsiid) & ((((ahc)->features & AHC_TWIN) != 0) ? TWIN_TID : TID)) \79>> TID_SHIFT)80#define SCSIID_OUR_ID(scsiid) \81((scsiid) & OID)82#define SCSIID_CHANNEL(ahc, scsiid) \83((((ahc)->features & AHC_TWIN) != 0) \84? ((((scsiid) & TWIN_CHNLB) != 0) ? 'B' : 'A') \85: 'A')86#define SCB_IS_SCSIBUS_B(ahc, scb) \87(SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid) == 'B')88#define SCB_GET_OUR_ID(scb) \89SCSIID_OUR_ID((scb)->hscb->scsiid)90#define SCB_GET_TARGET(ahc, scb) \91SCSIID_TARGET((ahc), (scb)->hscb->scsiid)92#define SCB_GET_CHANNEL(ahc, scb) \93SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid)94#define SCB_GET_LUN(scb) \95((scb)->hscb->lun & LID)96#define SCB_GET_TARGET_OFFSET(ahc, scb) \97(SCB_GET_TARGET(ahc, scb) + (SCB_IS_SCSIBUS_B(ahc, scb) ? 8 : 0))98#define SCB_GET_TARGET_MASK(ahc, scb) \99(0x01 << (SCB_GET_TARGET_OFFSET(ahc, scb)))100#ifdef AHC_DEBUG101#define SCB_IS_SILENT(scb) \102((ahc_debug & AHC_SHOW_MASKED_ERRORS) == 0 \103&& (((scb)->flags & SCB_SILENT) != 0))104#else105#define SCB_IS_SILENT(scb) \106(((scb)->flags & SCB_SILENT) != 0)107#endif108#define TCL_TARGET_OFFSET(tcl) \109((((tcl) >> 4) & TID) >> 4)110#define TCL_LUN(tcl) \111(tcl & (AHC_NUM_LUNS - 1))112#define BUILD_TCL(scsiid, lun) \113((lun) | (((scsiid) & TID) << 4))114115#ifndef AHC_TARGET_MODE116#undef AHC_TMODE_ENABLE117#define AHC_TMODE_ENABLE 0118#endif119120/**************************** Driver Constants ********************************/121/*122* The maximum number of supported targets.123*/124#define AHC_NUM_TARGETS 16125126/*127* The maximum number of supported luns.128* The identify message only supports 64 luns in SPI3.129* You can have 2^64 luns when information unit transfers are enabled,130* but it is doubtful this driver will ever support IUTs.131*/132#define AHC_NUM_LUNS 64133134/*135* The maximum transfer per S/G segment.136*/137#define AHC_MAXTRANSFER_SIZE 0x00ffffff /* limited by 24bit counter */138139/*140* The maximum amount of SCB storage in hardware on a controller.141* This value represents an upper bound. Controllers vary in the number142* they actually support.143*/144#define AHC_SCB_MAX 255145146/*147* The maximum number of concurrent transactions supported per driver instance.148* Sequencer Control Blocks (SCBs) store per-transaction information. Although149* the space for SCBs on the host adapter varies by model, the driver will150* page the SCBs between host and controller memory as needed. We are limited151* to 253 because:152* 1) The 8bit nature of the RISC engine holds us to an 8bit value.153* 2) We reserve one value, 255, to represent the invalid element.154* 3) Our input queue scheme requires one SCB to always be reserved155* in advance of queuing any SCBs. This takes us down to 254.156* 4) To handle our output queue correctly on machines that only157* support 32bit stores, we must clear the array 4 bytes at a158* time. To avoid colliding with a DMA write from the sequencer,159* we must be sure that 4 slots are empty when we write to clear160* the queue. This reduces us to 253 SCBs: 1 that just completed161* and the known three additional empty slots in the queue that162* precede it.163*/164#define AHC_MAX_QUEUE 253165166/*167* The maximum amount of SCB storage we allocate in host memory. This168* number should reflect the 1 additional SCB we require to handle our169* qinfifo mechanism.170*/171#define AHC_SCB_MAX_ALLOC (AHC_MAX_QUEUE+1)172173/*174* Ring Buffer of incoming target commands.175* We allocate 256 to simplify the logic in the sequencer176* by using the natural wrap point of an 8bit counter.177*/178#define AHC_TMODE_CMDS 256179180/* Reset line assertion time in us */181#define AHC_BUSRESET_DELAY 25182183/* Phase change constants used in target mode. */184#define AHC_BUSSETTLE_DELAY 400185#define AHC_DATARELEASE_DELAY 400186187/******************* Chip Characteristics/Operating Settings *****************/188/*189* Chip Type190* The chip order is from least sophisticated to most sophisticated.191*/192typedef enum {193AHC_NONE = 0x0000,194AHC_CHIPID_MASK = 0x00FF,195AHC_AIC7770 = 0x0001,196AHC_AIC7850 = 0x0002,197AHC_AIC7855 = 0x0003,198AHC_AIC7859 = 0x0004,199AHC_AIC7860 = 0x0005,200AHC_AIC7870 = 0x0006,201AHC_AIC7880 = 0x0007,202AHC_AIC7895 = 0x0008,203AHC_AIC7895C = 0x0009,204AHC_AIC7890 = 0x000a,205AHC_AIC7896 = 0x000b,206AHC_AIC7892 = 0x000c,207AHC_AIC7899 = 0x000d,208AHC_VL = 0x0100, /* Bus type VL */209AHC_EISA = 0x0200, /* Bus type EISA/ISA */210AHC_PCI = 0x0400, /* Bus type PCI */211AHC_BUS_MASK = 0x0F00212} ahc_chip;213214/*215* Features available in each chip type.216*/217typedef enum {218AHC_FENONE = 0x00000,219AHC_ULTRA = 0x00001, /* Supports 20MHz Transfers */220AHC_ULTRA2 = 0x00002, /* Supports 40MHz Transfers */221AHC_WIDE = 0x00004, /* Wide Channel */222AHC_TWIN = 0x00008, /* Twin Channel */223AHC_MORE_SRAM = 0x00010, /* 80 bytes instead of 64 */224AHC_CMD_CHAN = 0x00020, /* Has a Command DMA Channel */225AHC_QUEUE_REGS = 0x00040, /* Has Queue management registers */226AHC_SG_PRELOAD = 0x00080, /* Can perform auto-SG preload */227AHC_SPIOCAP = 0x00100, /* Has a Serial Port I/O Cap Register */228AHC_MULTI_TID = 0x00200, /* Has bitmask of TIDs for select-in */229AHC_HS_MAILBOX = 0x00400, /* Has HS_MAILBOX register */230AHC_DT = 0x00800, /* Double Transition transfers */231AHC_NEW_TERMCTL = 0x01000, /* Newer termination scheme */232AHC_MULTI_FUNC = 0x02000, /* Multi-Function Twin Channel Device */233AHC_LARGE_SCBS = 0x04000, /* 64byte SCBs */234AHC_AUTORATE = 0x08000, /* Automatic update of SCSIRATE/OFFSET*/235AHC_AUTOPAUSE = 0x10000, /* Automatic pause on register access */236AHC_TARGETMODE = 0x20000, /* Has tested target mode support */237AHC_MULTIROLE = 0x40000, /* Space for two roles at a time */238AHC_REMOVABLE = 0x80000, /* Hot-Swap supported */239AHC_AIC7770_FE = AHC_FENONE,240/*241* The real 7850 does not support Ultra modes, but there are242* several cards that use the generic 7850 PCI ID even though243* they are using an Ultra capable chip (7859/7860). We start244* out with the AHC_ULTRA feature set and then check the DEVSTATUS245* register to determine if the capability is really present.246*/247AHC_AIC7850_FE = AHC_SPIOCAP|AHC_AUTOPAUSE|AHC_TARGETMODE|AHC_ULTRA,248AHC_AIC7860_FE = AHC_AIC7850_FE,249AHC_AIC7870_FE = AHC_TARGETMODE|AHC_AUTOPAUSE,250AHC_AIC7880_FE = AHC_AIC7870_FE|AHC_ULTRA,251/*252* Although we have space for both the initiator and253* target roles on ULTRA2 chips, we currently disable254* the initiator role to allow multi-scsi-id target mode255* configurations. We can only respond on the same SCSI256* ID as our initiator role if we allow initiator operation.257* At some point, we should add a configuration knob to258* allow both roles to be loaded.259*/260AHC_AIC7890_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2261|AHC_QUEUE_REGS|AHC_SG_PRELOAD|AHC_MULTI_TID262|AHC_HS_MAILBOX|AHC_NEW_TERMCTL|AHC_LARGE_SCBS263|AHC_TARGETMODE,264AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_DT|AHC_AUTORATE|AHC_AUTOPAUSE,265AHC_AIC7895_FE = AHC_AIC7880_FE|AHC_MORE_SRAM|AHC_AUTOPAUSE266|AHC_CMD_CHAN|AHC_MULTI_FUNC|AHC_LARGE_SCBS,267AHC_AIC7895C_FE = AHC_AIC7895_FE|AHC_MULTI_TID,268AHC_AIC7896_FE = AHC_AIC7890_FE|AHC_MULTI_FUNC,269AHC_AIC7899_FE = AHC_AIC7892_FE|AHC_MULTI_FUNC270} ahc_feature;271272/*273* Bugs in the silicon that we work around in software.274*/275typedef enum {276AHC_BUGNONE = 0x00,277/*278* On all chips prior to the U2 product line,279* the WIDEODD S/G segment feature does not280* work during scsi->HostBus transfers.281*/282AHC_TMODE_WIDEODD_BUG = 0x01,283/*284* On the aic7890/91 Rev 0 chips, the autoflush285* feature does not work. A manual flush of286* the DMA FIFO is required.287*/288AHC_AUTOFLUSH_BUG = 0x02,289/*290* On many chips, cacheline streaming does not work.291*/292AHC_CACHETHEN_BUG = 0x04,293/*294* On the aic7896/97 chips, cacheline295* streaming must be enabled.296*/297AHC_CACHETHEN_DIS_BUG = 0x08,298/*299* PCI 2.1 Retry failure on non-empty data fifo.300*/301AHC_PCI_2_1_RETRY_BUG = 0x10,302/*303* Controller does not handle cacheline residuals304* properly on S/G segments if PCI MWI instructions305* are allowed.306*/307AHC_PCI_MWI_BUG = 0x20,308/*309* An SCB upload using the SCB channel's310* auto array entry copy feature may311* corrupt data. This appears to only312* occur on 66MHz systems.313*/314AHC_SCBCHAN_UPLOAD_BUG = 0x40315} ahc_bug;316317/*318* Configuration specific settings.319* The driver determines these settings by probing the320* chip/controller's configuration.321*/322typedef enum {323AHC_FNONE = 0x000,324AHC_PRIMARY_CHANNEL = 0x003, /*325* The channel that should326* be probed first.327*/328AHC_USEDEFAULTS = 0x004, /*329* For cards without an seeprom330* or a BIOS to initialize the chip's331* SRAM, we use the default target332* settings.333*/334AHC_SEQUENCER_DEBUG = 0x008,335AHC_SHARED_SRAM = 0x010,336AHC_LARGE_SEEPROM = 0x020, /* Uses C56_66 not C46 */337AHC_RESET_BUS_A = 0x040,338AHC_RESET_BUS_B = 0x080,339AHC_EXTENDED_TRANS_A = 0x100,340AHC_EXTENDED_TRANS_B = 0x200,341AHC_TERM_ENB_A = 0x400,342AHC_TERM_ENB_B = 0x800,343AHC_INITIATORROLE = 0x1000, /*344* Allow initiator operations on345* this controller.346*/347AHC_TARGETROLE = 0x2000, /*348* Allow target operations on this349* controller.350*/351AHC_NEWEEPROM_FMT = 0x4000,352AHC_RESOURCE_SHORTAGE = 0x8000,353AHC_TQINFIFO_BLOCKED = 0x10000, /* Blocked waiting for ATIOs */354AHC_INT50_SPEEDFLEX = 0x20000, /*355* Internal 50pin connector356* sits behind an aic3860357*/358AHC_SCB_BTT = 0x40000, /*359* The busy targets table is360* stored in SCB space rather361* than SRAM.362*/363AHC_BIOS_ENABLED = 0x80000,364AHC_ALL_INTERRUPTS = 0x100000,365AHC_PAGESCBS = 0x400000, /* Enable SCB paging */366AHC_EDGE_INTERRUPT = 0x800000, /* Device uses edge triggered ints */367AHC_39BIT_ADDRESSING = 0x1000000, /* Use 39 bit addressing scheme. */368AHC_LSCBS_ENABLED = 0x2000000, /* 64Byte SCBs enabled */369AHC_SCB_CONFIG_USED = 0x4000000, /* No SEEPROM but SCB2 had info. */370AHC_NO_BIOS_INIT = 0x8000000, /* No BIOS left over settings. */371AHC_DISABLE_PCI_PERR = 0x10000000,372AHC_HAS_TERM_LOGIC = 0x20000000,373AHC_SHUTDOWN_RECOVERY = 0x40000000 /* Terminate recovery thread. */374} ahc_flag;375376/************************* Hardware SCB Definition ***************************/377378/*379* The driver keeps up to MAX_SCB scb structures per card in memory. The SCB380* consists of a "hardware SCB" mirroring the fields available on the card381* and additional information the kernel stores for each transaction.382*383* To minimize space utilization, a portion of the hardware scb stores384* different data during different portions of a SCSI transaction.385* As initialized by the host driver for the initiator role, this area386* contains the SCSI cdb (or a pointer to the cdb) to be executed. After387* the cdb has been presented to the target, this area serves to store388* residual transfer information and the SCSI status byte.389* For the target role, the contents of this area do not change, but390* still serve a different purpose than for the initiator role. See391* struct target_data for details.392*/393394/*395* Status information embedded in the shared poriton of396* an SCB after passing the cdb to the target. The kernel397* driver will only read this data for transactions that398* complete abnormally (non-zero status byte).399*/400struct status_pkt {401uint32_t residual_datacnt; /* Residual in the current S/G seg */402uint32_t residual_sg_ptr; /* The next S/G for this transfer */403uint8_t scsi_status; /* Standard SCSI status byte */404};405406/*407* Target mode version of the shared data SCB segment.408*/409struct target_data {410uint32_t residual_datacnt; /* Residual in the current S/G seg */411uint32_t residual_sg_ptr; /* The next S/G for this transfer */412uint8_t scsi_status; /* SCSI status to give to initiator */413uint8_t target_phases; /* Bitmap of phases to execute */414uint8_t data_phase; /* Data-In or Data-Out */415uint8_t initiator_tag; /* Initiator's transaction tag */416};417418#define MAX_CDB_LEN 16419struct hardware_scb {420/*0*/ union {421/*422* If the cdb is 12 bytes or less, we embed it directly423* in the SCB. For longer cdbs, we embed the address424* of the cdb payload as seen by the chip and a DMA425* is used to pull it in.426*/427uint8_t cdb[12];428uint32_t cdb_ptr;429struct status_pkt status;430struct target_data tdata;431} shared_data;432/*433* A word about residuals.434* The scb is presented to the sequencer with the dataptr and datacnt435* fields initialized to the contents of the first S/G element to436* transfer. The sgptr field is initialized to the bus address for437* the S/G element that follows the first in the in core S/G array438* or'ed with the SG_FULL_RESID flag. Sgptr may point to an invalid439* S/G entry for this transfer (single S/G element transfer with the440* first elements address and length preloaded in the dataptr/datacnt441* fields). If no transfer is to occur, sgptr is set to SG_LIST_NULL.442* The SG_FULL_RESID flag ensures that the residual will be correctly443* noted even if no data transfers occur. Once the data phase is entered,444* the residual sgptr and datacnt are loaded from the sgptr and the445* datacnt fields. After each S/G element's dataptr and length are446* loaded into the hardware, the residual sgptr is advanced. After447* each S/G element is expired, its datacnt field is checked to see448* if the LAST_SEG flag is set. If so, SG_LIST_NULL is set in the449* residual sg ptr and the transfer is considered complete. If the450* sequencer determines that there is a residual in the transfer, it451* will set the SG_RESID_VALID flag in sgptr and dma the scb back into452* host memory. To sumarize:453*454* Sequencer:455* o A residual has occurred if SG_FULL_RESID is set in sgptr,456* or residual_sgptr does not have SG_LIST_NULL set.457*458* o We are transferring the last segment if residual_datacnt has459* the SG_LAST_SEG flag set.460*461* Host:462* o A residual has occurred if a completed scb has the463* SG_RESID_VALID flag set.464*465* o residual_sgptr and sgptr refer to the "next" sg entry466* and so may point beyond the last valid sg entry for the467* transfer.468*/469/*12*/ uint32_t dataptr;470/*16*/ uint32_t datacnt; /*471* Byte 3 (numbered from 0) of472* the datacnt is really the473* 4th byte in that data address.474*/475/*20*/ uint32_t sgptr;476#define SG_PTR_MASK 0xFFFFFFF8477/*24*/ uint8_t control; /* See SCB_CONTROL in aic7xxx.reg for details */478/*25*/ uint8_t scsiid; /* what to load in the SCSIID register */479/*26*/ uint8_t lun;480/*27*/ uint8_t tag; /*481* Index into our kernel SCB array.482* Also used as the tag for tagged I/O483*/484/*28*/ uint8_t cdb_len;485/*29*/ uint8_t scsirate; /* Value for SCSIRATE register */486/*30*/ uint8_t scsioffset; /* Value for SCSIOFFSET register */487/*31*/ uint8_t next; /*488* Used for threading SCBs in the489* "Waiting for Selection" and490* "Disconnected SCB" lists down491* in the sequencer.492*/493/*32*/ uint8_t cdb32[32]; /*494* CDB storage for cdbs of size495* 13->32. We store them here496* because hardware scbs are497* allocated from DMA safe498* memory so we are guaranteed499* the controller can access500* this data.501*/502};503504/************************ Kernel SCB Definitions ******************************/505/*506* Some fields of the SCB are OS dependent. Here we collect the507* definitions for elements that all OS platforms need to include508* in there SCB definition.509*/510511/*512* Definition of a scatter/gather element as transferred to the controller.513* The aic7xxx chips only support a 24bit length. We use the top byte of514* the length to store additional address bits and a flag to indicate515* that a given segment terminates the transfer. This gives us an516* addressable range of 512GB on machines with 64bit PCI or with chips517* that can support dual address cycles on 32bit PCI busses.518*/519struct ahc_dma_seg {520uint32_t addr;521uint32_t len;522#define AHC_DMA_LAST_SEG 0x80000000523#define AHC_SG_HIGH_ADDR_MASK 0x7F000000524#define AHC_SG_LEN_MASK 0x00FFFFFF525};526527struct sg_map_node {528bus_dmamap_t sg_dmamap;529bus_addr_t sg_physaddr;530struct ahc_dma_seg* sg_vaddr;531SLIST_ENTRY(sg_map_node) links;532};533534/*535* The current state of this SCB.536*/537typedef enum {538SCB_FLAG_NONE = 0x0000,539SCB_OTHERTCL_TIMEOUT = 0x0002,/*540* Another device was active541* during the first timeout for542* this SCB so we gave ourselves543* an additional timeout period544* in case it was hogging the545* bus.546*/547SCB_DEVICE_RESET = 0x0004,548SCB_SENSE = 0x0008,549SCB_CDB32_PTR = 0x0010,550SCB_RECOVERY_SCB = 0x0020,551SCB_AUTO_NEGOTIATE = 0x0040,/* Negotiate to achieve goal. */552SCB_NEGOTIATE = 0x0080,/* Negotiation forced for command. */553SCB_ABORT = 0x0100,554SCB_UNTAGGEDQ = 0x0200,555SCB_ACTIVE = 0x0400,556SCB_TARGET_IMMEDIATE = 0x0800,557SCB_TRANSMISSION_ERROR = 0x1000,/*558* We detected a parity or CRC559* error that has effected the560* payload of the command. This561* flag is checked when normal562* status is returned to catch563* the case of a target not564* responding to our attempt565* to report the error.566*/567SCB_TARGET_SCB = 0x2000,568SCB_SILENT = 0x4000,/*569* Be quiet about transmission type570* errors. They are expected and we571* don't want to upset the user. This572* flag is typically used during DV.573*/574SCB_TIMEDOUT = 0x8000 /*575* SCB has timed out and is on the576* timedout list.577*/578} scb_flag;579580struct scb {581struct hardware_scb *hscb;582union {583SLIST_ENTRY(scb) sle;584TAILQ_ENTRY(scb) tqe;585} links;586LIST_ENTRY(scb) pending_links;587LIST_ENTRY(scb) timedout_links;588aic_io_ctx_t io_ctx;589struct ahc_softc *ahc_softc;590scb_flag flags;591bus_dmamap_t dmamap;592struct scb_platform_data *platform_data;593struct sg_map_node *sg_map;594struct ahc_dma_seg *sg_list;595bus_addr_t sg_list_phys;596u_int sg_count;/* How full ahc_dma_seg is */597aic_timer_t io_timer;598};599600struct scb_data {601SLIST_HEAD(, scb) free_scbs; /*602* Pool of SCBs ready to be assigned603* commands to execute.604*/605struct scb *scbindex[256]; /*606* Mapping from tag to SCB.607* As tag identifiers are an608* 8bit value, we provide space609* for all possible tag values.610* Any lookups to entries at or611* above AHC_SCB_MAX_ALLOC will612* always fail.613*/614struct hardware_scb *hscbs; /* Array of hardware SCBs */615struct scb *scbarray; /* Array of kernel SCBs */616struct scsi_sense_data *sense; /* Per SCB sense data */617618u_int recovery_scbs; /* Transactions currently in recovery */619620/*621* "Bus" addresses of our data structures.622*/623bus_dma_tag_t hscb_dmat; /* dmat for our hardware SCB array */624bus_dmamap_t hscb_dmamap;625bus_addr_t hscb_busaddr;626bus_dma_tag_t sense_dmat;627bus_dmamap_t sense_dmamap;628bus_addr_t sense_busaddr;629bus_dma_tag_t sg_dmat; /* dmat for our sg segments */630SLIST_HEAD(, sg_map_node) sg_maps;631uint8_t numscbs;632uint8_t maxhscbs; /* Number of SCBs on the card */633uint8_t init_level; /*634* How far we've initialized635* this structure.636*/637};638639/************************ Target Mode Definitions *****************************/640641/*642* Connection descriptor for select-in requests in target mode.643*/644struct target_cmd {645uint8_t scsiid; /* Our ID and the initiator's ID */646uint8_t identify; /* Identify message */647uint8_t bytes[22]; /*648* Bytes contains any additional message649* bytes terminated by 0xFF. The remainder650* is the cdb to execute.651*/652uint8_t cmd_valid; /*653* When a command is complete, the firmware654* will set cmd_valid to all bits set.655* After the host has seen the command,656* the bits are cleared. This allows us657* to just peek at host memory to determine658* if more work is complete. cmd_valid is on659* an 8 byte boundary to simplify setting660* it on aic7880 hardware which only has661* limited direct access to the DMA FIFO.662*/663uint8_t pad[7];664};665666/*667* Number of events we can buffer up if we run out668* of immediate notify ccbs.669*/670#define AHC_TMODE_EVENT_BUFFER_SIZE 8671struct ahc_tmode_event {672uint8_t initiator_id;673uint8_t event_type; /* MSG type or EVENT_TYPE_BUS_RESET */674#define EVENT_TYPE_BUS_RESET 0xFF675uint8_t event_arg;676};677678/*679* Per enabled lun target mode state.680* As this state is directly influenced by the host OS'es target mode681* environment, we let the OS module define it. Forward declare the682* structure here so we can store arrays of them, etc. in OS neutral683* data structures.684*/685#ifdef AHC_TARGET_MODE686struct ahc_tmode_lstate {687struct cam_path *path;688struct ccb_hdr_slist accept_tios;689struct ccb_hdr_slist immed_notifies;690struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE];691uint8_t event_r_idx;692uint8_t event_w_idx;693};694#else695struct ahc_tmode_lstate;696#endif697698/******************** Transfer Negotiation Datastructures *********************/699#define AHC_TRANS_CUR 0x01 /* Modify current neogtiation status */700#define AHC_TRANS_ACTIVE 0x03 /* Assume this target is on the bus */701#define AHC_TRANS_GOAL 0x04 /* Modify negotiation goal */702#define AHC_TRANS_USER 0x08 /* Modify user negotiation settings */703704#define AHC_WIDTH_UNKNOWN 0xFF705#define AHC_PERIOD_UNKNOWN 0xFF706#define AHC_OFFSET_UNKNOWN 0xFF707#define AHC_PPR_OPTS_UNKNOWN 0xFF708709/*710* Transfer Negotiation Information.711*/712struct ahc_transinfo {713uint8_t protocol_version; /* SCSI Revision level */714uint8_t transport_version; /* SPI Revision level */715uint8_t width; /* Bus width */716uint8_t period; /* Sync rate factor */717uint8_t offset; /* Sync offset */718uint8_t ppr_options; /* Parallel Protocol Request options */719};720721/*722* Per-initiator current, goal and user transfer negotiation information. */723struct ahc_initiator_tinfo {724uint8_t scsirate; /* Computed value for SCSIRATE reg */725struct ahc_transinfo curr;726struct ahc_transinfo goal;727struct ahc_transinfo user;728};729730/*731* Per enabled target ID state.732* Pointers to lun target state as well as sync/wide negotiation information733* for each initiator<->target mapping. For the initiator role we pretend734* that we are the target and the targets are the initiators since the735* negotiation is the same regardless of role.736*/737struct ahc_tmode_tstate {738struct ahc_tmode_lstate* enabled_luns[AHC_NUM_LUNS];739struct ahc_initiator_tinfo transinfo[AHC_NUM_TARGETS];740741/*742* Per initiator state bitmasks.743*/744uint16_t auto_negotiate;/* Auto Negotiation Required */745uint16_t ultraenb; /* Using ultra sync rate */746uint16_t discenable; /* Disconnection allowed */747uint16_t tagenable; /* Tagged Queuing allowed */748};749750/*751* Data structure for our table of allowed synchronous transfer rates.752*/753struct ahc_syncrate {754u_int sxfr_u2; /* Value of the SXFR parameter for Ultra2+ Chips */755u_int sxfr; /* Value of the SXFR parameter for <= Ultra Chips */756#define ULTRA_SXFR 0x100 /* Rate Requires Ultra Mode set */757#define ST_SXFR 0x010 /* Rate Single Transition Only */758#define DT_SXFR 0x040 /* Rate Double Transition Only */759uint8_t period; /* Period to send to SCSI target */760char *rate;761};762763/* Safe and valid period for async negotiations. */764#define AHC_ASYNC_XFER_PERIOD 0x45765#define AHC_ULTRA2_XFER_PERIOD 0x0a766767/*768* Indexes into our table of synchronous transfer rates.769*/770#define AHC_SYNCRATE_DT 0771#define AHC_SYNCRATE_ULTRA2 1772#define AHC_SYNCRATE_ULTRA 3773#define AHC_SYNCRATE_FAST 6774#define AHC_SYNCRATE_MAX AHC_SYNCRATE_DT775#define AHC_SYNCRATE_MIN 13776777/***************************** Lookup Tables **********************************/778/*779* Phase -> name and message out response780* to parity errors in each phase table.781*/782struct ahc_phase_table_entry {783uint8_t phase;784uint8_t mesg_out; /* Message response to parity errors */785char *phasemsg;786};787788/************************** Serial EEPROM Format ******************************/789790struct seeprom_config {791/*792* Per SCSI ID Configuration Flags793*/794uint16_t device_flags[16]; /* words 0-15 */795#define CFXFER 0x0007 /* synchronous transfer rate */796#define CFSYNCH 0x0008 /* enable synchronous transfer */797#define CFDISC 0x0010 /* enable disconnection */798#define CFWIDEB 0x0020 /* wide bus device */799#define CFSYNCHISULTRA 0x0040 /* CFSYNCH is an ultra offset (2940AU)*/800#define CFSYNCSINGLE 0x0080 /* Single-Transition signalling */801#define CFSTART 0x0100 /* send start unit SCSI command */802#define CFINCBIOS 0x0200 /* include in BIOS scan */803#define CFRNFOUND 0x0400 /* report even if not found */804#define CFMULTILUNDEV 0x0800 /* Probe multiple luns in BIOS scan */805#define CFWBCACHEENB 0x4000 /* Enable W-Behind Cache on disks */806#define CFWBCACHENOP 0xc000 /* Don't touch W-Behind Cache */807808/*809* BIOS Control Bits810*/811uint16_t bios_control; /* word 16 */812#define CFSUPREM 0x0001 /* support all removeable drives */813#define CFSUPREMB 0x0002 /* support removeable boot drives */814#define CFBIOSEN 0x0004 /* BIOS enabled */815#define CFBIOS_BUSSCAN 0x0008 /* Have the BIOS Scan the Bus */816#define CFSM2DRV 0x0010 /* support more than two drives */817#define CFSTPWLEVEL 0x0010 /* Termination level control */818#define CF284XEXTEND 0x0020 /* extended translation (284x cards) */819#define CFCTRL_A 0x0020 /* BIOS displays Ctrl-A message */820#define CFTERM_MENU 0x0040 /* BIOS displays termination menu */821#define CFEXTEND 0x0080 /* extended translation enabled */822#define CFSCAMEN 0x0100 /* SCAM enable */823#define CFMSG_LEVEL 0x0600 /* BIOS Message Level */824#define CFMSG_VERBOSE 0x0000825#define CFMSG_SILENT 0x0200826#define CFMSG_DIAG 0x0400827#define CFBOOTCD 0x0800 /* Support Bootable CD-ROM */828/* UNUSED 0xff00 */829830/*831* Host Adapter Control Bits832*/833uint16_t adapter_control; /* word 17 */834#define CFAUTOTERM 0x0001 /* Perform Auto termination */835#define CFULTRAEN 0x0002 /* Ultra SCSI speed enable */836#define CF284XSELTO 0x0003 /* Selection timeout (284x cards) */837#define CF284XFIFO 0x000C /* FIFO Threshold (284x cards) */838#define CFSTERM 0x0004 /* SCSI low byte termination */839#define CFWSTERM 0x0008 /* SCSI high byte termination */840#define CFSPARITY 0x0010 /* SCSI parity */841#define CF284XSTERM 0x0020 /* SCSI low byte term (284x cards) */842#define CFMULTILUN 0x0020843#define CFRESETB 0x0040 /* reset SCSI bus at boot */844#define CFCLUSTERENB 0x0080 /* Cluster Enable */845#define CFBOOTCHAN 0x0300 /* probe this channel first */846#define CFBOOTCHANSHIFT 8847#define CFSEAUTOTERM 0x0400 /* Ultra2 Perform secondary Auto Term*/848#define CFSELOWTERM 0x0800 /* Ultra2 secondary low term */849#define CFSEHIGHTERM 0x1000 /* Ultra2 secondary high term */850#define CFENABLEDV 0x4000 /* Perform Domain Validation*/851852/*853* Bus Release Time, Host Adapter ID854*/855uint16_t brtime_id; /* word 18 */856#define CFSCSIID 0x000f /* host adapter SCSI ID */857/* UNUSED 0x00f0 */858#define CFBRTIME 0xff00 /* bus release time */859860/*861* Maximum targets862*/863uint16_t max_targets; /* word 19 */864#define CFMAXTARG 0x00ff /* maximum targets */865#define CFBOOTLUN 0x0f00 /* Lun to boot from */866#define CFBOOTID 0xf000 /* Target to boot from */867uint16_t res_1[10]; /* words 20-29 */868uint16_t signature; /* Signature == 0x250 */869#define CFSIGNATURE 0x250870#define CFSIGNATURE2 0x300871uint16_t checksum; /* word 31 */872};873874/**************************** Message Buffer *********************************/875typedef enum {876MSG_TYPE_NONE = 0x00,877MSG_TYPE_INITIATOR_MSGOUT = 0x01,878MSG_TYPE_INITIATOR_MSGIN = 0x02,879MSG_TYPE_TARGET_MSGOUT = 0x03,880MSG_TYPE_TARGET_MSGIN = 0x04881} ahc_msg_type;882883typedef enum {884MSGLOOP_IN_PROG,885MSGLOOP_MSGCOMPLETE,886MSGLOOP_TERMINATED887} msg_loop_stat;888889/*********************** Software Configuration Structure *********************/890TAILQ_HEAD(scb_tailq, scb);891892struct ahc_aic7770_softc {893/*894* Saved register state used for chip_init().895*/896uint8_t busspd;897uint8_t bustime;898};899900struct ahc_pci_softc {901/*902* Saved register state used for chip_init().903*/904uint32_t devconfig;905uint16_t targcrccnt;906uint8_t command;907uint8_t csize_lattime;908uint8_t optionmode;909uint8_t crccontrol1;910uint8_t dscommand0;911uint8_t dspcistatus;912uint8_t scbbaddr;913uint8_t dff_thrsh;914};915916union ahc_bus_softc {917struct ahc_aic7770_softc aic7770_softc;918struct ahc_pci_softc pci_softc;919};920921typedef void (*ahc_bus_intr_t)(struct ahc_softc *);922typedef int (*ahc_bus_chip_init_t)(struct ahc_softc *);923typedef int (*ahc_bus_suspend_t)(struct ahc_softc *);924typedef int (*ahc_bus_resume_t)(struct ahc_softc *);925typedef void ahc_callback_t (void *);926927#define AIC_SCB_DATA(softc) ((softc)->scb_data)928929struct ahc_softc {930bus_space_tag_t tag;931bus_space_handle_t bsh;932bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */933struct scb_data *scb_data;934935struct scb *next_queued_scb;936937/*938* SCBs that have been sent to the controller939*/940LIST_HEAD(, scb) pending_scbs;941942/*943* SCBs whose timeout routine has been called.944*/945LIST_HEAD(, scb) timedout_scbs;946947/*948* Counting lock for deferring the release of additional949* untagged transactions from the untagged_queues. When950* the lock is decremented to 0, all queues in the951* untagged_queues array are run.952*/953u_int untagged_queue_lock;954955/*956* Per-target queue of untagged-transactions. The957* transaction at the head of the queue is the958* currently pending untagged transaction for the959* target. The driver only allows a single untagged960* transaction per target.961*/962struct scb_tailq untagged_queues[AHC_NUM_TARGETS];963964/*965* Bus attachment specific data.966*/967union ahc_bus_softc bus_softc;968969/*970* Platform specific data.971*/972struct ahc_platform_data *platform_data;973974/*975* Platform specific device information.976*/977aic_dev_softc_t dev_softc;978979/*980* Bus specific device information.981*/982ahc_bus_intr_t bus_intr;983984/*985* Bus specific initialization required986* after a chip reset.987*/988ahc_bus_chip_init_t bus_chip_init;989990/*991* Bus specific suspend routine.992*/993ahc_bus_suspend_t bus_suspend;994995/*996* Bus specific resume routine.997*/998ahc_bus_resume_t bus_resume;9991000/*1001* Target mode related state kept on a per enabled lun basis.1002* Targets that are not enabled will have null entries.1003* As an initiator, we keep one target entry for our initiator1004* ID to store our sync/wide transfer settings.1005*/1006struct ahc_tmode_tstate *enabled_targets[AHC_NUM_TARGETS];10071008/*1009* The black hole device responsible for handling requests for1010* disabled luns on enabled targets.1011*/1012struct ahc_tmode_lstate *black_hole;10131014/*1015* Device instance currently on the bus awaiting a continue TIO1016* for a command that was not given the disconnect priveledge.1017*/1018struct ahc_tmode_lstate *pending_device;10191020/*1021* Card characteristics1022*/1023ahc_chip chip;1024ahc_feature features;1025ahc_bug bugs;1026ahc_flag flags;1027struct seeprom_config *seep_config;10281029/* Values to store in the SEQCTL register for pause and unpause */1030uint8_t unpause;1031uint8_t pause;10321033/* Command Queues */1034uint8_t qoutfifonext;1035uint8_t qinfifonext;1036uint8_t *qoutfifo;1037uint8_t *qinfifo;10381039/* Critical Section Data */1040struct cs *critical_sections;1041u_int num_critical_sections;10421043/* Links for chaining softcs */1044TAILQ_ENTRY(ahc_softc) links;10451046/* Channel Names ('A', 'B', etc.) */1047char channel;1048char channel_b;10491050/* Initiator Bus ID */1051uint8_t our_id;1052uint8_t our_id_b;10531054/*1055* PCI error detection.1056*/1057int unsolicited_ints;10581059/*1060* Target incoming command FIFO.1061*/1062struct target_cmd *targetcmds;1063uint8_t tqinfifonext;10641065/*1066* Cached copy of the sequencer control register.1067*/1068uint8_t seqctl;10691070/*1071* Incoming and outgoing message handling.1072*/1073uint8_t send_msg_perror;1074ahc_msg_type msg_type;1075uint8_t msgout_buf[12];/* Message we are sending */1076uint8_t msgin_buf[12];/* Message we are receiving */1077u_int msgout_len; /* Length of message to send */1078u_int msgout_index; /* Current index in msgout */1079u_int msgin_index; /* Current index in msgin */10801081/*1082* Mapping information for data structures shared1083* between the sequencer and kernel.1084*/1085bus_dma_tag_t parent_dmat;1086bus_dma_tag_t shared_data_dmat;1087bus_dmamap_t shared_data_dmamap;1088bus_addr_t shared_data_busaddr;10891090/*1091* Bus address of the one byte buffer used to1092* work-around a DMA bug for chips <= aic78801093* in target mode.1094*/1095bus_addr_t dma_bug_buf;10961097/* Number of enabled target mode device on this card */1098u_int enabled_luns;10991100/* Initialization level of this data structure */1101u_int init_level;11021103/* PCI cacheline size. */1104u_int pci_cachesize;11051106/*1107* Count of parity errors we have seen as a target.1108* We auto-disable parity error checking after seeing1109* AHC_PCI_TARGET_PERR_THRESH number of errors.1110*/1111u_int pci_target_perr_count;1112#define AHC_PCI_TARGET_PERR_THRESH 1011131114/* Maximum number of sequencer instructions supported. */1115u_int instruction_ram_size;11161117/* Per-Unit descriptive information */1118const char *description;1119char *name;1120int unit;11211122/* Selection Timer settings */1123int seltime;1124int seltime_b;11251126uint16_t user_discenable;/* Disconnection allowed */1127uint16_t user_tagenable;/* Tagged Queuing allowed */1128};11291130TAILQ_HEAD(ahc_softc_tailq, ahc_softc);1131extern struct ahc_softc_tailq ahc_tailq;11321133/************************ Active Device Information ***************************/1134typedef enum {1135ROLE_UNKNOWN,1136ROLE_INITIATOR,1137ROLE_TARGET1138} role_t;11391140struct ahc_devinfo {1141int our_scsiid;1142int target_offset;1143uint16_t target_mask;1144u_int target;1145u_int lun;1146char channel;1147role_t role; /*1148* Only guaranteed to be correct if not1149* in the busfree state.1150*/1151};11521153/****************************** PCI Structures ********************************/1154#define AHC_PCI_IOADDR PCIR_BAR(0) /* I/O Address */1155#define AHC_PCI_MEMADDR PCIR_BAR(1) /* Mem I/O Address */11561157typedef int (ahc_device_setup_t)(struct ahc_softc *);11581159struct ahc_pci_identity {1160uint64_t full_id;1161uint64_t id_mask;1162char *name;1163ahc_device_setup_t *setup;1164};1165extern struct ahc_pci_identity ahc_pci_ident_table[];1166extern const u_int ahc_num_pci_devs;11671168/*************************** VL/EISA/ISA Declarations *************************/1169struct aic7770_identity {1170uint32_t full_id;1171uint32_t id_mask;1172const char *name;1173ahc_device_setup_t *setup;1174};1175extern struct aic7770_identity aic7770_ident_table[];1176extern const int ahc_num_aic7770_devs;11771178#define AHC_EISA_SLOT_SIZE 0x10001179#define AHC_EISA_SLOT_OFFSET 0xc001180#define AHC_EISA_IOSIZE 0x10011811182/*************************** Function Declarations ****************************/1183/******************************************************************************/1184u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl);1185void ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl);1186void ahc_busy_tcl(struct ahc_softc *ahc,1187u_int tcl, u_int busyid);11881189/***************************** PCI Front End *********************************/1190struct ahc_pci_identity *ahc_find_pci_device(aic_dev_softc_t);1191int ahc_pci_config(struct ahc_softc *,1192struct ahc_pci_identity *);1193int ahc_pci_test_register_access(struct ahc_softc *);11941195/*************************** ISA/EISA/VL Front End ****************************/1196struct aic7770_identity *aic7770_find_device(uint32_t);1197int aic7770_config(struct ahc_softc *ahc,1198struct aic7770_identity *,1199u_int port);12001201/************************** SCB and SCB queue management **********************/1202int ahc_probe_scbs(struct ahc_softc *);1203void ahc_run_untagged_queues(struct ahc_softc *ahc);1204void ahc_run_untagged_queue(struct ahc_softc *ahc,1205struct scb_tailq *queue);1206void ahc_qinfifo_requeue_tail(struct ahc_softc *ahc,1207struct scb *scb);1208int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb,1209int target, char channel, int lun,1210u_int tag, role_t role);12111212/****************************** Initialization ********************************/1213struct ahc_softc *ahc_alloc(void *platform_arg, char *name);1214int ahc_softc_init(struct ahc_softc *);1215void ahc_controller_info(struct ahc_softc *ahc, char *buf);1216int ahc_chip_init(struct ahc_softc *ahc);1217int ahc_init(struct ahc_softc *ahc);1218void ahc_intr_enable(struct ahc_softc *ahc, int enable);1219void ahc_pause_and_flushwork(struct ahc_softc *ahc);1220int ahc_suspend(struct ahc_softc *ahc);1221int ahc_resume(struct ahc_softc *ahc);1222void ahc_softc_insert(struct ahc_softc *);1223void ahc_set_unit(struct ahc_softc *, int);1224void ahc_set_name(struct ahc_softc *, char *);1225int ahc_alloc_scbs(struct ahc_softc *ahc);1226void ahc_free(struct ahc_softc *ahc);1227int ahc_reset(struct ahc_softc *ahc, int reinit);1228void ahc_shutdown(void *arg);12291230/*************************** Interrupt Services *******************************/1231void ahc_clear_intstat(struct ahc_softc *ahc);1232void ahc_run_qoutfifo(struct ahc_softc *ahc);1233#ifdef AHC_TARGET_MODE1234void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);1235#endif1236void ahc_handle_brkadrint(struct ahc_softc *ahc);1237void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);1238void ahc_handle_scsiint(struct ahc_softc *ahc,1239u_int intstat);1240void ahc_clear_critical_section(struct ahc_softc *ahc);12411242/***************************** Error Recovery *********************************/1243typedef enum {1244SEARCH_COMPLETE,1245SEARCH_COUNT,1246SEARCH_REMOVE1247} ahc_search_action;1248int ahc_search_qinfifo(struct ahc_softc *ahc, int target,1249char channel, int lun, u_int tag,1250role_t role, uint32_t status,1251ahc_search_action action);1252int ahc_search_untagged_queues(struct ahc_softc *ahc,1253aic_io_ctx_t ctx,1254int target, char channel,1255int lun, uint32_t status,1256ahc_search_action action);1257int ahc_search_disc_list(struct ahc_softc *ahc, int target,1258char channel, int lun, u_int tag,1259int stop_on_first, int remove,1260int save_state);1261void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);1262int ahc_reset_channel(struct ahc_softc *ahc, char channel,1263int initiate_reset);1264int ahc_abort_scbs(struct ahc_softc *ahc, int target,1265char channel, int lun, u_int tag,1266role_t role, uint32_t status);1267void ahc_restart(struct ahc_softc *ahc);1268void ahc_calc_residual(struct ahc_softc *ahc,1269struct scb *scb);1270void ahc_timeout(struct scb *scb);1271void ahc_recover_commands(struct ahc_softc *ahc);1272/*************************** Utility Functions ********************************/1273struct ahc_phase_table_entry*1274ahc_lookup_phase_entry(int phase);1275void ahc_compile_devinfo(struct ahc_devinfo *devinfo,1276u_int our_id, u_int target,1277u_int lun, char channel,1278role_t role);1279/************************** Transfer Negotiation ******************************/1280struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,1281u_int *ppr_options, u_int maxsync);1282u_int ahc_find_period(struct ahc_softc *ahc,1283u_int scsirate, u_int maxsync);1284void ahc_validate_offset(struct ahc_softc *ahc,1285struct ahc_initiator_tinfo *tinfo,1286struct ahc_syncrate *syncrate,1287u_int *offset, int wide,1288role_t role);1289void ahc_validate_width(struct ahc_softc *ahc,1290struct ahc_initiator_tinfo *tinfo,1291u_int *bus_width,1292role_t role);1293/*1294* Negotiation types. These are used to qualify if we should renegotiate1295* even if our goal and current transport parameters are identical.1296*/1297typedef enum {1298AHC_NEG_TO_GOAL, /* Renegotiate only if goal and curr differ. */1299AHC_NEG_IF_NON_ASYNC, /* Renegotiate so long as goal is non-async. */1300AHC_NEG_ALWAYS /* Renegotiat even if goal is async. */1301} ahc_neg_type;1302int ahc_update_neg_request(struct ahc_softc*,1303struct ahc_devinfo*,1304struct ahc_tmode_tstate*,1305struct ahc_initiator_tinfo*,1306ahc_neg_type);1307void ahc_set_width(struct ahc_softc *ahc,1308struct ahc_devinfo *devinfo,1309u_int width, u_int type, int paused);1310void ahc_set_syncrate(struct ahc_softc *ahc,1311struct ahc_devinfo *devinfo,1312struct ahc_syncrate *syncrate,1313u_int period, u_int offset,1314u_int ppr_options,1315u_int type, int paused);1316typedef enum {1317AHC_QUEUE_NONE,1318AHC_QUEUE_BASIC,1319AHC_QUEUE_TAGGED1320} ahc_queue_alg;13211322void ahc_set_tags(struct ahc_softc *ahc,1323struct ahc_devinfo *devinfo,1324ahc_queue_alg alg);13251326/**************************** Target Mode *************************************/1327#ifdef AHC_TARGET_MODE1328void ahc_send_lstate_events(struct ahc_softc *,1329struct ahc_tmode_lstate *);1330void ahc_handle_en_lun(struct ahc_softc *ahc,1331struct cam_sim *sim, union ccb *ccb);1332cam_status ahc_find_tmode_devs(struct ahc_softc *ahc,1333struct cam_sim *sim, union ccb *ccb,1334struct ahc_tmode_tstate **tstate,1335struct ahc_tmode_lstate **lstate,1336int notfound_failure);1337#ifndef AHC_TMODE_ENABLE1338#define AHC_TMODE_ENABLE 01339#endif1340#endif1341/******************************* Debug ***************************************/1342#ifdef AHC_DEBUG1343extern uint32_t ahc_debug;1344#define AHC_SHOW_MISC 0x00011345#define AHC_SHOW_SENSE 0x00021346#define AHC_DUMP_SEEPROM 0x00041347#define AHC_SHOW_TERMCTL 0x00081348#define AHC_SHOW_MEMORY 0x00101349#define AHC_SHOW_MESSAGES 0x00201350#define AHC_SHOW_DV 0x00401351#define AHC_SHOW_SELTO 0x00801352#define AHC_SHOW_QFULL 0x02001353#define AHC_SHOW_QUEUE 0x04001354#define AHC_SHOW_TQIN 0x08001355#define AHC_SHOW_MASKED_ERRORS 0x10001356#define AHC_DEBUG_SEQUENCER 0x20001357#endif1358void ahc_print_scb(struct scb *scb);1359void ahc_print_devinfo(struct ahc_softc *ahc,1360struct ahc_devinfo *dev);1361void ahc_dump_card_state(struct ahc_softc *ahc);1362int ahc_print_register(ahc_reg_parse_entry_t *table,1363u_int num_entries,1364const char *name,1365u_int address,1366u_int value,1367u_int *cur_column,1368u_int wrap_point);1369/******************************* SEEPROM *************************************/1370int ahc_acquire_seeprom(struct ahc_softc *ahc,1371struct seeprom_descriptor *sd);1372void ahc_release_seeprom(struct seeprom_descriptor *sd);1373#endif /* _AIC7XXX_H_ */137413751376