summaryrefslogtreecommitdiff
path: root/sys/dev/twe
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2000-10-27 01:19:03 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2000-10-27 01:19:03 +0000
commit0c9d7cf2b74ce0e58fbe16a33d442a9a056fbf03 (patch)
tree94a956fdfa9eeb6d85281ed01c7a48a9edf35d41 /sys/dev/twe
parent8b380c46fcbf9d420ef520940995e4dbfb5eca2e (diff)
Notes
Diffstat (limited to 'sys/dev/twe')
-rw-r--r--sys/dev/twe/twe_tables.h161
-rw-r--r--sys/dev/twe/tweio.h92
2 files changed, 253 insertions, 0 deletions
diff --git a/sys/dev/twe/twe_tables.h b/sys/dev/twe/twe_tables.h
new file mode 100644
index 000000000000..aa1ab020772f
--- /dev/null
+++ b/sys/dev/twe/twe_tables.h
@@ -0,0 +1,161 @@
+/*-
+ * 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$
+ */
+
+/*
+ * 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 */
+
+/********************************************************************************
+ * Look up a text description of a numeric code and return a pointer to same.
+ */
+char *
+twe_describe_code(struct twe_code_lookup *table, u_int32_t code)
+{
+ int i;
+
+ for (i = 0; table[i].string != NULL; i++)
+ if (table[i].code == code)
+ return(table[i].string);
+ return(table[i+1].string);
+}
+
+
+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 mirror", 0x02},
+ {"p 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},
+ {"p 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
diff --git a/sys/dev/twe/tweio.h b/sys/dev/twe/tweio.h
new file mode 100644
index 000000000000..eaf0d7be4c51
--- /dev/null
+++ b/sys/dev/twe/tweio.h
@@ -0,0 +1,92 @@
+/*-
+ * 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$
+ */
+
+
+/*
+ * 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;
+};
+
+/*
+ * 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, int)
+#define TWEIO_AEN_WAIT _IOR('T', 103, int)
+
+/*
+ * 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)