Print this page
@@ -10,12 +10,43 @@
* 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
+ * and/or other materials provided with the distribution.
+ *
+ * 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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
#ifndef _MR_SAS_H_
#define _MR_SAS_H_
#ifdef __cplusplus
extern "C" {
@@ -26,11 +57,11 @@
#include "ld_pd_map.h"
/*
* MegaRAID SAS2.0 Driver meta data
*/
-#define MRSAS_VERSION "6.503.00.00JOYENT"
+#define MRSAS_VERSION "6.503.00.00ILLUMOS"
#define MRSAS_RELDATE "July 30, 2012"
#define MRSAS_TRUE 1
#define MRSAS_FALSE 0
@@ -37,12 +68,10 @@
#define ADAPTER_RESET_NOT_REQUIRED 0
#define ADAPTER_RESET_REQUIRED 1
#define PDSUPPORT 1
-#define SWAP_BYTES(w) ((((w)>>8)&0xFF) | (((w)&0xFF)<<8))
-#define BIG_ENDIAN(d) (SWAP_BYTES((d) >> 16) | (SWAP_BYTES(d) << 16))
/*
* MegaRAID SAS2.0 device id conversion definitions.
*/
#define INST2LSIRDCTL(x) ((x) << INST_MINOR_SHIFT)
#define MRSAS_GET_BOUNDARY_ALIGNED_LEN(len, new_len, boundary_len) { \
@@ -51,11 +80,11 @@
if ((rem * boundary_len) != len) { \
new_len = len + ((rem + 1) * boundary_len - len); \
} else { \
new_len = len; \
} \
-} \
+}
/*
* MegaRAID SAS2.0 supported controllers
*/
@@ -508,45 +537,47 @@
uint16_t subsysid;
int instance;
int baseaddress;
char iocnode[16];
- /*Driver resources unroll flags.
- The flag is set for resources that are needed to be free'd at detach() time */
-
+ 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 {
- uint8_t softs; // The software state was allocated.
- uint8_t regs; // Controller registers mapped.
- uint8_t intr; // Interrupt handler added.
- uint8_t reqs; // Request structs allocated.
- uint8_t mutexs; // Mutex's allocated.
- uint8_t taskq; // Task q's created.
- uint8_t tran; // Tran struct allocated
- uint8_t tranSetup; // Tran attached to the ddi.
- uint8_t devctl; // Device nodes for cfgadm created.
- uint8_t scsictl; // Device nodes for cfgadm created.
- uint8_t ioctl; // Device nodes for ioctl's created.
- uint8_t timer; // Timer started.
- uint8_t aenPend; // AEN cmd pending f/w.
- uint8_t mapUpdate_pend; // LD MAP update cmd pending f/w.
- uint8_t soft_isr;
- uint8_t ldlist_buff;
- uint8_t pdlist_buff;
- uint8_t syncCmd;
- uint8_t verBuff;
- uint8_t alloc_space_mfi;
- uint8_t alloc_space_mpi2;
+ uint8_t softs; /* The software state was allocated. */
+ uint8_t regs; /* Controller registers mapped. */
+ uint8_t intr; /* Interrupt handler added. */
+ uint8_t reqs; /* Request structs allocated. */
+ uint8_t mutexs; /* Mutex's allocated. */
+ uint8_t taskq; /* Task q's created. */
+ uint8_t tran; /* Tran struct allocated */
+ uint8_t tranSetup; /* Tran attached to the ddi. */
+ uint8_t devctl; /* Device nodes for cfgadm created. */
+ uint8_t scsictl; /* Device nodes for cfgadm created. */
+ uint8_t ioctl; /* Device nodes for ioctl's created. */
+ uint8_t timer; /* Timer started. */
+ uint8_t aenPend; /* AEN cmd pending f/w. */
+ uint8_t mapUpdate_pend; /* LD MAP update cmd pending f/w. */
+ uint8_t soft_isr; /* Soft interrupt handler allocated. */
+ uint8_t ldlist_buff; /* Logical disk list allocated. */
+ uint8_t pdlist_buff; /* Physical disk list allocated. */
+ uint8_t syncCmd; /* Sync map command allocated. */
+ uint8_t verBuff; /* 2108 MFI buffer allocated. */
+ uint8_t alloc_space_mfi; /* Allocated space for 2108 MFI. */
+ uint8_t alloc_space_mpi2; /* Allocated space for 2208 MPI2. */
} unroll;
/* function template pointer */
struct mrsas_function_template *func_ptr;
/* MSI interrupts specific */
- ddi_intr_handle_t *intr_htable; //Interrupt handle array
- size_t intr_htable_size; //Interrupt handle array size
+ ddi_intr_handle_t *intr_htable; /* Interrupt handle array */
+ size_t intr_htable_size; /* Int. handle array size */
int intr_type;
int intr_cnt;
uint_t intr_pri;
int intr_cap;
@@ -563,21 +594,26 @@
uint8_t fast_path_io;
uint16_t tbolt;
uint16_t reply_read_index;
- uint16_t reply_size; // Single Reply structure size
- uint16_t raid_io_msg_size; // Single message size
+ uint16_t reply_size; /* Single Reply struct size */
+ uint16_t raid_io_msg_size; /* Single message size */
uint32_t io_request_frames_phy;
uint8_t *io_request_frames;
- MRSAS_REQUEST_DESCRIPTOR_UNION *request_message_pool; // Virtual address of request desc frame pool
- uint32_t request_message_pool_phy; // Physical address of request desc frame pool
- MPI2_REPLY_DESCRIPTORS_UNION *reply_frame_pool; // Virtual address of reply Frame
- uint32_t reply_frame_pool_phy; // Physical address of reply Frame
- uint8_t *reply_pool_limit; // Last reply frame address
- uint32_t reply_pool_limit_phy; // Physical address of Last reply frame
- uint32_t reply_q_depth; // Reply Queue Depth
+ /* Virtual address of request desc frame pool */
+ MRSAS_REQUEST_DESCRIPTOR_UNION *request_message_pool;
+ /* Physical address of request desc frame pool */
+ uint32_t request_message_pool_phy;
+ /* Virtual address of reply Frame */
+ MPI2_REPLY_DESCRIPTORS_UNION *reply_frame_pool;
+ /* Physical address of reply Frame */
+ uint32_t reply_frame_pool_phy;
+ uint8_t *reply_pool_limit; /* Last reply frame address */
+ /* Physical address of Last reply frame */
+ uint32_t reply_pool_limit_phy;
+ uint32_t reply_q_depth; /* Reply Queue Depth */
uint8_t max_sge_in_main_msg;
uint8_t max_sge_in_chain;
uint8_t chain_offset_io_req;
uint8_t chain_offset_mpt_msg;
MR_FW_RAID_MAP_ALL *ld_map[2];
@@ -604,11 +640,11 @@
struct mrsas_cmd *);
void (*enable_intr)(struct mrsas_instance *);
void (*disable_intr)(struct mrsas_instance *);
int (*intr_ack)(struct mrsas_instance *);
int (*init_adapter)(struct mrsas_instance *);
-// int (*reset_adapter)(struct mrsas_instance *);
+/* int (*reset_adapter)(struct mrsas_instance *); */
};
/*
* ### Helper routines ###
*/
@@ -625,17 +661,17 @@
*
* console messages debug levels
*/
#define CL_NONE 0 /* No debug information */
#define CL_ANN 1 /* print unconditionally, announcements */
-#define CL_ANN1 2 /* No o/p */
+#define CL_ANN1 2 /* No-op */
#define CL_DLEVEL1 3 /* debug level 1, informative */
#define CL_DLEVEL2 4 /* debug level 2, verbose */
#define CL_DLEVEL3 5 /* debug level 3, very verbose */
#ifdef __SUNPRO_C
-#define __func__ __FUNCTION__ //""
+#define __func__ ""
#endif
#define con_log(level, fmt) { if (debug_level_g >= level) cmn_err fmt; }
/*
@@ -1915,126 +1951,26 @@
#ifndef DDI_VENDOR_LSI
#define DDI_VENDOR_LSI "LSI"
#endif /* DDI_VENDOR_LSI */
-static int mrsas_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
-static int mrsas_attach(dev_info_t *, ddi_attach_cmd_t);
-static int mrsas_reset(dev_info_t *, ddi_reset_cmd_t);
-int mrsas_quiesce(dev_info_t *);
-static int mrsas_detach(dev_info_t *, ddi_detach_cmd_t);
-static int mrsas_open(dev_t *, int, int, cred_t *);
-static int mrsas_close(dev_t, int, int, cred_t *);
-static int mrsas_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
-
-static int mrsas_tran_tgt_init(dev_info_t *, dev_info_t *,
- scsi_hba_tran_t *, struct scsi_device *);
-static struct scsi_pkt *mrsas_tran_init_pkt(struct scsi_address *, register
- struct scsi_pkt *, struct buf *, int, int, int, int,
- int (*)(), caddr_t);
-static int mrsas_tran_start(struct scsi_address *,
- register struct scsi_pkt *);
-static int mrsas_tran_abort(struct scsi_address *, struct scsi_pkt *);
-static int mrsas_tran_reset(struct scsi_address *, int);
-static int mrsas_tran_bus_reset(dev_info_t *, int);
-static int mrsas_tran_getcap(struct scsi_address *, char *, int);
-static int mrsas_tran_setcap(struct scsi_address *, char *, int, int);
-static void mrsas_tran_destroy_pkt(struct scsi_address *,
- struct scsi_pkt *);
-static void mrsas_tran_dmafree(struct scsi_address *, struct scsi_pkt *);
-static void mrsas_tran_sync_pkt(struct scsi_address *, struct scsi_pkt *);
-static int mrsas_tran_quiesce(dev_info_t *dip);
-static int mrsas_tran_unquiesce(dev_info_t *dip);
-static uint_t mrsas_isr();
-static uint_t mrsas_softintr();
-
-static struct mrsas_cmd *get_mfi_pkt(struct mrsas_instance *);
-static void return_mfi_pkt(struct mrsas_instance *,
- struct mrsas_cmd *);
-
-static void free_space_for_mfi(struct mrsas_instance *);
-static int mrsas_tbolt_alloc_additional_dma_buffer
-(struct mrsas_instance *);
-int mrsas_tbolt_sync_map_info(struct mrsas_instance *instance);
-static int alloc_additional_dma_buffer(struct mrsas_instance *);
-static uint32_t read_fw_status_reg_ppc(struct mrsas_instance *);
-static void issue_cmd_ppc(struct mrsas_cmd *, struct mrsas_instance *);
-static int issue_cmd_in_poll_mode_ppc(struct mrsas_instance *,
- struct mrsas_cmd *);
-static int issue_cmd_in_sync_mode_ppc(struct mrsas_instance *,
- struct mrsas_cmd *);
-static void enable_intr_ppc(struct mrsas_instance *);
-static void disable_intr_ppc(struct mrsas_instance *);
-static int intr_ack_ppc(struct mrsas_instance *);
-int mfi_state_transition_to_ready(struct mrsas_instance *);
-static void flush_cache(struct mrsas_instance *instance);
-void display_scsi_inquiry(caddr_t);
-static int start_mfi_aen(struct mrsas_instance *instance);
-static int handle_drv_ioctl(struct mrsas_instance *instance,
- struct mrsas_ioctl *ioctl, int mode);
-static int handle_mfi_ioctl(struct mrsas_instance *instance,
- struct mrsas_ioctl *ioctl, int mode);
-static int handle_mfi_aen(struct mrsas_instance *instance,
- struct mrsas_aen *aen);
-void fill_up_drv_ver(struct mrsas_drv_ver *dv);
-static struct mrsas_cmd *build_cmd(struct mrsas_instance *instance,
- struct scsi_address *ap, struct scsi_pkt *pkt,
- uchar_t *cmd_done);
-static struct mrsas_cmd *mrsas_tbolt_build_cmd(struct mrsas_instance *instance,
- struct scsi_address *ap, struct scsi_pkt *pkt,
- uchar_t *cmd_done);
-static int wait_for_outstanding(struct mrsas_instance *instance);
-static int register_mfi_aen(struct mrsas_instance *instance,
- uint32_t seq_num, uint32_t class_locale_word);
-static int issue_mfi_pthru(struct mrsas_instance *instance, struct
- mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
-static int issue_mfi_dcmd(struct mrsas_instance *instance, struct
- mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
-static int issue_mfi_smp(struct mrsas_instance *instance, struct
- mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
-static int issue_mfi_stp(struct mrsas_instance *instance, struct
- mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
-static int abort_aen_cmd(struct mrsas_instance *instance,
- struct mrsas_cmd *cmd_to_abort);
-
-
-static void mrsas_rem_intrs(struct mrsas_instance *instance);
-static int mrsas_add_intrs(struct mrsas_instance *instance, int intr_type);
-
-static void mrsas_tran_tgt_free(dev_info_t *, dev_info_t *,
- scsi_hba_tran_t *, struct scsi_device *);
-static int mrsas_tran_bus_config(dev_info_t *, uint_t,
- ddi_bus_config_op_t, void *, dev_info_t **);
-static int mrsas_parse_devname(char *, int *, int *);
-static int mrsas_config_all_devices(struct mrsas_instance *);
int mrsas_config_scsi_device(struct mrsas_instance *,
struct scsi_device *, dev_info_t **);
-static int mrsas_config_ld(struct mrsas_instance *, uint16_t,
- uint8_t, dev_info_t **);
#ifdef PDSUPPORT
int mrsas_tbolt_config_pd(struct mrsas_instance *, uint16_t,
uint8_t, dev_info_t **);
-static void mrsas_tbolt_get_pd_info(struct mrsas_instance *,
- struct mrsas_tbolt_pd_info *, int);
#endif
-dev_info_t *mrsas_find_child(struct mrsas_instance *, uint16_t,
- uint8_t);
-static int mrsas_name_node(dev_info_t *, char *, int);
-static void mrsas_issue_evt_taskq(struct mrsas_eventinfo *);
-int mrsas_service_evt(struct mrsas_instance *, int, int, int,
- uint64_t);
-static void free_additional_dma_buffer(struct mrsas_instance *);
-
-struct mrsas_cmd *get_raid_msg_pkt(struct mrsas_instance *);
+dev_info_t *mrsas_find_child(struct mrsas_instance *, uint16_t, uint8_t);
+int mrsas_service_evt(struct mrsas_instance *, int, int, int, uint64_t);
void return_raid_msg_pkt(struct mrsas_instance *, struct mrsas_cmd *);
struct mrsas_cmd *get_raid_msg_mfi_pkt(struct mrsas_instance *);
void return_raid_msg_mfi_pkt(struct mrsas_instance *, struct mrsas_cmd *);
int alloc_space_for_mpi2(struct mrsas_instance *);
-int alloc_additional_dma_buffer(struct mrsas_instance *);
+void fill_up_drv_ver(struct mrsas_drv_ver *dv);
int mrsas_issue_init_mpi2(struct mrsas_instance *);
struct scsi_pkt *mrsas_tbolt_tran_init_pkt(struct scsi_address *, register
struct scsi_pkt *, struct buf *, int, int, int, int,
int (*)(), caddr_t);
@@ -2058,41 +1994,22 @@
struct buf *, int, int (*)());
int mrsas_dma_move(struct mrsas_instance *,
struct scsi_pkt *, struct buf *);
int mrsas_alloc_dma_obj(struct mrsas_instance *, dma_obj_t *,
uchar_t);
-int mrsas_tbolt_ioc_init(struct mrsas_instance *, dma_obj_t *,
- ddi_acc_handle_t);
-int mrsas_tbolt_prepare_pkt(struct scsa_cmd *);
void mr_sas_tbolt_build_mfi_cmd(struct mrsas_instance *, struct mrsas_cmd *);
int mrsas_dma_alloc_dmd(struct mrsas_instance *, dma_obj_t *);
-int mr_sas_tbolt_build_sgl(struct mrsas_instance *,
- struct scsa_cmd *,
- struct mrsas_cmd *,
- Mpi2RaidSCSIIORequest_t *,
- uint32_t *);
void tbolt_complete_cmd_in_sync_mode(struct mrsas_instance *,
struct mrsas_cmd *);
int alloc_req_rep_desc(struct mrsas_instance *);
-static void complete_cmd_in_sync_mode(struct mrsas_instance *,
- struct mrsas_cmd *);
-static void io_timeout_checker(void *instance);
-static int mrsas_kill_adapter(struct mrsas_instance *);
int mrsas_mode_sense_build(struct scsi_pkt *);
void push_pending_mfi_pkt(struct mrsas_instance *,
struct mrsas_cmd *);
-static int mrsas_issue_init_mfi(struct mrsas_instance *);
int mrsas_issue_pending_cmds(struct mrsas_instance *);
int mrsas_print_pending_cmds(struct mrsas_instance *);
int mrsas_complete_pending_cmds(struct mrsas_instance *);
-static int mrsas_reset_ppc(struct mrsas_instance *);
-static uint32_t mrsas_initiate_ocr_if_fw_is_faulty(struct mrsas_instance *);
-MRSAS_REQUEST_DESCRIPTOR_UNION *\
- mr_sas_get_request_descriptor(struct mrsas_instance *,
- uint16_t, struct mrsas_cmd *);
-
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 *);
@@ -2101,38 +2018,41 @@
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 tbolt_complete_cmd(struct mrsas_instance *, struct mrsas_cmd *);
-void io_timeout_checker(void *);
void display_scsi_inquiry(caddr_t);
void service_mfi_aen(struct mrsas_instance *, struct mrsas_cmd *);
int mrsas_mode_sense_build(struct scsi_pkt *);
int mrsas_tbolt_get_ld_map_info(struct mrsas_instance *);
-void mrsas_tbolt_set_pd_lba(U8 cdb[], uint8_t *cdb_len, U64 start_blk, U32 num_blocks, U8 DifCapable);
-U8 mrsas_tbolt_check_map_info(struct mrsas_instance *);
struct mrsas_cmd *mrsas_tbolt_build_poll_cmd(struct mrsas_instance *,
struct scsi_address *, struct scsi_pkt *, uchar_t *);
int mrsas_tbolt_reset_ppc(struct mrsas_instance *instance);
-int mrsas_tbolt_kill_adapter(struct mrsas_instance *instance);
+void mrsas_tbolt_kill_adapter(struct mrsas_instance *instance);
int abort_syncmap_cmd(struct mrsas_instance *, struct mrsas_cmd *);
-void mrsas_tbolt_prepare_cdb(struct mrsas_instance *instance, U8 cdb[],struct IO_REQUEST_INFO *,
- Mpi2RaidSCSIIORequest_t *, U32);
+void mrsas_tbolt_prepare_cdb(struct mrsas_instance *instance, U8 cdb[],
+ struct IO_REQUEST_INFO *, Mpi2RaidSCSIIORequest_t *, U32);
-static int
-mrsas_undo_resources (dev_info_t *dip, struct mrsas_instance *instance);
+int mrsas_init_adapter_ppc(struct mrsas_instance *instance);
+int mrsas_init_adapter_tbolt(struct mrsas_instance *instance);
+int mrsas_init_adapter(struct mrsas_instance *instance);
-int mrsas_init_adapter_ppc (struct mrsas_instance *instance);
-int mrsas_init_adapter_tbolt (struct mrsas_instance *instance);
-int mrsas_init_adapter (struct mrsas_instance *instance);
-
int mrsas_alloc_cmd_pool(struct mrsas_instance *instance);
void mrsas_free_cmd_pool(struct mrsas_instance *instance);
-void mrsas_print_cmd_details(struct mrsas_instance *, struct mrsas_cmd *, int );
+void mrsas_print_cmd_details(struct mrsas_instance *, struct mrsas_cmd *, int);
+struct mrsas_cmd *get_raid_msg_pkt(struct mrsas_instance *);
+int mfi_state_transition_to_ready(struct mrsas_instance *);
+
+
+/* FMA functions. */
+int mrsas_common_check(struct mrsas_instance *, struct mrsas_cmd *);
+void mrsas_fm_ereport(struct mrsas_instance *, char *);
+
+
#ifdef __cplusplus
}
#endif
#endif /* _MR_SAS_H_ */