twe: Remove driver
Sponsored by: Netflix
This commit is contained in:
parent
3cb2f5f369
commit
062a7b918f
@ -195,7 +195,6 @@ device mlx # Mylex DAC960 family
|
|||||||
device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
|
device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
|
||||||
#XXX pointer/int warnings
|
#XXX pointer/int warnings
|
||||||
#device pst # Promise Supertrak SX6000
|
#device pst # Promise Supertrak SX6000
|
||||||
device twe # 3ware ATA RAID
|
|
||||||
|
|
||||||
# NVM Express (NVMe) support
|
# NVM Express (NVMe) support
|
||||||
device nvme # base NVMe driver
|
device nvme # base NVMe driver
|
||||||
|
@ -1646,11 +1646,6 @@ device mfip # LSI MegaRAID SAS passthrough, requires CAM
|
|||||||
options MFI_DEBUG
|
options MFI_DEBUG
|
||||||
device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
|
device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
|
||||||
|
|
||||||
#
|
|
||||||
# 3ware ATA RAID
|
|
||||||
#
|
|
||||||
device twe # 3ware ATA RAID
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Serial ATA host controllers:
|
# Serial ATA host controllers:
|
||||||
#
|
#
|
||||||
|
@ -3171,8 +3171,6 @@ dev/syscons/warp/warp_saver.c optional warp_saver
|
|||||||
dev/tcp_log/tcp_log_dev.c optional tcp_blackbox inet | tcp_blackbox inet6
|
dev/tcp_log/tcp_log_dev.c optional tcp_blackbox inet | tcp_blackbox inet6
|
||||||
dev/tdfx/tdfx_pci.c optional tdfx pci
|
dev/tdfx/tdfx_pci.c optional tdfx pci
|
||||||
dev/ti/if_ti.c optional ti pci
|
dev/ti/if_ti.c optional ti pci
|
||||||
dev/twe/twe.c optional twe
|
|
||||||
dev/twe/twe_freebsd.c optional twe
|
|
||||||
dev/tws/tws.c optional tws
|
dev/tws/tws.c optional tws
|
||||||
dev/tws/tws_cam.c optional tws
|
dev/tws/tws_cam.c optional tws
|
||||||
dev/tws/tws_hdm.c optional tws
|
dev/tws/tws_hdm.c optional tws
|
||||||
|
1973
sys/dev/twe/twe.c
1973
sys/dev/twe/twe.c
File diff suppressed because it is too large
Load Diff
@ -1,127 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
||||||
*
|
|
||||||
* Copyright (c) 2000 Michael Smith
|
|
||||||
* Copyright (c) 2003 Paul Saab
|
|
||||||
* Copyright (c) 2003 Vinod Kashyap
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Portability and compatibility interfaces.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
/******************************************************************************
|
|
||||||
* FreeBSD
|
|
||||||
*/
|
|
||||||
#define TWE_SUPPORTED_PLATFORM
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/endian.h>
|
|
||||||
#include <sys/systm.h>
|
|
||||||
#include <sys/malloc.h>
|
|
||||||
#include <sys/kernel.h>
|
|
||||||
#include <sys/lock.h>
|
|
||||||
#include <sys/module.h>
|
|
||||||
#include <sys/mutex.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/sx.h>
|
|
||||||
|
|
||||||
#include <sys/bio.h>
|
|
||||||
#include <sys/bus.h>
|
|
||||||
#include <sys/conf.h>
|
|
||||||
#include <sys/disk.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <machine/bus.h>
|
|
||||||
#include <machine/resource.h>
|
|
||||||
#include <sys/rman.h>
|
|
||||||
|
|
||||||
#include <dev/pci/pcireg.h>
|
|
||||||
#include <dev/pci/pcivar.h>
|
|
||||||
|
|
||||||
#include <geom/geom_disk.h>
|
|
||||||
|
|
||||||
#define TWE_DRIVER_NAME twe
|
|
||||||
#define TWED_DRIVER_NAME twed
|
|
||||||
#define TWE_MALLOC_CLASS M_TWE
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wrappers for bus-space actions
|
|
||||||
*/
|
|
||||||
#define TWE_CONTROL(sc, val) bus_write_4((sc)->twe_io, 0x0, (u_int32_t)val)
|
|
||||||
#define TWE_STATUS(sc) (u_int32_t)bus_read_4((sc)->twe_io, 0x4)
|
|
||||||
#define TWE_COMMAND_QUEUE(sc, val) bus_write_4((sc)->twe_io, 0x8, (u_int32_t)val)
|
|
||||||
#define TWE_RESPONSE_QUEUE(sc) (TWE_Response_Queue)bus_read_4((sc)->twe_io, 0xc)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FreeBSD-specific softc elements
|
|
||||||
*/
|
|
||||||
#define TWE_PLATFORM_SOFTC \
|
|
||||||
bus_dmamap_t twe_cmdmap; /* DMA map for command */ \
|
|
||||||
u_int32_t twe_cmdphys; /* address of command in controller space */ \
|
|
||||||
device_t twe_dev; /* bus device */ \
|
|
||||||
struct cdev *twe_dev_t; /* control device */ \
|
|
||||||
struct resource *twe_io; /* register interface window */ \
|
|
||||||
bus_dma_tag_t twe_parent_dmat; /* parent DMA tag */ \
|
|
||||||
bus_dma_tag_t twe_buffer_dmat; /* data buffer DMA tag */ \
|
|
||||||
bus_dma_tag_t twe_cmd_dmat; /* command buffer DMA tag */ \
|
|
||||||
bus_dma_tag_t twe_immediate_dmat; /* command buffer DMA tag */ \
|
|
||||||
struct resource *twe_irq; /* interrupt */ \
|
|
||||||
void *twe_intr; /* interrupt handle */ \
|
|
||||||
struct intr_config_hook twe_ich; /* delayed-startup hook */ \
|
|
||||||
void *twe_cmd; /* command structures */ \
|
|
||||||
void *twe_immediate; /* immediate commands */ \
|
|
||||||
bus_dmamap_t twe_immediate_map; \
|
|
||||||
struct mtx twe_io_lock; \
|
|
||||||
struct sx twe_config_lock;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FreeBSD-specific request elements
|
|
||||||
*/
|
|
||||||
#define TWE_PLATFORM_REQUEST \
|
|
||||||
bus_dmamap_t tr_dmamap; /* DMA map for data */ \
|
|
||||||
u_int32_t tr_dataphys; /* data buffer base address in controller space */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Output identifying the controller/disk
|
|
||||||
*/
|
|
||||||
#define twe_printf(sc, fmt, args...) device_printf(sc->twe_dev, fmt , ##args)
|
|
||||||
#define twed_printf(twed, fmt, args...) device_printf(twed->twed_dev, fmt , ##args)
|
|
||||||
|
|
||||||
#define TWE_IO_LOCK(sc) mtx_lock(&(sc)->twe_io_lock)
|
|
||||||
#define TWE_IO_UNLOCK(sc) mtx_unlock(&(sc)->twe_io_lock)
|
|
||||||
#define TWE_IO_ASSERT_LOCKED(sc) mtx_assert(&(sc)->twe_io_lock, MA_OWNED)
|
|
||||||
#define TWE_CONFIG_LOCK(sc) sx_xlock(&(sc)->twe_config_lock)
|
|
||||||
#define TWE_CONFIG_UNLOCK(sc) sx_xunlock(&(sc)->twe_config_lock)
|
|
||||||
#define TWE_CONFIG_ASSERT_LOCKED(sc) sx_assert(&(sc)->twe_config_lock, SA_XLOCKED)
|
|
||||||
|
|
||||||
#endif /* FreeBSD */
|
|
||||||
|
|
||||||
#ifndef TWE_SUPPORTED_PLATFORM
|
|
||||||
#error platform not supported
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -1,169 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
||||||
*
|
|
||||||
* Copyright (c) 2000 Michael Smith
|
|
||||||
* Copyright (c) 2003 Paul Saab
|
|
||||||
* Copyright (c) 2003 Vinod Kashyap
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lookup table for code-to-text translations.
|
|
||||||
*/
|
|
||||||
struct twe_code_lookup {
|
|
||||||
char *string;
|
|
||||||
u_int32_t code;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern char *twe_describe_code(struct twe_code_lookup *table, u_int32_t code);
|
|
||||||
|
|
||||||
#ifndef TWE_DEFINE_TABLES
|
|
||||||
extern struct twe_code_lookup twe_table_status[];
|
|
||||||
extern struct twe_code_lookup twe_table_unitstate[];
|
|
||||||
extern struct twe_code_lookup twe_table_unittype[];
|
|
||||||
extern struct twe_code_lookup twe_table_aen[];
|
|
||||||
extern struct twe_code_lookup twe_table_opcode[];
|
|
||||||
#else /* TWE_DEFINE_TABLES */
|
|
||||||
|
|
||||||
struct twe_code_lookup twe_table_status[] = {
|
|
||||||
/* success */
|
|
||||||
{"successful completion", 0x00},
|
|
||||||
/* info */
|
|
||||||
{"command in progress", 0x42},
|
|
||||||
{"retrying interface CRC error from UDMA command", 0x6c},
|
|
||||||
/* warning */
|
|
||||||
{"redundant/inconsequential request ignored", 0x81},
|
|
||||||
{"failed to write zeroes to LBA 0", 0x8e},
|
|
||||||
{"failed to profile TwinStor zones", 0x8f},
|
|
||||||
/* fatal */
|
|
||||||
{"aborted due to system command or reconfiguration", 0xc1},
|
|
||||||
{"aborted", 0xc4},
|
|
||||||
{"access error", 0xc5},
|
|
||||||
{"access violation", 0xc6},
|
|
||||||
{"device failure", 0xc7}, /* high byte may be port number */
|
|
||||||
{"controller error", 0xc8},
|
|
||||||
{"timed out", 0xc9},
|
|
||||||
{"invalid unit number", 0xcb},
|
|
||||||
{"unit not available", 0xcf},
|
|
||||||
{"undefined opcode", 0xd2},
|
|
||||||
{"request incompatible with unit", 0xdb},
|
|
||||||
{"invalid request", 0xdc},
|
|
||||||
{"firmware error, reset requested", 0xff},
|
|
||||||
{NULL, 0},
|
|
||||||
{"unknown status", 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct twe_code_lookup twe_table_unitstate[] = {
|
|
||||||
{"Normal", TWE_PARAM_UNITSTATUS_Normal},
|
|
||||||
{"Initialising", TWE_PARAM_UNITSTATUS_Initialising},
|
|
||||||
{"Degraded", TWE_PARAM_UNITSTATUS_Degraded},
|
|
||||||
{"Rebuilding", TWE_PARAM_UNITSTATUS_Rebuilding},
|
|
||||||
{"Verifying", TWE_PARAM_UNITSTATUS_Verifying},
|
|
||||||
{"Corrupt", TWE_PARAM_UNITSTATUS_Corrupt},
|
|
||||||
{"Missing", TWE_PARAM_UNITSTATUS_Missing},
|
|
||||||
{NULL, 0},
|
|
||||||
{"unknown state", 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct twe_code_lookup twe_table_unittype[] = {
|
|
||||||
{"RAID0", TWE_UD_CONFIG_RAID0},
|
|
||||||
{"RAID1", TWE_UD_CONFIG_RAID1},
|
|
||||||
{"TwinStor", TWE_UD_CONFIG_TwinStor},
|
|
||||||
{"RAID5", TWE_UD_CONFIG_RAID5},
|
|
||||||
{"RAID10", TWE_UD_CONFIG_RAID10},
|
|
||||||
{"CBOD", TWE_UD_CONFIG_CBOD},
|
|
||||||
{"SPARE", TWE_UD_CONFIG_SPARE},
|
|
||||||
{"SUBUNIT", TWE_UD_CONFIG_SUBUNIT},
|
|
||||||
{"JBOD", TWE_UD_CONFIG_JBOD},
|
|
||||||
{NULL, 0},
|
|
||||||
{"unknown type", 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct twe_code_lookup twe_table_aen[] = {
|
|
||||||
{"q queue empty", 0x00},
|
|
||||||
{"q soft reset", 0x01},
|
|
||||||
{"c degraded unit", 0x02},
|
|
||||||
{"a controller error", 0x03},
|
|
||||||
{"c rebuild fail", 0x04},
|
|
||||||
{"c rebuild done", 0x05},
|
|
||||||
{"c incomplete unit", 0x06},
|
|
||||||
{"c initialisation done", 0x07},
|
|
||||||
{"c unclean shutdown detected", 0x08},
|
|
||||||
{"c drive timeout", 0x09},
|
|
||||||
{"c drive error", 0x0a},
|
|
||||||
{"c rebuild started", 0x0b},
|
|
||||||
{"c init started", 0x0c},
|
|
||||||
{"c logical unit deleted", 0x0d},
|
|
||||||
{"p SMART threshold exceeded", 0x0f},
|
|
||||||
{"p ATA UDMA downgrade", 0x21},
|
|
||||||
{"p ATA UDMA upgrade", 0x22},
|
|
||||||
{"p sector repair occurred", 0x23},
|
|
||||||
{"a SBUF integrity check failure", 0x24},
|
|
||||||
{"p lost cached write", 0x25},
|
|
||||||
{"p drive ECC error detected", 0x26},
|
|
||||||
{"p DCB checksum error", 0x27},
|
|
||||||
{"p DCB unsupported version", 0x28},
|
|
||||||
{"c verify started", 0x29},
|
|
||||||
{"c verify failed", 0x2a},
|
|
||||||
{"c verify complete", 0x2b},
|
|
||||||
{"p overwrote bad sector during rebuild", 0x2c},
|
|
||||||
{"p encountered bad sector during rebuild", 0x2d},
|
|
||||||
{"a replacement drive too small", 0x2e},
|
|
||||||
{"c array not previously initialized", 0x2f},
|
|
||||||
{"p drive not supported", 0x30},
|
|
||||||
{"a aen queue full", 0xff},
|
|
||||||
{NULL, 0},
|
|
||||||
{"x unknown AEN", 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct twe_code_lookup twe_table_opcode[] = {
|
|
||||||
{"NOP", 0x00},
|
|
||||||
{"INIT_CONNECTION", 0x01},
|
|
||||||
{"READ", 0x02},
|
|
||||||
{"WRITE", 0x03},
|
|
||||||
{"READVERIFY", 0x04},
|
|
||||||
{"VERIFY", 0x05},
|
|
||||||
{"ZEROUNIT", 0x08},
|
|
||||||
{"REPLACEUNIT", 0x09},
|
|
||||||
{"HOTSWAP", 0x0a},
|
|
||||||
{"SETATAFEATURE", 0x0c},
|
|
||||||
{"FLUSH", 0x0e},
|
|
||||||
{"ABORT", 0x0f},
|
|
||||||
{"CHECKSTATUS", 0x10},
|
|
||||||
{"GET_PARAM", 0x12},
|
|
||||||
{"SET_PARAM", 0x13},
|
|
||||||
{"CREATEUNIT", 0x14},
|
|
||||||
{"DELETEUNIT", 0x15},
|
|
||||||
{"REBUILDUNIT", 0x17},
|
|
||||||
{"SECTOR_INFO", 0x1a},
|
|
||||||
{"AEN_LISTEN", 0x1c},
|
|
||||||
{"CMD_PACKET", 0x1d},
|
|
||||||
{NULL, 0},
|
|
||||||
{"unknown opcode", 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,106 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
||||||
*
|
|
||||||
* Copyright (c) 2000 Michael Smith
|
|
||||||
* Copyright (c) 2003 Paul Saab
|
|
||||||
* Copyright (c) 2003 Vinod Kashyap
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* User-space command
|
|
||||||
*
|
|
||||||
* Note that the command's scatter/gather list will be computed by the
|
|
||||||
* driver, and cannot be filled in by the consumer.
|
|
||||||
*/
|
|
||||||
struct twe_usercommand {
|
|
||||||
TWE_Command tu_command; /* command ready for the controller */
|
|
||||||
void *tu_data; /* pointer to data in userspace */
|
|
||||||
size_t tu_size; /* userspace data length */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TWEIO_COMMAND _IOWR('T', 100, struct twe_usercommand)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Command queue statistics
|
|
||||||
*/
|
|
||||||
#define TWEQ_FREE 0
|
|
||||||
#define TWEQ_BIO 1
|
|
||||||
#define TWEQ_READY 2
|
|
||||||
#define TWEQ_BUSY 3
|
|
||||||
#define TWEQ_COMPLETE 4
|
|
||||||
#define TWEQ_COUNT 5 /* total number of queues */
|
|
||||||
|
|
||||||
struct twe_qstat {
|
|
||||||
u_int32_t q_length;
|
|
||||||
u_int32_t q_max;
|
|
||||||
u_int32_t q_min;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Statistics request
|
|
||||||
*/
|
|
||||||
union twe_statrequest {
|
|
||||||
u_int32_t ts_item;
|
|
||||||
struct twe_qstat ts_qstat;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TWEIO_STATS _IOWR('T', 101, union twe_statrequest)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* AEN listen
|
|
||||||
*/
|
|
||||||
#define TWEIO_AEN_POLL _IOR('T', 102, u_int16_t)
|
|
||||||
#define TWEIO_AEN_WAIT _IOR('T', 103, u_int16_t)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Controller parameter access
|
|
||||||
*/
|
|
||||||
struct twe_paramcommand {
|
|
||||||
u_int16_t tp_table_id;
|
|
||||||
u_int8_t tp_param_id;
|
|
||||||
void *tp_data;
|
|
||||||
u_int8_t tp_size;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TWEIO_SET_PARAM _IOW ('T', 104, struct twe_paramcommand)
|
|
||||||
#define TWEIO_GET_PARAM _IOW ('T', 105, struct twe_paramcommand)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Request a controller soft-reset
|
|
||||||
*/
|
|
||||||
#define TWEIO_RESET _IO ('T', 106)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Request a drive addition or deletion
|
|
||||||
*/
|
|
||||||
struct twe_drivecommand {
|
|
||||||
int td_unit;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TWEIO_ADD_UNIT _IOW ('U', 107, int)
|
|
||||||
#define TWEIO_DEL_UNIT _IOW ('U', 108, int)
|
|
@ -1,496 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
||||||
*
|
|
||||||
* Copyright (c) 2000 Michael Smith
|
|
||||||
* Copyright (c) 2003 Paul Saab
|
|
||||||
* Copyright (c) 2003 Vinod Kashyap
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Register names, bit definitions, structure names and members are
|
|
||||||
* identical with those in the Linux driver where possible and sane
|
|
||||||
* for simplicity's sake. (The TW_ prefix has become TWE_)
|
|
||||||
* Some defines that are clearly irrelevant to FreeBSD have been
|
|
||||||
* removed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* control register bit definitions */
|
|
||||||
#define TWE_CONTROL_CLEAR_HOST_INTERRUPT 0x00080000
|
|
||||||
#define TWE_CONTROL_CLEAR_ATTENTION_INTERRUPT 0x00040000
|
|
||||||
#define TWE_CONTROL_MASK_COMMAND_INTERRUPT 0x00020000
|
|
||||||
#define TWE_CONTROL_MASK_RESPONSE_INTERRUPT 0x00010000
|
|
||||||
#define TWE_CONTROL_UNMASK_COMMAND_INTERRUPT 0x00008000
|
|
||||||
#define TWE_CONTROL_UNMASK_RESPONSE_INTERRUPT 0x00004000
|
|
||||||
#define TWE_CONTROL_CLEAR_ERROR_STATUS 0x00000200
|
|
||||||
#define TWE_CONTROL_ISSUE_SOFT_RESET 0x00000100
|
|
||||||
#define TWE_CONTROL_ENABLE_INTERRUPTS 0x00000080
|
|
||||||
#define TWE_CONTROL_DISABLE_INTERRUPTS 0x00000040
|
|
||||||
#define TWE_CONTROL_ISSUE_HOST_INTERRUPT 0x00000020
|
|
||||||
#define TWE_CONTROL_CLEAR_PARITY_ERROR 0x00800000
|
|
||||||
#define TWE_CONTROL_CLEAR_PCI_ABORT 0x00100000
|
|
||||||
|
|
||||||
#define TWE_SOFT_RESET(sc) TWE_CONTROL(sc, TWE_CONTROL_ISSUE_SOFT_RESET | \
|
|
||||||
TWE_CONTROL_CLEAR_HOST_INTERRUPT | \
|
|
||||||
TWE_CONTROL_CLEAR_ATTENTION_INTERRUPT | \
|
|
||||||
TWE_CONTROL_MASK_COMMAND_INTERRUPT | \
|
|
||||||
TWE_CONTROL_MASK_RESPONSE_INTERRUPT | \
|
|
||||||
TWE_CONTROL_CLEAR_ERROR_STATUS | \
|
|
||||||
TWE_CONTROL_DISABLE_INTERRUPTS)
|
|
||||||
|
|
||||||
/* status register bit definitions */
|
|
||||||
#define TWE_STATUS_MAJOR_VERSION_MASK 0xF0000000
|
|
||||||
#define TWE_STATUS_MINOR_VERSION_MASK 0x0F000000
|
|
||||||
#define TWE_STATUS_PCI_PARITY_ERROR 0x00800000
|
|
||||||
#define TWE_STATUS_QUEUE_ERROR 0x00400000
|
|
||||||
#define TWE_STATUS_MICROCONTROLLER_ERROR 0x00200000
|
|
||||||
#define TWE_STATUS_PCI_ABORT 0x00100000
|
|
||||||
#define TWE_STATUS_HOST_INTERRUPT 0x00080000
|
|
||||||
#define TWE_STATUS_ATTENTION_INTERRUPT 0x00040000
|
|
||||||
#define TWE_STATUS_COMMAND_INTERRUPT 0x00020000
|
|
||||||
#define TWE_STATUS_RESPONSE_INTERRUPT 0x00010000
|
|
||||||
#define TWE_STATUS_COMMAND_QUEUE_FULL 0x00008000
|
|
||||||
#define TWE_STATUS_RESPONSE_QUEUE_EMPTY 0x00004000
|
|
||||||
#define TWE_STATUS_MICROCONTROLLER_READY 0x00002000
|
|
||||||
#define TWE_STATUS_COMMAND_QUEUE_EMPTY 0x00001000
|
|
||||||
#define TWE_STATUS_ALL_INTERRUPTS 0x000F0000
|
|
||||||
#define TWE_STATUS_CLEARABLE_BITS 0x00D00000
|
|
||||||
#define TWE_STATUS_EXPECTED_BITS 0x00002000
|
|
||||||
#define TWE_STATUS_UNEXPECTED_BITS 0x00F80000
|
|
||||||
|
|
||||||
/* XXX this is a little harsh, but necessary to chase down firmware problems */
|
|
||||||
#define TWE_STATUS_PANIC_BITS (TWE_STATUS_MICROCONTROLLER_ERROR)
|
|
||||||
|
|
||||||
/* for use with the %b printf format */
|
|
||||||
#define TWE_STATUS_BITS_DESCRIPTION \
|
|
||||||
"\20\15CQEMPTY\16UCREADY\17RQEMPTY\20CQFULL\21RINTR\22CINTR\23AINTR\24HINTR\25PCIABRT\26MCERR\27QERR\30PCIPERR\n"
|
|
||||||
|
|
||||||
/* detect inconsistencies in the status register */
|
|
||||||
#define TWE_STATUS_ERRORS(x) \
|
|
||||||
(((x & TWE_STATUS_PCI_ABORT) || \
|
|
||||||
(x & TWE_STATUS_PCI_PARITY_ERROR) || \
|
|
||||||
(x & TWE_STATUS_QUEUE_ERROR) || \
|
|
||||||
(x & TWE_STATUS_MICROCONTROLLER_ERROR)) && \
|
|
||||||
(x & TWE_STATUS_MICROCONTROLLER_READY))
|
|
||||||
|
|
||||||
/* Response queue bit definitions */
|
|
||||||
#define TWE_RESPONSE_ID_MASK 0x00000FF0
|
|
||||||
|
|
||||||
/* PCI related defines */
|
|
||||||
#define TWE_IO_CONFIG_REG 0x10
|
|
||||||
#define TWE_DEVICE_NAME "3ware Storage Controller"
|
|
||||||
#define TWE_VENDOR_ID 0x13C1
|
|
||||||
#define TWE_DEVICE_ID 0x1000
|
|
||||||
#define TWE_DEVICE_ID_ASIC 0x1001
|
|
||||||
#define TWE_PCI_CLEAR_PARITY_ERROR 0xc100
|
|
||||||
#define TWE_PCI_CLEAR_PCI_ABORT 0x2000
|
|
||||||
|
|
||||||
/* command packet opcodes */
|
|
||||||
#define TWE_OP_NOP 0x00
|
|
||||||
#define TWE_OP_INIT_CONNECTION 0x01
|
|
||||||
#define TWE_OP_READ 0x02
|
|
||||||
#define TWE_OP_WRITE 0x03
|
|
||||||
#define TWE_OP_READVERIFY 0x04
|
|
||||||
#define TWE_OP_VERIFY 0x05
|
|
||||||
#define TWE_OP_ZEROUNIT 0x08
|
|
||||||
#define TWE_OP_REPLACEUNIT 0x09
|
|
||||||
#define TWE_OP_HOTSWAP 0x0a
|
|
||||||
#define TWE_OP_SETATAFEATURE 0x0c
|
|
||||||
#define TWE_OP_FLUSH 0x0e
|
|
||||||
#define TWE_OP_ABORT 0x0f
|
|
||||||
#define TWE_OP_CHECKSTATUS 0x10
|
|
||||||
#define TWE_OP_ATA_PASSTHROUGH 0x11
|
|
||||||
#define TWE_OP_GET_PARAM 0x12
|
|
||||||
#define TWE_OP_SET_PARAM 0x13
|
|
||||||
#define TWE_OP_CREATEUNIT 0x14
|
|
||||||
#define TWE_OP_DELETEUNIT 0x15
|
|
||||||
#define TWE_OP_REBUILDUNIT 0x17
|
|
||||||
#define TWE_OP_SECTOR_INFO 0x1a
|
|
||||||
#define TWE_OP_AEN_LISTEN 0x1c
|
|
||||||
#define TWE_OP_CMD_PACKET 0x1d
|
|
||||||
#define TWE_OP_CMD_WITH_DATA 0x1f
|
|
||||||
|
|
||||||
/* command status values */
|
|
||||||
#define TWE_STATUS_RESET 0xff /* controller requests reset */
|
|
||||||
#define TWE_STATUS_FATAL 0xc0 /* fatal errors not requiring reset */
|
|
||||||
#define TWE_STATUS_WARNING 0x80 /* warnings */
|
|
||||||
#define TWE_STAUS_INFO 0x40 /* informative status */
|
|
||||||
|
|
||||||
/* misc defines */
|
|
||||||
#define TWE_ALIGNMENT 0x200
|
|
||||||
#define TWE_MAX_UNITS 16
|
|
||||||
#define TWE_COMMAND_ALIGNMENT_MASK 0x1ff
|
|
||||||
#define TWE_INIT_MESSAGE_CREDITS 0xff /* older firmware has issues with 256 commands */
|
|
||||||
#define TWE_SHUTDOWN_MESSAGE_CREDITS 0x001
|
|
||||||
#define TWE_INIT_COMMAND_PACKET_SIZE 0x3
|
|
||||||
#define TWE_MAX_SGL_LENGTH 62
|
|
||||||
#define TWE_MAX_ATA_SGL_LENGTH 60
|
|
||||||
#define TWE_MAX_PASSTHROUGH 4096
|
|
||||||
#define TWE_Q_LENGTH TWE_INIT_MESSAGE_CREDITS
|
|
||||||
#define TWE_Q_START 0
|
|
||||||
#define TWE_MAX_RESET_TRIES 3
|
|
||||||
#define TWE_BLOCK_SIZE 0x200 /* 512-byte blocks */
|
|
||||||
#define TWE_SECTOR_SIZE 0x200 /* generic I/O bufffer */
|
|
||||||
#define TWE_IOCTL 0x80
|
|
||||||
#define TWE_MAX_AEN_TRIES 100
|
|
||||||
#define TWE_UNIT_ONLINE 1
|
|
||||||
|
|
||||||
/* scatter/gather list entry */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int32_t address;
|
|
||||||
u_int32_t length;
|
|
||||||
} __packed TWE_SG_Entry;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_INITCONNECTION */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t res2:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int16_t message_credits;
|
|
||||||
u_int32_t response_queue_pointer;
|
|
||||||
} __packed TWE_Command_INITCONNECTION;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_READ/TWE_OP_WRITE */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int16_t block_count;
|
|
||||||
u_int32_t lba;
|
|
||||||
TWE_SG_Entry sgl[TWE_MAX_SGL_LENGTH];
|
|
||||||
} __packed TWE_Command_IO;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_HOTSWAP */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int8_t action;
|
|
||||||
#define TWE_OP_HOTSWAP_REMOVE 0x00 /* remove assumed-degraded unit */
|
|
||||||
#define TWE_OP_HOTSWAP_ADD_CBOD 0x01 /* add CBOD to empty port */
|
|
||||||
#define TWE_OP_HOTSWAP_ADD_SPARE 0x02 /* add spare to empty port */
|
|
||||||
u_int8_t aport;
|
|
||||||
} __packed TWE_Command_HOTSWAP;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_SETATAFEATURE */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int8_t feature;
|
|
||||||
#define TWE_OP_SETATAFEATURE_WCE 0x02
|
|
||||||
#define TWE_OP_SETATAFEATURE_DIS_WCE 0x82
|
|
||||||
u_int8_t feature_mode;
|
|
||||||
u_int16_t all_units;
|
|
||||||
u_int16_t persistence;
|
|
||||||
} __packed TWE_Command_SETATAFEATURE;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_CHECKSTATUS */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t res2:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int16_t target_status; /* set low byte to target request's ID */
|
|
||||||
} __packed TWE_Command_CHECKSTATUS;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_GETPARAM, TWE_OP_SETPARAM */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int16_t param_count;
|
|
||||||
TWE_SG_Entry sgl[TWE_MAX_SGL_LENGTH];
|
|
||||||
} __packed TWE_Command_PARAM;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5; /* TWE_OP_REBUILDUNIT */
|
|
||||||
u_int8_t res1:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t src_unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int8_t action:7;
|
|
||||||
#define TWE_OP_REBUILDUNIT_NOP 0
|
|
||||||
#define TWE_OP_REBUILDUNIT_STOP 2 /* stop all rebuilds */
|
|
||||||
#define TWE_OP_REBUILDUNIT_START 4 /* start rebuild with lowest unit */
|
|
||||||
#define TWE_OP_REBUILDUNIT_STARTUNIT 5 /* rebuild src_unit (not supported) */
|
|
||||||
u_int8_t cs:1; /* request state change on src_unit */
|
|
||||||
u_int8_t logical_subunit; /* for RAID10 rebuild of logical subunit */
|
|
||||||
} __packed TWE_Command_REBUILDUNIT;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5;
|
|
||||||
u_int8_t sgl_offset:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
u_int16_t param;
|
|
||||||
u_int16_t features;
|
|
||||||
u_int16_t sector_count;
|
|
||||||
u_int16_t sector_num;
|
|
||||||
u_int16_t cylinder_lo;
|
|
||||||
u_int16_t cylinder_hi;
|
|
||||||
u_int8_t drive_head;
|
|
||||||
u_int8_t command;
|
|
||||||
TWE_SG_Entry sgl[TWE_MAX_ATA_SGL_LENGTH];
|
|
||||||
} __packed TWE_Command_ATA;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t opcode:5;
|
|
||||||
u_int8_t sgl_offset:3;
|
|
||||||
u_int8_t size;
|
|
||||||
u_int8_t request_id;
|
|
||||||
u_int8_t unit:4;
|
|
||||||
u_int8_t host_id:4;
|
|
||||||
u_int8_t status;
|
|
||||||
u_int8_t flags;
|
|
||||||
#define TWE_FLAGS_SUCCESS 0x00
|
|
||||||
#define TWE_FLAGS_INFORMATIONAL 0x01
|
|
||||||
#define TWE_FLAGS_WARNING 0x02
|
|
||||||
#define TWE_FLAGS_FATAL 0x03
|
|
||||||
#define TWE_FLAGS_PERCENTAGE (1<<8) /* bits 0-6 indicate completion percentage */
|
|
||||||
u_int16_t count; /* block count, parameter count, message credits */
|
|
||||||
} __packed TWE_Command_Generic;
|
|
||||||
|
|
||||||
/* command packet - must be TWE_ALIGNMENT aligned */
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
TWE_Command_INITCONNECTION initconnection;
|
|
||||||
TWE_Command_IO io;
|
|
||||||
TWE_Command_PARAM param;
|
|
||||||
TWE_Command_CHECKSTATUS checkstatus;
|
|
||||||
TWE_Command_REBUILDUNIT rebuildunit;
|
|
||||||
TWE_Command_SETATAFEATURE setatafeature;
|
|
||||||
TWE_Command_ATA ata;
|
|
||||||
TWE_Command_Generic generic;
|
|
||||||
u_int8_t pad[512];
|
|
||||||
} TWE_Command;
|
|
||||||
|
|
||||||
/* response queue entry */
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
u_int32_t undefined_1:4;
|
|
||||||
u_int32_t response_id:8;
|
|
||||||
u_int32_t undefined_2:20;
|
|
||||||
} u;
|
|
||||||
u_int32_t value;
|
|
||||||
} TWE_Response_Queue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* From 3ware's documentation:
|
|
||||||
* All parameters maintained by the controller are grouped into related tables.
|
|
||||||
* Tables are are accessed indirectly via get and set parameter commands.
|
|
||||||
* To access a specific parameter in a table, the table ID and parameter index
|
|
||||||
* are used to uniquely identify a parameter. Table 0xffff is the directory
|
|
||||||
* table and provides a list of the table IDs and sizes of all other tables.
|
|
||||||
* Index zero in each table specifies the entire table, and index one specifies
|
|
||||||
* the size of the table. An entire table can be read or set by using index zero.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define TWE_PARAM_PARAM_ALL 0
|
|
||||||
#define TWE_PARAM_PARAM_SIZE 1
|
|
||||||
|
|
||||||
#define TWE_PARAM_DIRECTORY 0xffff /* size is 4 * number of tables */
|
|
||||||
#define TWE_PARAM_DIRECTORY_TABLES 2 /* 16 bits * number of tables */
|
|
||||||
#define TWE_PARAM_DIRECTORY_SIZES 3 /* 16 bits * number of tables */
|
|
||||||
|
|
||||||
#define TWE_PARAM_DRIVESUMMARY 0x0002
|
|
||||||
#define TWE_PARAM_DRIVESUMMARY_Num 2 /* number of physical drives [2] */
|
|
||||||
#define TWE_PARAM_DRIVESUMMARY_Status 3 /* array giving drive status per aport */
|
|
||||||
#define TWE_PARAM_DRIVESTATUS_Missing 0x00
|
|
||||||
#define TWE_PARAM_DRIVESTATUS_NotSupp 0xfe
|
|
||||||
#define TWE_PARAM_DRIVESTATUS_Present 0xff
|
|
||||||
|
|
||||||
#define TWE_PARAM_UNITSUMMARY 0x0003
|
|
||||||
#define TWE_PARAM_UNITSUMMARY_Num 2 /* number of logical units [2] */
|
|
||||||
#define TWE_PARAM_UNITSUMMARY_Status 3 /* array giving unit status [16] */
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Online (1<<0)
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Complete (1<<1)
|
|
||||||
#define TWE_PARAM_UNITSTATUS_MASK 0xfc
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Normal 0xfc
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Initialising 0xf4 /* cannot be incomplete */
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Degraded 0xec
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Rebuilding 0xdc /* cannot be incomplete */
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Verifying 0xcc /* cannot be incomplete */
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Corrupt 0xbc /* cannot be complete */
|
|
||||||
#define TWE_PARAM_UNITSTATUS_Missing 0x00 /* cannot be complete or online */
|
|
||||||
|
|
||||||
#define TWE_PARAM_DRIVEINFO 0x0200 /* add drive number 0x00-0x0f XXX docco confused 0x0100 vs 0x0200 */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_Size 2 /* size in blocks [4] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_Model 3 /* drive model string [40] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_Serial 4 /* drive serial number [20] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_PhysCylNum 5 /* physical geometry [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_PhysHeadNum 6 /* [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_PhysSectorNym 7 /* [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_LogCylNum 8 /* logical geometry [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_LogHeadNum 9 /* [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_LogSectorNum 10 /* [2] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_UnitNum 11 /* unit number this drive is associated with or 0xff [1] */
|
|
||||||
#define TWE_PARAM_DRIVEINFO_DriveFlags 12 /* N/A [1] */
|
|
||||||
|
|
||||||
#define TWE_PARAM_APORTTIMEOUT 0x02c0 /* add (aport_number * 3) to parameter index */
|
|
||||||
#define TWE_PARAM_APORTTIMEOUT_READ 2 /* read timeouts last 24hrs [2] */
|
|
||||||
#define TWE_PARAM_APORTTIMEOUT_WRITE 3 /* write timeouts last 24hrs [2] */
|
|
||||||
#define TWE_PARAM_APORTTIMEOUT_DEGRADE 4 /* degrade threshold [2] */
|
|
||||||
|
|
||||||
#define TWE_PARAM_UNITINFO 0x0300 /* add unit number 0x00-0x0f */
|
|
||||||
#define TWE_PARAM_UNITINFO_Number 2 /* unit number [1] */
|
|
||||||
#define TWE_PARAM_UNITINFO_Status 3 /* unit status [1] */
|
|
||||||
#define TWE_PARAM_UNITINFO_Capacity 4 /* unit capacity in blocks [4] */
|
|
||||||
#define TWE_PARAM_UNITINFO_DescriptorSize 5 /* unit descriptor size + 3 bytes [2] */
|
|
||||||
#define TWE_PARAM_UNITINFO_Descriptor 6 /* unit descriptor, TWE_UnitDescriptor or TWE_Array_Descriptor */
|
|
||||||
#define TWE_PARAM_UNITINFO_Flags 7 /* unit flags [1] */
|
|
||||||
#define TWE_PARAM_UNITFLAGS_WCE (1<<0)
|
|
||||||
|
|
||||||
#define TWE_PARAM_AEN 0x0401
|
|
||||||
#define TWE_PARAM_AEN_UnitCode 2 /* (unit number << 8) | AEN code [2] */
|
|
||||||
#define TWE_AEN_QUEUE_EMPTY 0x00
|
|
||||||
#define TWE_AEN_SOFT_RESET 0x01
|
|
||||||
#define TWE_AEN_DEGRADED_MIRROR 0x02 /* reports unit */
|
|
||||||
#define TWE_AEN_CONTROLLER_ERROR 0x03
|
|
||||||
#define TWE_AEN_REBUILD_FAIL 0x04 /* reports unit */
|
|
||||||
#define TWE_AEN_REBUILD_DONE 0x05 /* reports unit */
|
|
||||||
#define TWE_AEN_INCOMP_UNIT 0x06 /* reports unit */
|
|
||||||
#define TWE_AEN_INIT_DONE 0x07 /* reports unit */
|
|
||||||
#define TWE_AEN_UNCLEAN_SHUTDOWN 0x08 /* reports unit */
|
|
||||||
#define TWE_AEN_APORT_TIMEOUT 0x09 /* reports unit, rate limited to 1 per 2^16 errors */
|
|
||||||
#define TWE_AEN_DRIVE_ERROR 0x0a /* reports unit */
|
|
||||||
#define TWE_AEN_REBUILD_STARTED 0x0b /* reports unit */
|
|
||||||
#define TWE_AEN_QUEUE_FULL 0xff
|
|
||||||
#define TWE_AEN_TABLE_UNDEFINED 0x15
|
|
||||||
#define TWE_AEN_CODE(x) ((x) & 0xff)
|
|
||||||
#define TWE_AEN_UNIT(x) ((x) >> 8)
|
|
||||||
|
|
||||||
#define TWE_PARAM_VERSION 0x0402
|
|
||||||
#define TWE_PARAM_VERSION_Mon 2 /* monitor version [16] */
|
|
||||||
#define TWE_PARAM_VERSION_FW 3 /* firmware version [16] */
|
|
||||||
#define TWE_PARAM_VERSION_BIOS 4 /* BIOSs version [16] */
|
|
||||||
#define TWE_PARAM_VERSION_PCB 5 /* PCB version [8] */
|
|
||||||
#define TWE_PARAM_VERSION_ATA 6 /* A-chip version [8] */
|
|
||||||
#define TWE_PARAM_VERSION_PCI 7 /* P-chip version [8] */
|
|
||||||
#define TWE_PARAM_VERSION_CtrlModel 8 /* N/A */
|
|
||||||
#define TWE_PARAM_VERSION_CtrlSerial 9 /* N/A */
|
|
||||||
#define TWE_PARAM_VERSION_SBufSize 10 /* N/A */
|
|
||||||
#define TWE_PARAM_VERSION_CompCode 11 /* compatibility code [4] */
|
|
||||||
|
|
||||||
#define TWE_PARAM_CONTROLLER 0x0403
|
|
||||||
#define TWE_PARAM_CONTROLLER_DCBSectors 2 /* # sectors reserved for DCB per drive [2] */
|
|
||||||
#define TWE_PARAM_CONTROLLER_PortCount 3 /* number of drive ports [1] */
|
|
||||||
|
|
||||||
#define TWE_PARAM_FEATURES 0x404
|
|
||||||
#define TWE_PARAM_FEATURES_DriverShutdown 2 /* set to 1 if driver supports shutdown notification [1] */
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t num_subunits; /* must be zero */
|
|
||||||
u_int8_t configuration;
|
|
||||||
#define TWE_UD_CONFIG_CBOD 0x0c /* JBOD with DCB, used for mirrors */
|
|
||||||
#define TWE_UD_CONFIG_SPARE 0x0d /* same as CBOD, but firmware will use as spare */
|
|
||||||
#define TWE_UD_CONFIG_SUBUNIT 0x0e /* drive is a subunit in an array */
|
|
||||||
#define TWE_UD_CONFIG_JBOD 0x0f /* plain drive */
|
|
||||||
u_int8_t phys_drv_num; /* may be 0xff if port can't be determined at runtime */
|
|
||||||
u_int8_t log_drv_num; /* must be zero for configuration == 0x0f */
|
|
||||||
u_int32_t start_lba;
|
|
||||||
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
|
|
||||||
} __packed TWE_Unit_Descriptor;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t flag; /* must be 0xff */
|
|
||||||
u_int8_t res1;
|
|
||||||
u_int8_t mirunit_status[4]; /* bitmap of functional subunits in each mirror */
|
|
||||||
u_int8_t res2[6];
|
|
||||||
} __packed TWE_Mirror_Descriptor;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int8_t num_subunits; /* number of subunits, or number of mirror units in RAID10 */
|
|
||||||
u_int8_t configuration;
|
|
||||||
#define TWE_UD_CONFIG_RAID0 0x00
|
|
||||||
#define TWE_UD_CONFIG_RAID1 0x01
|
|
||||||
#define TWE_UD_CONFIG_TwinStor 0x02
|
|
||||||
#define TWE_UD_CONFIG_RAID5 0x05
|
|
||||||
#define TWE_UD_CONFIG_RAID10 0x06
|
|
||||||
u_int8_t stripe_size;
|
|
||||||
#define TWE_UD_STRIPE_4k 0x03
|
|
||||||
#define TWE_UD_STRIPE_8k 0x04
|
|
||||||
#define TWE_UD_STRIPE_16k 0x05
|
|
||||||
#define TWE_UD_STRIPE_32k 0x06
|
|
||||||
#define TWE_UD_STRIPE_64k 0x07
|
|
||||||
u_int8_t log_drv_status; /* bitmap of functional subunits, or mirror units in RAID10 */
|
|
||||||
u_int32_t start_lba;
|
|
||||||
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
|
|
||||||
TWE_Unit_Descriptor subunit[0]; /* subunit descriptors, in RAID10 mode is [mirunit][subunit] */
|
|
||||||
} __packed TWE_Array_Descriptor;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u_int16_t table_id;
|
|
||||||
u_int8_t parameter_id;
|
|
||||||
u_int8_t parameter_size_bytes;
|
|
||||||
u_int8_t data[0];
|
|
||||||
} __packed TWE_Param;
|
|
@ -1,274 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
||||||
*
|
|
||||||
* Copyright (c) 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
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define TWE_DRIVER_VERSION_STRING "1.50.01.002"
|
|
||||||
|
|
||||||
#ifdef TWE_DEBUG
|
|
||||||
#define debug(level, fmt, args...) \
|
|
||||||
do { \
|
|
||||||
if (level <= TWE_DEBUG) printf("%s: " fmt "\n", __func__ , ##args); \
|
|
||||||
} while(0)
|
|
||||||
#define debug_called(level) \
|
|
||||||
do { \
|
|
||||||
if (level <= TWE_DEBUG) printf("%s: called\n", __func__); \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define debug(level, fmt, args...)
|
|
||||||
#define debug_called(level)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure describing a logical unit as attached to the controller
|
|
||||||
*/
|
|
||||||
struct twe_drive
|
|
||||||
{
|
|
||||||
/* unit properties */
|
|
||||||
u_int32_t td_size;
|
|
||||||
int td_cylinders;
|
|
||||||
int td_heads;
|
|
||||||
int td_sectors;
|
|
||||||
int td_sys_unit; /* device unit number */
|
|
||||||
int td_twe_unit; /* index into sc->twe_drive[] */
|
|
||||||
|
|
||||||
/* unit state and type */
|
|
||||||
u_int8_t td_state;
|
|
||||||
u_int8_t td_type;
|
|
||||||
u_int8_t td_stripe;
|
|
||||||
|
|
||||||
/* handle for attached driver */
|
|
||||||
device_t td_disk;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Per-command control structure.
|
|
||||||
*
|
|
||||||
* Note that due to alignment constraints on the tc_command field, this *must* be 64-byte aligned.
|
|
||||||
* We achieve this by placing the command at the beginning of the structure, and using malloc()
|
|
||||||
* to allocate each structure.
|
|
||||||
*/
|
|
||||||
struct twe_request
|
|
||||||
{
|
|
||||||
int tr_tag;
|
|
||||||
/* command payload */
|
|
||||||
void *tr_data; /* data buffer */
|
|
||||||
void *tr_realdata; /* copy of real data buffer pointer for alignment fixup */
|
|
||||||
size_t tr_length;
|
|
||||||
|
|
||||||
TAILQ_ENTRY(twe_request) tr_link; /* list linkage */
|
|
||||||
struct twe_softc *tr_sc; /* controller that owns us */
|
|
||||||
int tr_status; /* command status */
|
|
||||||
#define TWE_CMD_SETUP 0 /* being assembled */
|
|
||||||
#define TWE_CMD_BUSY 1 /* submitted to controller */
|
|
||||||
#define TWE_CMD_COMPLETE 2 /* completed by controller (maybe with error) */
|
|
||||||
#define TWE_CMD_ERROR 3 /* encountered error, even before submission to controller */
|
|
||||||
int tr_flags;
|
|
||||||
#define TWE_CMD_DATAIN (1<<0)
|
|
||||||
#define TWE_CMD_DATAOUT (1<<1)
|
|
||||||
#define TWE_CMD_ALIGNBUF (1<<2) /* data in bio is misaligned, have to copy to/from private buffer */
|
|
||||||
#define TWE_CMD_SLEEPER (1<<3) /* owner is sleeping on this command */
|
|
||||||
#define TWE_CMD_IMMEDIATE (1<<4) /* immediate request */
|
|
||||||
#define TWE_CMD_MAPPED (1<<5)
|
|
||||||
#define TWE_CMD_IN_PROGRESS (1<<6) /* bus_dmamap_load returned EINPROGRESS */
|
|
||||||
void (* tr_complete)(struct twe_request *tr); /* completion handler */
|
|
||||||
void *tr_private; /* submitter-private data or wait channel */
|
|
||||||
|
|
||||||
TWE_PLATFORM_REQUEST /* platform-specific request elements */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TWE_FIND_COMMAND(tr) \
|
|
||||||
(TWE_Command *)((u_int8_t *)(tr)->tr_sc->twe_cmd + \
|
|
||||||
((tr)->tr_tag * sizeof(TWE_Command)))
|
|
||||||
#define TWE_FIND_COMMANDPHYS(tr) ((tr)->tr_sc->twe_cmdphys + \
|
|
||||||
((tr)->tr_tag * sizeof(TWE_Command)))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Per-controller state.
|
|
||||||
*/
|
|
||||||
struct twe_softc
|
|
||||||
{
|
|
||||||
/* controller queues and arrays */
|
|
||||||
TAILQ_HEAD(, twe_request) twe_free; /* command structures available for reuse */
|
|
||||||
struct bio_queue_head twe_bioq; /* outstanding I/O operations */
|
|
||||||
TAILQ_HEAD(, twe_request) twe_ready; /* requests ready for the controller */
|
|
||||||
TAILQ_HEAD(, twe_request) twe_busy; /* requests busy in the controller */
|
|
||||||
TAILQ_HEAD(, twe_request) twe_complete; /* active commands (busy or waiting for completion) */
|
|
||||||
struct twe_request *twe_lookup[TWE_Q_LENGTH]; /* commands indexed by request ID */
|
|
||||||
struct twe_drive twe_drive[TWE_MAX_UNITS]; /* attached drives */
|
|
||||||
|
|
||||||
/* asynchronous event handling */
|
|
||||||
u_int16_t twe_aen_queue[TWE_Q_LENGTH]; /* AENs queued for userland tool(s) */
|
|
||||||
int twe_aen_head, twe_aen_tail; /* ringbuffer pointers for AEN queue */
|
|
||||||
int twe_wait_aen; /* wait-for-aen notification */
|
|
||||||
char twe_aen_buf[80]; /* AEN format buffer */
|
|
||||||
|
|
||||||
/* controller status */
|
|
||||||
int twe_state;
|
|
||||||
#define TWE_STATE_INTEN (1<<0) /* interrupts have been enabled */
|
|
||||||
#define TWE_STATE_SHUTDOWN (1<<1) /* controller is shut down */
|
|
||||||
#define TWE_STATE_OPEN (1<<2) /* control device is open */
|
|
||||||
#define TWE_STATE_SUSPEND (1<<3) /* controller is suspended */
|
|
||||||
#define TWE_STATE_FRZN (1<<4) /* got EINPROGRESS */
|
|
||||||
#define TWE_STATE_CTLR_BUSY (1<<5) /* controller cmd queue full */
|
|
||||||
#define TWE_STATE_DETACHING (1<<6) /* controller is being shut down */
|
|
||||||
int twe_host_id;
|
|
||||||
struct twe_qstat twe_qstat[TWEQ_COUNT]; /* queue statistics */
|
|
||||||
|
|
||||||
TWE_PLATFORM_SOFTC /* platform-specific softc elements */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Interface between driver core and platform-dependant code.
|
|
||||||
*/
|
|
||||||
extern int twe_setup(struct twe_softc *sc); /* do early driver/controller setup */
|
|
||||||
extern void twe_init(struct twe_softc *sc); /* init controller */
|
|
||||||
extern void twe_deinit(struct twe_softc *sc); /* stop controller */
|
|
||||||
extern void twe_intr(struct twe_softc *sc); /* hardware interrupt signalled */
|
|
||||||
extern void twe_startio(struct twe_softc *sc);
|
|
||||||
extern int twe_start(struct twe_request *tr);
|
|
||||||
extern int twe_dump_blocks(struct twe_softc *sc, int unit, /* crashdump block write */
|
|
||||||
u_int32_t lba, void *data, int nblks);
|
|
||||||
extern int twe_ioctl(struct twe_softc *sc, u_long cmd,
|
|
||||||
void *addr); /* handle user request */
|
|
||||||
extern void twe_describe_controller(struct twe_softc *sc); /* print controller info */
|
|
||||||
extern void twe_print_controller(struct twe_softc *sc);
|
|
||||||
extern void twe_enable_interrupts(struct twe_softc *sc); /* enable controller interrupts */
|
|
||||||
extern void twe_disable_interrupts(struct twe_softc *sc); /* disable controller interrupts */
|
|
||||||
|
|
||||||
extern int twe_attach_drive(struct twe_softc *sc,
|
|
||||||
struct twe_drive *dr); /* attach drive when found in twe_init */
|
|
||||||
extern int twe_detach_drive(struct twe_softc *sc,
|
|
||||||
int unit); /* detach drive */
|
|
||||||
extern void twe_clear_pci_parity_error(struct twe_softc *sc);
|
|
||||||
extern void twe_clear_pci_abort(struct twe_softc *sc);
|
|
||||||
extern void twed_intr(struct bio *bp); /* return bio from core */
|
|
||||||
extern struct twe_request *twe_allocate_request(struct twe_softc *sc, int tag); /* allocate request structure */
|
|
||||||
extern void twe_free_request(struct twe_request *tr); /* free request structure */
|
|
||||||
extern int twe_map_request(struct twe_request *tr); /* make request visible to controller, do s/g */
|
|
||||||
extern void twe_unmap_request(struct twe_request *tr); /* cleanup after transfer, unmap */
|
|
||||||
|
|
||||||
/********************************************************************************
|
|
||||||
* Queue primitives
|
|
||||||
*/
|
|
||||||
#define TWEQ_ADD(sc, qname) \
|
|
||||||
do { \
|
|
||||||
struct twe_qstat *qs = &(sc)->twe_qstat[qname]; \
|
|
||||||
\
|
|
||||||
qs->q_length++; \
|
|
||||||
if (qs->q_length > qs->q_max) \
|
|
||||||
qs->q_max = qs->q_length; \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define TWEQ_REMOVE(sc, qname) \
|
|
||||||
do { \
|
|
||||||
struct twe_qstat *qs = &(sc)->twe_qstat[qname]; \
|
|
||||||
\
|
|
||||||
qs->q_length--; \
|
|
||||||
if (qs->q_length < qs->q_min) \
|
|
||||||
qs->q_min = qs->q_length; \
|
|
||||||
} while(0);
|
|
||||||
|
|
||||||
#define TWEQ_INIT(sc, qname) \
|
|
||||||
do { \
|
|
||||||
sc->twe_qstat[qname].q_length = 0; \
|
|
||||||
sc->twe_qstat[qname].q_max = 0; \
|
|
||||||
sc->twe_qstat[qname].q_min = 0xFFFFFFFF; \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define TWEQ_REQUEST_QUEUE(name, index) \
|
|
||||||
static __inline void \
|
|
||||||
twe_initq_ ## name (struct twe_softc *sc) \
|
|
||||||
{ \
|
|
||||||
TAILQ_INIT(&sc->twe_ ## name); \
|
|
||||||
TWEQ_INIT(sc, index); \
|
|
||||||
} \
|
|
||||||
static __inline void \
|
|
||||||
twe_enqueue_ ## name (struct twe_request *tr) \
|
|
||||||
{ \
|
|
||||||
TAILQ_INSERT_TAIL(&tr->tr_sc->twe_ ## name, tr, tr_link); \
|
|
||||||
TWEQ_ADD(tr->tr_sc, index); \
|
|
||||||
} \
|
|
||||||
static __inline void \
|
|
||||||
twe_requeue_ ## name (struct twe_request *tr) \
|
|
||||||
{ \
|
|
||||||
TAILQ_INSERT_HEAD(&tr->tr_sc->twe_ ## name, tr, tr_link); \
|
|
||||||
TWEQ_ADD(tr->tr_sc, index); \
|
|
||||||
} \
|
|
||||||
static __inline struct twe_request * \
|
|
||||||
twe_dequeue_ ## name (struct twe_softc *sc) \
|
|
||||||
{ \
|
|
||||||
struct twe_request *tr; \
|
|
||||||
\
|
|
||||||
if ((tr = TAILQ_FIRST(&sc->twe_ ## name)) != NULL) { \
|
|
||||||
TAILQ_REMOVE(&sc->twe_ ## name, tr, tr_link); \
|
|
||||||
TWEQ_REMOVE(sc, index); \
|
|
||||||
} \
|
|
||||||
return(tr); \
|
|
||||||
} \
|
|
||||||
static __inline void \
|
|
||||||
twe_remove_ ## name (struct twe_request *tr) \
|
|
||||||
{ \
|
|
||||||
TAILQ_REMOVE(&tr->tr_sc->twe_ ## name, tr, tr_link); \
|
|
||||||
TWEQ_REMOVE(tr->tr_sc, index); \
|
|
||||||
}
|
|
||||||
|
|
||||||
TWEQ_REQUEST_QUEUE(free, TWEQ_FREE)
|
|
||||||
TWEQ_REQUEST_QUEUE(ready, TWEQ_READY)
|
|
||||||
TWEQ_REQUEST_QUEUE(busy, TWEQ_BUSY)
|
|
||||||
TWEQ_REQUEST_QUEUE(complete, TWEQ_COMPLETE)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* outstanding bio queue
|
|
||||||
*/
|
|
||||||
static __inline void
|
|
||||||
twe_initq_bio(struct twe_softc *sc)
|
|
||||||
{
|
|
||||||
bioq_init(&sc->twe_bioq);
|
|
||||||
TWEQ_INIT(sc, TWEQ_BIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void
|
|
||||||
twe_enqueue_bio(struct twe_softc *sc, struct bio *bp)
|
|
||||||
{
|
|
||||||
bioq_insert_tail(&sc->twe_bioq, bp);
|
|
||||||
TWEQ_ADD(sc, TWEQ_BIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline struct bio *
|
|
||||||
twe_dequeue_bio(struct twe_softc *sc)
|
|
||||||
{
|
|
||||||
struct bio *bp;
|
|
||||||
|
|
||||||
if ((bp = bioq_first(&sc->twe_bioq)) != NULL) {
|
|
||||||
bioq_remove(&sc->twe_bioq, bp);
|
|
||||||
TWEQ_REMOVE(sc, TWEQ_BIO);
|
|
||||||
}
|
|
||||||
return(bp);
|
|
||||||
}
|
|
@ -383,7 +383,6 @@ SUBDIR= \
|
|||||||
tmpfs \
|
tmpfs \
|
||||||
${_toecore} \
|
${_toecore} \
|
||||||
${_tpm} \
|
${_tpm} \
|
||||||
twe \
|
|
||||||
tws \
|
tws \
|
||||||
uart \
|
uart \
|
||||||
udf \
|
udf \
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
# $FreeBSD$
|
|
||||||
|
|
||||||
KMOD= twe
|
|
||||||
.PATH: ${SRCTOP}/sys/dev/${KMOD}
|
|
||||||
SRCS= bus_if.h device_if.h pci_if.h twe.c twe_freebsd.c
|
|
||||||
|
|
||||||
#CFLAGS+=-DTWE_DEBUG=0
|
|
||||||
|
|
||||||
# The 3ware controller offers a choice of options related to handling of
|
|
||||||
# mirror consistency in shutdown situations.
|
|
||||||
#
|
|
||||||
# If TWE_SHUTDOWN_NOTIFICATION is defined, the driver will inform the
|
|
||||||
# controller on clean shutdown. On reboot after an unclean shutdown, the
|
|
||||||
# controller will perform a complete mirror rebuild. This is the most
|
|
||||||
# "safe" configuration, but it imposes a severe performance penalty in the
|
|
||||||
# event of an unexpected reboot.
|
|
||||||
#
|
|
||||||
# In the alternate configuration, the controller assumes that all writes to
|
|
||||||
# a mirror complete successfully. In the case of an unclean shutdown,
|
|
||||||
# mirror corruption may occur if the controller is reset or power is lost
|
|
||||||
# during a disk write. This configuration is more suitable if the system
|
|
||||||
# has reliable power, but may be unstable for other reasons.
|
|
||||||
#
|
|
||||||
CFLAGS+=-DTWE_SHUTDOWN_NOTIFICATION
|
|
||||||
|
|
||||||
# The module can be built to override a compiled-in driver
|
|
||||||
#
|
|
||||||
#CFLAGS+=-DTWE_OVERRIDE
|
|
||||||
|
|
||||||
.include <bsd.kmod.mk>
|
|
Loading…
Reference in New Issue
Block a user