2006-03-25 06:14:32 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2006 IronPort Systems
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-08-25 23:58:45 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2007 LSI Corp.
|
|
|
|
* Copyright (c) 2007 Rajesh Prabhakaran.
|
|
|
|
* 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.
|
|
|
|
*/
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
#ifndef _MFIVAR_H
|
|
|
|
#define _MFIVAR_H
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2007-08-13 19:29:17 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/sx.h>
|
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
#include <sys/types.h>
|
2012-03-30 23:05:48 +00:00
|
|
|
#include <sys/taskqueue.h>
|
2012-07-11 19:08:23 +00:00
|
|
|
#include "opt_mfi.h"
|
2011-11-04 02:34:52 +00:00
|
|
|
|
2006-03-25 06:14:32 +00:00
|
|
|
/*
|
|
|
|
* SCSI structures and definitions are used from here, but no linking
|
|
|
|
* requirements are made to CAM.
|
|
|
|
*/
|
|
|
|
#include <cam/scsi/scsi_all.h>
|
|
|
|
|
|
|
|
struct mfi_hwcomms {
|
|
|
|
uint32_t hw_pi;
|
|
|
|
uint32_t hw_ci;
|
|
|
|
uint32_t hw_reply_q[1];
|
|
|
|
};
|
2012-03-30 23:05:48 +00:00
|
|
|
#define MEGASAS_MAX_NAME 32
|
|
|
|
#define MEGASAS_VERSION "4.23"
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
struct mfi_softc;
|
2007-05-10 15:33:41 +00:00
|
|
|
struct disk;
|
2007-05-16 17:23:36 +00:00
|
|
|
struct ccb_hdr;
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
struct mfi_command {
|
|
|
|
TAILQ_ENTRY(mfi_command) cm_link;
|
2006-09-25 11:35:34 +00:00
|
|
|
time_t cm_timestamp;
|
2006-03-25 06:14:32 +00:00
|
|
|
struct mfi_softc *cm_sc;
|
|
|
|
union mfi_frame *cm_frame;
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_addr_t cm_frame_busaddr;
|
2006-03-25 06:14:32 +00:00
|
|
|
struct mfi_sense *cm_sense;
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_addr_t cm_sense_busaddr;
|
2006-03-25 06:14:32 +00:00
|
|
|
bus_dmamap_t cm_dmamap;
|
|
|
|
union mfi_sgl *cm_sg;
|
|
|
|
void *cm_data;
|
|
|
|
int cm_len;
|
2011-09-29 08:37:53 +00:00
|
|
|
int cm_stp_len;
|
2006-03-25 06:14:32 +00:00
|
|
|
int cm_total_frame_size;
|
|
|
|
int cm_extra_frames;
|
|
|
|
int cm_flags;
|
|
|
|
#define MFI_CMD_MAPPED (1<<0)
|
|
|
|
#define MFI_CMD_DATAIN (1<<1)
|
|
|
|
#define MFI_CMD_DATAOUT (1<<2)
|
|
|
|
#define MFI_CMD_COMPLETED (1<<3)
|
|
|
|
#define MFI_CMD_POLLED (1<<4)
|
|
|
|
#define MFI_ON_MFIQ_FREE (1<<5)
|
|
|
|
#define MFI_ON_MFIQ_READY (1<<6)
|
|
|
|
#define MFI_ON_MFIQ_BUSY (1<<7)
|
|
|
|
#define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7))
|
2011-11-04 02:34:52 +00:00
|
|
|
uint8_t retry_for_fw_reset;
|
2006-03-25 06:14:32 +00:00
|
|
|
void (* cm_complete)(struct mfi_command *cm);
|
|
|
|
void *cm_private;
|
2006-09-25 11:35:34 +00:00
|
|
|
int cm_index;
|
2007-06-04 16:39:22 +00:00
|
|
|
int cm_error;
|
2006-03-25 06:14:32 +00:00
|
|
|
};
|
|
|
|
|
2007-05-10 15:33:41 +00:00
|
|
|
struct mfi_disk {
|
|
|
|
TAILQ_ENTRY(mfi_disk) ld_link;
|
|
|
|
device_t ld_dev;
|
|
|
|
int ld_id;
|
|
|
|
int ld_unit;
|
|
|
|
struct mfi_softc *ld_controller;
|
2006-06-20 22:41:44 +00:00
|
|
|
struct mfi_ld_info *ld_info;
|
2007-05-10 15:33:41 +00:00
|
|
|
struct disk *ld_disk;
|
|
|
|
int ld_flags;
|
|
|
|
#define MFI_DISK_FLAGS_OPEN 0x01
|
2007-08-13 19:29:17 +00:00
|
|
|
#define MFI_DISK_FLAGS_DISABLED 0x02
|
2006-03-25 06:14:32 +00:00
|
|
|
};
|
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
struct mfi_system_pd {
|
2012-03-30 23:05:48 +00:00
|
|
|
TAILQ_ENTRY(mfi_system_pd) pd_link;
|
2011-11-04 02:34:52 +00:00
|
|
|
device_t pd_dev;
|
|
|
|
int pd_id;
|
|
|
|
int pd_unit;
|
|
|
|
struct mfi_softc *pd_controller;
|
2012-03-30 23:05:48 +00:00
|
|
|
struct mfi_pd_info *pd_info;
|
2011-11-04 02:34:52 +00:00
|
|
|
struct disk *pd_disk;
|
|
|
|
int pd_flags;
|
|
|
|
};
|
2012-03-30 23:05:48 +00:00
|
|
|
|
|
|
|
struct mfi_evt_queue_elm {
|
|
|
|
TAILQ_ENTRY(mfi_evt_queue_elm) link;
|
|
|
|
struct mfi_evt_detail detail;
|
|
|
|
};
|
|
|
|
|
2006-05-18 23:30:48 +00:00
|
|
|
struct mfi_aen {
|
|
|
|
TAILQ_ENTRY(mfi_aen) aen_link;
|
|
|
|
struct proc *p;
|
|
|
|
};
|
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
struct mfi_skinny_dma_info {
|
2012-04-02 02:22:22 +00:00
|
|
|
bus_dma_tag_t dmat[514];
|
|
|
|
bus_dmamap_t dmamap[514];
|
|
|
|
uint32_t mem[514];
|
|
|
|
int noofmaps;
|
2011-11-04 02:34:52 +00:00
|
|
|
};
|
|
|
|
|
2012-04-02 19:13:02 +00:00
|
|
|
struct megasas_sge
|
|
|
|
{
|
|
|
|
bus_addr_t phys_addr;
|
|
|
|
uint32_t length;
|
|
|
|
};
|
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
struct mfi_cmd_tbolt;
|
|
|
|
|
2006-03-25 06:14:32 +00:00
|
|
|
struct mfi_softc {
|
|
|
|
device_t mfi_dev;
|
|
|
|
int mfi_flags;
|
|
|
|
#define MFI_FLAGS_SG64 (1<<0)
|
|
|
|
#define MFI_FLAGS_QFRZN (1<<1)
|
|
|
|
#define MFI_FLAGS_OPEN (1<<2)
|
2006-10-16 04:18:38 +00:00
|
|
|
#define MFI_FLAGS_STOP (1<<3)
|
2007-08-25 23:58:45 +00:00
|
|
|
#define MFI_FLAGS_1064R (1<<4)
|
|
|
|
#define MFI_FLAGS_1078 (1<<5)
|
2008-11-12 22:44:50 +00:00
|
|
|
#define MFI_FLAGS_GEN2 (1<<6)
|
2011-11-04 02:34:52 +00:00
|
|
|
#define MFI_FLAGS_SKINNY (1<<7)
|
|
|
|
#define MFI_FLAGS_TBOLT (1<<8)
|
|
|
|
// Start: LSIP200113393
|
|
|
|
bus_dma_tag_t verbuf_h_dmat;
|
|
|
|
bus_dmamap_t verbuf_h_dmamap;
|
2012-05-12 05:05:22 +00:00
|
|
|
bus_addr_t verbuf_h_busaddr;
|
2012-03-30 23:05:48 +00:00
|
|
|
uint32_t *verbuf;
|
|
|
|
void *kbuff_arr[MAX_IOCTL_SGE];
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_dma_tag_t mfi_kbuff_arr_dmat[2];
|
|
|
|
bus_dmamap_t mfi_kbuff_arr_dmamap[2];
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t mfi_kbuff_arr_busaddr[2];
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
struct mfi_hwcomms *mfi_comms;
|
|
|
|
TAILQ_HEAD(,mfi_command) mfi_free;
|
|
|
|
TAILQ_HEAD(,mfi_command) mfi_ready;
|
2011-11-04 02:34:52 +00:00
|
|
|
TAILQ_HEAD(BUSYQ,mfi_command) mfi_busy;
|
2006-03-25 06:14:32 +00:00
|
|
|
struct bio_queue_head mfi_bioq;
|
|
|
|
struct mfi_qstat mfi_qstat[MFIQ_COUNT];
|
|
|
|
|
|
|
|
struct resource *mfi_regs_resource;
|
|
|
|
bus_space_handle_t mfi_bhandle;
|
|
|
|
bus_space_tag_t mfi_btag;
|
|
|
|
int mfi_regs_rid;
|
|
|
|
|
|
|
|
bus_dma_tag_t mfi_parent_dmat;
|
|
|
|
bus_dma_tag_t mfi_buffer_dmat;
|
|
|
|
|
|
|
|
bus_dma_tag_t mfi_comms_dmat;
|
|
|
|
bus_dmamap_t mfi_comms_dmamap;
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t mfi_comms_busaddr;
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
bus_dma_tag_t mfi_frames_dmat;
|
|
|
|
bus_dmamap_t mfi_frames_dmamap;
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t mfi_frames_busaddr;
|
2006-03-25 06:14:32 +00:00
|
|
|
union mfi_frame *mfi_frames;
|
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_dma_tag_t mfi_tb_init_dmat;
|
|
|
|
bus_dmamap_t mfi_tb_init_dmamap;
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t mfi_tb_init_busaddr;
|
|
|
|
bus_addr_t mfi_tb_ioc_init_busaddr;
|
2011-11-04 02:34:52 +00:00
|
|
|
union mfi_frame *mfi_tb_init;
|
|
|
|
|
2012-03-30 23:05:48 +00:00
|
|
|
TAILQ_HEAD(,mfi_evt_queue_elm) mfi_evt_queue;
|
|
|
|
struct task mfi_evt_task;
|
2012-05-04 16:00:39 +00:00
|
|
|
struct task mfi_map_sync_task;
|
2006-05-18 23:30:48 +00:00
|
|
|
TAILQ_HEAD(,mfi_aen) mfi_aen_pids;
|
|
|
|
struct mfi_command *mfi_aen_cm;
|
2011-11-04 02:34:52 +00:00
|
|
|
struct mfi_command *mfi_skinny_cm;
|
2012-05-04 16:00:39 +00:00
|
|
|
struct mfi_command *mfi_map_sync_cm;
|
|
|
|
int cm_aen_abort;
|
|
|
|
int cm_map_abort;
|
2006-05-18 23:30:48 +00:00
|
|
|
uint32_t mfi_aen_triggered;
|
|
|
|
uint32_t mfi_poll_waiting;
|
2012-03-30 23:05:48 +00:00
|
|
|
uint32_t mfi_boot_seq_num;
|
2006-05-18 23:30:48 +00:00
|
|
|
struct selinfo mfi_select;
|
2007-08-13 19:29:17 +00:00
|
|
|
int mfi_delete_busy_volumes;
|
|
|
|
int mfi_keep_deleted_volumes;
|
|
|
|
int mfi_detaching;
|
2006-05-18 23:30:48 +00:00
|
|
|
|
2006-03-25 06:14:32 +00:00
|
|
|
bus_dma_tag_t mfi_sense_dmat;
|
|
|
|
bus_dmamap_t mfi_sense_dmamap;
|
2012-05-12 05:05:22 +00:00
|
|
|
bus_addr_t mfi_sense_busaddr;
|
2006-03-25 06:14:32 +00:00
|
|
|
struct mfi_sense *mfi_sense;
|
|
|
|
|
|
|
|
struct resource *mfi_irq;
|
|
|
|
void *mfi_intr;
|
|
|
|
int mfi_irq_rid;
|
|
|
|
|
|
|
|
struct intr_config_hook mfi_ich;
|
|
|
|
eventhandler_tag eh;
|
2012-03-30 23:05:48 +00:00
|
|
|
/* OCR flags */
|
2011-11-04 02:34:52 +00:00
|
|
|
uint8_t adpreset;
|
|
|
|
uint8_t issuepend_done;
|
|
|
|
uint8_t disableOnlineCtrlReset;
|
|
|
|
uint32_t mfiStatus;
|
|
|
|
uint32_t last_seq_num;
|
|
|
|
uint32_t volatile hw_crit_error;
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocation for the command array. Used as an indexable array to
|
|
|
|
* recover completed commands.
|
|
|
|
*/
|
|
|
|
struct mfi_command *mfi_commands;
|
|
|
|
/*
|
|
|
|
* How many commands were actually allocated
|
|
|
|
*/
|
|
|
|
int mfi_total_cmds;
|
|
|
|
/*
|
|
|
|
* How many commands the firmware can handle. Also how big the reply
|
|
|
|
* queue is, minus 1.
|
|
|
|
*/
|
|
|
|
int mfi_max_fw_cmds;
|
|
|
|
/*
|
2012-03-30 23:05:48 +00:00
|
|
|
* How many S/G elements we'll ever actually use
|
2006-03-25 06:14:32 +00:00
|
|
|
*/
|
2006-09-20 06:58:02 +00:00
|
|
|
int mfi_max_sge;
|
2006-03-25 06:14:32 +00:00
|
|
|
/*
|
|
|
|
* How many bytes a compound frame is, including all of the extra frames
|
|
|
|
* that are used for S/G elements.
|
|
|
|
*/
|
2006-09-20 06:58:02 +00:00
|
|
|
int mfi_cmd_size;
|
2006-03-25 06:14:32 +00:00
|
|
|
/*
|
|
|
|
* How large an S/G element is. Used to calculate the number of single
|
|
|
|
* frames in a command.
|
|
|
|
*/
|
2006-09-20 06:58:02 +00:00
|
|
|
int mfi_sge_size;
|
2006-03-25 06:14:32 +00:00
|
|
|
/*
|
|
|
|
* Max number of sectors that the firmware allows
|
|
|
|
*/
|
|
|
|
uint32_t mfi_max_io;
|
|
|
|
|
2007-05-10 15:33:41 +00:00
|
|
|
TAILQ_HEAD(,mfi_disk) mfi_ld_tqh;
|
2011-11-04 02:34:52 +00:00
|
|
|
TAILQ_HEAD(,mfi_system_pd) mfi_syspd_tqh;
|
2006-03-25 06:14:32 +00:00
|
|
|
eventhandler_tag mfi_eh;
|
|
|
|
struct cdev *mfi_cdev;
|
|
|
|
|
2007-05-16 17:23:36 +00:00
|
|
|
TAILQ_HEAD(, ccb_hdr) mfi_cam_ccbq;
|
|
|
|
struct mfi_command * (* mfi_cam_start)(void *);
|
2006-09-25 11:35:34 +00:00
|
|
|
struct callout mfi_watchdog_callout;
|
2006-03-25 06:14:32 +00:00
|
|
|
struct mtx mfi_io_lock;
|
2007-08-13 19:29:17 +00:00
|
|
|
struct sx mfi_config_lock;
|
2007-08-25 23:58:45 +00:00
|
|
|
|
|
|
|
/* Controller type specific interfaces */
|
|
|
|
void (*mfi_enable_intr)(struct mfi_softc *sc);
|
2011-11-04 02:34:52 +00:00
|
|
|
void (*mfi_disable_intr)(struct mfi_softc *sc);
|
2007-08-25 23:58:45 +00:00
|
|
|
int32_t (*mfi_read_fw_status)(struct mfi_softc *sc);
|
|
|
|
int (*mfi_check_clear_intr)(struct mfi_softc *sc);
|
2012-03-30 23:05:48 +00:00
|
|
|
void (*mfi_issue_cmd)(struct mfi_softc *sc, bus_addr_t bus_add,
|
|
|
|
uint32_t frame_cnt);
|
|
|
|
int (*mfi_adp_reset)(struct mfi_softc *sc);
|
|
|
|
int (*mfi_adp_check_reset)(struct mfi_softc *sc);
|
2011-11-04 02:34:52 +00:00
|
|
|
|
|
|
|
/* ThunderBolt */
|
|
|
|
uint32_t mfi_tbolt;
|
|
|
|
uint32_t MFA_enabled;
|
2012-03-30 23:05:48 +00:00
|
|
|
/* Single Reply structure size */
|
|
|
|
uint16_t reply_size;
|
|
|
|
/* Singler message size. */
|
|
|
|
uint16_t raid_io_msg_size;
|
2011-11-04 02:34:52 +00:00
|
|
|
TAILQ_HEAD(TB, mfi_cmd_tbolt) mfi_cmd_tbolt_tqh;
|
2012-03-30 23:05:48 +00:00
|
|
|
/* ThunderBolt base contiguous memory mapping. */
|
|
|
|
bus_dma_tag_t mfi_tb_dmat;
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_dmamap_t mfi_tb_dmamap;
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t mfi_tb_busaddr;
|
|
|
|
/* ThunderBolt Contiguous DMA memory Mapping */
|
|
|
|
uint8_t * request_message_pool;
|
2011-11-04 02:34:52 +00:00
|
|
|
uint8_t * request_message_pool_align;
|
|
|
|
uint8_t * request_desc_pool;
|
2012-03-30 23:05:48 +00:00
|
|
|
bus_addr_t request_msg_busaddr;
|
|
|
|
bus_addr_t reply_frame_busaddr;
|
|
|
|
bus_addr_t sg_frame_busaddr;
|
|
|
|
/* ThunderBolt IOC Init Descriptor */
|
|
|
|
bus_dma_tag_t mfi_tb_ioc_init_dmat;
|
2011-11-04 02:34:52 +00:00
|
|
|
bus_dmamap_t mfi_tb_ioc_init_dmamap;
|
|
|
|
uint8_t * mfi_tb_ioc_init_desc;
|
|
|
|
struct mfi_cmd_tbolt **mfi_cmd_pool_tbolt;
|
2012-03-30 23:05:48 +00:00
|
|
|
/* Virtual address of reply Frame Pool */
|
|
|
|
struct mfi_mpi2_reply_header* reply_frame_pool;
|
2011-11-04 02:34:52 +00:00
|
|
|
struct mfi_mpi2_reply_header* reply_frame_pool_align;
|
|
|
|
|
2012-03-30 23:05:48 +00:00
|
|
|
/* Last reply frame address */
|
|
|
|
uint8_t * reply_pool_limit;
|
2011-11-04 02:34:52 +00:00
|
|
|
uint16_t last_reply_idx;
|
|
|
|
uint8_t max_SGEs_in_chain_message;
|
|
|
|
uint8_t max_SGEs_in_main_message;
|
|
|
|
uint8_t chain_offset_value_for_main_message;
|
|
|
|
uint8_t chain_offset_value_for_mpt_ptmsg;
|
|
|
|
};
|
|
|
|
|
|
|
|
union desc_value {
|
2012-03-30 23:05:48 +00:00
|
|
|
uint64_t word;
|
2011-11-04 02:34:52 +00:00
|
|
|
struct {
|
2012-03-30 23:05:48 +00:00
|
|
|
uint32_t low;
|
|
|
|
uint32_t high;
|
|
|
|
}u;
|
2011-11-04 02:34:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// TODO find the right definition
|
|
|
|
#define XXX_MFI_CMD_OP_INIT2 0x9
|
|
|
|
/*
|
|
|
|
* Request descriptor types
|
|
|
|
*/
|
|
|
|
#define MFI_REQ_DESCRIPT_FLAGS_LD_IO 0x7
|
|
|
|
#define MFI_REQ_DESCRIPT_FLAGS_MFA 0x1
|
|
|
|
#define MFI_REQ_DESCRIPT_FLAGS_TYPE_SHIFT 0x1
|
|
|
|
#define MFI_FUSION_FP_DEFAULT_TIMEOUT 0x14
|
|
|
|
#define MFI_LOAD_BALANCE_FLAG 0x1
|
|
|
|
#define MFI_DCMD_MBOX_PEND_FLAG 0x1
|
|
|
|
|
|
|
|
//#define MR_PROT_INFO_TYPE_CONTROLLER 0x08
|
|
|
|
#define MEGASAS_SCSI_VARIABLE_LENGTH_CMD 0x7f
|
|
|
|
#define MEGASAS_SCSI_SERVICE_ACTION_READ32 0x9
|
|
|
|
#define MEGASAS_SCSI_SERVICE_ACTION_WRITE32 0xB
|
|
|
|
#define MEGASAS_SCSI_ADDL_CDB_LEN 0x18
|
|
|
|
#define MEGASAS_RD_WR_PROTECT_CHECK_ALL 0x20
|
|
|
|
#define MEGASAS_RD_WR_PROTECT_CHECK_NONE 0x60
|
|
|
|
#define MEGASAS_EEDPBLOCKSIZE 512
|
|
|
|
struct mfi_cmd_tbolt {
|
2012-03-30 23:05:48 +00:00
|
|
|
union mfi_mpi2_request_descriptor *request_desc;
|
|
|
|
struct mfi_mpi2_request_raid_scsi_io *io_request;
|
|
|
|
bus_addr_t io_request_phys_addr;
|
|
|
|
bus_addr_t sg_frame_phys_addr;
|
|
|
|
bus_addr_t sense_phys_addr;
|
|
|
|
MPI2_SGE_IO_UNION *sg_frame;
|
|
|
|
uint8_t *sense;
|
2011-11-04 02:34:52 +00:00
|
|
|
TAILQ_ENTRY(mfi_cmd_tbolt) next;
|
|
|
|
/*
|
|
|
|
* Context for a MFI frame.
|
|
|
|
* Used to get the mfi cmd from list when a MFI cmd is completed
|
|
|
|
*/
|
2012-03-30 23:05:48 +00:00
|
|
|
uint32_t sync_cmd_idx;
|
|
|
|
uint16_t index;
|
|
|
|
uint8_t status;
|
2006-03-25 06:14:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int mfi_attach(struct mfi_softc *);
|
|
|
|
extern void mfi_free(struct mfi_softc *);
|
|
|
|
extern int mfi_shutdown(struct mfi_softc *);
|
|
|
|
extern void mfi_startio(struct mfi_softc *);
|
|
|
|
extern void mfi_disk_complete(struct bio *);
|
2007-08-13 19:29:17 +00:00
|
|
|
extern int mfi_disk_disable(struct mfi_disk *);
|
|
|
|
extern void mfi_disk_enable(struct mfi_disk *);
|
2006-03-25 06:14:32 +00:00
|
|
|
extern int mfi_dump_blocks(struct mfi_softc *, int id, uint64_t, void *, int);
|
2011-11-04 02:34:52 +00:00
|
|
|
extern int mfi_syspd_disable(struct mfi_system_pd *);
|
|
|
|
extern void mfi_syspd_enable(struct mfi_system_pd *);
|
|
|
|
extern int mfi_dump_syspd_blocks(struct mfi_softc *, int id, uint64_t, void *,
|
|
|
|
int);
|
|
|
|
extern int mfi_transition_firmware(struct mfi_softc *sc);
|
|
|
|
extern int mfi_aen_setup(struct mfi_softc *sc, uint32_t seq_start);
|
|
|
|
extern void mfi_complete(struct mfi_softc *sc, struct mfi_command *cm);
|
|
|
|
extern int mfi_mapcmd(struct mfi_softc *sc,struct mfi_command *cm);
|
|
|
|
extern int mfi_wait_command(struct mfi_softc *sc, struct mfi_command *cm);
|
|
|
|
extern void mfi_tbolt_enable_intr_ppc(struct mfi_softc *);
|
|
|
|
extern void mfi_tbolt_disable_intr_ppc(struct mfi_softc *);
|
|
|
|
extern int32_t mfi_tbolt_read_fw_status_ppc(struct mfi_softc *);
|
|
|
|
extern int32_t mfi_tbolt_check_clear_intr_ppc(struct mfi_softc *);
|
2012-03-30 23:05:48 +00:00
|
|
|
extern void mfi_tbolt_issue_cmd_ppc(struct mfi_softc *, bus_addr_t, uint32_t);
|
2011-11-04 02:34:52 +00:00
|
|
|
extern void mfi_tbolt_init_globals(struct mfi_softc*);
|
|
|
|
extern uint32_t mfi_tbolt_get_memory_requirement(struct mfi_softc *);
|
|
|
|
extern int mfi_tbolt_init_desc_pool(struct mfi_softc *, uint8_t *, uint32_t);
|
|
|
|
extern int mfi_tbolt_init_MFI_queue(struct mfi_softc *);
|
|
|
|
extern void mfi_intr_tbolt(void *arg);
|
|
|
|
extern int mfi_tbolt_alloc_cmd(struct mfi_softc *sc);
|
|
|
|
extern int mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_command *cm);
|
|
|
|
extern int mfi_tbolt_adp_reset(struct mfi_softc *sc);
|
|
|
|
extern int mfi_tbolt_reset(struct mfi_softc *sc);
|
2012-05-04 16:00:39 +00:00
|
|
|
extern void mfi_tbolt_sync_map_info(struct mfi_softc *sc);
|
|
|
|
extern void mfi_handle_map_sync(void *context, int pending);
|
|
|
|
extern int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **,
|
|
|
|
uint32_t, void **, size_t);
|
2006-03-25 06:14:32 +00:00
|
|
|
|
|
|
|
#define MFIQ_ADD(sc, qname) \
|
|
|
|
do { \
|
|
|
|
struct mfi_qstat *qs; \
|
|
|
|
\
|
|
|
|
qs = &(sc)->mfi_qstat[qname]; \
|
|
|
|
qs->q_length++; \
|
|
|
|
if (qs->q_length > qs->q_max) \
|
|
|
|
qs->q_max = qs->q_length; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define MFIQ_REMOVE(sc, qname) (sc)->mfi_qstat[qname].q_length--
|
|
|
|
|
|
|
|
#define MFIQ_INIT(sc, qname) \
|
|
|
|
do { \
|
|
|
|
sc->mfi_qstat[qname].q_length = 0; \
|
|
|
|
sc->mfi_qstat[qname].q_max = 0; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define MFIQ_COMMAND_QUEUE(name, index) \
|
|
|
|
static __inline void \
|
|
|
|
mfi_initq_ ## name (struct mfi_softc *sc) \
|
|
|
|
{ \
|
|
|
|
TAILQ_INIT(&sc->mfi_ ## name); \
|
|
|
|
MFIQ_INIT(sc, index); \
|
|
|
|
} \
|
|
|
|
static __inline void \
|
|
|
|
mfi_enqueue_ ## name (struct mfi_command *cm) \
|
|
|
|
{ \
|
|
|
|
if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \
|
|
|
|
printf("command %p is on another queue, " \
|
|
|
|
"flags = %#x\n", cm, cm->cm_flags); \
|
|
|
|
panic("command is on another queue"); \
|
|
|
|
} \
|
|
|
|
TAILQ_INSERT_TAIL(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
|
|
|
|
cm->cm_flags |= MFI_ON_ ## index; \
|
|
|
|
MFIQ_ADD(cm->cm_sc, index); \
|
|
|
|
} \
|
|
|
|
static __inline void \
|
|
|
|
mfi_requeue_ ## name (struct mfi_command *cm) \
|
|
|
|
{ \
|
|
|
|
if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \
|
|
|
|
printf("command %p is on another queue, " \
|
|
|
|
"flags = %#x\n", cm, cm->cm_flags); \
|
|
|
|
panic("command is on another queue"); \
|
|
|
|
} \
|
|
|
|
TAILQ_INSERT_HEAD(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
|
|
|
|
cm->cm_flags |= MFI_ON_ ## index; \
|
|
|
|
MFIQ_ADD(cm->cm_sc, index); \
|
|
|
|
} \
|
|
|
|
static __inline struct mfi_command * \
|
|
|
|
mfi_dequeue_ ## name (struct mfi_softc *sc) \
|
|
|
|
{ \
|
|
|
|
struct mfi_command *cm; \
|
|
|
|
\
|
|
|
|
if ((cm = TAILQ_FIRST(&sc->mfi_ ## name)) != NULL) { \
|
|
|
|
if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \
|
|
|
|
printf("command %p not in queue, " \
|
|
|
|
"flags = %#x, bit = %#x\n", cm, \
|
|
|
|
cm->cm_flags, MFI_ON_ ## index); \
|
|
|
|
panic("command not in queue"); \
|
|
|
|
} \
|
|
|
|
TAILQ_REMOVE(&sc->mfi_ ## name, cm, cm_link); \
|
|
|
|
cm->cm_flags &= ~MFI_ON_ ## index; \
|
|
|
|
MFIQ_REMOVE(sc, index); \
|
|
|
|
} \
|
|
|
|
return (cm); \
|
|
|
|
} \
|
|
|
|
static __inline void \
|
|
|
|
mfi_remove_ ## name (struct mfi_command *cm) \
|
|
|
|
{ \
|
|
|
|
if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \
|
|
|
|
printf("command %p not in queue, flags = %#x, " \
|
|
|
|
"bit = %#x\n", cm, cm->cm_flags, \
|
|
|
|
MFI_ON_ ## index); \
|
|
|
|
panic("command not in queue"); \
|
|
|
|
} \
|
|
|
|
TAILQ_REMOVE(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
|
|
|
|
cm->cm_flags &= ~MFI_ON_ ## index; \
|
|
|
|
MFIQ_REMOVE(cm->cm_sc, index); \
|
|
|
|
} \
|
|
|
|
struct hack
|
|
|
|
|
|
|
|
MFIQ_COMMAND_QUEUE(free, MFIQ_FREE);
|
|
|
|
MFIQ_COMMAND_QUEUE(ready, MFIQ_READY);
|
|
|
|
MFIQ_COMMAND_QUEUE(busy, MFIQ_BUSY);
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
mfi_initq_bio(struct mfi_softc *sc)
|
|
|
|
{
|
|
|
|
bioq_init(&sc->mfi_bioq);
|
|
|
|
MFIQ_INIT(sc, MFIQ_BIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
mfi_enqueue_bio(struct mfi_softc *sc, struct bio *bp)
|
|
|
|
{
|
|
|
|
bioq_insert_tail(&sc->mfi_bioq, bp);
|
|
|
|
MFIQ_ADD(sc, MFIQ_BIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct bio *
|
|
|
|
mfi_dequeue_bio(struct mfi_softc *sc)
|
|
|
|
{
|
|
|
|
struct bio *bp;
|
|
|
|
|
|
|
|
if ((bp = bioq_first(&sc->mfi_bioq)) != NULL) {
|
|
|
|
bioq_remove(&sc->mfi_bioq, bp);
|
|
|
|
MFIQ_REMOVE(sc, MFIQ_BIO);
|
|
|
|
}
|
|
|
|
return (bp);
|
|
|
|
}
|
|
|
|
|
2011-10-29 06:26:49 +00:00
|
|
|
/*
|
|
|
|
* This is from the original scsi_extract_sense() in CAM. It's copied
|
|
|
|
* here because CAM now uses a non-inline version that follows more complex
|
|
|
|
* additions to the SPC spec, and we don't want to force a dependency on
|
|
|
|
* the CAM module for such a trivial action.
|
|
|
|
*/
|
|
|
|
static __inline void
|
|
|
|
mfi_extract_sense(struct scsi_sense_data_fixed *sense,
|
|
|
|
int *error_code, int *sense_key, int *asc, int *ascq)
|
|
|
|
{
|
|
|
|
|
|
|
|
*error_code = sense->error_code & SSD_ERRCODE;
|
|
|
|
*sense_key = sense->flags & SSD_KEY;
|
|
|
|
*asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
|
|
|
|
*ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
|
|
|
|
}
|
|
|
|
|
2006-03-25 06:14:32 +00:00
|
|
|
static __inline void
|
|
|
|
mfi_print_sense(struct mfi_softc *sc, void *sense)
|
|
|
|
{
|
|
|
|
int error, key, asc, ascq;
|
|
|
|
|
2011-10-29 06:26:49 +00:00
|
|
|
mfi_extract_sense((struct scsi_sense_data_fixed *)sense,
|
2006-03-25 06:14:32 +00:00
|
|
|
&error, &key, &asc, &ascq);
|
|
|
|
device_printf(sc->mfi_dev, "sense error %d, sense_key %d, "
|
|
|
|
"asc %d, ascq %d\n", error, key, asc, ascq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define MFI_WRITE4(sc, reg, val) bus_space_write_4((sc)->mfi_btag, \
|
|
|
|
sc->mfi_bhandle, (reg), (val))
|
|
|
|
#define MFI_READ4(sc, reg) bus_space_read_4((sc)->mfi_btag, \
|
|
|
|
(sc)->mfi_bhandle, (reg))
|
|
|
|
#define MFI_WRITE2(sc, reg, val) bus_space_write_2((sc)->mfi_btag, \
|
|
|
|
sc->mfi_bhandle, (reg), (val))
|
|
|
|
#define MFI_READ2(sc, reg) bus_space_read_2((sc)->mfi_btag, \
|
|
|
|
(sc)->mfi_bhandle, (reg))
|
|
|
|
#define MFI_WRITE1(sc, reg, val) bus_space_write_1((sc)->mfi_btag, \
|
|
|
|
sc->mfi_bhandle, (reg), (val))
|
|
|
|
#define MFI_READ1(sc, reg) bus_space_read_1((sc)->mfi_btag, \
|
|
|
|
(sc)->mfi_bhandle, (reg))
|
|
|
|
|
|
|
|
MALLOC_DECLARE(M_MFIBUF);
|
2011-11-16 15:39:27 +00:00
|
|
|
SYSCTL_DECL(_hw_mfi);
|
2006-03-25 06:14:32 +00:00
|
|
|
|
2011-11-04 02:34:52 +00:00
|
|
|
#define MFI_RESET_WAIT_TIME 180
|
2006-09-25 11:35:34 +00:00
|
|
|
#define MFI_CMD_TIMEOUT 30
|
2011-11-04 02:34:52 +00:00
|
|
|
#define MFI_SYS_PD_IO 0
|
|
|
|
#define MFI_LD_IO 1
|
2012-04-02 19:13:02 +00:00
|
|
|
#define MFI_SKINNY_MEMORY 0x02000000
|
Separate the parallel scsi knowledge out of the core of the XPT, and
modularize it so that new transports can be created.
Add a transport for SATA
Add a periph+protocol layer for ATA
Add a driver for AHCI-compliant hardware.
Add a maxio field to CAM so that drivers can advertise their max
I/O capability. Modify various drivers so that they are insulated
from the value of MAXPHYS.
The new ATA/SATA code supports AHCI-compliant hardware, and will override
the classic ATA driver if it is loaded as a module at boot time or compiled
into the kernel. The stack now support NCQ (tagged queueing) for increased
performance on modern SATA drives. It also supports port multipliers.
ATA drives are accessed via 'ada' device nodes. ATAPI drives are
accessed via 'cd' device nodes. They can all be enumerated and manipulated
via camcontrol, just like SCSI drives. SCSI commands are not translated to
their ATA equivalents; ATA native commands are used throughout the entire
stack, including camcontrol. See the camcontrol manpage for further
details. Testing this code may require that you update your fstab, and
possibly modify your BIOS to enable AHCI functionality, if available.
This code is very experimental at the moment. The userland ABI/API has
changed, so applications will need to be recompiled. It may change
further in the near future. The 'ada' device name may also change as
more infrastructure is completed in this project. The goal is to
eventually put all CAM busses and devices until newbus, allowing for
interesting topology and management options.
Few functional changes will be seen with existing SCSI/SAS/FC drivers,
though the userland ABI has still changed. In the future, transports
specific modules for SAS and FC may appear in order to better support
the topologies and capabilities of these technologies.
The modularization of CAM and the addition of the ATA/SATA modules is
meant to break CAM out of the mold of being specific to SCSI, letting it
grow to be a framework for arbitrary transports and protocols. It also
allows drivers to be written to support discrete hardware without
jeopardizing the stability of non-related hardware. While only an AHCI
driver is provided now, a Silicon Image driver is also in the works.
Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware
is possible and encouraged. Help with new transports is also encouraged.
Submitted by: scottl, mav
Approved by: re
2009-07-10 08:18:08 +00:00
|
|
|
#define MFI_MAXPHYS (128 * 1024)
|
2006-09-25 11:35:34 +00:00
|
|
|
|
|
|
|
#ifdef MFI_DEBUG
|
|
|
|
extern void mfi_print_cmd(struct mfi_command *cm);
|
|
|
|
extern void mfi_dump_cmds(struct mfi_softc *sc);
|
2006-10-16 04:18:38 +00:00
|
|
|
extern void mfi_validate_sg(struct mfi_softc *, struct mfi_command *, const char *, int );
|
2006-09-25 11:35:34 +00:00
|
|
|
#define MFI_PRINT_CMD(cm) mfi_print_cmd(cm)
|
2006-10-16 04:18:38 +00:00
|
|
|
#define MFI_DUMP_CMDS(sc) mfi_dump_cmds(sc)
|
|
|
|
#define MFI_VALIDATE_CMD(sc, cm) mfi_validate_sg(sc, cm, __FUNCTION__, __LINE__)
|
2006-09-25 11:35:34 +00:00
|
|
|
#else
|
|
|
|
#define MFI_PRINT_CMD(cm)
|
|
|
|
#define MFI_DUMP_CMDS(sc)
|
2006-10-16 04:18:38 +00:00
|
|
|
#define MFI_VALIDATE_CMD(sc, cm)
|
2006-09-25 11:35:34 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-16 17:23:36 +00:00
|
|
|
extern void mfi_release_command(struct mfi_command *cm);
|
|
|
|
|
2006-03-25 06:14:32 +00:00
|
|
|
#endif /* _MFIVAR_H */
|