/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 2000 Michael Smith
* Copyright (c) 2000 BSDi
* Copyright (c) 2000 Niklas Hallqvist
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from FreeBSD: aacvar.h,v 1.1 2000/09/13 03:20:34 msmith Exp
* via OpenBSD: aacvar.h,v 1.2 2002/03/14 01:26:53 millert Exp
*/
/*
* We allocate a small set of FIBs for the adapter to use to send us messages.
*/
#define AAC_ADAPTER_FIBS 8
/*
* FIBs are allocated in page-size chunks and can grow up to the 512
* limit imposed by the hardware.
* XXX -- There should be some way to allocate these as-needed without
* allocating them at interrupt time. For now, though, allocate
* all that we'll ever need up-front.
*/
#define AAC_PREALLOCATE_FIBS(sc) ((sc)->sc_max_fibs)
/*
* Firmware messages are passed in the printf buffer.
*/
#define AAC_PRINTF_BUFSIZE 256
/*
* We wait this many seconds for the adapter to come ready if it is still
* booting.
*/
#define AAC_BOOT_TIMEOUT (3 * 60)
/*
* Wait this long for a lost interrupt to get detected.
*/
#define AAC_WATCH_TIMEOUT 10000 /* 10000 * 1ms = 10s */
/*
* Timeout for immediate commands.
*/
#define AAC_IMMEDIATE_TIMEOUT 30
/*
* Delay 20ms after the qnotify in sync operations. Experimentally deduced.
*/
#define AAC_SYNC_DELAY 20000
/*
* sc->sc_max_sgs is the number of scatter-gather elements we can fit
* in one block I/O request (64-bit or 32-bit, depending) FIB, or the
* maximum number that the firmware will accept. We subtract one to
* deal with requests that do not start on an even page boundary.
*/
#define AAC_MAX_XFER(sc) (((sc)->sc_max_sgs - 1) * PAGE_SIZE)
/*
* Number of CCBs to reserve for control operations.
*/
#define AAC_NCCBS_RESERVE 8
/*
* Quirk listings.
*/
#define AAC_QUIRK_PERC2QC (1 << 0) /* Dell PERC 2QC */
#define AAC_QUIRK_SG_64BIT (1 << 4) /* Use 64-bit S/G addresses */
#define AAC_QUIRK_4GB_WINDOW (1 << 5) /* Device can access host mem
* in 2GB-4GB range */
#define AAC_QUIRK_NO4GB (1 << 6) /* Can't access host mem >2GB */
#define AAC_QUIRK_256FIBS (1 << 7) /* Can only handle 256 cmds */
#define AAC_QUIRK_BROKEN_MMAP (1 << 8) /* Broken HostPhysMemPages */
#define AAC_QUIRK_NEW_COMM (1 << 11) /* New comm. i/f supported */
#define AAC_QUIRK_RAW_IO (1 << 12) /* Raw I/O interface */
#define AAC_QUIRK_ARRAY_64BIT (1 << 13) /* 64-bit array size */
#define AAC_QUIRK_LBA_64BIT (1 << 14) /* 64-bit LBA support */
/*
* We gather a number of adapter-visible items into a single structure.
*
* The ordering of this structure may be important; we copy the Linux driver:
*
* Adapter FIBs
* Init struct
* Queue headers (Comm Area)
* Printf buffer
*
* In addition, we add:
* Sync Fib
*/
struct aac_common {
/* fibs for the controller to send us messages */
struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
/* the init structure */
struct aac_adapter_init ac_init;
/* arena within which the queue structures are kept */
u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + AAC_QUEUE_ALIGN];
/* buffer for text messages from the controller */
char ac_printf[AAC_PRINTF_BUFSIZE];
/* fib for synchronous commands */
struct aac_fib ac_sync_fib;
};