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