linux-bk/drivers/scsi/sym53c8xx_2/sym_glue.h
<<
>>
Prefs
   1/*
   2 * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family 
   3 * of PCI-SCSI IO processors.
   4 *
   5 * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
   6 *
   7 * This driver is derived from the Linux sym53c8xx driver.
   8 * Copyright (C) 1998-2000  Gerard Roudier
   9 *
  10 * The sym53c8xx driver is derived from the ncr53c8xx driver that had been 
  11 * a port of the FreeBSD ncr driver to Linux-1.2.13.
  12 *
  13 * The original ncr driver has been written for 386bsd and FreeBSD by
  14 *         Wolfgang Stanglmeier        <wolf@cologne.de>
  15 *         Stefan Esser                <se@mi.Uni-Koeln.de>
  16 * Copyright (C) 1994  Wolfgang Stanglmeier
  17 *
  18 * Other major contributions:
  19 *
  20 * NVRAM detection and reading.
  21 * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  22 *
  23 *-----------------------------------------------------------------------------
  24 *
  25 * Redistribution and use in source and binary forms, with or without
  26 * modification, are permitted provided that the following conditions
  27 * are met:
  28 * 1. Redistributions of source code must retain the above copyright
  29 *    notice, this list of conditions and the following disclaimer.
  30 * 2. The name of the author may not be used to endorse or promote products
  31 *    derived from this software without specific prior written permission.
  32 *
  33 * Where this Software is combined with software released under the terms of 
  34 * the GNU Public License ("GPL") and the terms of the GPL would require the 
  35 * combined work to also be released under the terms of the GPL, the terms
  36 * and conditions of this License will apply in addition to those of the
  37 * GPL with the exception of any terms or conditions of this License that
  38 * conflict with, or are expressly prohibited by, the GPL.
  39 *
  40 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
  41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  44 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50 * SUCH DAMAGE.
  51 */
  52
  53#ifndef SYM_GLUE_H
  54#define SYM_GLUE_H
  55
  56#if 0
  57#define SYM_CONF_DMA_ADDRESSING_MODE 2
  58#endif
  59
  60#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
  61#include <linux/version.h>
  62#if     LINUX_VERSION_CODE < LinuxVersionCode(2, 2, 0)
  63#error  "This driver requires a kernel version not lower than 2.2.0"
  64#endif
  65
  66#include <asm/dma.h>
  67#include <asm/io.h>
  68#include <asm/system.h>
  69#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
  70#include <linux/spinlock.h>
  71#else
  72#include <asm/spinlock.h>
  73#endif
  74#include <linux/delay.h>
  75#include <linux/signal.h>
  76#include <linux/sched.h>
  77#include <linux/errno.h>
  78#include <linux/pci.h>
  79#include <linux/string.h>
  80#include <linux/mm.h>
  81#include <linux/ioport.h>
  82#include <linux/time.h>
  83#include <linux/timer.h>
  84#include <linux/stat.h>
  85#include <linux/interrupt.h>
  86
  87#include <linux/blk.h>
  88
  89#ifdef __sparc__
  90#  include <asm/irq.h>
  91#endif
  92#include <linux/init.h>
  93
  94#ifndef __init
  95#define __init
  96#endif
  97#ifndef __initdata
  98#define __initdata
  99#endif
 100
 101#include "../scsi.h"
 102#include "../hosts.h"
 103
 104#include <linux/types.h>
 105
 106/*
 107 *  Define BITS_PER_LONG for earlier linux versions.
 108 */
 109#ifndef BITS_PER_LONG
 110#if (~0UL) == 0xffffffffUL
 111#define BITS_PER_LONG   32
 112#else
 113#define BITS_PER_LONG   64
 114#endif
 115#endif
 116
 117typedef u_long  vm_offset_t;
 118
 119#ifndef bcopy
 120#define bcopy(s, d, n)  memcpy((d), (s), (n))
 121#endif
 122
 123#ifndef bzero
 124#define bzero(d, n)     memset((d), 0, (n))
 125#endif
 126
 127#ifndef bcmp
 128#define bcmp(a, b, n)   memcmp((a), (b), (n))
 129#endif
 130
 131/*
 132 *  General driver includes.
 133 */
 134#include "sym53c8xx.h"
 135#include "sym_misc.h"
 136#include "sym_conf.h"
 137#include "sym_defs.h"
 138
 139/*
 140 * Configuration addendum for Linux.
 141 */
 142#if     LINUX_VERSION_CODE >= LinuxVersionCode(2,3,47)
 143#define SYM_LINUX_DYNAMIC_DMA_MAPPING
 144#endif
 145
 146#define SYM_CONF_TIMER_INTERVAL         ((HZ+1)/2)
 147
 148#define SYM_OPT_HANDLE_DIR_UNKNOWN
 149#define SYM_OPT_HANDLE_DEVICE_QUEUEING
 150#define SYM_OPT_NVRAM_PRE_READ
 151#define SYM_OPT_SNIFF_INQUIRY
 152#define SYM_OPT_LIMIT_COMMAND_REORDERING
 153#define SYM_OPT_ANNOUNCE_TRANSFER_RATE
 154
 155#ifdef  SYM_LINUX_DYNAMIC_DMA_MAPPING
 156#define SYM_OPT_BUS_DMA_ABSTRACTION
 157#endif
 158
 159/*
 160 *  Print a message with severity.
 161 */
 162#define printf_emerg(args...)   printk(KERN_EMERG args)
 163#define printf_alert(args...)   printk(KERN_ALERT args)
 164#define printf_crit(args...)    printk(KERN_CRIT args)
 165#define printf_err(args...)     printk(KERN_ERR args)
 166#define printf_warning(args...) printk(KERN_WARNING args)
 167#define printf_notice(args...)  printk(KERN_NOTICE args)
 168#define printf_info(args...)    printk(KERN_INFO args)
 169#define printf_debug(args...)   printk(KERN_DEBUG args)
 170#define printf(args...)         printk(args)
 171
 172/*
 173 *  Insert a delay in micro-seconds and milli-seconds.
 174 */
 175void sym_udelay(int us);
 176void sym_mdelay(int ms);
 177
 178/*
 179 *  Let the compiler know about driver data structure names.
 180 */
 181typedef struct sym_tcb *tcb_p;
 182typedef struct sym_lcb *lcb_p;
 183typedef struct sym_ccb *ccb_p;
 184typedef struct sym_hcb *hcb_p;
 185typedef struct sym_stcb *stcb_p;
 186typedef struct sym_slcb *slcb_p;
 187typedef struct sym_sccb *sccb_p;
 188typedef struct sym_shcb *shcb_p;
 189
 190/*
 191 *  Define a reference to the O/S dependant IO request.
 192 */
 193typedef Scsi_Cmnd *cam_ccb_p;   /* Generic */
 194typedef Scsi_Cmnd *cam_scsiio_p;/* SCSI I/O */
 195
 196
 197/*
 198 *  IO functions definition for big/little endian CPU support.
 199 *  For now, PCI chips are only supported in little endian addressing mode, 
 200 */
 201
 202#ifdef  __BIG_ENDIAN
 203
 204#define inw_l2b         inw
 205#define inl_l2b         inl
 206#define outw_b2l        outw
 207#define outl_b2l        outl
 208#define readw_l2b       readw
 209#define readl_l2b       readl
 210#define writew_b2l      writew
 211#define writel_b2l      writel
 212
 213#else   /* little endian */
 214
 215#if defined(__i386__)   /* i386 implements full FLAT memory/MMIO model */
 216#define inw_raw         inw
 217#define inl_raw         inl
 218#define outw_raw        outw
 219#define outl_raw        outl
 220#define readb_raw(a)    (*(volatile unsigned char *) (a))
 221#define readw_raw(a)    (*(volatile unsigned short *) (a))
 222#define readl_raw(a)    (*(volatile unsigned int *) (a))
 223#define writeb_raw(b,a) ((*(volatile unsigned char *) (a)) = (b))
 224#define writew_raw(b,a) ((*(volatile unsigned short *) (a)) = (b))
 225#define writel_raw(b,a) ((*(volatile unsigned int *) (a)) = (b))
 226
 227#else   /* Other little-endian */
 228#define inw_raw         inw
 229#define inl_raw         inl
 230#define outw_raw        outw
 231#define outl_raw        outl
 232#define readw_raw       readw
 233#define readl_raw       readl
 234#define writew_raw      writew
 235#define writel_raw      writel
 236
 237#endif
 238#endif
 239
 240#ifdef  SYM_CONF_CHIP_BIG_ENDIAN
 241#error  "Chips in BIG ENDIAN addressing mode are not (yet) supported"
 242#endif
 243
 244
 245/*
 246 *  If the chip uses big endian addressing mode over the 
 247 *  PCI, actual io register addresses for byte and word 
 248 *  accesses must be changed according to lane routing.
 249 *  Btw, sym_offb() and sym_offw() macros only apply to 
 250 *  constants and so donnot generate bloated code.
 251 */
 252
 253#if     defined(SYM_CONF_CHIP_BIG_ENDIAN)
 254
 255#define sym_offb(o)     (((o)&~3)+((~((o)&3))&3))
 256#define sym_offw(o)     (((o)&~3)+((~((o)&3))&2))
 257
 258#else
 259
 260#define sym_offb(o)     (o)
 261#define sym_offw(o)     (o)
 262
 263#endif
 264
 265/*
 266 *  If the CPU and the chip use same endian-ness adressing,
 267 *  no byte reordering is needed for script patching.
 268 *  Macro cpu_to_scr() is to be used for script patching.
 269 *  Macro scr_to_cpu() is to be used for getting a DWORD 
 270 *  from the script.
 271 */
 272
 273#if     defined(__BIG_ENDIAN) && !defined(SYM_CONF_CHIP_BIG_ENDIAN)
 274
 275#define cpu_to_scr(dw)  cpu_to_le32(dw)
 276#define scr_to_cpu(dw)  le32_to_cpu(dw)
 277
 278#elif   defined(__LITTLE_ENDIAN) && defined(SYM_CONF_CHIP_BIG_ENDIAN)
 279
 280#define cpu_to_scr(dw)  cpu_to_be32(dw)
 281#define scr_to_cpu(dw)  be32_to_cpu(dw)
 282
 283#else
 284
 285#define cpu_to_scr(dw)  (dw)
 286#define scr_to_cpu(dw)  (dw)
 287
 288#endif
 289
 290/*
 291 *  Access to the controller chip.
 292 *
 293 *  If SYM_CONF_IOMAPPED is defined, the driver will use 
 294 *  normal IOs instead of the MEMORY MAPPED IO method  
 295 *  recommended by PCI specifications.
 296 *  If all PCI bridges, host brigdes and architectures 
 297 *  would have been correctly designed for PCI, this 
 298 *  option would be useless.
 299 *
 300 *  If the CPU and the chip use same endian-ness adressing,
 301 *  no byte reordering is needed for accessing chip io 
 302 *  registers. Functions suffixed by '_raw' are assumed 
 303 *  to access the chip over the PCI without doing byte 
 304 *  reordering. Functions suffixed by '_l2b' are 
 305 *  assumed to perform little-endian to big-endian byte 
 306 *  reordering, those suffixed by '_b2l' blah, blah,
 307 *  blah, ...
 308 */
 309
 310#if defined(SYM_CONF_IOMAPPED)
 311
 312/*
 313 *  IO mapped only input / ouput
 314 */
 315
 316#define INB_OFF(o)        inb (np->s.io_port + sym_offb(o))
 317#define OUTB_OFF(o, val)  outb ((val), np->s.io_port + sym_offb(o))
 318
 319#if     defined(__BIG_ENDIAN) && !defined(SYM_CONF_CHIP_BIG_ENDIAN)
 320
 321#define INW_OFF(o)        inw_l2b (np->s.io_port + sym_offw(o))
 322#define INL_OFF(o)        inl_l2b (np->s.io_port + (o))
 323
 324#define OUTW_OFF(o, val)  outw_b2l ((val), np->s.io_port + sym_offw(o))
 325#define OUTL_OFF(o, val)  outl_b2l ((val), np->s.io_port + (o))
 326
 327#elif   defined(__LITTLE_ENDIAN) && defined(SYM_CONF_CHIP_BIG_ENDIAN)
 328
 329#define INW_OFF(o)        inw_b2l (np->s.io_port + sym_offw(o))
 330#define INL_OFF(o)        inl_b2l (np->s.io_port + (o))
 331
 332#define OUTW_OFF(o, val)  outw_l2b ((val), np->s.io_port + sym_offw(o))
 333#define OUTL_OFF(o, val)  outl_l2b ((val), np->s.io_port + (o))
 334
 335#else
 336
 337#define INW_OFF(o)        inw_raw (np->s.io_port + sym_offw(o))
 338#define INL_OFF(o)        inl_raw (np->s.io_port + (o))
 339
 340#define OUTW_OFF(o, val)  outw_raw ((val), np->s.io_port + sym_offw(o))
 341#define OUTL_OFF(o, val)  outl_raw ((val), np->s.io_port + (o))
 342
 343#endif  /* ENDIANs */
 344
 345#else   /* defined SYM_CONF_IOMAPPED */
 346
 347/*
 348 *  MEMORY mapped IO input / output
 349 */
 350
 351#define INB_OFF(o)        readb((char *)np->s.mmio_va + sym_offb(o))
 352#define OUTB_OFF(o, val)  writeb((val), (char *)np->s.mmio_va + sym_offb(o))
 353
 354#if     defined(__BIG_ENDIAN) && !defined(SYM_CONF_CHIP_BIG_ENDIAN)
 355
 356#define INW_OFF(o)        readw_l2b((char *)np->s.mmio_va + sym_offw(o))
 357#define INL_OFF(o)        readl_l2b((char *)np->s.mmio_va + (o))
 358
 359#define OUTW_OFF(o, val)  writew_b2l((val), (char *)np->s.mmio_va + sym_offw(o))
 360#define OUTL_OFF(o, val)  writel_b2l((val), (char *)np->s.mmio_va + (o))
 361
 362#elif   defined(__LITTLE_ENDIAN) && defined(SYM_CONF_CHIP_BIG_ENDIAN)
 363
 364#define INW_OFF(o)        readw_b2l((char *)np->s.mmio_va + sym_offw(o))
 365#define INL_OFF(o)        readl_b2l((char *)np->s.mmio_va + (o))
 366
 367#define OUTW_OFF(o, val)  writew_l2b((val), (char *)np->s.mmio_va + sym_offw(o))
 368#define OUTL_OFF(o, val)  writel_l2b((val), (char *)np->s.mmio_va + (o))
 369
 370#else
 371
 372#define INW_OFF(o)        readw_raw((char *)np->s.mmio_va + sym_offw(o))
 373#define INL_OFF(o)        readl_raw((char *)np->s.mmio_va + (o))
 374
 375#define OUTW_OFF(o, val)  writew_raw((val), (char *)np->s.mmio_va + sym_offw(o))
 376#define OUTL_OFF(o, val)  writel_raw((val), (char *)np->s.mmio_va + (o))
 377
 378#endif
 379
 380#endif  /* defined SYM_CONF_IOMAPPED */
 381
 382#define OUTRAM_OFF(o, a, l) memcpy_toio(np->s.ram_va + (o), (a), (l))
 383
 384/*
 385 *  Remap some status field values.
 386 */
 387#define CAM_REQ_CMP             DID_OK
 388#define CAM_SEL_TIMEOUT         DID_NO_CONNECT
 389#define CAM_CMD_TIMEOUT         DID_TIME_OUT
 390#define CAM_REQ_ABORTED         DID_ABORT
 391#define CAM_UNCOR_PARITY        DID_PARITY
 392#define CAM_SCSI_BUS_RESET      DID_RESET       
 393#define CAM_REQUEUE_REQ         DID_SOFT_ERROR
 394#define CAM_UNEXP_BUSFREE       DID_ERROR
 395#define CAM_SCSI_BUSY           DID_BUS_BUSY
 396
 397#define CAM_DEV_NOT_THERE       DID_NO_CONNECT
 398#define CAM_REQ_INVALID         DID_ERROR
 399#define CAM_REQ_TOO_BIG         DID_ERROR
 400
 401#define CAM_RESRC_UNAVAIL       DID_ERROR
 402
 403/*
 404 *  Remap SCSI data direction values.
 405 */
 406#ifndef SCSI_DATA_UNKNOWN
 407#define SCSI_DATA_UNKNOWN       0
 408#define SCSI_DATA_WRITE         1
 409#define SCSI_DATA_READ          2
 410#define SCSI_DATA_NONE          3
 411#endif
 412#define CAM_DIR_NONE            SCSI_DATA_NONE
 413#define CAM_DIR_IN              SCSI_DATA_READ
 414#define CAM_DIR_OUT             SCSI_DATA_WRITE
 415#define CAM_DIR_UNKNOWN         SCSI_DATA_UNKNOWN
 416
 417/*
 418 *  These ones are used as return code from 
 419 *  error recovery handlers under Linux.
 420 */
 421#define SCSI_SUCCESS    SUCCESS
 422#define SCSI_FAILED     FAILED
 423
 424/*
 425 *  System specific target data structure.
 426 *  None for now, under Linux.
 427 */
 428/* #define SYM_HAVE_STCB */
 429
 430/*
 431 *  System specific lun data structure.
 432 */
 433#define SYM_HAVE_SLCB
 434struct sym_slcb {
 435        u_short reqtags;        /* Number of tags requested by user */
 436        u_short scdev_depth;    /* Queue depth set in select_queue_depth() */
 437};
 438
 439/*
 440 *  System specific command data structure.
 441 *  Not needed under Linux.
 442 */
 443/* struct sym_sccb */
 444
 445/*
 446 *  System specific host data structure.
 447 */
 448struct sym_shcb {
 449        /*
 450         *  Chip and controller indentification.
 451         */
 452        int             unit;
 453        char            inst_name[16];
 454        char            chip_name[8];
 455        struct pci_dev  *device;
 456
 457        struct Scsi_Host *host;
 458
 459        u_char          bus;            /* PCI BUS number               */
 460        u_char          device_fn;      /* PCI BUS device and function  */
 461
 462        vm_offset_t     mmio_va;        /* MMIO kernel virtual address  */
 463        vm_offset_t     ram_va;         /* RAM  kernel virtual address  */
 464        u_long          io_port;        /* IO port address cookie       */
 465        u_short         io_ws;          /* IO window size               */
 466        int             irq;            /* IRQ number                   */
 467
 468        SYM_QUEHEAD     wait_cmdq;      /* Awaiting SCSI commands       */
 469        SYM_QUEHEAD     busy_cmdq;      /* Enqueued SCSI commands       */
 470
 471        struct timer_list timer;        /* Timer handler link header    */
 472        u_long          lasttime;
 473        u_long          settle_time;    /* Resetting the SCSI BUS       */
 474        u_char          settle_time_valid;
 475#if LINUX_VERSION_CODE < LinuxVersionCode(2, 4, 0)
 476        u_char          release_stage;  /* Synchronisation on release   */
 477#endif
 478};
 479
 480/*
 481 *  Return the name of the controller.
 482 */
 483#define sym_name(np) (np)->s.inst_name
 484
 485/*
 486 *  Data structure used as input for the NVRAM reading.
 487 *  Must resolve the IO macros and sym_name(), when  
 488 *  used as sub-field 's' of another structure.
 489 */
 490typedef struct {
 491        int     bus;
 492        u_char  device_fn;
 493        u_long  base;
 494        u_long  base_2;
 495        u_long  base_c;
 496        u_long  base_2_c;
 497        int     irq;
 498/* port and address fields to fit INB, OUTB macros */
 499        u_long  io_port;
 500        vm_offset_t mmio_va;
 501        char    inst_name[16];
 502} sym_slot;
 503
 504typedef struct sym_nvram sym_nvram;
 505typedef struct sym_pci_chip sym_chip;
 506
 507typedef struct {
 508        struct pci_dev *pdev;
 509        sym_slot  s;
 510        sym_chip  chip;
 511        sym_nvram *nvram;
 512        u_short device_id;
 513        u_char host_id;
 514#ifdef  SYM_CONF_PQS_PDS_SUPPORT
 515        u_char pqs_pds;
 516#endif
 517        int attach_done;
 518} sym_device;
 519
 520typedef sym_device *sdev_p;
 521
 522/*
 523 *  The driver definitions (sym_hipd.h) must know about a 
 524 *  couple of things related to the memory allocator.
 525 */
 526typedef u_long m_addr_t;        /* Enough bits to represent any address */
 527#define SYM_MEM_PAGE_ORDER 0    /* 1 PAGE  maximum */
 528#define SYM_MEM_CLUSTER_SHIFT   (PAGE_SHIFT+SYM_MEM_PAGE_ORDER)
 529#ifdef  MODULE
 530#define SYM_MEM_FREE_UNUSED     /* Free unused pages immediately */
 531#endif
 532#ifdef  SYM_LINUX_DYNAMIC_DMA_MAPPING
 533typedef struct pci_dev *m_pool_ident_t;
 534#endif
 535
 536/*
 537 *  Include driver soft definitions.
 538 */
 539#include "sym_fw.h"
 540#include "sym_hipd.h"
 541
 542/*
 543 *  Memory allocator related stuff.
 544 */
 545
 546#define SYM_MEM_GFP_FLAGS       GFP_ATOMIC
 547#define SYM_MEM_WARN    1       /* Warn on failed operations */
 548
 549#define sym_get_mem_cluster()   \
 550        __get_free_pages(SYM_MEM_GFP_FLAGS, SYM_MEM_PAGE_ORDER)
 551#define sym_free_mem_cluster(p) \
 552        free_pages(p, SYM_MEM_PAGE_ORDER)
 553
 554void *sym_calloc(int size, char *name);
 555void sym_mfree(void *m, int size, char *name);
 556
 557#ifndef SYM_LINUX_DYNAMIC_DMA_MAPPING
 558/*
 559 *  Simple case.
 560 *  All the memory assummed DMAable and O/S providing virtual 
 561 *  to bus physical address translation.
 562 */
 563#define __sym_calloc_dma(pool_id, size, name)   sym_calloc(size, name)
 564#define __sym_mfree_dma(pool_id, m, size, name) sym_mfree(m, size, name)
 565#define __vtobus(b, p)                          virt_to_bus(p)
 566
 567#else   /* SYM_LINUX_DYNAMIC_DMA_MAPPING */
 568/*
 569 *  Complex case.
 570 *  We have to provide the driver memory allocator with methods for 
 571 *  it to maintain virtual to bus physical address translations.
 572 */
 573
 574#define sym_m_pool_match(mp_id1, mp_id2)        (mp_id1 == mp_id2)
 575
 576static __inline m_addr_t sym_m_get_dma_mem_cluster(m_pool_p mp, m_vtob_p vbp)
 577{
 578        void *vaddr = 0;
 579        dma_addr_t baddr = 0;
 580
 581        vaddr = pci_alloc_consistent(mp->dev_dmat,SYM_MEM_CLUSTER_SIZE, &baddr);
 582        if (vaddr) {
 583                vbp->vaddr = (m_addr_t) vaddr;
 584                vbp->baddr = (m_addr_t) baddr;
 585        }
 586        return (m_addr_t) vaddr;
 587}
 588
 589static __inline void sym_m_free_dma_mem_cluster(m_pool_p mp, m_vtob_p vbp)
 590{
 591        pci_free_consistent(mp->dev_dmat, SYM_MEM_CLUSTER_SIZE,
 592                            (void *)vbp->vaddr, (dma_addr_t)vbp->baddr);
 593}
 594
 595#define sym_m_create_dma_mem_tag(mp)    (0)
 596
 597#define sym_m_delete_dma_mem_tag(mp)    do { ; } while (0)
 598
 599void *__sym_calloc_dma(m_pool_ident_t dev_dmat, int size, char *name);
 600void __sym_mfree_dma(m_pool_ident_t dev_dmat, void *m, int size, char *name);
 601m_addr_t __vtobus(m_pool_ident_t dev_dmat, void *m);
 602
 603#endif  /* SYM_LINUX_DYNAMIC_DMA_MAPPING */
 604
 605/*
 606 *  Set the status field of a CAM CCB.
 607 */
 608static __inline void 
 609sym_set_cam_status(Scsi_Cmnd  *ccb, int status)
 610{
 611        ccb->result &= ~(0xff  << 16);
 612        ccb->result |= (status << 16);
 613}
 614
 615/*
 616 *  Get the status field of a CAM CCB.
 617 */
 618static __inline int 
 619sym_get_cam_status(Scsi_Cmnd  *ccb)
 620{
 621        return ((ccb->result >> 16) & 0xff);
 622}
 623
 624/*
 625 *  The dma mapping is mostly handled by the 
 626 *  SCSI layer and the driver glue under Linux.
 627 */
 628#define sym_data_dmamap_create(np, cp)          (0)
 629#define sym_data_dmamap_destroy(np, cp)         do { ; } while (0)
 630#define sym_data_dmamap_unload(np, cp)          do { ; } while (0)
 631#define sym_data_dmamap_presync(np, cp)         do { ; } while (0)
 632#define sym_data_dmamap_postsync(np, cp)        do { ; } while (0)
 633
 634/*
 635 *  Async handler for negotiations.
 636 */
 637void sym_xpt_async_nego_wide(hcb_p np, int target);
 638#define sym_xpt_async_nego_sync(np, target)     \
 639        sym_announce_transfer_rate(np, target)
 640#define sym_xpt_async_nego_ppr(np, target)      \
 641        sym_announce_transfer_rate(np, target)
 642
 643/*
 644 *  Build CAM result for a successful IO and for a failed IO.
 645 */
 646static __inline void sym_set_cam_result_ok(hcb_p np, ccb_p cp, int resid)
 647{
 648        Scsi_Cmnd *cmd = cp->cam_ccb;
 649
 650#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,99)
 651        cmd->resid = resid;
 652#endif
 653        cmd->result = (((DID_OK) << 16) + ((cp->ssss_status) & 0x7f));
 654}
 655void sym_set_cam_result_error(hcb_p np, ccb_p cp, int resid);
 656
 657/*
 658 *  Other O/S specific methods.
 659 */
 660#define sym_cam_target_id(ccb)  (ccb)->target
 661#define sym_cam_target_lun(ccb) (ccb)->lun
 662#define sym_freeze_cam_ccb(ccb) do { ; } while (0)
 663void sym_xpt_done(hcb_p np, cam_ccb_p ccb);
 664void sym_xpt_done2(hcb_p np, cam_ccb_p ccb, int cam_status);
 665void sym_print_addr (ccb_p cp);
 666void sym_xpt_async_bus_reset(hcb_p np);
 667void sym_xpt_async_sent_bdr(hcb_p np, int target);
 668int  sym_setup_data_and_start (hcb_p np, cam_scsiio_p csio, ccb_p cp);
 669void sym_log_bus_error(hcb_p np);
 670#ifdef  SYM_OPT_SNIFF_INQUIRY
 671void sym_sniff_inquiry(hcb_p np, Scsi_Cmnd *cmd, int resid);
 672#endif
 673
 674#endif /* SYM_GLUE_H */
 675
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.