xref: /freebsd/sys/dev/mrsas/mrsas_ioctl.h (revision 04803ab2177f1c57467b12f497a7ab8eabc3e8d2)
1 /*
2  * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
3  * Support: freebsdraid@lsi.com
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer. 2. Redistributions
11  * in binary form must reproduce the above copyright notice, this list of
12  * conditions and the following disclaimer in the documentation and/or other
13  * materials provided with the distribution. 3. Neither the name of the
14  * <ORGANIZATION> nor the names of its contributors may be used to endorse or
15  * promote products derived from this software without specific prior written
16  * permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * The views and conclusions contained in the software and documentation are
31  * those of the authors and should not be interpreted as representing
32  * official policies,either expressed or implied, of the FreeBSD Project.
33  *
34  * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
35  * Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
36  *
37  */
38 
39 #include <sys/cdefs.h>
40 __FBSDID("$FreeBSD$");
41 
42 #ifndef MRSAS_IOCTL_H
43 #define	MRSAS_IOCTL_H
44 
45 #ifndef _IOWR
46 #include <sys/ioccom.h>
47 #endif					/* !_IOWR */
48 
49 #ifdef COMPAT_FREEBSD32
50 /* Compilation error FIX */
51 #if (__FreeBSD_version <= 900000)
52 #include <sys/socket.h>
53 #endif
54 #include <sys/mount.h>
55 #include <compat/freebsd32/freebsd32.h>
56 #endif
57 
58 /*
59  * We need to use the same values as the mfi driver until MegaCli adds
60  * support for this (mrsas) driver: M is for MegaRAID. (This is typically the
61  * vendor or product initial) 1 arbitrary. (This may be used to segment kinds
62  * of commands.  (1-9 status, 10-20 policy, etc.) struct mrsas_iocpacket
63  * (sizeof() this parameter will be used.) These three values are encoded
64  * into a somewhat unique, 32-bit value.
65  */
66 
67 #define	MRSAS_IOC_FIRMWARE_PASS_THROUGH64	_IOWR('M', 1, struct mrsas_iocpacket)
68 #ifdef COMPAT_FREEBSD32
69 #define	MRSAS_IOC_FIRMWARE_PASS_THROUGH32	_IOWR('M', 1, struct mrsas_iocpacket32)
70 #endif
71 
72 #define	MRSAS_IOC_SCAN_BUS		_IO('M',  10)
73 
74 #define	MRSAS_LINUX_CMD32		0xc1144d01
75 
76 #define	MAX_IOCTL_SGE			16
77 #define	MFI_FRAME_DIR_READ		0x0010
78 #define	MFI_CMD_LD_SCSI_IO		0x03
79 
80 #define	INQUIRY_CMD				0x12
81 #define	INQUIRY_CMDLEN			6
82 #define	INQUIRY_REPLY_LEN		96
83 #define	INQUIRY_VENDOR			8	/* Offset in reply data to
84 						 * vendor name */
85 #define	SCSI_SENSE_BUFFERSIZE	96
86 
87 #define	MEGAMFI_RAW_FRAME_SIZE	128
88 
89 
90 #pragma pack(1)
91 struct mrsas_iocpacket {
92 	u_int16_t host_no;
93 	u_int16_t __pad1;
94 	u_int32_t sgl_off;
95 	u_int32_t sge_count;
96 	u_int32_t sense_off;
97 	u_int32_t sense_len;
98 	union {
99 		u_int8_t raw[MEGAMFI_RAW_FRAME_SIZE];
100 		struct mrsas_header hdr;
101 	}	frame;
102 	struct iovec sgl[MAX_IOCTL_SGE];
103 };
104 
105 #pragma pack()
106 
107 #ifdef COMPAT_FREEBSD32
108 #pragma pack(1)
109 struct mrsas_iocpacket32 {
110 	u_int16_t host_no;
111 	u_int16_t __pad1;
112 	u_int32_t sgl_off;
113 	u_int32_t sge_count;
114 	u_int32_t sense_off;
115 	u_int32_t sense_len;
116 	union {
117 		u_int8_t raw[MEGAMFI_RAW_FRAME_SIZE];
118 		struct mrsas_header hdr;
119 	}	frame;
120 	struct iovec32 sgl[MAX_IOCTL_SGE];
121 };
122 
123 #pragma pack()
124 #endif					/* COMPAT_FREEBSD32 */
125 
126 #endif					/* MRSAS_IOCTL_H */
127