/*
* mr_sas.h: header for mr_sas
*
* Solaris MegaRAID driver for SAS2.0 controllers
* Copyright (c) 2008-2012, LSI Logic Corporation.
* All rights reserved.
*
* Version:
* Author:
* Swaminathan K S
* Arun Chandrashekhar
* Manju R
* Rasheed
* Shakeel Bukhari
*
* 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 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2015 Garrett D'Amore <garrett@damore.org>
*/
#ifndef _MR_SAS_H_
#define _MR_SAS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "mr_sas_list.h"
#include "ld_pd_map.h"
/*
* MegaRAID SAS2.0 Driver meta data
*/
#define MRSAS_FALSE 0
#define ADAPTER_RESET_NOT_REQUIRED 0
/*
* MegaRAID SAS2.0 device id conversion definitions.
*/
int rem; \
} else { \
} \
}
/*
* MegaRAID SAS2.0 supported controllers
*/
/*
* Register Index for 2108 Controllers.
*/
#ifdef PDSUPPORT
#endif
/* Raid Context Flags */
typedef enum MR_RAID_FLAGS_IO_SUB_TYPE {
/* Dynamic Enumeration Flags */
#define MRSAS_LD_LUN 0
/* ThunderBolt (TB) specific */
/*
* =====================================
* MegaRAID SAS2.0 MFI firmware definitions
* =====================================
*/
/*
* MFI stands for MegaRAID SAS2.0 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 {
};
enum LD_STATE {
LD_OFFLINE = 0,
};
enum MRSAS_EVT {
MRSAS_EVT_CONFIG_TGT = 0,
};
/*
* 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 mrsas_eventinfo {
int tgt;
int lun;
int event;
};
struct mrsas_ld {
};
#ifdef PDSUPPORT
struct mrsas_tbolt_pd {
};
struct mrsas_tbolt_pd_info {
uint8_t a;
struct {
} pathInfo;
};
#endif
typedef struct mrsas_instance {
/* ThunderBolt (TB) specific */
int instance;
int baseaddress;
int fm_capabilities;
/*
* Driver resources unroll flags. The flag is set for resources that
* are needed to be free'd at detach() time.
*/
struct _unroll {
} unroll;
/* function template pointer */
/* MSI interrupts specific */
int intr_type;
int intr_cnt;
int intr_cap;
/* ThunderBolt (TB) specific */
#ifdef PDSUPPORT
#endif
/* Virtual address of request desc frame pool */
/* Physical address of request desc frame pool */
/* Virtual address of reply Frame */
/* Physical address of reply Frame */
/* Physical address of Last reply frame */
} mrsas_t;
/*
* Function templates for various controller specific functions
*/
struct mrsas_function_template {
struct mrsas_cmd *);
struct mrsas_cmd *);
/* int (*reset_adapter)(struct mrsas_instance *); */
};
/*
* ### 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
/*
* ### SCSA definitions ###
*/
/*
* ### Data structures for ioctl inteface and internal commands ###
*/
/*
* Data direction flags
*/
#define NORMAL_LEVEL_INTR 0
#define IO_TIMEOUT_VAL 0
/*
* scsa_cmd - Per-command mr 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 mrsas_cmd {
/*
* ThunderBolt(TB) We would be needing to have a placeholder
* for RAID_MSG_IO_REQUEST inside this structure. We are
* supposed to embed the mr_frame inside the RAID_MSG and post
* it down to the firmware.
*/
};
struct mrsas_mgmt_info {
int max_index;
};
#pragma pack(1)
/*
* SAS controller properties
*/
struct mrsas_ctrl_prop {
};
/*
* SAS controller information
*/
struct mrsas_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 SAS2.0 driver definitions
* ==================================
*/
#define MRSAS_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 mrsas_register_set*
*/
(v))
/* Thunderbolt specific registers */
(uint32_t *)\
(v))
(uint32_t *)\
(v))
(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_2108_MESSAGE_INTR flag is used also
* in enable_intr_ppc also. Hence bit 2, i.e. 0x4 has
* been set in this flag along with bit 1.
*/
/* Fusion interrupt mask */
{ \
}
/* By default, the firmware programs for 8 Kbytes of memory */
/* DCMD Message Frame MAILBOX0-11 */
/*
* on_off_property of mrsas_ctrl_prop
* bit0-9, 11-31 are reserved
*/
struct mrsas_register_set {
};
struct mrsas_sge32 {
};
struct mrsas_sge64 {
};
struct mrsas_sge_ieee {
};
union mrsas_sgl {
};
struct mrsas_header {
};
union mrsas_sgl_frame {
};
struct mrsas_init_frame {
};
struct mrsas_init_queue_info {
};
struct mrsas_io_frame {
};
struct mrsas_pthru_frame {
};
struct mrsas_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 mrsas_abort_frame {
};
struct mrsas_smp_frame {
};
struct mrsas_stp_frame {
};
union mrsas_frame {
};
typedef struct mrsas_pd_address {
union {
struct {
} pd_address;
struct {
} encl_address;
}address;
union {
} connected;
union mrsas_evt_class_locale {
struct {
} members;
};
struct mrsas_evt_log_info {
};
struct mrsas_progress {
};
struct mrsas_evtarg_ld {
};
struct mrsas_evtarg_pd {
};
struct mrsas_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;
struct mrsas_drv_ver {
};
struct mrsas_pci_common_header {
union {
struct {
} type_0;
struct {
} type_1;
struct {
struct {
} type_2;
} header;
};
struct mrsas_pci_link_capability {
union {
struct {
} bits;
} cap;
};
struct mrsas_pci_link_status_capability {
union {
struct {
} bits;
} stat_cap;
};
struct mrsas_pci_capabilities {
};
struct mrsas_pci_information
{
};
struct mrsas_ioctl {
};
struct mrsas_aen {
};
#pragma pack()
#ifndef DDI_VENDOR_LSI
#endif /* DDI_VENDOR_LSI */
int mrsas_config_scsi_device(struct mrsas_instance *,
struct scsi_device *, dev_info_t **);
#ifdef PDSUPPORT
uint8_t, dev_info_t **);
#endif
int alloc_space_for_mpi2(struct mrsas_instance *);
int mrsas_issue_init_mpi2(struct mrsas_instance *);
int (*)(), caddr_t);
int mrsas_tbolt_tran_start(struct scsi_address *,
register struct scsi_pkt *);
int tbolt_issue_cmd_in_poll_mode(struct mrsas_instance *,
struct mrsas_cmd *);
int tbolt_issue_cmd_in_sync_mode(struct mrsas_instance *,
struct mrsas_cmd *);
void tbolt_enable_intr(struct mrsas_instance *);
void tbolt_disable_intr(struct mrsas_instance *);
int tbolt_intr_ack(struct mrsas_instance *);
struct buf *, int, int (*)());
int mrsas_dma_move(struct mrsas_instance *,
uchar_t);
void tbolt_complete_cmd_in_sync_mode(struct mrsas_instance *,
struct mrsas_cmd *);
int alloc_req_rep_desc(struct mrsas_instance *);
int mrsas_mode_sense_build(struct scsi_pkt *);
void push_pending_mfi_pkt(struct mrsas_instance *,
struct mrsas_cmd *);
int mrsas_issue_pending_cmds(struct mrsas_instance *);
int mrsas_print_pending_cmds(struct mrsas_instance *);
int mrsas_complete_pending_cmds(struct mrsas_instance *);
int create_mfi_frame_pool(struct mrsas_instance *);
void destroy_mfi_frame_pool(struct mrsas_instance *);
int create_mfi_mpi_frame_pool(struct mrsas_instance *);
void destroy_mfi_mpi_frame_pool(struct mrsas_instance *);
int create_mpi2_frame_pool(struct mrsas_instance *);
void destroy_mpi2_frame_pool(struct mrsas_instance *);
void mrsas_tbolt_free_additional_dma_buffer(struct mrsas_instance *);
void free_req_desc_pool(struct mrsas_instance *);
void free_space_for_mpi2(struct mrsas_instance *);
void mrsas_dump_reply_desc(struct mrsas_instance *);
void display_scsi_inquiry(caddr_t);
int mrsas_mode_sense_build(struct scsi_pkt *);
int mrsas_tbolt_get_ld_map_info(struct mrsas_instance *);
int mfi_state_transition_to_ready(struct mrsas_instance *);
/* FMA functions. */
void mrsas_fm_ereport(struct mrsas_instance *, char *);
#ifdef __cplusplus
}
#endif
#endif /* _MR_SAS_H_ */