xref: /freebsd/sys/dev/mfi/mfi_ioctl.h (revision bdd1243d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2006 IronPort Systems
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 
32 #include <dev/mfi/mfireg.h>
33 
34 struct iovec32 {
35 	u_int32_t	iov_base;
36 	int		iov_len;
37 };
38 
39 #define MFIQ_FREE	0
40 #define MFIQ_BIO	1
41 #define MFIQ_READY	2
42 #define MFIQ_BUSY	3
43 #define MFIQ_COUNT	4
44 
45 struct mfi_qstat {
46 	uint32_t	q_length;
47 	uint32_t	q_max;
48 };
49 
50 union mfi_statrequest {
51 	uint32_t		ms_item;
52 	struct mfi_qstat	ms_qstat;
53 };
54 
55 #define MAX_SPACE_FOR_SENSE_PTR		32
56 union mfi_sense_ptr {
57 	uint8_t		sense_ptr_data[MAX_SPACE_FOR_SENSE_PTR];
58 	void 		*user_space;
59 	struct {
60 		uint32_t	low;
61 		uint32_t	high;
62 	} addr;
63 } __packed;
64 
65 #define MAX_IOCTL_SGE	16
66 
67 struct mfi_ioc_packet {
68 	uint16_t	mfi_adapter_no;
69 	uint16_t	mfi_pad1;
70 	uint32_t	mfi_sgl_off;
71 	uint32_t	mfi_sge_count;
72 	uint32_t	mfi_sense_off;
73 	uint32_t	mfi_sense_len;
74 	union {
75 		uint8_t raw[128];
76 		struct mfi_frame_header hdr;
77 	} mfi_frame;
78 
79 	struct iovec mfi_sgl[MAX_IOCTL_SGE];
80 } __packed;
81 
82 #ifdef COMPAT_FREEBSD32
83 struct mfi_ioc_packet32 {
84 	uint16_t	mfi_adapter_no;
85 	uint16_t	mfi_pad1;
86 	uint32_t	mfi_sgl_off;
87 	uint32_t	mfi_sge_count;
88 	uint32_t	mfi_sense_off;
89 	uint32_t	mfi_sense_len;
90 	union {
91 		uint8_t raw[128];
92 		struct mfi_frame_header hdr;
93 	} mfi_frame;
94 
95 	struct iovec32 mfi_sgl[MAX_IOCTL_SGE];
96 } __packed;
97 #endif
98 
99 struct mfi_ioc_aen {
100 	uint16_t	aen_adapter_no;
101 	uint16_t	aen_pad1;
102 	uint32_t	aen_seq_num;
103 	uint32_t	aen_class_locale;
104 } __packed;
105 
106 #define MFI_CMD		_IOWR('M', 1, struct mfi_ioc_packet)
107 #ifdef COMPAT_FREEBSD32
108 #define MFI_CMD32	_IOWR('M', 1, struct mfi_ioc_packet32)
109 #endif
110 #define MFI_SET_AEN	_IOW('M', 3, struct mfi_ioc_aen)
111 
112 #define MAX_LINUX_IOCTL_SGE	16
113 
114 struct mfi_linux_ioc_packet {
115 	uint16_t	lioc_adapter_no;
116 	uint16_t	lioc_pad1;
117 	uint32_t	lioc_sgl_off;
118 	uint32_t	lioc_sge_count;
119 	uint32_t	lioc_sense_off;
120 	uint32_t	lioc_sense_len;
121 	union {
122 		uint8_t raw[128];
123 		struct mfi_frame_header hdr;
124 	} lioc_frame;
125 
126 #if defined(__amd64__) /* Assume amd64 wants 32 bit Linux */
127 	struct iovec32 lioc_sgl[MAX_LINUX_IOCTL_SGE];
128 #else
129 	struct iovec lioc_sgl[MAX_LINUX_IOCTL_SGE];
130 #endif
131 } __packed;
132 
133 struct mfi_ioc_passthru {
134 	struct mfi_dcmd_frame	ioc_frame;
135 	uint32_t		buf_size;
136 	uint8_t			*buf;
137 } __packed;
138 
139 #ifdef COMPAT_FREEBSD32
140 struct mfi_ioc_passthru32 {
141 	struct mfi_dcmd_frame	ioc_frame;
142 	uint32_t		buf_size;
143 	uint32_t		buf;
144 } __packed;
145 #endif
146 
147 #define MFIIO_STATS	_IOWR('Q', 101, union mfi_statrequest)
148 #define MFIIO_PASSTHRU	_IOWR('C', 102, struct mfi_ioc_passthru)
149 #ifdef COMPAT_FREEBSD32
150 #define MFIIO_PASSTHRU32	_IOWR('C', 102, struct mfi_ioc_passthru32)
151 #endif
152 
153 struct mfi_linux_ioc_aen {
154 	uint16_t	laen_adapter_no;
155 	uint16_t	laen_pad1;
156 	uint32_t	laen_seq_num;
157 	uint32_t	laen_class_locale;
158 } __packed;
159 
160 struct mfi_query_disk {
161 	uint8_t	array_id;
162 	uint8_t	present;
163 	uint8_t	open;
164 	uint8_t reserved;	/* reserved for future use */
165 	char	devname[SPECNAMELEN + 1];
166 } __packed;
167 
168 #define MFIIO_QUERY_DISK	_IOWR('Q', 102, struct mfi_query_disk)
169 
170 /*
171  * Create a second set so the FreeBSD native ioctl doesn't
172  * conflict in FreeBSD ioctl handler.  Translate in mfi_linux.c.
173  */
174 #define MFI_LINUX_CMD		0xc1144d01
175 #define MFI_LINUX_SET_AEN	0x400c4d03
176 #define MFI_LINUX_CMD_2		0xc1144d02
177 #define MFI_LINUX_SET_AEN_2	0x400c4d04
178