aac.h revision b6094a86b9116e02728dfbe9a1d4ecfa4cfd90f5
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2005-06 Adaptec, Inc.
* Copyright (c) 2005-06 Adaptec Inc., Achim Leubner
* Copyright (c) 2000 Michael Smith
* Copyright (c) 2001 Scott Long
* Copyright (c) 2000 BSDi
* 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
*
* 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.
*
*/
#ifndef _AAC_H_
#define _AAC_H_
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define AAC_ROUNDUP(x, y) (((x) + (y) - 1) / (y) * (y))
#define AAC_TYPE_DEVO 1
#define AAC_TYPE_ALPHA 2
#define AAC_TYPE_BETA 3
#define AAC_TYPE_RELEASE 4
#ifndef AAC_DRIVER_BUILD
#define AAC_DRIVER_BUILD 1
#endif
#define AAC_DRIVER_MAJOR_VERSION 2
#define AAC_DRIVER_MINOR_VERSION 2
#define AAC_DRIVER_BUGFIX_LEVEL 3
#define AAC_DRIVER_TYPE AAC_TYPE_RELEASE
#define STR(s) # s
#define AAC_VERSION(a, b, c) STR(a.b.c)
#define AACOK 0
#define AACERR -1
#define AAC_MAX_ADAPTERS 64
/* Definitions for mode sense */
#ifndef SD_MODE_SENSE_PAGE3_CODE
#define SD_MODE_SENSE_PAGE3_CODE 0x03
#endif
#ifndef SD_MODE_SENSE_PAGE4_CODE
#define SD_MODE_SENSE_PAGE4_CODE 0x04
#endif
#ifndef SCMD_SYNCHRONIZE_CACHE
#define SCMD_SYNCHRONIZE_CACHE 0x35
#endif
/*
* The controller reports status events in AIFs. We hang on to a number of
* these in order to pass them out to user-space management tools.
*/
#define AAC_AIFQ_LENGTH 64
#ifdef __x86
#else
#endif
/* Adapter hardware interface types */
#define AAC_HWIF_UNKNOWN 0
#define AAC_HWIF_I960RX 1
#define AAC_HWIF_RKT 2
#define AAC_TYPE_UNKNOWN 0
#define AAC_TYPE_SCSI 1
#define AAC_TYPE_SATA 2
#define AAC_TYPE_SAS 3
/*
* AAC_CMDQ_SYNC should be 0 and AAC_CMDQ_ASYNC be 1 for Sync FIB io
* to be served before async FIB io, see aac_start_waiting_io().
* So that io requests sent by interactive userland commands get
* responded asap.
*/
enum aac_cmdq {
AAC_CMDQ_SYNC, /* sync FIB queue */
AAC_CMDQ_ASYNC, /* async FIB queue */
};
/*
* IO command flags
*/
struct aac_cmd_queue {
};
struct aac_card_type {
char *vid; /* ASCII data for INQUIRY command vendor id */
char *desc; /* ASCII data for INQUIRY command product id */
};
/* Array description */
struct aac_container {
};
/*
* The firmware can support a lot of outstanding commands. Each aac_slot
* is corresponding to one of such commands. It records the command and
* associated DMA resource for FIB command.
*/
struct aac_slot {
int index; /* index of this slot */
};
/* Flags for attach tracking */
#define AAC_ATTACH_SOFTSTATE_ALLOCED (1 << 0)
/* Driver running states */
#define AAC_STATE_STOPPED 0
#define AAC_STATE_RUN (1 << 0)
/*
* Flags for aac firmware
* Note: Quirks are only valid for the older cards. These cards only supported
* old comm. Thus they are not valid for any cards that support new comm.
*/
/* between 0x2000 & 0x7FFFFFFF */
struct aac_softstate;
struct aac_interface {
int (*aif_get_fwstatus)(struct aac_softstate *);
int (*aif_get_mailbox)(struct aac_softstate *, int);
};
struct aac_fib_context {
int ctx_idx;
int ctx_filled; /* aifq is full for this fib context */
};
#define AAC_VENDOR_LEN 8
#define AAC_PRODUCT_LEN 16
struct aac_softstate {
int card; /* index to aac_cards */
/* mapped to address the card */
int flags; /* firmware features enabled */
int instance;
int slen;
/* DMA attributes */
/* PCI spaces */
char *pci_mem_base_vaddr;
/* Communication space */
struct aac_comm_space *comm_space;
/* Old Comm. interface: message queues */
struct aac_queue_table *qtablep;
/* New Comm. interface */
int state; /* driver state */
int container_count; /* max container id + 1 */
/*
* Command queues
* Each aac command flows through wait(or wait_sync) queue,
* busy queue, and complete queue sequentially.
*/
/* I/O slots and FIBs */
int total_slots; /* total slots allocated */
int total_fibs; /* total FIBs allocated */
struct aac_slot *free_io_slot_head;
int ndrains; /* number of draining threads */
/* AIF */
int aifq_idx; /* slot for next new AIF */
int aifq_wrap; /* AIF queue has ever been wrapped */
struct aac_fib_context *fibctx;
int devcfg_wait_on; /* AIF event waited for rescan */
int fm_capabilities;
/* MSI specific fields */
int intr_type; /* What type of interrupt */
int intr_cnt; /* # of intrs count returned */
int intr_cap; /* Interrupt capabilities */
#ifdef DEBUG
/* UART trace printf variables */
#endif
};
/*
* The following data are kept stable because they are only written at driver
* initialization, and we do not allow them changed otherwise even at driver
* re-initialization.
*/
/*
* Scatter-gather list structure defined by HBA hardware
*/
struct aac_sge {
union {
struct {
} ad64; /* 64 bit address */
} addr;
};
/* aac_cmd flags */
#define AAC_CMD_CONSISTENT (1 << 0)
struct aac_cmd {
/*
* Note: should be the first member for aac_cmd_queue to work
* correctly.
*/
int cmdlen;
int flags;
/* For non-aligned buffer and SRB */
/* Data transfer state */
/* FIB construct function */
/* Call back function for completed command */
/* FIB for this IO command */
};
#ifdef DEBUG
#define AACDB_FLAGS_MASK 0x0000ffff
#define AACDB_FLAGS_KERNEL_PRINT 0x00000001
#define AACDB_FLAGS_FW_PRINT 0x00000002
#define AACDB_FLAGS_NO_HEADERS 0x00000004
#define AACDB_FLAGS_MISC 0x00000010
#define AACDB_FLAGS_FUNC1 0x00000020
#define AACDB_FLAGS_FUNC2 0x00000040
#define AACDB_FLAGS_SCMD 0x00000080
#define AACDB_FLAGS_AIF 0x00000100
#define AACDB_FLAGS_FIB 0x00000200
#define AACDB_FLAGS_IOCTL 0x00000400
extern uint32_t aac_debug_flags;
extern int aac_dbflag_on(struct aac_softstate *, int);
#define AACDB_PRINT(s, lev, ...) { \
if (aac_dbflag_on((s), AACDB_FLAGS_MISC)) \
#define AACDB_PRINT_IOCTL(s, ...) { \
if (aac_dbflag_on((s), AACDB_FLAGS_IOCTL)) \
#define AACDB_PRINT_TRAN(s, ...) { \
if (aac_dbflag_on((s), AACDB_FLAGS_SCMD)) \
#define DBCALLED(s, n) { \
if (aac_dbflag_on((s), AACDB_FLAGS_FUNC ## n)) \
#define AACDB_PRINT_SCMD(s, x) { \
#define AACDB_PRINT_AIF(s, x) { \
#define AACDB_PRINT_FIB(s, x) { \
#else /* DEBUG */
#define AACDB_PRINT(s, lev, ...)
#define AACDB_PRINT_IOCTL(s, ...)
#define AACDB_PRINT_TRAN(s, ...)
#define AACDB_PRINT_FIB(s, x)
#define AACDB_PRINT_SCMD(s, x)
#define AACDB_PRINT_AIF(s, x)
#define DBCALLED(s, n)
#endif /* DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _AAC_H_ */