amrreg.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1999,2000 Michael Smith
* 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.
*
* Copyright (c) 2002 Eric Moore
* Copyright (c) 2002 LSI Logic Corporation
* 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
* 3. The party using or redistributing the source code and binary forms
* agrees to the disclaimer below and the terms and conditions set forth
* herein.
*
* 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.
*/
/*
* Note: If the structures and variables definitions can be found from the
* "MegaRAID PCI SCSI Disk Array Controller F/W Technical Reference
* Manual", the names defined in this documents will also be provided
* by " ", and the descriptions for each variables and constants are
* given as well.
*/
#ifndef _AMRREG_H
#define _AMRREG_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define AMR_NSEG 26
#define AMR_MAX_STATUS_ACK 46
#define AMR_MAXLD 40
#define AMR_MAX_CHANNELS 4
#define AMR_MAX_TARGETS 15
#define AMR_MAX_LUNS 7
#define AMR_MAX_CDB_LEN 0x0a
#define AMR_MAX_EXTCDB_LEN 0x10
#define AMR_MAX_REQ_SENSE_LEN 0x20
/*
* Array constraints for controllers that support 8 logic drivers
*/
#define AMR_8LD_MAXDRIVES 8
#define AMR_8LD_MAXCHAN 5
#define AMR_8LD_MAXTARG 15
/*
* Array constraints for controllers that support 40 logic drivers
*/
#define AMR_40LD_MAXDRIVES 40
#define AMR_40LD_MAXCHAN 16
#define AMR_40LD_MAXTARG 16
/*
* The buffer size for enquiry command
*/
#define AMR_ENQ_BUFFER_SIZE sizeof (union amr_enq_buffer)
/*
* Constants used for poll command
*/
#define AMR_POLL_COMMAND_ID 0xfe
#define AMR_POLL_DEFAULT_NSTATUS 0xff
#define AMR_POLL_DEFAULT_STATUS 0xff
#define AMR_POLL_ACK 0x77
#pragma pack(1)
/*
* The AMR mailbox. This is the main interface for
* programming the controller. Must be aligned at
* a 16-Byte physical address boundary.
*
* The first sixteen bytes are commands to the controller.
*
* There are two formats:
* 1. Commands for I/O: mb_blkcount/mb_lba are used.
* 2. Commands for I/O control: mb_channel/mb_param are used.
*
*/
struct amr_mailbox
{
/* code of the command */
/* id for this command */
union {
/* number of sectors for */
/* this request */
/* OUT, Channel No. and */
/* parameters */
} mb_un1;
union {
/* LBA for this request */
} mb_un2;
/* physical address for a */
/* non-s/g command or the */
/* physical address of a s/g */
/* list for a s/g command */
/* the log-drive for which */
/* this request is intended */
/* number of s/g elements */
/* to 1 before submit the */
/* command, firmware picks */
/* it and makes this byte 0 */
/* number of status returned */
/* by firmware */
/* the IDs in mb_completed[] */
/* "CompletedIdList", IN, */
/* finished ID list */
/* polling/interrupt-driven */
/* polling/interrupt-driver */
};
/* Fields before mb_nstatus are the portions worth copying for controller */
/*
* I/O commands expect the physical address of an array
* in mb_physaddr.
*
* sg_addr is a physical address.
*/
struct amr_sgentry
{
};
/*
* Mailbox commands
* Note: This is a subset for the command set
*/
#define AMR_CMD_LREAD 0x01
#define AMR_CMD_LWRITE 0x02
#define AMR_CMD_PASS 0x03
#define AMR_CMD_EXT_ENQUIRY 0x04
#define AMR_CMD_ENQUIRY 0x05
#define AMR_CMD_FLUSH 0x0a
#define AMR_CMD_EXT_ENQUIRY2 0x0c
#define AMR_CMD_GET_MACHINEID 0x36
#define AMR_CMD_GET_INITIATOR 0x7d
#define AMR_CMD_RESET_ADAPTER 0x96
#define AMR_CMD_CONFIG 0xa1
#define AMR_CMD_MISC_OPCODE 0xa4
#define AMR_CMD_EXTPASS 0xe3
/*
* Subcodes for AMR_CMD_CONFIG
*/
#define AMR_CONFIG_PRODUCT_INFO 0x0e
#define AMR_CONFIG_ENQ3 0x0f
#define AMR_CONFIG_ENQ3_SOLICITED_NOTIFY 0x01
#define AMR_CONFIG_ENQ3_SOLICITED_FULL 0x02
#define AMR_CONFIG_ENQ3_UNSOLICITED 0x03
/*
* Subcodes for AMR_CMD_MISC_OPCODE
*/
#define AMR_MISC_CDB_QUERY 0x16
/*
* Mailbox command results
*/
#define AMR_STATUS_SUCCESS 0x00
#define AMR_STATUS_ABORTED 0x02
#define AMR_STATUS_FAILED 0x80
/*
* Adapter Info structure
*/
struct amr_adapter_info
{
/* commands supported */
/* varies from 0%-100% */
/* supported per chan */
/* Chans present on this */
/* adapter */
/* FW has been downloaded */
/* of 0xC0000832 */
/* terms of Seconds */
/* increase with evry */
/* configuration change */
/* increase with every drive */
/* inserted */
/* of inserted drive */
/* status */
/* reserved */
};
/*
* aa_batterystatus values
*/
#define AMR_BATT_MODULE_MISSING 0x01
#define AMR_BATT_LOW_VOLTAGE 0x02
#define AMR_BATT_TEMP_HIGH 0x04
#define AMR_BATT_PACK_MISSING 0x08
#define AMR_BATT_CHARGE_MASK 0x30
#define AMR_BATT_CHARGE_DONE 0x00
#define AMR_BATT_CHARGE_INPROG 0x10
#define AMR_BATT_CHARGE_FAIL 0x20
#define AMR_BATT_CYCLES_EXCEEDED 0x40
/*
* Logical Drive info structure
*/
struct amr_logdrive_info
{
/* configured logic drivers */
/* "LDrvSize", size of each */
/* logic driver */
/* "LDrvProp", properties of */
/* each logic driver */
/* "LDrvState", state of */
/* each logic driver */
};
/*
* Logical drive only: al_properties
*/
/*
* Physical Drive info structure
*/
struct amr_physdrive_info
{
/* "PDrvState", state of each */
/* phy-driver. Low nibble is */
/* current state, high nibble */
/* is previous state */
};
/*
*
* Both logical and physical drives maintain
* nibble of the _state field.
*/
#define AMR_DRV_CURSTATE(x) ((x) & 0x0f)
/*
* Logical drives: al_state.
*/
#define AMR_LDRV_OFFLINE 0x00
#define AMR_LDRV_DEGRADED 0x01
#define AMR_LDRV_OPTIMAL 0x02
/*
* Physical drives: ap_state.
*/
#define AMR_PDRV_UNCNF 0x00
#define AMR_PDRV_ONLINE 0x03
#define AMR_PDRV_FAILED 0x04
#define AMR_PDRV_REBUILD 0x05
#define AMR_PDRV_HOTSPARE 0x06
/*
* Notify structure
*/
struct amr_notify
{
/* counter */
/* change counter */
/* last param modified */
/* write config occurred */
/* drive operation */
/* operations */
/* the operation */
/* of logical drive state */
/* of physical drive state */
/* xfer rate change */
/* params of last pdrv */
/* loop 0 */
/* loop 1 */
/* fc loop 0 */
/* fc loop 1 */
};
/*
* an_param values
*/
#define AMR_PARAM_REBUILD_RATE 0x01
#define AMR_PARAM_FLUSH_INTERVAL 0x02
#define AMR_PARAM_SENSE_ALERT 0x03
#define AMR_PARAM_DRIVE_INSERTED 0x04
#define AMR_PARAM_BATTERY_STATUS 0x05
/*
* an_ldrvopcmd values
*/
#define AMR_LDRVOP_CHECK 0x01
#define AMR_LDRVOP_INIT 0x02
#define AMR_LDRVOP_REBUILD 0x03
/*
* an_ldrvopstatus: return values after issuing command
* via an_ldrvopcmd.
*/
#define AMR_LDRVOP_SUCCESS 0x00
#define AMR_LDRVOP_FAILED 0x01
#define AMR_LDRVOP_ABORTED 0x02
#define AMR_LDRVOP_CORRECTED 0x03
#define AMR_LDRVOP_STARTED 0x04
/*
*/
#define AMR_FORMAT_START 0x01
#define AMR_FORMAT_COMPLETE 0x02
/*
* Enquiry response structure for AMR_CMD_ENQUIRY, AMR_CMD_EXT_ENQUIRY and
* AMR_CMD_EXT_ENQUIRY2.
*/
struct amr_enquiry
{
struct amr_adapter_info ae_adapter;
struct amr_logdrive_info ae_ldrv;
struct amr_physdrive_info ae_pdrv;
};
/*
* ae_signature values
*/
#define AMR_SIG_431 0xfffe0001
#define AMR_SIG_438 0xfffd0002
#define AMR_SIG_762 0xfffc0003
#define AMR_SIG_T5 0xfffb0004
#define AMR_SIG_466 0xfffa0005
#define AMR_SIG_467 0xfff90006
#define AMR_SIG_T7 0xfff80007
#define AMR_SIG_490 0xfff70008
/*
* Enquiry3 structure
*/
struct amr_enquiry3
{
/* in bytes(resvd excluded) */
/* structure */
/* rebuild rate in % */
/* flush interval in seconds */
/* count of inserted drives */
/* drivers configured */
/* "reconState", */
/* reconstruction state */
/* "lDrvOpStatus", operation */
/* state per logic driver */
/* "lDrvSize", size of each */
/* logic driver */
/* "lDrvProp", properties of */
/* each logic driver */
/* "lDrvState", state of */
/* each logic driver */
/* "pDrvState", state of each */
/* physical driver */
/* "physDrvFormat" */
/* transfer rates */
};
/*
* Product Info structure. Query for this via AMR_CONFIG_PRODUCT_INFO.
*/
struct amr_prodinfo
{
/* in bytes */
/* is 0x00282008, indicating */
/* 0x28 max logical drives, */
/* 0x20 maximum stripes and */
/* 0x08 maximum spans */
/* of concurrent commands */
/* of SCSI channels present */
/* fibre loops present */
/* in MB */
/* identifier */
/* of notify counters */
};
/*
* The union for used enquiry commands
*/
union amr_enq_buffer
{
struct amr_enquiry3 aeb_enquiry3;
struct amr_enquiry aeb_enquiry;
struct amr_prodinfo aeb_prodinfo;
};
#pragma pack()
#ifdef _KERNEL
/*
* I/O Port offsets
*/
#define ACK_BYTE 0x08
#define I_CMD_PORT 0x00
#define I_ACK_PORT 0x00
#define I_TOGGLE_PORT 0x01
#define INTR_PORT 0x0a
#define ENABLE_INTR_BYTE 0xc0
#define DISABLE_INTR_BYTE 0x00
#define AMR_QINTR 0x0a
#define AMR_QINTR_VALID 0x40
/*
* Doorbell registers
*/
#define AMR_QIDB 0x20
#define AMR_QODB 0x2c
/*
* Initialisation status
*/
/*
* I/O primitives
*/
/*
* I/O registers
*/
#define AMR_SMBOX_1 0x15
#define AMR_SMBOX_2 0x16
/*
* I/O magic numbers
*/
/*
* Initialisation status
*/
/*
* I/O primitives
*/
#define AMR_SENABLE_INTR(sc) \
#define AMR_SDISABLE_INTR(sc) \
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _AMRREG_H */