Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Adaptec AIC7xxx device driver for Linux.
0003  *
0004  * Copyright (c) 1994 John Aycock
0005  *   The University of Calgary Department of Computer Science.
0006  *
0007  * This program is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU General Public License as published by
0009  * the Free Software Foundation; either version 2, or (at your option)
0010  * any later version.
0011  *
0012  * This program is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015  * GNU General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU General Public License
0018  * along with this program; see the file COPYING.  If not, write to
0019  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0020  * 
0021  * Copyright (c) 2000-2003 Adaptec Inc.
0022  * All rights reserved.
0023  *
0024  * Redistribution and use in source and binary forms, with or without
0025  * modification, are permitted provided that the following conditions
0026  * are met:
0027  * 1. Redistributions of source code must retain the above copyright
0028  *    notice, this list of conditions, and the following disclaimer,
0029  *    without modification.
0030  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0031  *    substantially similar to the "NO WARRANTY" disclaimer below
0032  *    ("Disclaimer") and any redistribution must be conditioned upon
0033  *    including a substantially similar Disclaimer requirement for further
0034  *    binary redistribution.
0035  * 3. Neither the names of the above-listed copyright holders nor the names
0036  *    of any contributors may be used to endorse or promote products derived
0037  *    from this software without specific prior written permission.
0038  *
0039  * Alternatively, this software may be distributed under the terms of the
0040  * GNU General Public License ("GPL") version 2 as published by the Free
0041  * Software Foundation.
0042  *
0043  * NO WARRANTY
0044  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0045  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0046  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
0047  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0048  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0049  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0050  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0051  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0052  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0053  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0054  * POSSIBILITY OF SUCH DAMAGES.
0055  *
0056  * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#151 $
0057  *
0058  */
0059 #ifndef _AIC7XXX_LINUX_H_
0060 #define _AIC7XXX_LINUX_H_
0061 
0062 #include <linux/types.h>
0063 #include <linux/blkdev.h>
0064 #include <linux/delay.h>
0065 #include <linux/ioport.h>
0066 #include <linux/pci.h>
0067 #include <linux/interrupt.h>
0068 #include <linux/module.h>
0069 #include <linux/slab.h>
0070 #include <asm/byteorder.h>
0071 #include <asm/io.h>
0072 
0073 #include <scsi/scsi.h>
0074 #include <scsi/scsi_cmnd.h>
0075 #include <scsi/scsi_eh.h>
0076 #include <scsi/scsi_device.h>
0077 #include <scsi/scsi_host.h>
0078 #include <scsi/scsi_tcq.h>
0079 #include <scsi/scsi_transport.h>
0080 #include <scsi/scsi_transport_spi.h>
0081 
0082 /* Core SCSI definitions */
0083 #define AIC_LIB_PREFIX ahc
0084 
0085 #include "cam.h"
0086 #include "queue.h"
0087 #include "scsi_message.h"
0088 #include "aiclib.h"
0089 
0090 /*********************************** Debugging ********************************/
0091 #ifdef CONFIG_AIC7XXX_DEBUG_ENABLE
0092 #ifdef CONFIG_AIC7XXX_DEBUG_MASK
0093 #define AHC_DEBUG 1
0094 #define AHC_DEBUG_OPTS CONFIG_AIC7XXX_DEBUG_MASK
0095 #else
0096 /*
0097  * Compile in debugging code, but do not enable any printfs.
0098  */
0099 #define AHC_DEBUG 1
0100 #endif
0101 /* No debugging code. */
0102 #endif
0103 
0104 /************************* Forward Declarations *******************************/
0105 struct ahc_softc;
0106 typedef struct pci_dev *ahc_dev_softc_t;
0107 typedef struct scsi_cmnd      *ahc_io_ctx_t;
0108 
0109 /******************************* Byte Order ***********************************/
0110 #define ahc_htobe16(x)  cpu_to_be16(x)
0111 #define ahc_htobe32(x)  cpu_to_be32(x)
0112 #define ahc_htobe64(x)  cpu_to_be64(x)
0113 #define ahc_htole16(x)  cpu_to_le16(x)
0114 #define ahc_htole32(x)  cpu_to_le32(x)
0115 #define ahc_htole64(x)  cpu_to_le64(x)
0116 
0117 #define ahc_be16toh(x)  be16_to_cpu(x)
0118 #define ahc_be32toh(x)  be32_to_cpu(x)
0119 #define ahc_be64toh(x)  be64_to_cpu(x)
0120 #define ahc_le16toh(x)  le16_to_cpu(x)
0121 #define ahc_le32toh(x)  le32_to_cpu(x)
0122 #define ahc_le64toh(x)  le64_to_cpu(x)
0123 
0124 /************************* Configuration Data *********************************/
0125 extern u_int aic7xxx_no_probe;
0126 extern u_int aic7xxx_allow_memio;
0127 extern struct scsi_host_template aic7xxx_driver_template;
0128 
0129 /***************************** Bus Space/DMA **********************************/
0130 
0131 typedef uint32_t bus_size_t;
0132 
0133 typedef enum {
0134     BUS_SPACE_MEMIO,
0135     BUS_SPACE_PIO
0136 } bus_space_tag_t;
0137 
0138 typedef union {
0139     u_long        ioport;
0140     volatile uint8_t __iomem *maddr;
0141 } bus_space_handle_t;
0142 
0143 typedef struct bus_dma_segment
0144 {
0145     dma_addr_t  ds_addr;
0146     bus_size_t  ds_len;
0147 } bus_dma_segment_t;
0148 
0149 struct ahc_linux_dma_tag
0150 {
0151     bus_size_t  alignment;
0152     bus_size_t  boundary;
0153     bus_size_t  maxsize;
0154 };
0155 typedef struct ahc_linux_dma_tag* bus_dma_tag_t;
0156 
0157 typedef dma_addr_t bus_dmamap_t;
0158 
0159 typedef int bus_dma_filter_t(void*, dma_addr_t);
0160 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
0161 
0162 #define BUS_DMA_WAITOK      0x0
0163 #define BUS_DMA_NOWAIT      0x1
0164 #define BUS_DMA_ALLOCNOW    0x2
0165 #define BUS_DMA_LOAD_SEGS   0x4 /*
0166                      * Argument is an S/G list not
0167                      * a single buffer.
0168                      */
0169 
0170 #define BUS_SPACE_MAXADDR   0xFFFFFFFF
0171 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
0172 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
0173 
0174 int ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/,
0175                bus_size_t /*alignment*/, bus_size_t /*boundary*/,
0176                dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/,
0177                bus_dma_filter_t*/*filter*/, void */*filterarg*/,
0178                bus_size_t /*maxsize*/, int /*nsegments*/,
0179                bus_size_t /*maxsegsz*/, int /*flags*/,
0180                bus_dma_tag_t */*dma_tagp*/);
0181 
0182 void    ahc_dma_tag_destroy(struct ahc_softc *, bus_dma_tag_t /*tag*/);
0183 
0184 int ahc_dmamem_alloc(struct ahc_softc *, bus_dma_tag_t /*dmat*/,
0185              void** /*vaddr*/, int /*flags*/,
0186              bus_dmamap_t* /*mapp*/);
0187 
0188 void    ahc_dmamem_free(struct ahc_softc *, bus_dma_tag_t /*dmat*/,
0189             void* /*vaddr*/, bus_dmamap_t /*map*/);
0190 
0191 void    ahc_dmamap_destroy(struct ahc_softc *, bus_dma_tag_t /*tag*/,
0192                bus_dmamap_t /*map*/);
0193 
0194 int ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t /*dmat*/,
0195             bus_dmamap_t /*map*/, void * /*buf*/,
0196             bus_size_t /*buflen*/, bus_dmamap_callback_t *,
0197             void */*callback_arg*/, int /*flags*/);
0198 
0199 int ahc_dmamap_unload(struct ahc_softc *, bus_dma_tag_t, bus_dmamap_t);
0200 
0201 /*
0202  * Operations performed by ahc_dmamap_sync().
0203  */
0204 #define BUS_DMASYNC_PREREAD 0x01    /* pre-read synchronization */
0205 #define BUS_DMASYNC_POSTREAD    0x02    /* post-read synchronization */
0206 #define BUS_DMASYNC_PREWRITE    0x04    /* pre-write synchronization */
0207 #define BUS_DMASYNC_POSTWRITE   0x08    /* post-write synchronization */
0208 
0209 /*
0210  * XXX
0211  * ahc_dmamap_sync is only used on buffers allocated with
0212  * the dma_alloc_coherent() API.  Although I'm not sure how
0213  * this works on architectures with a write buffer, Linux does
0214  * not have an API to sync "coherent" memory.  Perhaps we need
0215  * to do an mb()?
0216  */
0217 #define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op)
0218 
0219 /********************************** Includes **********************************/
0220 #ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT
0221 #define AIC_DEBUG_REGISTERS 1
0222 #else
0223 #define AIC_DEBUG_REGISTERS 0
0224 #endif
0225 #include "aic7xxx.h"
0226 
0227 /***************************** Timer Facilities *******************************/
0228 static inline void
0229 ahc_scb_timer_reset(struct scb *scb, u_int usec)
0230 {
0231 }
0232 
0233 /***************************** SMP support ************************************/
0234 #include <linux/spinlock.h>
0235 
0236 #define AIC7XXX_DRIVER_VERSION "7.0"
0237 
0238 /*************************** Device Data Structures ***************************/
0239 /*
0240  * A per probed device structure used to deal with some error recovery
0241  * scenarios that the Linux mid-layer code just doesn't know how to
0242  * handle.  The structure allocated for a device only becomes persistent
0243  * after a successfully completed inquiry command to the target when
0244  * that inquiry data indicates a lun is present.
0245  */
0246 typedef enum {
0247     AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */
0248     AHC_DEV_Q_BASIC      = 0x10, /* Allow basic device queuing */
0249     AHC_DEV_Q_TAGGED     = 0x20, /* Allow full SCSI2 command queueing */
0250     AHC_DEV_PERIODIC_OTAG    = 0x40, /* Send OTAG to prevent starvation */
0251 } ahc_linux_dev_flags;
0252 
0253 struct ahc_linux_device {
0254     /*
0255      * The number of transactions currently
0256      * queued to the device.
0257      */
0258     int         active;
0259 
0260     /*
0261      * The currently allowed number of
0262      * transactions that can be queued to
0263      * the device.  Must be signed for
0264      * conversion from tagged to untagged
0265      * mode where the device may have more
0266      * than one outstanding active transaction.
0267      */
0268     int         openings;
0269 
0270     /*
0271      * A positive count indicates that this
0272      * device's queue is halted.
0273      */
0274     u_int           qfrozen;
0275 
0276     /*
0277      * Cumulative command counter.
0278      */
0279     u_long          commands_issued;
0280 
0281     /*
0282      * The number of tagged transactions when
0283      * running at our current opening level
0284      * that have been successfully received by
0285      * this device since the last QUEUE FULL.
0286      */
0287     u_int           tag_success_count;
0288 #define AHC_TAG_SUCCESS_INTERVAL 50
0289 
0290     ahc_linux_dev_flags flags;
0291 
0292     /*
0293      * The high limit for the tags variable.
0294      */
0295     u_int           maxtags;
0296 
0297     /*
0298      * The computed number of tags outstanding
0299      * at the time of the last QUEUE FULL event.
0300      */
0301     u_int           tags_on_last_queuefull;
0302 
0303     /*
0304      * How many times we have seen a queue full
0305      * with the same number of tags.  This is used
0306      * to stop our adaptive queue depth algorithm
0307      * on devices with a fixed number of tags.
0308      */
0309     u_int           last_queuefull_same_count;
0310 #define AHC_LOCK_TAGS_COUNT 50
0311 
0312     /*
0313      * How many transactions have been queued
0314      * without the device going idle.  We use
0315      * this statistic to determine when to issue
0316      * an ordered tag to prevent transaction
0317      * starvation.  This statistic is only updated
0318      * if the AHC_DEV_PERIODIC_OTAG flag is set
0319      * on this device.
0320      */
0321     u_int           commands_since_idle_or_otag;
0322 #define AHC_OTAG_THRESH 500
0323 };
0324 
0325 /********************* Definitions Required by the Core ***********************/
0326 /*
0327  * Number of SG segments we require.  So long as the S/G segments for
0328  * a particular transaction are allocated in a physically contiguous
0329  * manner and are allocated below 4GB, the number of S/G segments is
0330  * unrestricted.
0331  */
0332 #define AHC_NSEG 128
0333 
0334 /*
0335  * Per-SCB OSM storage.
0336  */
0337 struct scb_platform_data {
0338     struct ahc_linux_device *dev;
0339     dma_addr_t       buf_busaddr;
0340     uint32_t         xfer_len;
0341     uint32_t         sense_resid;   /* Auto-Sense residual */
0342 };
0343 
0344 /*
0345  * Define a structure used for each host adapter.  All members are
0346  * aligned on a boundary >= the size of the member to honor the
0347  * alignment restrictions of the various platforms supported by
0348  * this driver.
0349  */
0350 struct ahc_platform_data {
0351     /*
0352      * Fields accessed from interrupt context.
0353      */
0354     struct scsi_target *starget[AHC_NUM_TARGETS];
0355 
0356     spinlock_t       spin_lock;
0357     u_int            qfrozen;
0358     struct completion   *eh_done;
0359     struct Scsi_Host    *host;      /* pointer to scsi host */
0360 #define AHC_LINUX_NOIRQ ((uint32_t)~0)
0361     uint32_t         irq;       /* IRQ for this adapter */
0362     uint32_t         bios_address;
0363     resource_size_t      mem_busaddr;   /* Mem Base Addr */
0364 };
0365 
0366 void ahc_delay(long);
0367 
0368 
0369 /***************************** Low Level I/O **********************************/
0370 uint8_t ahc_inb(struct ahc_softc * ahc, long port);
0371 void ahc_outb(struct ahc_softc * ahc, long port, uint8_t val);
0372 void ahc_outsb(struct ahc_softc * ahc, long port,
0373            uint8_t *, int count);
0374 void ahc_insb(struct ahc_softc * ahc, long port,
0375            uint8_t *, int count);
0376 
0377 /**************************** Initialization **********************************/
0378 int     ahc_linux_register_host(struct ahc_softc *,
0379                     struct scsi_host_template *);
0380 
0381 /******************************** Locking *************************************/
0382 /* Lock protecting internal data structures */
0383 
0384 static inline void
0385 ahc_lockinit(struct ahc_softc *ahc)
0386 {
0387     spin_lock_init(&ahc->platform_data->spin_lock);
0388 }
0389 
0390 static inline void
0391 ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
0392 {
0393     spin_lock_irqsave(&ahc->platform_data->spin_lock, *flags);
0394 }
0395 
0396 static inline void
0397 ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
0398 {
0399     spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags);
0400 }
0401 
0402 /******************************* PCI Definitions ******************************/
0403 /*
0404  * PCIM_xxx: mask to locate subfield in register
0405  * PCIR_xxx: config register offset
0406  * PCIC_xxx: device class
0407  * PCIS_xxx: device subclass
0408  * PCIP_xxx: device programming interface
0409  * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices)
0410  * PCID_xxx: device ID
0411  */
0412 #define PCIR_DEVVENDOR      0x00
0413 #define PCIR_VENDOR     0x00
0414 #define PCIR_DEVICE     0x02
0415 #define PCIR_COMMAND        0x04
0416 #define PCIM_CMD_PORTEN     0x0001
0417 #define PCIM_CMD_MEMEN      0x0002
0418 #define PCIM_CMD_BUSMASTEREN    0x0004
0419 #define PCIM_CMD_MWRICEN    0x0010
0420 #define PCIM_CMD_PERRESPEN  0x0040
0421 #define PCIM_CMD_SERRESPEN  0x0100
0422 #define PCIR_STATUS     0x06
0423 #define PCIR_REVID      0x08
0424 #define PCIR_PROGIF     0x09
0425 #define PCIR_SUBCLASS       0x0a
0426 #define PCIR_CLASS      0x0b
0427 #define PCIR_CACHELNSZ      0x0c
0428 #define PCIR_LATTIMER       0x0d
0429 #define PCIR_HEADERTYPE     0x0e
0430 #define PCIM_MFDEV      0x80
0431 #define PCIR_BIST       0x0f
0432 #define PCIR_CAP_PTR        0x34
0433 
0434 /* config registers for header type 0 devices */
0435 #define PCIR_MAPS   0x10
0436 
0437 typedef enum
0438 {
0439     AHC_POWER_STATE_D0,
0440     AHC_POWER_STATE_D1,
0441     AHC_POWER_STATE_D2,
0442     AHC_POWER_STATE_D3
0443 } ahc_power_state;
0444 
0445 /**************************** VL/EISA Routines ********************************/
0446 #ifdef CONFIG_EISA
0447 int          ahc_linux_eisa_init(void);
0448 void             ahc_linux_eisa_exit(void);
0449 int          aic7770_map_registers(struct ahc_softc *ahc,
0450                            u_int port);
0451 int          aic7770_map_int(struct ahc_softc *ahc, u_int irq);
0452 #else
0453 static inline int   ahc_linux_eisa_init(void) {
0454     return -ENODEV;
0455 }
0456 static inline void  ahc_linux_eisa_exit(void) {
0457 }
0458 #endif
0459 
0460 /******************************* PCI Routines *********************************/
0461 #ifdef CONFIG_PCI
0462 int          ahc_linux_pci_init(void);
0463 void             ahc_linux_pci_exit(void);
0464 int          ahc_pci_map_registers(struct ahc_softc *ahc);
0465 int          ahc_pci_map_int(struct ahc_softc *ahc);
0466 
0467 uint32_t         ahc_pci_read_config(ahc_dev_softc_t pci,
0468                          int reg, int width);
0469 
0470 void             ahc_pci_write_config(ahc_dev_softc_t pci,
0471                           int reg, uint32_t value,
0472                           int width);
0473 
0474 static inline int ahc_get_pci_function(ahc_dev_softc_t);
0475 static inline int
0476 ahc_get_pci_function(ahc_dev_softc_t pci)
0477 {
0478     return (PCI_FUNC(pci->devfn));
0479 }
0480 
0481 static inline int ahc_get_pci_slot(ahc_dev_softc_t);
0482 static inline int
0483 ahc_get_pci_slot(ahc_dev_softc_t pci)
0484 {
0485     return (PCI_SLOT(pci->devfn));
0486 }
0487 
0488 static inline int ahc_get_pci_bus(ahc_dev_softc_t);
0489 static inline int
0490 ahc_get_pci_bus(ahc_dev_softc_t pci)
0491 {
0492     return (pci->bus->number);
0493 }
0494 #else
0495 static inline int ahc_linux_pci_init(void) {
0496     return 0;
0497 }
0498 static inline void ahc_linux_pci_exit(void) {
0499 }
0500 #endif
0501 
0502 static inline void ahc_flush_device_writes(struct ahc_softc *);
0503 static inline void
0504 ahc_flush_device_writes(struct ahc_softc *ahc)
0505 {
0506     /* XXX Is this sufficient for all architectures??? */
0507     ahc_inb(ahc, INTSTAT);
0508 }
0509 
0510 /**************************** Proc FS Support *********************************/
0511 int ahc_proc_write_seeprom(struct Scsi_Host *, char *, int);
0512 int ahc_linux_show_info(struct seq_file *, struct Scsi_Host *);
0513 
0514 /*************************** Domain Validation ********************************/
0515 /*********************** Transaction Access Wrappers *************************/
0516 
0517 static inline
0518 void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status)
0519 {
0520     cmd->result &= ~(CAM_STATUS_MASK << 16);
0521     cmd->result |= status << 16;
0522 }
0523 
0524 static inline
0525 void ahc_set_transaction_status(struct scb *scb, uint32_t status)
0526 {
0527     ahc_cmd_set_transaction_status(scb->io_ctx,status);
0528 }
0529 
0530 static inline
0531 void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
0532 {
0533     cmd->result &= ~0xFFFF;
0534     cmd->result |= status;
0535 }
0536 
0537 static inline
0538 void ahc_set_scsi_status(struct scb *scb, uint32_t status)
0539 {
0540     ahc_cmd_set_scsi_status(scb->io_ctx, status);
0541 }
0542 
0543 static inline
0544 uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd)
0545 {
0546     return ((cmd->result >> 16) & CAM_STATUS_MASK);
0547 }
0548 
0549 static inline
0550 uint32_t ahc_get_transaction_status(struct scb *scb)
0551 {
0552     return (ahc_cmd_get_transaction_status(scb->io_ctx));
0553 }
0554 
0555 static inline
0556 uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd)
0557 {
0558     return (cmd->result & 0xFFFF);
0559 }
0560 
0561 static inline
0562 uint32_t ahc_get_scsi_status(struct scb *scb)
0563 {
0564     return (ahc_cmd_get_scsi_status(scb->io_ctx));
0565 }
0566 
0567 static inline
0568 void ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type)
0569 {
0570     /*
0571      * Nothing to do for linux as the incoming transaction
0572      * has no concept of tag/non tagged, etc.
0573      */
0574 }
0575 
0576 static inline
0577 u_long ahc_get_transfer_length(struct scb *scb)
0578 {
0579     return (scb->platform_data->xfer_len);
0580 }
0581 
0582 static inline
0583 int ahc_get_transfer_dir(struct scb *scb)
0584 {
0585     return (scb->io_ctx->sc_data_direction);
0586 }
0587 
0588 static inline
0589 void ahc_set_residual(struct scb *scb, u_long resid)
0590 {
0591     scsi_set_resid(scb->io_ctx, resid);
0592 }
0593 
0594 static inline
0595 void ahc_set_sense_residual(struct scb *scb, u_long resid)
0596 {
0597     scb->platform_data->sense_resid = resid;
0598 }
0599 
0600 static inline
0601 u_long ahc_get_residual(struct scb *scb)
0602 {
0603     return scsi_get_resid(scb->io_ctx);
0604 }
0605 
0606 static inline
0607 u_long ahc_get_sense_residual(struct scb *scb)
0608 {
0609     return (scb->platform_data->sense_resid);
0610 }
0611 
0612 static inline
0613 int ahc_perform_autosense(struct scb *scb)
0614 {
0615     /*
0616      * We always perform autosense in Linux.
0617      * On other platforms this is set on a
0618      * per-transaction basis.
0619      */
0620     return (1);
0621 }
0622 
0623 static inline uint32_t
0624 ahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb)
0625 {
0626     return (sizeof(struct scsi_sense_data));
0627 }
0628 
0629 static inline void
0630 ahc_notify_xfer_settings_change(struct ahc_softc *ahc,
0631                 struct ahc_devinfo *devinfo)
0632 {
0633     /* Nothing to do here for linux */
0634 }
0635 
0636 static inline void
0637 ahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb)
0638 {
0639 }
0640 
0641 int ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg);
0642 void    ahc_platform_free(struct ahc_softc *ahc);
0643 void    ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
0644 
0645 static inline void
0646 ahc_freeze_scb(struct scb *scb)
0647 {
0648     if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) {
0649         scb->io_ctx->result |= CAM_DEV_QFRZN << 16;
0650         scb->platform_data->dev->qfrozen++;
0651     }
0652 }
0653 
0654 void    ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
0655                   struct ahc_devinfo *devinfo, ahc_queue_alg);
0656 int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
0657                 char channel, int lun, u_int tag,
0658                 role_t role, uint32_t status);
0659 irqreturn_t
0660     ahc_linux_isr(int irq, void *dev_id);
0661 void    ahc_platform_flushwork(struct ahc_softc *ahc);
0662 void    ahc_done(struct ahc_softc*, struct scb*);
0663 void    ahc_send_async(struct ahc_softc *, char channel,
0664                u_int target, u_int lun, ac_code);
0665 void    ahc_print_path(struct ahc_softc *, struct scb *);
0666 
0667 #ifdef CONFIG_PCI
0668 #define AHC_PCI_CONFIG 1
0669 #else
0670 #define AHC_PCI_CONFIG 0
0671 #endif
0672 #define bootverbose aic7xxx_verbose
0673 extern u_int aic7xxx_verbose;
0674 #endif /* _AIC7XXX_LINUX_H_ */