]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - megaraid.h
Merge commit 'upstream/5.38+svn2920'
[mirror_smartmontools-debian.git] / megaraid.h
1 int megaraid_io_interface(int device, int target, struct scsi_cmnd_io *, int);
2
3 #undef u32
4
5 #define u8 uint8_t
6 #define u16 uint16_t
7 #define u32 uint32_t
8 #define u64 uint64_t
9
10 /*======================================================
11 * PERC2/3/4 Passthrough SCSI Command Interface
12 *
13 * Contents from:
14 * drivers/scsi/megaraid/megaraid_ioctl.h
15 * drivers/scsi/megaraid/mbox_defs.h
16 *======================================================*/
17 #define MEGAIOC_MAGIC 'm'
18 #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, struct uioctl_t)
19
20 /* Following subopcode work for opcode == 0x82 */
21 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | adapno)
22 #define MEGAIOC_QNADAP 'm'
23 #define MEGAIOC_QDRVRVER 'e'
24 #define MEGAIOC_QADAPINFO 'g'
25
26 #define MEGA_MBOXCMD_PASSTHRU 0x03
27
28 #define MAX_REQ_SENSE_LEN 0x20
29 #define MAX_CDB_LEN 10
30
31 typedef struct
32 {
33 uint8_t timeout : 3;
34 uint8_t ars : 1;
35 uint8_t reserved : 3;
36 uint8_t islogical : 1;
37 uint8_t logdrv;
38 uint8_t channel;
39 uint8_t target;
40 uint8_t queuetag;
41 uint8_t queueaction;
42 uint8_t cdb[MAX_CDB_LEN];
43 uint8_t cdblen;
44 uint8_t reqsenselen;
45 uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
46 uint8_t numsgelements;
47 uint8_t scsistatus;
48 uint32_t dataxferaddr;
49 uint32_t dataxferlen;
50 } __attribute__((packed)) mega_passthru;
51
52 typedef struct
53 {
54 uint8_t cmd;
55 uint8_t cmdid;
56 uint8_t opcode;
57 uint8_t subopcode;
58 uint32_t lba;
59 uint32_t xferaddr;
60 uint8_t logdrv;
61 uint8_t resvd[3];
62 uint8_t numstatus;
63 uint8_t status;
64 } __attribute__((packed)) megacmd_t;
65
66 typedef struct {
67 uint8_t *pointer;
68 #if BITS_PER_LONG == 32
69 uint8_t pad[4];
70 #endif
71 } ptr_t;
72
73 struct uioctl_t
74 {
75 uint32_t inlen;
76 uint32_t outlen;
77 union {
78 uint8_t fca[16];
79 struct {
80 uint8_t opcode;
81 uint8_t subopcode;
82 uint16_t adapno;
83 ptr_t buffer;
84 uint32_t length;
85 } __attribute__((packed)) fcs;
86 } __attribute__((packed)) ui;
87
88 megacmd_t mbox;
89 mega_passthru pthru;
90 ptr_t data;
91 } __attribute__((packed));
92
93 /*===================================================
94 * PERC5/6 Passthrough SCSI Command Interface
95 *
96 * Contents from:
97 * drivers/scsi/megaraid/megaraid_sas.h
98 *===================================================*/
99 #define MEGASAS_MAGIC 'M'
100 #define MEGASAS_IOC_FIRMWARE _IOWR(MEGASAS_MAGIC, 1, struct megasas_iocpacket)
101
102 #define MFI_CMD_PD_SCSI_IO 0x04
103 #define MFI_FRAME_SGL64 0x02
104 #define MFI_FRAME_DIR_READ 0x10
105
106 #define MAX_IOCTL_SGE 16
107
108 struct megasas_sge32 {
109
110 u32 phys_addr;
111 u32 length;
112
113 } __attribute__ ((packed));
114
115 struct megasas_sge64 {
116
117 u64 phys_addr;
118 u32 length;
119
120 } __attribute__ ((packed));
121
122 union megasas_sgl {
123
124 struct megasas_sge32 sge32[1];
125 struct megasas_sge64 sge64[1];
126
127 } __attribute__ ((packed));
128
129 struct megasas_header {
130
131 u8 cmd; /*00h */
132 u8 sense_len; /*01h */
133 u8 cmd_status; /*02h */
134 u8 scsi_status; /*03h */
135
136 u8 target_id; /*04h */
137 u8 lun; /*05h */
138 u8 cdb_len; /*06h */
139 u8 sge_count; /*07h */
140
141 u32 context; /*08h */
142 u32 pad_0; /*0Ch */
143
144 u16 flags; /*10h */
145 u16 timeout; /*12h */
146 u32 data_xferlen; /*14h */
147
148 } __attribute__ ((packed));
149
150 struct megasas_pthru_frame {
151
152 u8 cmd; /*00h */
153 u8 sense_len; /*01h */
154 u8 cmd_status; /*02h */
155 u8 scsi_status; /*03h */
156
157 u8 target_id; /*04h */
158 u8 lun; /*05h */
159 u8 cdb_len; /*06h */
160 u8 sge_count; /*07h */
161
162 u32 context; /*08h */
163 u32 pad_0; /*0Ch */
164
165 u16 flags; /*10h */
166 u16 timeout; /*12h */
167 u32 data_xfer_len; /*14h */
168
169 u32 sense_buf_phys_addr_lo; /*18h */
170 u32 sense_buf_phys_addr_hi; /*1Ch */
171
172 u8 cdb[16]; /*20h */
173 union megasas_sgl sgl; /*30h */
174
175 } __attribute__ ((packed));
176
177 struct megasas_dcmd_frame {
178
179 u8 cmd; /*00h */
180 u8 reserved_0; /*01h */
181 u8 cmd_status; /*02h */
182 u8 reserved_1[4]; /*03h */
183 u8 sge_count; /*07h */
184
185 u32 context; /*08h */
186 u32 pad_0; /*0Ch */
187
188 u16 flags; /*10h */
189 u16 timeout; /*12h */
190
191 u32 data_xfer_len; /*14h */
192 u32 opcode; /*18h */
193
194 union { /*1Ch */
195 u8 b[12];
196 u16 s[6];
197 u32 w[3];
198 } mbox;
199
200 union megasas_sgl sgl; /*28h */
201
202 } __attribute__ ((packed));
203
204 struct megasas_iocpacket {
205
206 u16 host_no;
207 u16 __pad1;
208 u32 sgl_off;
209 u32 sge_count;
210 u32 sense_off;
211 u32 sense_len;
212 union {
213 u8 raw[128];
214 struct megasas_header hdr;
215 } frame;
216
217 struct iovec sgl[MAX_IOCTL_SGE];
218
219 } __attribute__ ((packed));
220
221 #undef u8
222 #undef u16
223 #undef u32
224 #undef u64
225