Merge branch 'vendor/XZ'
[dragonfly.git] / sys / dev / raid / mfi / mfi_ioctl.h
1 /*-
2  * Copyright (c) 2006 IronPort Systems
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: src/sys/dev/mfi/mfi_ioctl.h,v 1.9 2009/08/13 23:18:45 scottl Exp $
27  */
28
29 #include <sys/conf.h>
30
31 #include <dev/raid/mfi/mfireg.h>
32
33 #if defined(__x86_64__) /* Assume amd64 wants 32 bit Linux */
34 struct iovec32 {
35         u_int32_t       iov_base;
36         int             iov_len;
37 };
38 #endif
39
40 #define MFIQ_FREE       0
41 #define MFIQ_BIO        1
42 #define MFIQ_READY      2
43 #define MFIQ_BUSY       3
44 #define MFIQ_COUNT      4
45
46 struct mfi_qstat {
47         uint32_t        q_length;
48         uint32_t        q_max;
49 };
50
51 union mfi_statrequest {
52         uint32_t                ms_item;
53         struct mfi_qstat        ms_qstat;
54 };
55
56 #define MAX_SPACE_FOR_SENSE_PTR         32
57 union mfi_sense_ptr {
58         uint8_t         sense_ptr_data[MAX_SPACE_FOR_SENSE_PTR];
59         void            *user_space;
60         struct {
61                 uint32_t        low;
62                 uint32_t        high;
63         } addr;
64 } __packed;
65
66 #define MAX_IOCTL_SGE   16
67
68 struct mfi_ioc_packet {
69         uint16_t        mfi_adapter_no;
70         uint16_t        mfi_pad1;
71         uint32_t        mfi_sgl_off;
72         uint32_t        mfi_sge_count;
73         uint32_t        mfi_sense_off;
74         uint32_t        mfi_sense_len;
75         union {
76                 uint8_t raw[128];
77                 struct mfi_frame_header hdr;
78         } mfi_frame;
79
80         struct iovec mfi_sgl[MAX_IOCTL_SGE];
81 } __packed;
82
83 #ifdef __x86_64__
84 struct mfi_ioc_packet32 {
85         uint16_t        mfi_adapter_no;
86         uint16_t        mfi_pad1;
87         uint32_t        mfi_sgl_off;
88         uint32_t        mfi_sge_count;
89         uint32_t        mfi_sense_off;
90         uint32_t        mfi_sense_len;
91         union {
92                 uint8_t raw[128];
93                 struct mfi_frame_header hdr;
94         } mfi_frame;
95
96         struct iovec32 mfi_sgl[MAX_IOCTL_SGE];
97 } __packed;
98 #endif
99
100 struct mfi_ioc_aen {
101         uint16_t        aen_adapter_no;
102         uint16_t        aen_pad1;
103         uint32_t        aen_seq_num;
104         uint32_t        aen_class_locale;
105 } __packed;
106
107 #define MFI_CMD         _IOWR('M', 1, struct mfi_ioc_packet)
108 #ifdef __x86_64__
109 #define MFI_CMD32       _IOWR('M', 1, struct mfi_ioc_packet32)
110 #endif
111 #define MFI_SET_AEN     _IOW('M', 3, struct mfi_ioc_aen)
112
113 #define MAX_LINUX_IOCTL_SGE     16
114
115 struct mfi_linux_ioc_packet {
116         uint16_t        lioc_adapter_no;
117         uint16_t        lioc_pad1;
118         uint32_t        lioc_sgl_off;
119         uint32_t        lioc_sge_count;
120         uint32_t        lioc_sense_off;
121         uint32_t        lioc_sense_len;
122         union {
123                 uint8_t raw[128];
124                 struct mfi_frame_header hdr;
125         } lioc_frame;
126
127 #if defined(__x86_64__) /* Assume amd64 wants 32 bit Linux */
128         struct iovec32 lioc_sgl[MAX_LINUX_IOCTL_SGE];
129 #else
130         struct iovec lioc_sgl[MAX_LINUX_IOCTL_SGE];
131 #endif
132 } __packed;
133
134 struct mfi_ioc_passthru {
135         struct mfi_dcmd_frame   ioc_frame;
136         uint32_t                buf_size;
137         uint8_t                 *buf;
138 } __packed;
139
140 #ifdef __x86_64__
141 struct mfi_ioc_passthru32 {
142         struct mfi_dcmd_frame   ioc_frame;
143         uint32_t                buf_size;
144         uint32_t                buf;
145 } __packed;
146 #endif
147
148 #define MFIIO_STATS     _IOWR('Q', 101, union mfi_statrequest)
149 #define MFIIO_PASSTHRU  _IOWR('C', 102, struct mfi_ioc_passthru)
150 #ifdef __x86_64__
151 #define MFIIO_PASSTHRU32        _IOWR('C', 102, struct mfi_ioc_passthru32)
152 #endif
153
154 struct mfi_linux_ioc_aen {
155         uint16_t        laen_adapter_no;
156         uint16_t        laen_pad1;
157         uint32_t        laen_seq_num;
158         uint32_t        laen_class_locale;
159 } __packed;
160
161 struct mfi_query_disk {
162         uint8_t array_id;
163         uint8_t present;
164         uint8_t open;
165         uint8_t reserved;       /* reserved for future use */
166         char    devname[SPECNAMELEN + 1];
167 } __packed;
168
169 #define MFIIO_QUERY_DISK        _IOWR('Q', 102, struct mfi_query_disk)
170
171 /*
172  * Create a second set so the FreeBSD native ioctl doesn't
173  * conflict in FreeBSD ioctl handler.  Translate in mfi_linux.c.
174  */
175 #define MFI_LINUX_CMD           0xc1144d01
176 #define MFI_LINUX_SET_AEN       0x400c4d03
177 #define MFI_LINUX_CMD_2         0xc1144d02
178 #define MFI_LINUX_SET_AEN_2     0x400c4d04