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