/*-
* Copyright (c) 2002, 2007 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-2001 Scott Long
* 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: aacreg.h,v 1.1 2000/09/13 03:20:34 msmith Exp
* via OpenBSD: aacreg.h,v 1.3 2001/06/12 15:40:29 niklas Exp
* incorporating some of: aacreg.h,v 1.23 2005/10/14 16:22:45 scottl Exp
*/
/*
* Data structures defining the interface between the driver and the Adaptec
* 'FSA' adapters. Note that many field names and comments here are taken
* verbatim from the Adaptec driver source in order to make comparing the
* two slightly easier.
*/
/*
* Communications interface.
*
* Where datastructure layouts are closely parallel to the Adaptec sample code,
* retain their naming conventions (for now) to aid in cross-referencing.
*/
/*
* We establish 4 command queues and matching response queues. Queues must
* be 16-byte aligned, and are sized as follows:
*/
#define AAC_HOST_NORM_CMD_ENTRIES 8 /* cmd adapter->host, normal pri */
#define AAC_HOST_HIGH_CMD_ENTRIES 4 /* cmd adapter->host, high pri */
#define AAC_ADAP_NORM_CMD_ENTRIES 512 /* cmd host->adapter, normal pri */
#define AAC_ADAP_HIGH_CMD_ENTRIES 4 /* cmd host->adapter, high pri */
#define AAC_HOST_NORM_RESP_ENTRIES 512 /* resp, adapter->host, normal pri */
#define AAC_HOST_HIGH_RESP_ENTRIES 4 /* resp, adapter->host, high pri */
#define AAC_ADAP_NORM_RESP_ENTRIES 8 /* resp, host->adapter, normal pri */
#define AAC_ADAP_HIGH_RESP_ENTRIES 4 /* resp, host->adapter, high pri */
/*
* Table of queue indices and queues used to communicate with the
* controller. This structure must be aligned to AAC_QUEUE_ALIGN
*/
struct aac_queue_table {
/* queue consumer/producer indexes (layout mandated by adapter) */
u_int32_t qt_qindex[AAC_QUEUE_COUNT][2];
/*
* Adapter Init Structure: this is passed to the adapter with the
* AAC_MONKER_INITSTRUCT command to point it at our control structures.
*/
struct aac_adapter_init {
u_int32_t InitStructRevision;
u_int32_t MiniPortRevision;
u_int32_t FilesystemRevision;
u_int32_t CommHeaderAddress;
u_int32_t FastIoCommAreaAddress;
u_int32_t AdapterFibsPhysicalAddress;
u_int32_t AdapterFibsVirtualAddress;
u_int32_t AdapterFibsSize;
u_int32_t AdapterFibAlign;
u_int32_t PrintfBufferAddress;
u_int32_t PrintfBufferSize;
u_int32_t HostPhysMemPages;
u_int32_t HostElapsedSeconds;
/* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
u_int32_t InitFlags; /* flags for supported features */
u_int32_t MaxIoCommands; /* max outstanding commands */
u_int32_t MaxIoSize; /* largest I/O command */
u_int32_t MaxFibSize; /* largest FIB to adapter */
} __packed;
#define AAC_INIT_STRUCT_REVISION 3
#define AAC_INIT_STRUCT_REVISION_4 4
#define AAC_INIT_STRUCT_MINIPORT_REVISION 1
#define AAC_INITFLAGS_NEW_COMM_SUPPORTED 1
#define AAC_PAGE_SIZE 4096 /* Used to set HostPhysMemPages */
/*
* Host-side scatter/gather list for raw commands.
*/
struct aac_sg_entryraw {
u_int32_t Next; /* reserved for FW use */
u_int32_t Prev; /* reserved for FW use */
u_int64_t SgAddress;
u_int32_t SgByteCount;
u_int32_t Flags; /* reserved for FW use */
} __packed;
/*
* Common bit definitions for the doorbell registers.
*/
/*
* Status bits in the doorbell registers.
*/
#define AAC_DB_SYNC_COMMAND (1<<0) /* send/completed synchronous FIB */
#define AAC_DB_COMMAND_READY (1<<1) /* posted one or more commands */
#define AAC_DB_RESPONSE_READY (1<<2) /* one or more commands complete */
#define AAC_DB_COMMAND_NOT_FULL (1<<3) /* command queue not full */
#define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */
/*
* The adapter can request the host print a message by setting the
* DB_PRINTF flag in DOORBELL0. The driver responds by collecting the
* message from the printf buffer, clearing the DB_PRINTF flag in
* DOORBELL0 and setting it in DOORBELL1.
* (ODBR and IDBR respectively for the i960Rx adapters)
*/
#define AAC_DB_PRINTF (1<<5) /* adapter requests host printf */
#define AAC_PRINTF_DONE (1<<5) /* host completed printf processing */
/*
* Mask containing the interrupt bits we care about. We don't anticipate
* (or want) interrupts not in this mask.
*/
#define AAC_DB_INTERRUPTS \
(AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)
#define AAC_DB_INT_NEW_COMM 0x08
/*
* Queue names
*
* Note that we base these at 0 in order to use them as array indices. Adaptec
* used base 1 for some unknown reason, and sorted them in a different order.
*/
#define AAC_HOST_NORM_CMD_QUEUE 0
#define AAC_HOST_HIGH_CMD_QUEUE 1
#define AAC_ADAP_NORM_CMD_QUEUE 2
#define AAC_ADAP_HIGH_CMD_QUEUE 3
#define AAC_HOST_NORM_RESP_QUEUE 4
#define AAC_HOST_HIGH_RESP_QUEUE 5
#define AAC_ADAP_NORM_RESP_QUEUE 6
#define AAC_ADAP_HIGH_RESP_QUEUE 7
/*
* List structure used to chain FIBs (used by the adapter - we hang FIBs off
* our private command structure and don't touch these)
*/
struct aac_fib_list_entry {
u_int32_t Flink;
u_int32_t Blink;
} __packed;
/*
* FIB (FSA Interface Block?); this is the datastructure passed between the
* host and adapter.
*/
struct aac_fib_header {
u_int32_t XferState;
u_int16_t Command;
u_int8_t StructType;
u_int8_t Flags;
u_int16_t Size;
u_int16_t SenderSize;
u_int32_t SenderFibAddress;
u_int32_t ReceiverFibAddress;
u_int32_t SenderData;
union {
struct {
u_int32_t ReceiverTimeStart;
u_int32_t ReceiverTimeDone;
} _s;
struct aac_fib_list_entry FibLinks;
} _u;
} __packed;
/*
* Adapter Status Register
*
* Phase Status mailbox is 32bits:
* <31:16> = Phase Status
* <15:0> = Phase
*
* The adapter reports its present state through the phase. Only
* a single phase should be ever be set. Each phase can have multiple
* phase status bits to provide more detailed information about the
* state of the adapter.
*/
#define AAC_SELF_TEST_FAILED 0x00000004
#define AAC_MONITOR_PANIC 0x00000020
#define AAC_UP_AND_RUNNING 0x00000080
#define AAC_KERNEL_PANIC 0x00000100
/*
* Data types relating to control and monitoring of the NVRAM/WriteCache
* subsystem.
*/
#define AAC_NFILESYS 24 /* maximum number of filesystems */
/*
* NVRAM/Write Cache subsystem states
*/
typedef enum {
NVSTATUS_DISABLED = 0, /* present, clean, not being used */
NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */
NVSTATUS_ERROR, /* present, dirty, contains dirty data */
NVSTATUS_BATTERY, /* present, bad or low battery, may contain
* dirty data */
NVSTATUS_UNKNOWN /* for bad/missing device */
} AAC_NVSTATUS;
/*
* NVRAM/Write Cache subsystem battery component states
*
*/
typedef enum {
NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */
NVBATTSTATUS_LOW, /* battery is low on power */
NVBATTSTATUS_OK, /* battery is okay - normal operation possible
* only in this state */
NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning
* in process */
} AAC_NVBATTSTATUS;
/*
* Battery transition type
*/
typedef enum {
NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not
* present */
NVBATT_TRANSITION_LOW, /* battery is now low on power */
NVBATT_TRANSITION_OK /* battery is now okay - normal
* operation possible only in this
* state */
} AAC_NVBATT_TRANSITION;
/*
* NVRAM Info structure returned for NVRAM_GetInfo call
*/
struct aac_nvramdevinfo {
u_int32_t NV_Enabled; /* write caching enabled */
u_int32_t NV_Error; /* device in error state */
u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */
u_int32_t NV_NActive; /* count of NVRAM buffers being
* written */
} __packed;
struct aac_nvraminfo {
AAC_NVSTATUS NV_Status; /* nvram subsystem status */
AAC_NVBATTSTATUS NV_BattStatus; /* battery status */
u_int32_t NV_Size; /* size of WriteCache NVRAM in
* bytes */
u_int32_t NV_BufSize; /* size of NVRAM buffers in
* bytes */
u_int32_t NV_NBufs; /* number of NVRAM buffers */
u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */
u_int32_t NV_NClean; /* Num clean NVRAM buffers */
u_int32_t NV_NActive; /* Num NVRAM buffers being
* written */
u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */
struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device
* info */
u_int32_t NV_BattNeedsReconditioning; /* boolean */
u_int32_t NV_TotalSize; /* size of all non-volatile
* memories in bytes */
} __packed;
/*
* Data types relating to adapter-initiated FIBs
*
* Based on types and structures in <aifstruc.h>
*/
/*
* Progress Reports
*/
typedef enum {
AifJobStsSuccess = 1,
AifJobStsFinished,
AifJobStsAborted,
AifJobStsFailed,
AifJobStsLastReportMarker = 100, /* All prior mean last report */
AifJobStsSuspended,
AifJobStsRunning
} AAC_AifJobStatus;
typedef enum {
AifJobScsiMin = 1, /* Minimum value for Scsi operation */
AifJobScsiZero, /* SCSI device clear operation */
AifJobScsiVerify, /* SCSI device Verify operation NO
* REPAIR */
AifJobScsiExercise, /* SCSI device Exercise operation */
AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH
* repair */
AifJobScsiWritePattern, /* write pattern */
AifJobScsiMax = 99, /* Max Scsi value */
AifJobCtrMin, /* Min Ctr op value */
AifJobCtrZero, /* Container clear operation */
AifJobCtrCopy, /* Container copy operation */
AifJobCtrCreateMirror, /* Container Create Mirror operation */
AifJobCtrMergeMirror, /* Container Merge Mirror operation */
AifJobCtrScrubMirror, /* Container Scrub Mirror operation */
AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */
AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */
AifJobCtrMorph, /* Container morph operation */
AifJobCtrPartCopy, /* Container Partition copy operation */
AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */
AifJobCtrCrazyCache, /* crazy cache */
AifJobCtrCopyback, /* Container Copyback operation */
AifJobCtrCompactRaid5D, /* Container Compaction operation */
AifJobCtrExpandRaid5D, /* Container Expansion operation */
AifJobCtrRebuildRaid6, /* Container Rebuild Raid6 operation */
AifJobCtrScrubRaid6, /* Container Scrub Raid6 operation */
AifJobCtrSSBackup, /* Container snapshot backup task */
AifJobCtrMax = 199, /* Max Ctr type operation */
AifJobFsMin, /* Min Fs type operation */
AifJobFsCreate, /* File System Create operation */
AifJobFsVerify, /* File System Verify operation */
AifJobFsExtend, /* File System Extend operation */
AifJobFsMax = 299, /* Max Fs type operation */
AifJobApiFormatNTFS, /* Format a drive to NTFS */
AifJobApiFormatFAT, /* Format a drive to FAT */
AifJobApiUpdateSnapshot, /* update the read/write half of a
* snapshot */
AifJobApiFormatFAT32, /* Format a drive to FAT32 */
AifJobApiMax = 399, /* Max API type operation */
AifJobCtlContinuousCtrVerify, /* Adapter operation */
AifJobCtlMax = 499 /* Max Adapter type operation */
} AAC_AifJobType;
union aac_AifJobClient {
struct aac_AifContainers container; /* For Container and
* filesystem progress
* ops; */
int32_t scsi_dh; /* For SCSI progress
* ops */
};
struct aac_AifJobDesc {
u_int32_t jobID; /* DO NOT FILL IN! Will be
* filled in by AIF */
AAC_AifJobType type; /* Operation that is being
* performed */
union aac_AifJobClient client; /* Details */
} __packed;
struct aac_AifEnsMirrorFailover {
u_int32_t container; /* Container with failed element */
u_int32_t failedSlice; /* Old slice which failed */
u_int32_t creatingSlice; /* New slice used for auto-create */
} __packed;
struct aac_AifEnsContainerChange {
u_int32_t container[2]; /* container that changed, -1 if no
* container */
} __packed;
struct aac_AifEnsContainerEvent {
u_int32_t container; /* container number */
u_int32_t eventType; /* event type */
} __packed;
struct aac_AifEnsEnclosureEvent {
u_int32_t empID; /* enclosure management proc number */
u_int32_t unitID; /* unitId, fan id, power supply id,
* slot id, tempsensor id. */
u_int32_t eventType; /* event type */
} __packed;
struct aac_AifEnsBatteryEvent {
AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */
AAC_NVBATTSTATUS current_state; /* current batt state */
AAC_NVBATTSTATUS prior_state; /* prev batt state */
} __packed;
typedef enum {
CLUSTER_NULL_EVENT = 0,
CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or
* adaptername from NULL to non-NULL */
/* (partner's agent may be up) */
CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or
* adaptername from non-null to NULL */
/* (partner has rebooted) */
} AAC_ClusterAifEvent;
/*
* Adapter Initiated FIB command structures. Start with the adapter
* initiated FIBs that really come from the adapter, and get responded
* to by the host.
*/
#define AAC_AIF_REPORT_MAX_SIZE 64
typedef enum {
AifCmdEventNotify = 1, /* Notify of event */
AifCmdJobProgress, /* Progress report */
AifCmdAPIReport, /* Report from other user of API */
AifCmdDriverNotify, /* Notify host driver of event */
AifReqJobList = 100, /* Gets back complete job list */
AifReqJobsForCtr, /* Gets back jobs for specific container */
AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */
AifReqJobReport, /* Gets back a specific job report or list */
AifReqTerminateJob, /* Terminates job */
AifReqSuspendJob, /* Suspends a job */
AifReqResumeJob, /* Resumes a job */
AifReqSendAPIReport, /* API generic report requests */
AifReqAPIJobStart, /* Start a job from the API */
AifReqAPIJobUpdate, /* Update a job report from the API */
AifReqAPIJobFinish /* Finish a job from the API */
} AAC_AifCommand;
struct aac_aif_command {
AAC_AifCommand command; /* Tell host what type of
* notify this is */
u_int32_t seqNumber; /* To allow ordering of
* reports (if necessary) */
union {
struct aac_AifEventNotify EN; /* Event notify */
struct aac_AifJobProgressReport PR[1]; /* Progress report */
u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE];
u_int8_t data[AAC_FIB_DATASIZE - 8];
} data;
} __packed;