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