Add in the twa(4) driver. This adds in support for the 3Ware
[dragonfly.git] / sys / dev / raid / twa / twa_ioctl.h
1 /*-
2  * Copyright (c) 2003-04 3ware, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  *      $FreeBSD$
27  * $DragonFly: src/sys/dev/raid/twa/twa_ioctl.h,v 1.1 2004/04/16 20:13:17 drhodus Exp $
28  */
29
30 /*
31  * 3ware driver for 9000 series storage controllers.
32  *
33  * Author: Vinod Kashyap
34  */
35
36
37 #define TWA_AEN_NOT_RETRIEVED   0x1
38 #define TWA_AEN_RETRIEVED       0x2
39
40 #define TWA_ERROR_AEN_NO_EVENTS 0x1003           /* No more events */
41 #define TWA_ERROR_AEN_OVERFLOW  0x1004           /* AEN clobber occurred */
42
43 #define TWA_ERROR_IOCTL_LOCK_NOT_HELD           0x1001   /* Not locked */
44 #define TWA_ERROR_IOCTL_LOCK_ALREADY_HELD       0x1002   /* Already locked */
45
46
47 #pragma pack(1)
48 struct twa_scan_bus_packet {
49         u_int32_t       unit;
50 } __attribute__ ((packed));
51
52
53 struct twa_event_packet {
54         u_int32_t       sequence_id;
55         u_int32_t       time_stamp_sec;
56         u_int16_t       aen_code;
57         u_int8_t        severity;
58         u_int8_t        retrieved;
59         u_int8_t        repeat_count;
60         u_int8_t        parameter_len;
61         u_int8_t        parameter_data[98];
62 } __attribute__ ((packed));
63
64
65 struct twa_lock_packet {
66         u_int32_t       timeout_msec;
67         u_int32_t       time_remaining_msec;
68         u_int32_t       force_flag;
69 } __attribute__ ((packed));
70
71
72 struct twa_compatibility_packet {
73         uint8_t         driver_version[32];/* driver version */
74         uint16_t        working_srl;    /* driver & firmware negotiated srl */
75         uint16_t        working_branch; /* branch # of the firmware that the driver is compatible with */
76         uint16_t        working_build;  /* build # of the firmware that the driver is compatible with */
77 } __attribute__ ((packed));
78
79
80 struct twa_driver_packet {
81         u_int32_t       control_code;
82         u_int32_t       status;
83         u_int32_t       unique_id;
84         u_int32_t       sequence_id;
85         u_int32_t       os_status;
86         u_int32_t       buffer_length;
87 } __attribute__ ((packed));
88
89
90 struct twa_ioctl_9k {
91         struct twa_driver_packet        twa_drvr_pkt;
92         void                            *pdata; /* points to data_buf */
93         int8_t                          padding[484];
94         struct twa_command_packet       twa_cmd_pkt;
95         int8_t                          data_buf[1];
96 } __attribute__ ((packed));
97
98
99 /*
100  * We need the structure below to ensure that the first byte of
101  * data_buf is not overwritten by the kernel, after we return
102  * from the ioctl call.  Note that twa_cmd_pkt has been reduced
103  * to an array of 1024 bytes even though it's actually 2048 bytes
104  * in size.  This is because, we don't expect requests from user
105  * land requiring 2048 (273 sg elements) byte cmd pkts.
106  */
107 typedef struct twa_ioctl_no_data_buf {
108         struct twa_driver_packet        twa_drvr_pkt;
109         void                            *pdata; /* points to data_buf */
110         int8_t                          padding[484];
111         struct twa_command_packet       twa_cmd_pkt;
112 }  __attribute__ ((packed)) TWA_IOCTL_NO_DATA_BUF;
113 #pragma pack()
114
115
116 #define TWA_IOCTL_SCAN_BUS              _IOW ('T', 200, u_int32_t)
117 #define TWA_IOCTL_FIRMWARE_PASS_THROUGH _IOWR('T', 202, TWA_IOCTL_NO_DATA_BUF)
118 #define TWA_IOCTL_GET_FIRST_EVENT       _IOWR('T', 203, TWA_IOCTL_NO_DATA_BUF)
119 #define TWA_IOCTL_GET_LAST_EVENT        _IOWR('T', 204, TWA_IOCTL_NO_DATA_BUF)
120 #define TWA_IOCTL_GET_NEXT_EVENT        _IOWR('T', 205, TWA_IOCTL_NO_DATA_BUF)
121 #define TWA_IOCTL_GET_PREVIOUS_EVENT    _IOWR('T', 206, TWA_IOCTL_NO_DATA_BUF)
122 #define TWA_IOCTL_GET_LOCK              _IOWR('T', 207, TWA_IOCTL_NO_DATA_BUF)
123 #define TWA_IOCTL_RELEASE_LOCK          _IOWR('T', 208, TWA_IOCTL_NO_DATA_BUF)
124 #define TWA_IOCTL_GET_COMPATIBILITY_INFO _IOWR('T', 209, TWA_IOCTL_NO_DATA_BUF)
125
126