/*
* megaraid_sas.h: header for mega_sas
*
* Solaris MegaRAID driver for SAS controllers
* Copyright (c) 2004-2008, 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 documentation
*
* 3. Neither the name of the author nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MEGARAID_SAS_H_
#define _MEGARAID_SAS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "list.h"
/*
* MegaRAID SAS Driver meta data
*/
#define MEGASAS_FALSE 0
/*
* MegaRAID device id conversion definitions.
*/
/*
* MegaRAID SAS supported controllers
*/
/*
* =====================================
* MegaRAID SAS MFI firmware definitions
* =====================================
*/
/*
* MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
* protocol between the software and firmware. Commands are issued using
* "message frames"
*/
/*
* FW posts its state in upper 4 bits of outbound_msg_0 register
*/
/*
* During FW init, clear pending cmds & reset state using inbound_msg_0
*
* ABORT : Abort all pending cmds
* READY : Move from OPERATIONAL to READY state; discard queue info
* MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
* CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
*/
/*
* MFI frame flags
*/
/*
* Definition for cmd_status
*/
/*
* MFI command opcodes
*/
/*
* Solaris Specific MAX values
*/
/*
* MFI command completion codes
*/
enum MFI_STAT {
};
enum MR_EVT_CLASS {
MR_EVT_CLASS_INFO = 0,
};
enum MR_EVT_LOCALE {
};
enum MR_EVT_ARGS {
};
#pragma pack(1)
/*
* SAS controller properties
*/
struct megasas_ctrl_prop {
};
/*
* SAS controller information
*/
struct megasas_ctrl_info {
/* PCI device information */
struct {
} pci;
/* Host interface information */
struct {
/* Device (backend) interface information */
struct {
/* List of components residing in flash. All str are null terminated */
struct {
/*
* List of flash components that have been flashed on the card, but
* are not in use, pending reset of the adapter. This list will be
* empty if a flash operation has not occurred. All stings are null
* terminated
*/
struct {
/*
* Other physical/controller/operation information. Indicates the
* presence of the hardware
*/
struct {
} hw_present;
/* Maximum data transfer sizes */
/* Logical and physical device counts */
/* Memory size information */
/* Error counters */
/* Cluster information */
/* Controller capabilities structures */
struct {
} raid_levels;
struct {
struct {
struct {
struct {
struct {
/* Include the controller properties (changeable items) */
};
/*
* ===============================
* MegaRAID SAS driver definitions
* ===============================
*/
#define MEGASAS_IOCTL_CMD 0
/*
* FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
* SGLs based on the size of dma_addr_t
*/
/*
* All MFI register set macros accept megasas_register_set*
*/
(v))
/*
* When FW is in MFI_STATE_READY or MFI_STATE_OPERATIONAL, the state data
* of Outbound Msg Reg 0 indicates max concurrent cmds supported, max SGEs
* supported per cmd and if 64-bit MFAs (M64) is enabled or disabled.
*/
/*
* This MFI_REPLY_1078_MESSAGE_INTR flag is used also
* in enable_intr_pcc also. Hence bit 2, i.e. 0x4 has
* been set in this flag along with bit 31.
*/
{ \
}
/* By default, the firmware programs for 8 Kbytes of memory */
/* DCMD Message Frame MAILBOX0-11 */
struct megasas_register_set {
};
struct megasas_sge32 {
};
struct megasas_sge64 {
};
union megasas_sgl {
};
struct megasas_header {
};
union megasas_sgl_frame {
};
struct megasas_init_frame {
};
struct megasas_init_queue_info {
};
struct megasas_io_frame {
};
struct megasas_pthru_frame {
};
struct megasas_dcmd_frame {
/* uint8_t mbox[DCMD_MBOX_SZ]; */ /* 1Ch */
union { /* 1Ch */
uint8_t b[DCMD_MBOX_SZ];
uint16_t s[6];
uint32_t w[3];
} mbox;
};
struct megasas_abort_frame {
};
struct megasas_smp_frame {
};
struct megasas_stp_frame {
};
union megasas_frame {
};
union megasas_evt_class_locale {
struct {
} members;
};
struct megasas_evt_log_info {
};
struct megasas_progress {
};
struct megasas_evtarg_ld {
};
struct megasas_evtarg_pd {
};
struct megasas_evt_detail {
union {
struct {
} cdbSense;
struct {
} ld_count;
struct {
} ld_lba;
struct {
} ld_owner;
struct {
struct {
} ld_prog;
struct {
} ld_state;
struct {
} ld_strip;
struct {
} pd_err;
struct {
} pd_lba;
struct {
} pd_lba_ld;
struct {
} pd_prog;
struct {
} pd_state;
struct {
} pci;
struct {
} time;
struct {
} ecc;
uint8_t b[96];
uint16_t s[48];
uint32_t w[24];
uint64_t d[12];
} args;
};
/* only 63 are usable by the application */
/* only 255 physical devices may be used */
/* maximum disks per array */
/* maximum spans per logical drive */
/* maximum number of arrays a hot spare may be dedicated to */
/* maximum number of arrays which may exist */
/* maximum number of foreign configs that may ha managed at once */
/* maximum spares (global and dedicated combined) */
/* maximum possible Target IDs (i.e. 0 to 63) */
/* maximum number of supported enclosures */
/* maximum number of PHYs per controller */
/* maximum number of LDs per array (due to DDF limitations) */
/*
* -----------------------------------------------------------------------------
* -----------------------------------------------------------------------------
*
* Logical Drive commands
*
* -----------------------------------------------------------------------------
* -----------------------------------------------------------------------------
*/
/*
* Input: dcmd.opcode - MR_DCMD_LD_GET_LIST
* dcmd.mbox - reserved
* dcmd.sge IN - ptr to returned MR_LD_LIST structure
* Desc: Return the logical drive list structure
* Status: No error
*/
/*
* defines the logical drive reference structure
*/
struct {
} ld_ref;
/*
* defines the logical drive list structure
*/
typedef struct _MR_LD_LIST {
struct {
} MR_LD_LIST;
/* 4 + 4 + (MAX_LOGICAL_DRIVES * 16), for 40LD it is = 648 bytes */
#pragma pack()
/*
* dma_obj_t - Our DMA object
* @param buffer : kernel virtual address
* @param size : size of the data to be allocated
* @param acc_handle : access handle
* @param dma_handle : dma handle
* @param dma_cookie : scatter-gather list
* @param dma_attr : dma attributes for this buffer
*
* Our DMA object. The caller must initialize the size and dma attributes
* (dma_attr) fields before allocating the resources.
*/
typedef struct {
} dma_obj_t;
struct megasas_instance {
int baseaddress;
int fm_capabilities;
};
struct megasas_func_ptr {
struct megasas_cmd *);
struct megasas_cmd *);
};
/*
* ### Helper routines ###
*/
/*
* con_log() - console log routine
* @param level : indicates the severity of the message.
* @fparam mt : format string
*
* con_log displays the error messages on the console based on the current
* debug level. Also it attaches the appropriate kernel severity level with
* the message.
*
*
* console messages debug levels
*/
#ifdef __SUNPRO_C
#endif
#if DEBUG
#else
#endif /* DEBUG */
/* byte-ordering macros */
#ifdef __sparc
#else
#define host_to_le16(s) (s)
#endif
#ifdef __sparc
((l) & 0xFF0000) >> 8 | ((l) & 0xFF000000) >> 24)
#else
#define host_to_le32(l) (l)
#endif
#ifdef __sparc
#else
#endif
/*
* ### SCSA definitions ###
*/
/*
* ### Data structures for ioctl inteface and internal commands ###
*/
/*
* Data direction flags
*/
/*
* #define MAP_DEVICE_ID(instance,ap) \
* (ap->a_target)
*/
#define NORMAL_LEVEL_INTR 0
/*
* scsa_cmd - Per-command mega private data
* @param cmd_dmahandle : dma handle
* @param cmd_dmacookies : current dma cookies
* @param cmd_pkt : scsi_pkt reference
* @param cmd_dmacount : dma count
* @param cmd_cookie : next cookie
* @param cmd_ncookies : cookies per window
* @param cmd_cookiecnt : cookies per sub-win
* @param cmd_nwin : number of dma windows
* @param cmd_curwin : current dma window
* @param cmd_dma_offset : current window offset
* @param cmd_dma_len : current window length
* @param cmd_flags : private flags
* @param cmd_cdblen : length of cdb
* @param cmd_scblen : length of scb
* @param cmd_buf : command buffer
* @param channel : channel for scsi sub-system
* @param target : target for scsi sub-system
* @param lun : LUN for scsi sub-system
*
* - Allocated at same time as scsi_pkt by scsi_hba_pkt_alloc(9E)
* - Pointed to by pkt_ha_private field in scsi_pkt
*/
struct scsa_cmd {
};
struct megasas_cmd {
};
struct megasas_mgmt_info {
int max_index;
};
#pragma pack(1)
struct megasas_drv_ver {
};
struct megasas_pci_common_header {
union {
struct {
} type_0;
struct {
} type_1;
struct {
struct {
} type_2;
} header;
};
struct megasas_pci_link_capability {
union {
struct {
} bits;
} cap;
};
struct megasas_pci_link_status_capability {
union {
struct {
} bits;
} stat_cap;
};
struct megasas_pci_capabilities {
};
struct megasas_pci_information
{
};
struct megasas_ioctl {
};
struct megasas_aen {
};
#pragma pack()
#ifndef DDI_VENDOR_LSI
#endif /* DDI_VENDOR_LSI */
scsi_hba_tran_t *, struct scsi_device *);
int (*)(), caddr_t);
static int megasas_tran_start(struct scsi_address *,
register struct scsi_pkt *);
static int megasas_tran_reset(struct scsi_address *, int);
static int megasas_tran_bus_reset(dev_info_t *, int);
static int megasas_tran_getcap(struct scsi_address *, char *, int);
static int megasas_tran_setcap(struct scsi_address *, char *, int, int);
static void megasas_tran_destroy_pkt(struct scsi_address *,
struct scsi_pkt *);
static uint_t megasas_isr();
static uint_t megasas_softintr();
static int init_mfi(struct megasas_instance *);
static void return_mfi_pkt(struct megasas_instance *,
struct megasas_cmd *);
static void free_space_for_mfi(struct megasas_instance *);
static void free_additional_dma_buffer(struct megasas_instance *);
static int alloc_additional_dma_buffer(struct megasas_instance *);
static int read_fw_status_reg_xscale(struct megasas_instance *);
static int read_fw_status_reg_ppc(struct megasas_instance *);
static void issue_cmd_xscale(struct megasas_cmd *,
struct megasas_instance *);
static int issue_cmd_in_poll_mode_xscale(struct megasas_instance *,
struct megasas_cmd *);
static int issue_cmd_in_poll_mode_ppc(struct megasas_instance *,
struct megasas_cmd *);
static int issue_cmd_in_sync_mode_xscale(struct megasas_instance *,
struct megasas_cmd *);
static int issue_cmd_in_sync_mode_ppc(struct megasas_instance *,
struct megasas_cmd *);
static void enable_intr_xscale(struct megasas_instance *);
static void enable_intr_ppc(struct megasas_instance *);
static void disable_intr_xscale(struct megasas_instance *);
static void disable_intr_ppc(struct megasas_instance *);
static int intr_ack_xscale(struct megasas_instance *);
static int intr_ack_ppc(struct megasas_instance *);
static int mfi_state_transition_to_ready(struct megasas_instance *);
static void destroy_mfi_frame_pool(struct megasas_instance *);
static int create_mfi_frame_pool(struct megasas_instance *);
struct buf *, int, int (*)());
static int megasas_dma_move(struct megasas_instance *,
static void display_scsi_inquiry(caddr_t);
struct megasas_aen *aen);
struct megasas_cmd *cmd_to_abort);
struct megasas_cmd *cmd);
const void *);
char *detail);
#ifdef __cplusplus
}
#endif
#endif /* _MEGARAID_SAS_H_ */