xref: /linux/drivers/scsi/leapraid/leapraid.h (revision 35748ddd3b2c91555bd86b8cf88edc90e7317e57)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2026 LeapIO Tech Inc.
4  *
5  * LeapRAID storage and RAID controller driver.
6  */
7 #ifndef LEAPRAID_H
8 #define LEAPRAID_H
9 
10 /* Doorbell register definitions. */
11 #define LEAPRAID_DB_RESET       0x00000000
12 #define LEAPRAID_DB_READY       0x10000000
13 #define LEAPRAID_DB_OPERATIONAL 0x20000000
14 #define LEAPRAID_DB_FAULT       0x40000000
15 
16 #define LEAPRAID_DB_MASK        0xF0000000
17 
18 #define LEAPRAID_DB_OVER_TEMPERATURE    0x2810
19 
20 #define LEAPRAID_DB_USED                0x08000000
21 #define LEAPRAID_DB_DATA_MASK           0x0000FFFF
22 #define LEAPRAID_DB_FUNC_SHIFT          24
23 #define LEAPRAID_DB_ADD_DWORDS_SHIFT    16
24 
25 /* Maximum number of retries waiting for doorbell to become ready. */
26 #define LEAPRAID_DB_RETRY_COUNT_MAX    10
27 /* Maximum number of retries waiting for doorbell to become operational. */
28 #define LEAPRAID_DB_WAIT_OP_SHORT   10
29 #define LEAPRAID_DB_WAIT_OP_LONG   200
30 
31 /* Maximum number of retries waiting for host to end recovery. */
32 #define LEAPRAID_WAIT_SHOST_RECOVERY   400
33 
34 /* Diagnostic register definitions. */
35 #define LEAPRAID_DIAG_WRITE_ENABLE      0x00000080
36 #define LEAPRAID_DIAG_RESET             0x00000004
37 
38 /* Interrupt status register definitions. */
39 #define LEAPRAID_HOST2ADAPTER_DB_STATUS 0x80000000
40 #define LEAPRAID_ADAPTER2HOST_DB_STATUS 0x00000001
41 
42 /* The number of debug register. */
43 #define LEAPRAID_DEBUGLOG_SZ_MAX    16
44 
45 /* Reply post host register definitions. */
46 #define REP_POST_HOST_IDX_REG_CNT 16
47 #define LEAPRAID_RPHI_MSIX_IDX_SHIFT    24
48 
49 /* Virtual PHY flags. */
50 #define LEAPRAID_SAS_PHYINFO_VPHY       0x00001000
51 
52 /* Linux driver init firmware. */
53 #define LEAPRAID_WHOINIT_LINUX_DRIVER    0x04
54 
55 /* Reply descriptor post queue array mode. */
56 #define LEAPRAID_ADAPTER_INIT_MSGFLG_RDPQ_ARRAY_MODE    0x01
57 
58 /* Request description flags. */
59 #define LEAPRAID_REQ_DESC_FLG_SCSI_IO   0x00
60 #define LEAPRAID_REQ_DESC_FLG_HPR       0x06
61 #define LEAPRAID_REQ_DESC_FLG_DFLT_TYPE 0x08
62 
63 /* Reply description flags. */
64 #define LEAPRAID_RPY_DESC_FLG_TYPE_MASK                 0x0F
65 #define LEAPRAID_RPY_DESC_FLG_SCSI_IO_SUCCESS           0x00
66 #define LEAPRAID_RPY_DESC_FLG_ADDRESS_REPLY             0x01
67 #define LEAPRAID_RPY_DESC_FLG_FP_SCSI_IO_SUCCESS        0x06
68 #define LEAPRAID_RPY_DESC_FLG_UNUSED                    0x0F
69 
70 /* Request and reply messages share the same set of function codes.
71  *
72  * Note: SCSIIO (SCSI I/O) represents SCSI I/O operations and is used
73  * consistently throughout the driver for all SCSI command handling.
74  */
75 #define LEAPRAID_FUNC_SCSIIO                    0x00
76 #define LEAPRAID_FUNC_SCSI_TMF                  0x01
77 #define LEAPRAID_FUNC_ADAPTER_INIT              0x02
78 #define LEAPRAID_FUNC_GET_ADAPTER_FEATURES      0x03
79 #define LEAPRAID_FUNC_CONFIG_OP                 0x04
80 #define LEAPRAID_FUNC_SCAN_DEV                  0x06
81 #define LEAPRAID_FUNC_EVENT_NOTIFY              0x07
82 #define LEAPRAID_FUNC_FW_DOWNLOAD               0x09
83 #define LEAPRAID_FUNC_FW_UPLOAD                 0x12
84 #define LEAPRAID_FUNC_SCSIIO_RAID_PASSTHROUGH   0x16
85 #define LEAPRAID_FUNC_SCSI_ENC_PROCESSOR        0x18
86 #define LEAPRAID_FUNC_SMP_PASSTHROUGH           0x1A
87 #define LEAPRAID_FUNC_SAS_IO_UNIT_CTRL          0x1B
88 #define LEAPRAID_FUNC_SCSIIO_SATA_PASSTHROUGH   0x1C
89 #define LEAPRAID_FUNC_ADAPTER_UNIT_RESET        0x40
90 #define LEAPRAID_FUNC_HANDSHAKE                 0x42
91 #define LEAPRAID_FUNC_LOGBUF_INIT               0x57
92 
93 /* Adapter status values. */
94 #define LEAPRAID_ADAPTER_STATUS_MASK                    0x7FFF
95 #define LEAPRAID_ADAPTER_STATUS_SUCCESS                 0x0000
96 #define LEAPRAID_ADAPTER_STATUS_BUSY                    0x0002
97 #define LEAPRAID_ADAPTER_STATUS_INTERNAL_ERROR          0x0004
98 #define LEAPRAID_ADAPTER_STATUS_INSUFFICIENT_RESOURCES  0x0006
99 #define LEAPRAID_ADAPTER_STATUS_CONFIG_INVALID_ACTION   0x0020
100 #define LEAPRAID_ADAPTER_STATUS_CONFIG_INVALID_TYPE     0x0021
101 #define LEAPRAID_ADAPTER_STATUS_CONFIG_INVALID_PAGE     0x0022
102 #define LEAPRAID_ADAPTER_STATUS_CONFIG_INVALID_DATA     0x0023
103 #define LEAPRAID_ADAPTER_STATUS_CONFIG_NO_DEFAULTS      0x0024
104 #define LEAPRAID_ADAPTER_STATUS_CONFIG_CANT_COMMIT      0x0025
105 #define LEAPRAID_ADAPTER_STATUS_SCSI_RECOVERED_ERROR    0x0040
106 #define LEAPRAID_ADAPTER_STATUS_SCSI_DEVICE_NOT_THERE   0x0043
107 #define LEAPRAID_ADAPTER_STATUS_SCSI_DATA_OVERRUN       0x0044
108 #define LEAPRAID_ADAPTER_STATUS_SCSI_DATA_UNDERRUN      0x0045
109 #define LEAPRAID_ADAPTER_STATUS_SCSI_IO_DATA_ERROR      0x0046
110 #define LEAPRAID_ADAPTER_STATUS_SCSI_PROTOCOL_ERROR     0x0047
111 #define LEAPRAID_ADAPTER_STATUS_SCSI_TASK_TERMINATED    0x0048
112 #define LEAPRAID_ADAPTER_STATUS_SCSI_RESIDUAL_MISMATCH  0x0049
113 #define LEAPRAID_ADAPTER_STATUS_SCSI_TASK_MGMT_FAILED   0x004A
114 #define LEAPRAID_ADAPTER_STATUS_SCSI_ADAPTER_TERMINATED 0x004B
115 #define LEAPRAID_ADAPTER_STATUS_SCSI_EXT_TERMINATED     0x004C
116 
117 /* SGE flags. */
118 #define LEAPRAID_SGE_FLG_LAST_ONE       0x80
119 #define LEAPRAID_SGE_FLG_EOB            0x40
120 #define LEAPRAID_SGE_FLG_EOL            0x01
121 #define LEAPRAID_SGE_FLG_SHIFT          24
122 #define LEAPRAID_SGE_FLG_SIMPLE_ONE     0x10
123 #define LEAPRAID_SGE_FLG_SYSTEM_ADDR    0x00
124 #define LEAPRAID_SGE_FLG_H2C            0x04
125 #define LEAPRAID_SGE_FLG_32             0x00
126 #define LEAPRAID_SGE_FLG_64             0x02
127 
128 #define LEAPRAID_IEEE_SGE_FLG_EOL               0x40
129 #define LEAPRAID_IEEE_SGE_FLG_SIMPLE_ONE        0x00
130 #define LEAPRAID_IEEE_SGE_FLG_CHAIN_ONE         0x80
131 #define LEAPRAID_IEEE_SGE_FLG_SYSTEM_ADDR       0x00
132 
133 #define LEAPRAID_SGE_NO_DATA_ADDR -1
134 #define LEAPRAID_SGE_OFFSET_SIZE  4
135 
136 /* The type of page. */
137 #define LEAPRAID_CFG_PT_IO_UNIT         0x00
138 #define LEAPRAID_CFG_PT_ADAPTER         0x01
139 #define LEAPRAID_CFG_PT_BIOS            0x02
140 #define LEAPRAID_CFG_PT_RAID_VOLUME     0x08
141 #define LEAPRAID_CFG_PT_MANUFACTURING   0x09
142 #define LEAPRAID_CFG_PT_RAID_PHYSDISK   0x0A
143 #define LEAPRAID_CFG_PT_EXTENDED        0x0F
144 
145 /* The type of extended page. */
146 #define LEAPRAID_CFG_EXTPT_SAS_IO_UNIT  0x10
147 #define LEAPRAID_CFG_EXTPT_SAS_EXP      0x11
148 #define LEAPRAID_CFG_EXTPT_SAS_DEV      0x12
149 #define LEAPRAID_CFG_EXTPT_SAS_PHY      0x13
150 #define LEAPRAID_CFG_EXTPT_ENC          0x15
151 #define LEAPRAID_CFG_EXTPT_RAID_CONFIG  0x16
152 
153 /* Config page address. */
154 #define LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP     0x00000000
155 #define LEAPRAID_SAS_ENC_CFG_PGAD_HDL           0x10000000
156 #define LEAPRAID_SAS_DEV_CFG_PGAD_HDL           0x20000000
157 #define LEAPRAID_SAS_EXP_CFG_PGAD_HDL_PHY_NUM   0x10000000
158 #define LEAPRAID_SAS_EXP_CFD_PGAD_HDL           0x20000000
159 #define LEAPRAID_SAS_EXP_CFG_PGAD_PHYNUM_SHIFT  16
160 #define LEAPRAID_RAID_VOL_CFG_PGAD_HDL          0x10000000
161 #define LEAPRAID_SAS_PHY_CFG_PGAD_PHY_NUMBER    0x00000000
162 #define LEAPRAID_PHYSDISK_CFG_PGAD_PHYSDISKNUM  0x10000000
163 
164 /* Config page operations. */
165 #define LEAPRAID_CFG_ACT_PAGE_HEADER    0x00
166 #define LEAPRAID_CFG_ACT_PAGE_READ_CUR  0x01
167 #define LEAPRAID_CFG_ACT_PAGE_WRITE_CUR 0x02
168 
169 /* BIOS page number. */
170 #define LEAPRAID_CFG_PAGE_NUM_BIOS2     0x2
171 #define LEAPRAID_CFG_PAGE_NUM_BIOS3     0x3
172 
173 /* Manufacturing page number. */
174 #define LEAPRAID_CFG_PAGE_NUM_MANU0     0x0
175 
176 /* SAS device page number. */
177 #define LEAPRAID_CFG_PAGE_NUM_DEV0      0x0
178 
179 /* SAS device page 0 flags. */
180 #define LEAPRAID_SAS_DEV_P0_FLG_ENC_LEVEL_VALID 0x0002
181 #define LEAPRAID_SAS_DEV_P0_FLG_DEV_PRESENT     0x0001
182 #define LEAPRAID_SAS_DEV_P0_CON_NAME_LEN        4
183 
184 /* SAS I/O unit page number. */
185 #define LEAPRAID_CFG_PAGE_NUM_IOUNIT0   0x0
186 #define LEAPRAID_CFG_PAGE_NUM_IOUNIT1   0x1
187 
188 /* SAS expander page number. */
189 #define LEAPRAID_CFG_PAGE_NUM_EXP0      0x0
190 #define LEAPRAID_CFG_PAGE_NUM_EXP1      0x1
191 
192 /* SAS enclosure page number. */
193 #define LEAPRAID_CFG_PAGE_NUM_ENC0      0x0
194 
195 /* SAS PHY page number. */
196 #define LEAPRAID_CFG_PAGE_NUM_PHY0      0x0
197 
198 /* RAID volume page number. */
199 #define LEAPRAID_CFG_PAGE_NUM_VOL0      0x0
200 #define LEAPRAID_CFG_PAGE_NUM_VOL1      0x1
201 
202 /* Physical disk page number. */
203 #define LEAPRAID_CFG_PAGE_NUM_PD0       0x0
204 
205 #define LEAPRAID_CFG_UNIT_SIZE  4
206 
207 /* Raid volume type and state. */
208 #define LEAPRAID_VOL_STATE_ONLINE       0x03
209 #define LEAPRAID_VOL_STATE_DEGRADED     0x04
210 #define LEAPRAID_VOL_STATE_OPTIMAL      0x05
211 #define LEAPRAID_VOL_TYPE_RAID0         0x00
212 #define LEAPRAID_VOL_TYPE_RAID1E        0x01
213 #define LEAPRAID_VOL_TYPE_RAID1         0x02
214 #define LEAPRAID_VOL_TYPE_RAID10        0x05
215 #define LEAPRAID_VOL_TYPE_UNKNOWN       0xFF
216 
217 /* Raid volume element flags. */
218 #define LEAPRAID_RAIDCFG_P0_EFLG_MASK_ELEMENT_TYPE      0x000F
219 #define LEAPRAID_RAIDCFG_P0_EFLG_VOL_PHYS_DISK_ELEMENT  0x0001
220 #define LEAPRAID_RAIDCFG_P0_EFLG_HOT_SPARE_ELEMENT      0x0002
221 #define LEAPRAID_RAIDCFG_P0_EFLG_OCE_ELEMENT            0x0003
222 
223 /* SAS negotiated link rates. */
224 #define LEAPRAID_SAS_NEG_LINK_RATE_MASK_PHYSICAL        0x0F
225 #define LEAPRAID_SAS_NEG_LINK_RATE_UNKNOWN_LINK_RATE    0x00
226 #define LEAPRAID_SAS_NEG_LINK_RATE_PHY_DISABLED         0x01
227 #define LEAPRAID_SAS_NEG_LINK_RATE_NEGOTIATION_FAILED   0x02
228 #define LEAPRAID_SAS_NEG_LINK_RATE_SATA_OOB_COMPLETE    0x03
229 #define LEAPRAID_SAS_NEG_LINK_RATE_PORT_SELECTOR        0x04
230 #define LEAPRAID_SAS_NEG_LINK_RATE_SMP_RESETTING        0x05
231 #define LEAPRAID_SAS_NEG_LINK_RATE_SHIFT                4
232 
233 #define LEAPRAID_SAS_NEG_LINK_RATE_1_5  0x08
234 #define LEAPRAID_SAS_NEG_LINK_RATE_3_0  0x09
235 #define LEAPRAID_SAS_NEG_LINK_RATE_6_0  0x0A
236 #define LEAPRAID_SAS_NEG_LINK_RATE_12_0 0x0B
237 
238 #define LEAPRAID_SAS_PRATE_MIN_RATE_MASK        0x0F
239 #define LEAPRAID_SAS_HWRATE_MIN_RATE_MASK       0x0F
240 
241 /*
242  * Control flags for a SCSI I/O Request.
243  */
244 #define LEAPRAID_SCSIIO_CTRL_CDB_32BYTE         4
245 #define LEAPRAID_SCSIIO_CTRL_CDB_LEN_SHIFT      26
246 #define LEAPRAID_SCSIIO_CTRL_NODATATRANSFER     0x00000000
247 #define LEAPRAID_SCSIIO_CTRL_WRITE              0x01000000
248 #define LEAPRAID_SCSIIO_CTRL_READ               0x02000000
249 #define LEAPRAID_SCSIIO_CTRL_BIDIRECTIONAL      0x03000000
250 #define LEAPRAID_SCSIIO_CTRL_SIMPLEQ            0x00000000
251 #define LEAPRAID_SCSIIO_CTRL_ORDEREDQ           0x00000200
252 #define LEAPRAID_SCSIIO_CTRL_CMDPRI             0x00000800
253 
254 /* SCSI state and status. */
255 #define LEAPRAID_SCSI_STATUS_BUSY                       0x08
256 #define LEAPRAID_SCSI_STATUS_RESERVATION_CONFLICT       0x18
257 #define LEAPRAID_SCSI_STATUS_TASK_SET_FULL              0x28
258 
259 #define LEAPRAID_SCSI_STATE_RESPONSE_INFO_VALID 0x10
260 #define LEAPRAID_SCSI_STATE_TERMINATED          0x08
261 #define LEAPRAID_SCSI_STATE_NO_SCSI_STATUS      0x04
262 #define LEAPRAID_SCSI_STATE_AUTOSENSE_FAILED    0x02
263 #define LEAPRAID_SCSI_STATE_AUTOSENSE_VALID     0x01
264 
265 /* SCSI task management defines. */
266 #define LEAPRAID_TM_TASKTYPE_ABORT_TASK         0x01
267 #define LEAPRAID_TM_TASKTYPE_ABRT_TASK_SET      0x02
268 #define LEAPRAID_TM_TASKTYPE_TARGET_RESET       0x03
269 #define LEAPRAID_TM_TASKTYPE_LOGICAL_UNIT_RESET 0x05
270 #define LEAPRAID_TM_TASKTYPE_CLEAR_TASK_SET     0x06
271 #define LEAPRAID_TM_TASKTYPE_QUERY_TASK         0x07
272 #define LEAPRAID_TM_TASKTYPE_CLEAR_ACA          0x08
273 #define LEAPRAID_TM_TASKTYPE_QUERY_TASK_SET     0x09
274 #define LEAPRAID_TM_TASKTYPE_QUERY_ASYNC_EVENT  0x0A
275 
276 #define LEAPRAID_TM_MSGFLAGS_LINK_RESET         0x00
277 #define LEAPRAID_TM_RSP_INVALID_FRAME           0x02
278 
279 /* SCSI enclosure processor request defines. */
280 #define LEAPRAID_SEP_REQ_ACT_WRITE_STATUS               0x00
281 #define LEAPRAID_SEP_REQ_FLG_DEVHDL_ADDRESS             0x00
282 #define LEAPRAID_SEP_REQ_FLG_ENCLOSURE_SLOT_ADDRESS     0x01
283 #define LEAPRAID_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT     0x00000040
284 
285 /* The capabilities of the adapter. */
286 #define LEAPRAID_ADAPTER_FEATURES_CAP_ATOMIC_REQ                0x00080000
287 #define LEAPRAID_ADAPTER_FEATURES_CAP_INTEGRATED_RAID           0x00001000
288 
289 /* Event code definitions for the firmware. */
290 #define LEAPRAID_EVT_SAS_DEV_STATUS_CHANGE      0x000F
291 #define LEAPRAID_EVT_SAS_TOPO_CHANGE_LIST       0x001C
292 #define LEAPRAID_EVT_SAS_ENCL_DEV_STATUS_CHANGE 0x001D
293 #define LEAPRAID_EVT_IR_CHANGE          0x0020
294 #define LEAPRAID_EVT_TURN_ON_PFA_LED    0xFFFC
295 #define LEAPRAID_EVT_SCAN_DEV_DONE      0xFFFD
296 #define LEAPRAID_EVT_REMOVE_DEAD_DEV    0xFFFF
297 #define LEAPRAID_MAX_EVENT_NUM          128
298 
299 #define LEAPRAID_EVT_SAS_DEV_STAT_RC_INTERNAL_DEV_RESET         0x08
300 #define LEAPRAID_EVT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET     0x0E
301 
302 /* RAID configuration change event. */
303 #define LEAPRAID_EVT_IR_RC_VOLUME_ADD                   0x01
304 #define LEAPRAID_EVT_IR_RC_VOLUME_DELETE                0x02
305 #define LEAPRAID_EVT_IR_RC_PD_HIDDEN_TO_ADD             0x03
306 #define LEAPRAID_EVT_IR_RC_PD_UNHIDDEN_TO_DELETE        0x04
307 #define LEAPRAID_EVT_IR_RC_PD_CREATED_TO_HIDE           0x05
308 #define LEAPRAID_EVT_IR_RC_PD_DELETED_TO_EXPOSE         0x06
309 #define LEAPRAID_EVT_IR_RC_VOLUME_HIDE                  0x0A
310 #define LEAPRAID_EVT_IR_RC_VOLUME_UNHIDE                0x0B
311 
312 /* SAS topology change event. */
313 #define LEAPRAID_EVT_SAS_TOPO_ES_NO_EXPANDER    0x00
314 #define LEAPRAID_EVT_SAS_TOPO_ES_ADDED          0x01
315 #define LEAPRAID_EVT_SAS_TOPO_ES_NOT_RESPONDING 0x02
316 #define LEAPRAID_EVT_SAS_TOPO_ES_RESPONDING     0x03
317 
318 #define LEAPRAID_EVT_SAS_TOPO_RC_MASK                   0x0F
319 #define LEAPRAID_EVT_SAS_TOPO_RC_TARG_ADDED             0x01
320 #define LEAPRAID_EVT_SAS_TOPO_RC_TARG_NOT_RESPONDING    0x02
321 
322 /* Enclosure device status change event. */
323 #define LEAPRAID_EVT_SAS_ENCL_RC_ADDED          0x01
324 #define LEAPRAID_EVT_SAS_ENCL_RC_NOT_RESPONDING 0x02
325 
326 /* Device type and identifiers. */
327 #define LEAPRAID_DEVTYP_SEP             0x00004000
328 #define LEAPRAID_DEVTYP_SSP_TGT         0x00000400
329 #define LEAPRAID_DEVTYP_STP_TGT         0x00000200
330 #define LEAPRAID_DEVTYP_SMP_TGT         0x00000100
331 #define LEAPRAID_DEVTYP_SATA_DEV        0x00000080
332 #define LEAPRAID_DEVTYP_SSP_INIT        0x00000040
333 #define LEAPRAID_DEVTYP_STP_INIT        0x00000020
334 #define LEAPRAID_DEVTYP_SMP_INIT        0x00000010
335 #define LEAPRAID_DEVTYP_SATA_HOST       0x00000008
336 
337 #define LEAPRAID_DEVTYP_MASK_DEV_TYPE   0x00000007
338 #define LEAPRAID_DEVTYP_NO_DEV          0x00000000
339 #define LEAPRAID_DEVTYP_END_DEV         0x00000001
340 #define LEAPRAID_DEVTYP_EDGE_EXPANDER   0x00000002
341 #define LEAPRAID_DEVTYP_FANOUT_EXPANDER 0x00000003
342 
343 /* SAS control operation. */
344 #define LEAPRAID_SAS_OP_PHY_LINK_RESET  0x06
345 #define LEAPRAID_SAS_OP_PHY_HARD_RESET  0x07
346 #define LEAPRAID_SAS_OP_SET_PARAMETER   0x0F
347 
348 /* Boot device defines */
349 #define LEAPRAID_BOOTDEV_FORM_MASK      0x0F
350 #define LEAPRAID_BOOTDEV_FORM_NONE      0x00
351 #define LEAPRAID_BOOTDEV_FORM_SAS_WWID  0x05
352 #define LEAPRAID_BOOTDEV_FORM_ENC_SLOT  0x06
353 #define LEAPRAID_BOOTDEV_FORM_DEV_NAME  0x07
354 
355 /**
356  * struct leapraid_reg_base - Register layout of the LeapRAID controller
357  *
358  * @db: Doorbell register used to signal commands or status to firmware.
359  * @ws: Write sequence register for synchronizing doorbell operations.
360  * @host_diag: Diagnostic register used for status or debug reporting.
361  * @r1: Reserved.
362  * @host_int_status: Interrupt status register reporting active interrupts.
363  * @host_int_mask: Interrupt mask register enabling or disabling sources.
364  * @r2: Reserved.
365  * @rep_msg_host_idx: Reply message index for the next available reply slot.
366  * @r3: Reserved.
367  * @debug_log: DebugLog registers for firmware debug and diagnostic output.
368  * @r4: Reserved.
369  * @atomic_req_desc_post: Atomic register for single descriptor posting.
370  * @adapter_log_buf_pos: Adapter log buffer write position.
371  * @host_log_buf_pos: Host log buffer write position.
372  * @r5: Reserved.
373  * @rep_post_reg_idx: Array of reply post index registers, one per queue.
374  *                    The number of entries is defined by
375  *                    REP_POST_HOST_IDX_REG_CNT.
376  */
377 struct leapraid_reg_base {
378 	__le32 db;
379 	__le32 ws;
380 	__le32 host_diag;
381 	__le32 r1[9];
382 	__le32 host_int_status;
383 	__le32 host_int_mask;
384 	__le32 r2[4];
385 	__le32 rep_msg_host_idx;
386 	__le32 r3[13];
387 	__le32 debug_log[LEAPRAID_DEBUGLOG_SZ_MAX];
388 	__le32 r4[2];
389 	__le32 atomic_req_desc_post;
390 	__le32 adapter_log_buf_pos;
391 	__le32 host_log_buf_pos;
392 	__le32 r5[142];
393 	struct leapraid_rep_post_reg_idx {
394 		__le32 idx;
395 		__le32 r1;
396 		__le32 r2;
397 		__le32 r3;
398 	} rep_post_reg_idx[REP_POST_HOST_IDX_REG_CNT];
399 } __packed;
400 
401 /**
402  * struct leapraid_atomic_req_desc - Atomic request descriptor
403  *
404  * @flg: Descriptor flag indicating the type of request (e.g. SCSI I/O).
405  * @msix_idx: MSI-X vector index used for interrupt routing.
406  * @taskid: Unique task identifier associated with this request.
407  */
408 struct leapraid_atomic_req_desc {
409 	u8 flg;
410 	u8 msix_idx;
411 	__le16 taskid;
412 };
413 
414 /**
415  * union leapraid_rep_desc_union - Unified reply descriptor format
416  *
417  * @dflt_rep: Default reply descriptor containing basic completion info.
418  * @dflt_rep.rep_flg: Reply flag indicating reply type or status.
419  * @dflt_rep.msix_idx: MSI-X index for interrupt routing.
420  * @dflt_rep.taskid: Task identifier matching the submitted request.
421  * @r1: Reserved.
422  *
423  * @addr_rep: Address reply descriptor used when firmware returns a
424  *            memory address associated with the reply.
425  * @addr_rep.rep_flg: Reply flag indicating reply type or status.
426  * @addr_rep.msix_idx: MSI-X index for interrupt routing.
427  * @addr_rep.taskid: Task identifier matching the submitted request.
428  * @addr_rep.rep_frame_addr: Physical address of the reply frame.
429  *
430  * @words: Raw 64-bit representation of the reply descriptor.
431  * @u: Alternative access using 32-bit low/high words.
432  * @u.low: Lower 32 bits of the descriptor.
433  * @u.high: Upper 32 bits of the descriptor.
434  */
435 union leapraid_rep_desc_union {
436 	struct leapraid_rep_desc {
437 		u8 rep_flg;
438 		u8 msix_idx;
439 		__le16 taskid;
440 		u8 r1[4];
441 	} dflt_rep;
442 	struct leapraid_add_rep_desc {
443 		u8 rep_flg;
444 		u8 msix_idx;
445 		__le16 taskid;
446 		__le32 rep_frame_addr;
447 	} addr_rep;
448 	__le64 words;
449 	struct {
450 		u32 low;
451 		u32 high;
452 	} u;
453 }  __packed __aligned(4);
454 
455 /**
456  * struct leapraid_req - Generic request header
457  *
458  * @func_dep1: Function-dependent parameter (low 16 bits).
459  * @r1: Reserved.
460  * @func: Function code identifying the command type.
461  * @r2: Reserved.
462  */
463 struct leapraid_req {
464 	__le16 func_dep1;
465 	u8 r1;
466 	u8 func;
467 	u8 r2[8];
468 };
469 
470 /**
471  * struct leapraid_rep - Generic reply header
472  *
473  * @r1: Reserved.
474  * @msg_len: Length of the reply message in bytes.
475  * @function: Function code corresponding to the request.
476  * @r2: Reserved.
477  * @adapter_status: Status code reported by the adapter.
478  * @r3: Reserved.
479  */
480 struct leapraid_rep {
481 	u8 r1[2];
482 	u8 msg_len;
483 	u8 function;
484 	u8 r2[10];
485 	__le16 adapter_status;
486 	u8 r3[4];
487 };
488 
489 /**
490  * struct leapraid_sge_simple32 - 32-bit simple scatter-gather entry
491  *
492  * @flg_and_len: Combined field for flags and segment length.
493  * @addr: 32-bit physical address of the data buffer.
494  */
495 struct leapraid_sge_simple32 {
496 	__le32 flg_and_len;
497 	__le32 addr;
498 };
499 
500 /**
501  * struct leapraid_sge_simple64 - 64-bit simple scatter-gather entry
502  *
503  * @flg_and_len: Combined field for flags and segment length.
504  * @addr: 64-bit physical address of the data buffer.
505  */
506 struct leapraid_sge_simple64 {
507 	__le32 flg_and_len;
508 	__le64 addr;
509 } __packed __aligned(4);
510 
511 /**
512  * struct leapraid_sge_simple_union - Unified 32/64-bit SGE representation
513  *
514  * @flg_and_len: Combined field for flags and segment length.
515  * @u.addr32: 32-bit address field.
516  * @u.addr64: 64-bit address field.
517  */
518 struct leapraid_sge_simple_union {
519 	__le32 flg_and_len;
520 	union {
521 		__le32 addr32;
522 		__le64 addr64;
523 	} __packed __aligned(4) u;
524 } __packed __aligned(4);
525 
526 /**
527  * struct leapraid_sge_chain_union - Chained scatter-gather entry
528  *
529  * @len: Length of the chain descriptor.
530  * @next_chain_offset: Offset to the next SGE chain.
531  * @flg: Flags indicating chain or termination properties.
532  * @u.addr32: 32-bit physical address.
533  * @u.addr64: 64-bit physical address.
534  */
535 struct leapraid_sge_chain_union {
536 	__le16 len;
537 	u8 next_chain_offset;
538 	u8 flg;
539 	union {
540 		__le32 addr32;
541 		__le64 addr64;
542 	} __packed __aligned(4) u;
543 } __packed __aligned(4);
544 
545 /**
546  * struct leapraid_ieee_sge_simple32 - IEEE 32-bit simple SGE format
547  *
548  * @addr: 32-bit physical address of the data buffer.
549  * @flg_and_len: Combined field for flags and data length.
550  */
551 struct leapraid_ieee_sge_simple32 {
552 	__le32 addr;
553 	__le32 flg_and_len;
554 };
555 
556 /**
557  * struct leapraid_ieee_sge_simple64 - IEEE 64-bit simple SGE format
558  *
559  * @addr: 64-bit physical address of the data buffer.
560  * @len: Length of the data segment.
561  * @r1: Reserved.
562  * @flg: Flags indicating transfer properties.
563  */
564 struct leapraid_ieee_sge_simple64 {
565 	__le64 addr;
566 	__le32 len;
567 	u8 r1[3];
568 	u8 flg;
569 } __packed __aligned(4);
570 
571 /**
572  * union leapraid_ieee_sge_simple_union - Unified IEEE SGE format
573  *
574  * @simple32: IEEE 32-bit simple SGE entry.
575  * @simple64: IEEE 64-bit simple SGE entry.
576  */
577 union leapraid_ieee_sge_simple_union {
578 	struct leapraid_ieee_sge_simple32 simple32;
579 	struct leapraid_ieee_sge_simple64 simple64;
580 };
581 
582 /**
583  * union leapraid_ieee_sge_chain_union - Unified IEEE SGE chain format
584  *
585  * @chain32: IEEE 32-bit chain SGE entry.
586  * @chain64: IEEE 64-bit chain SGE entry.
587  */
588 union leapraid_ieee_sge_chain_union {
589 	struct leapraid_ieee_sge_simple32 chain32;
590 	struct leapraid_ieee_sge_simple64 chain64;
591 };
592 
593 /**
594  * struct leapraid_chain64_ieee_sg - 64-bit IEEE chain SGE descriptor
595  *
596  * @addr: Physical address of the next chain segment.
597  * @len: Length of the current SGE.
598  * @r1: Reserved.
599  * @next_chain_offset: Offset to the next chain element.
600  * @flg: Flags that describe SGE attributes.
601  */
602 struct leapraid_chain64_ieee_sg {
603 	__le64 addr;
604 	__le32 len;
605 	u8 r1[2];
606 	u8 next_chain_offset;
607 	u8 flg;
608 } __packed __aligned(4);
609 
610 /**
611  * union leapraid_ieee_sge_io_union - IEEE-style SGE union for I/O
612  *
613  * @ieee_simple: Simple IEEE SGE descriptor.
614  * @ieee_chain: IEEE chain SGE descriptor.
615  */
616 union leapraid_ieee_sge_io_union {
617 	struct leapraid_ieee_sge_simple64 ieee_simple;
618 	struct leapraid_chain64_ieee_sg ieee_chain;
619 };
620 
621 /**
622  * union leapraid_simple_sge_union - Union of simple SGE descriptors
623  *
624  * @leapraid_simple: LeapRAID simple SGE.
625  * @ieee_simple: IEEE-style simple SGE.
626  */
627 union leapraid_simple_sge_union {
628 	struct leapraid_sge_simple_union leapraid_simple;
629 	union leapraid_ieee_sge_simple_union ieee_simple;
630 };
631 
632 /**
633  * union leapraid_sge_io_union - Combined SGE union for all I/O types
634  *
635  * @leapraid_simple: LeapRAID simple SGE format.
636  * @leapraid_chain: LeapRAID chain SGE format.
637  * @ieee_simple: IEEE simple SGE format.
638  * @ieee_chain: IEEE chain SGE format.
639  */
640 union leapraid_sge_io_union {
641 	struct leapraid_sge_simple_union leapraid_simple;
642 	struct leapraid_sge_chain_union leapraid_chain;
643 	union leapraid_ieee_sge_simple_union ieee_simple;
644 	union leapraid_ieee_sge_chain_union ieee_chain;
645 };
646 
647 /**
648  * struct leapraid_cfg_pg_header - Standard configuration page header
649  *
650  * @r1: Reserved.
651  * @page_len: Length of the page in 4-byte units.
652  * @page_num: Page number.
653  * @page_type: Page type.
654  */
655 struct leapraid_cfg_pg_header {
656 	u8 r1;
657 	u8 page_len;
658 	u8 page_num;
659 	u8 page_type;
660 };
661 
662 /**
663  * struct leapraid_cfg_ext_pg_header - Extended configuration page header
664  *
665  * @r1: Reserved.
666  * @r2: Reserved.
667  * @page_num: Page number.
668  * @page_type: Page type.
669  * @ext_page_len: Extended page length.
670  * @ext_page_type: Extended page type.
671  * @r3: Reserved.
672  */
673 struct leapraid_cfg_ext_pg_header {
674 	u8 r1;
675 	u8 r2;
676 	u8 page_num;
677 	u8 page_type;
678 	__le16 ext_page_len;
679 	u8 ext_page_type;
680 	u8 r3;
681 };
682 
683 /**
684  * struct leapraid_cfg_req - Configuration request message
685  *
686  * @action: Requested action type.
687  * @sgl_flag: SGL flag field.
688  * @chain_offset: Offset to next chain SGE.
689  * @func: Function code.
690  * @ext_page_len: Extended page length.
691  * @ext_page_type: Extended page type.
692  * @msg_flag: Message flags.
693  * @r1: Reserved.
694  * @header: Configuration page header.
695  * @page_addr: Address of the page buffer.
696  * @page_buf_sge: SGE describing the page buffer.
697  */
698 struct leapraid_cfg_req {
699 	u8 action;
700 	u8 sgl_flag;
701 	u8 chain_offset;
702 	u8 func;
703 	__le16 ext_page_len;
704 	u8 ext_page_type;
705 	u8 msg_flag;
706 	u8 r1[12];
707 	struct leapraid_cfg_pg_header header;
708 	__le32 page_addr;
709 	union leapraid_sge_io_union page_buf_sge;
710 };
711 
712 /**
713  * struct leapraid_cfg_rep - Configuration reply message
714  *
715  * @action: Action type from the request.
716  * @r1: Reserved.
717  * @msg_len: Message length in bytes.
718  * @func: Function code.
719  * @ext_page_len: Extended page length.
720  * @ext_page_type: Extended page type.
721  * @msg_flag: Message flags.
722  * @r2: Reserved.
723  * @adapter_status: Adapter status code.
724  * @r3: Reserved.
725  * @header: Configuration page header.
726  */
727 struct leapraid_cfg_rep {
728 	u8 action;
729 	u8 r1;
730 	u8 msg_len;
731 	u8 func;
732 	__le16 ext_page_len;
733 	u8 ext_page_type;
734 	u8 msg_flag;
735 	u8 r2[6];
736 	__le16 adapter_status;
737 	u8 r3[4];
738 	struct leapraid_cfg_pg_header header;
739 };
740 
741 /**
742  * struct leapraid_boot_dev_format_sas_wwid - Boot device identified by wwid
743  *
744  * @sas_addr: SAS address of the device.
745  * @lun: Logical unit number.
746  * @r1: Reserved.
747  */
748 struct leapraid_boot_dev_format_sas_wwid {
749 	__le64 sas_addr;
750 	u8 lun[8];
751 	u8 r1[8];
752 } __packed __aligned(4);
753 
754 /**
755  * struct leapraid_boot_dev_format_enc_slot - identified by enclosure
756  *
757  * @enc_lid: Enclosure logical ID.
758  * @r1: Reserved.
759  * @slot_num: Slot number in the enclosure.
760  * @r2: Reserved.
761  */
762 struct leapraid_boot_dev_format_enc_slot {
763 	__le64 enc_lid;
764 	u8 r1[8];
765 	__le16 slot_num;
766 	u8 r2[6];
767 } __packed __aligned(4);
768 
769 /**
770  * struct leapraid_boot_dev_format_dev_name - Boot device by device name
771  *
772  * @dev_name: Device name identifier.
773  * @lun: Logical unit number.
774  * @r1: Reserved.
775  */
776 struct leapraid_boot_dev_format_dev_name {
777 	__le64 dev_name;
778 	u8 lun[8];
779 	u8 r1[8];
780 } __packed __aligned(4);
781 
782 /**
783  * union leapraid_boot_dev_format - Boot device format union
784  *
785  * @sas_wwid: Format using SAS WWID and LUN.
786  * @enc_slot: Format using enclosure slot and ID.
787  * @dev_name: Format using device name and LUN.
788  */
789 union leapraid_boot_dev_format {
790 	struct leapraid_boot_dev_format_sas_wwid sas_wwid;
791 	struct leapraid_boot_dev_format_enc_slot enc_slot;
792 	struct leapraid_boot_dev_format_dev_name dev_name;
793 };
794 
795 /**
796  * struct leapraid_manufacturing_p0 - Manufacturing configuration page 0
797  *
798  * @header: Configuration page header.
799  * @chip_name: Chip name as a 16-byte ASCII string.
800  * @chip_revision: Chip revision as an 8-byte ASCII string.
801  * @board_name: Board name as a 16-byte ASCII string.
802  * @board_assembly: Board assembly as a 16-byte ASCII string.
803  * @board_tracer_number: Board tracer number as a 16-byte ASCII string.
804  */
805 struct leapraid_manufacturing_p0 {
806 	struct leapraid_cfg_pg_header header;
807 	u8 chip_name[16];
808 	u8 chip_revision[8];
809 	u8 board_name[16];
810 	u8 board_assembly[16];
811 	u8 board_tracer_number[16];
812 };
813 
814 /**
815  * struct leapraid_bios_page2 - BIOS configuration page 2
816  *
817  * @header: Configuration page header.
818  * @r1: Reserved.
819  * @requested_boot_dev_form: Format type of the requested boot device.
820  * @r2: Reserved.
821  * @requested_boot_dev: Boot device requested by BIOS or user.
822  * @requested_alt_boot_dev_form: Format of the alternate boot device.
823  * @r3: Reserved.
824  * @requested_alt_boot_dev: Alternate boot device requested.
825  * @current_boot_dev_form: Format type of the active boot device.
826  * @r4: Reserved.
827  * @current_boot_dev: Currently active boot device in use.
828  */
829 struct leapraid_bios_page2 {
830 	struct leapraid_cfg_pg_header header;
831 	u8 r1[24];
832 	u8 requested_boot_dev_form;
833 	u8 r2[3];
834 	union leapraid_boot_dev_format requested_boot_dev;
835 	u8 requested_alt_boot_dev_form;
836 	u8 r3[3];
837 	union leapraid_boot_dev_format requested_alt_boot_dev;
838 	u8 current_boot_dev_form;
839 	u8 r4[3];
840 	union leapraid_boot_dev_format current_boot_dev;
841 };
842 
843 /**
844  * struct leapraid_bios_page3 - BIOS configuration page 3
845  *
846  * @header: Configuration page header.
847  * @r1: Reserved.
848  * @bios_version: BIOS firmware version number.
849  * @r2: Reserved.
850  */
851 struct leapraid_bios_page3 {
852 	struct leapraid_cfg_pg_header header;
853 	u8 r1[4];
854 	__le32 bios_version;
855 	u8 r2[84];
856 };
857 
858 /**
859  * struct leapraid_raidvol0_phys_disk - Physical disk in RAID volume
860  *
861  * @r1: Reserved.
862  * @phys_disk_num: Physical disk number within the RAID volume.
863  * @r2: Reserved.
864  */
865 struct leapraid_raidvol0_phys_disk {
866 	u8 r1[2];
867 	u8 phys_disk_num;
868 	u8 r2;
869 };
870 
871 /**
872  * struct leapraid_raidvol_p0 - RAID volume configuration page 0
873  *
874  * @header: Configuration page header.
875  * @dev_hdl: Device handle for the RAID volume.
876  * @volume_state: State of the RAID volume.
877  * @volume_type: RAID type.
878  * @r1: Reserved.
879  * @num_phys_disks: Number of physical disks in the volume.
880  * @r2: Reserved.
881  * @phys_disk: Array of physical disks in this volume.
882  */
883 struct leapraid_raidvol_p0 {
884 	struct leapraid_cfg_pg_header header;
885 	__le16 dev_hdl;
886 	u8 volume_state;
887 	u8 volume_type;
888 	u8 r1[28];
889 	u8 num_phys_disks;
890 	u8 r2[3];
891 	struct leapraid_raidvol0_phys_disk phys_disk[];
892 };
893 
894 /**
895  * struct leapraid_raidvol_p1 - RAID volume configuration page 1
896  *
897  * @header: Configuration page header.
898  * @dev_hdl: Device handle of the RAID volume.
899  * @r1: Reserved.
900  * @wwid: World-wide identifier for the volume.
901  * @r2: Reserved.
902  */
903 struct leapraid_raidvol_p1 {
904 	struct leapraid_cfg_pg_header header;
905 	__le16 dev_hdl;
906 	u8 r1[42];
907 	__le64 wwid;
908 	u8 r2[8];
909 } __packed __aligned(4);
910 
911 /**
912  * struct leapraid_raidpd_p0 - Physical disk configuration page 0
913  *
914  * @header: Configuration page header.
915  * @dev_hdl: Device handle of the physical disk.
916  * @r1: Reserved.
917  * @phys_disk_num: Physical disk number.
918  * @r2: Reserved.
919  */
920 struct leapraid_raidpd_p0 {
921 	struct leapraid_cfg_pg_header header;
922 	__le16 dev_hdl;
923 	u8 r1;
924 	u8 phys_disk_num;
925 	u8 r2[112];
926 };
927 
928 /**
929  * struct leapraid_sas_io_unit0_phy_info - PHY info for SAS I/O unit
930  *
931  * @port: Port number the PHY belongs to.
932  * @port_flg: Flags describing port status.
933  * @phy_flg: Flags describing PHY status.
934  * @neg_link_rate: Negotiated link rate of the PHY.
935  * @controller_phy_dev_info: Controller PHY device info.
936  * @attached_dev_hdl: Handle of attached device.
937  * @controller_dev_hdl: Handle of the controller device.
938  * @r1: Reserved.
939  */
940 struct leapraid_sas_io_unit0_phy_info {
941 	u8 port;
942 	u8 port_flg;
943 	u8 phy_flg;
944 	u8 neg_link_rate;
945 	__le32 controller_phy_dev_info;
946 	__le16 attached_dev_hdl;
947 	__le16 controller_dev_hdl;
948 	u8 r1[8];
949 };
950 
951 /**
952  * struct leapraid_sas_io_unit_p0 - SAS I/O unit configuration page 0
953  *
954  * @header: Extended configuration page header.
955  * @r1: Reserved.
956  * @phy_num: Number of PHYs in this unit.
957  * @r2: Reserved.
958  * @phy_info: Array of PHY information.
959  */
960 struct leapraid_sas_io_unit_p0 {
961 	struct leapraid_cfg_ext_pg_header header;
962 	u8 r1[4];
963 	u8 phy_num;
964 	u8 r2[3];
965 	struct leapraid_sas_io_unit0_phy_info phy_info[];
966 };
967 
968 /**
969  * struct leapraid_exp_p0 - SAS expander page 0
970  *
971  * @header: Extended page header.
972  * @physical_port: Physical port number.
973  * @r1: Reserved.
974  * @enc_hdl: Enclosure handle.
975  * @sas_address: SAS address of the expander.
976  * @r2: Reserved.
977  * @dev_hdl: Device handle of this expander.
978  * @parent_dev_hdl: Device handle of parent expander.
979  * @r3: Reserved.
980  * @phy_num: Number of PHYs.
981  * @r4: Reserved.
982  */
983 struct leapraid_exp_p0 {
984 	struct leapraid_cfg_ext_pg_header header;
985 	u8 physical_port;
986 	u8 r1;
987 	__le16 enc_hdl;
988 	__le64 sas_address;
989 	u8 r2[4];
990 	__le16 dev_hdl;
991 	__le16 parent_dev_hdl;
992 	u8 r3[4];
993 	u8 phy_num;
994 	u8 r4[27];
995 } __packed __aligned(4);
996 
997 /**
998  * struct leapraid_exp_p1 - SAS expander page 1
999  *
1000  * @header: Extended page header.
1001  * @r1: Reserved.
1002  * @p_link_rate: PHY link rate.
1003  * @hw_link_rate: Hardware supported link rate.
1004  * @attached_dev_hdl: Attached device handle.
1005  * @r2: Reserved.
1006  * @neg_link_rate: Negotiated link rate.
1007  * @r3: Reserved.
1008  */
1009 struct leapraid_exp_p1 {
1010 	struct leapraid_cfg_ext_pg_header header;
1011 	u8 r1[8];
1012 	u8 p_link_rate;
1013 	u8 hw_link_rate;
1014 	__le16 attached_dev_hdl;
1015 	u8 r2[11];
1016 	u8 neg_link_rate;
1017 	u8 r3[12];
1018 };
1019 
1020 /**
1021  * struct leapraid_sas_dev_p0 - SAS device page 0
1022  *
1023  * @header: Extended configuration page header.
1024  * @slot: Slot number.
1025  * @enc_hdl: Enclosure handle.
1026  * @sas_address: SAS address.
1027  * @parent_dev_hdl: Parent device handle.
1028  * @phy_num: Number of PHYs.
1029  * @r1: Reserved.
1030  * @dev_hdl: Device handle.
1031  * @r2: Reserved.
1032  * @dev_info: Device information.
1033  * @flg: Flags.
1034  * @physical_port: Physical port number.
1035  * @max_port_connections: Maximum port connections.
1036  * @dev_name: Device name.
1037  * @port_groups: Number of port groups.
1038  * @r3: Reserved.
1039  * @enc_level: Enclosure level.
1040  * @connector_name: Connector identifier.
1041  * @r4: Reserved.
1042  */
1043 struct leapraid_sas_dev_p0 {
1044 	struct leapraid_cfg_ext_pg_header header;
1045 	__le16 slot;
1046 	__le16 enc_hdl;
1047 	__le64 sas_address;
1048 	__le16 parent_dev_hdl;
1049 	u8 phy_num;
1050 	u8 r1;
1051 	__le16 dev_hdl;
1052 	u8 r2[2];
1053 	__le32 dev_info;
1054 	__le16 flg;
1055 	u8 physical_port;
1056 	u8 max_port_connections;
1057 	__le64 dev_name;
1058 	u8 port_groups;
1059 	u8 r3[2];
1060 	u8 enc_level;
1061 	u8 connector_name[LEAPRAID_SAS_DEV_P0_CON_NAME_LEN];
1062 	u8 r4[4];
1063 } __packed __aligned(4);
1064 
1065 /**
1066  * struct leapraid_sas_phy_p0 - SAS PHY configuration page 0
1067  *
1068  * @header: Extended configuration page header.
1069  * @r1: Reserved.
1070  * @attached_dev_hdl: Handle of attached device.
1071  * @r2: Reserved.
1072  * @p_link_rate: PHY link rate.
1073  * @hw_link_rate: Hardware supported link rate.
1074  * @r3: Reserved.
1075  * @phy_info: PHY information.
1076  * @neg_link_rate: Negotiated link rate.
1077  * @r4: Reserved.
1078  */
1079 struct leapraid_sas_phy_p0 {
1080 	struct leapraid_cfg_ext_pg_header header;
1081 	u8 r1[4];
1082 	__le16 attached_dev_hdl;
1083 	u8 r2[6];
1084 	u8 p_link_rate;
1085 	u8 hw_link_rate;
1086 	u8 r3[2];
1087 	__le32 phy_info;
1088 	u8 neg_link_rate;
1089 	u8 r4[3];
1090 };
1091 
1092 /**
1093  * struct leapraid_enc_p0 - SAS enclosure page 0
1094  *
1095  * @header: Extended configuration page header.
1096  * @r1: Reserved.
1097  * @enc_lid: Enclosure logical ID.
1098  * @r2: Reserved.
1099  * @enc_hdl: Enclosure handle.
1100  * @r3: Reserved.
1101  */
1102 struct leapraid_enc_p0 {
1103 	struct leapraid_cfg_ext_pg_header header;
1104 	u8 r1[4];
1105 	__le64 enc_lid;
1106 	u8 r2[2];
1107 	__le16 enc_hdl;
1108 	u8 r3[15];
1109 } __packed __aligned(4);
1110 
1111 /**
1112  * struct leapraid_raid_cfg_p0_element - RAID configuration element
1113  *
1114  * @element_flg: Element flags.
1115  * @vol_dev_hdl: Volume device handle.
1116  * @r1: Reserved.
1117  * @phys_disk_dev_hdl: Physical disk device handle.
1118  */
1119 struct leapraid_raid_cfg_p0_element {
1120 	__le16 element_flg;
1121 	__le16 vol_dev_hdl;
1122 	u8 r1[2];
1123 	__le16 phys_disk_dev_hdl;
1124 };
1125 
1126 /**
1127  * struct leapraid_raid_cfg_p0 - RAID configuration page 0
1128  *
1129  * @header: Extended configuration page header.
1130  * @r1: Reserved.
1131  * @cfg_num: Configuration number.
1132  * @r2: Reserved.
1133  * @elements_num: Number of RAID elements.
1134  * @r3: Reserved.
1135  * @cfg_element: Array of RAID elements.
1136  */
1137 struct leapraid_raid_cfg_p0 {
1138 	struct leapraid_cfg_ext_pg_header header;
1139 	u8 r1[3];
1140 	u8 cfg_num;
1141 	u8 r2[32];
1142 	u8 elements_num;
1143 	u8 r3[3];
1144 	struct leapraid_raid_cfg_p0_element cfg_element[];
1145 };
1146 
1147 /**
1148  * union leapraid_mpi_scsi_io_cdb_union - SCSI I/O CDB or simple SGE
1149  *
1150  * @cdb32: 32-byte SCSI command descriptor block.
1151  * @sge: Simple SGE format.
1152  */
1153 union leapraid_mpi_scsi_io_cdb_union {
1154 	u8 cdb32[32];
1155 	struct leapraid_sge_simple_union sge;
1156 };
1157 
1158 /**
1159  * struct leapraid_mpi_scsiio_req - MPI SCSI I/O request
1160  *
1161  * @dev_hdl: Device handle for the target.
1162  * @chain_offset: Offset for chained SGE.
1163  * @func: Function code.
1164  * @r1: Reserved.
1165  * @msg_flg: Message flags.
1166  * @r2: Reserved.
1167  * @sense_buffer_low_add: Lower 32-bit address of sense buffer.
1168  * @dma_flag: DMA flags.
1169  * @r3: Reserved.
1170  * @sense_buffer_len: Sense buffer length.
1171  * @r4: Reserved.
1172  * @sgl_offset0..3: SGL offsets.
1173  * @skip_count: Bytes to skip before transfer.
1174  * @data_len: Length of data transfer.
1175  * @bi_dir_data_len: Bi-directional transfer length.
1176  * @io_flg: I/O flags.
1177  * @eedp_flag: End-to-end data protection flags.
1178  * @eedp_block_size: End-to-end data protection block size.
1179  * @r5: Reserved.
1180  * @secondary_ref_tag: Secondary reference tag.
1181  * @secondary_app_tag: Secondary application tag.
1182  * @app_tag_trans_mask: Application tag mask.
1183  * @lun: Logical Unit Number.
1184  * @ctrl: Control flags.
1185  * @cdb: SCSI Command Descriptor Block or simple SGE.
1186  * @sgl: Scatter-gather list.
1187  */
1188 struct leapraid_mpi_scsiio_req {
1189 	__le16 dev_hdl;
1190 	u8 chain_offset;
1191 	u8 func;
1192 	u8 r1[3];
1193 	u8 msg_flg;
1194 	u8 r2[4];
1195 	__le32 sense_buffer_low_add;
1196 	u8 dma_flag;
1197 	u8 r3;
1198 	u8 sense_buffer_len;
1199 	u8 r4;
1200 	u8 sgl_offset0;
1201 	u8 sgl_offset1;
1202 	u8 sgl_offset2;
1203 	u8 sgl_offset3;
1204 	__le32 skip_count;
1205 	__le32 data_len;
1206 	__le32 bi_dir_data_len;
1207 	__le16 io_flg;
1208 	__le16 eedp_flag;
1209 	__le16 eedp_block_size;
1210 	u8 r5[2];
1211 	__le32 secondary_ref_tag;
1212 	__le16 secondary_app_tag;
1213 	__le16 app_tag_trans_mask;
1214 	u8 lun[8];
1215 	__le32 ctrl;
1216 	union leapraid_mpi_scsi_io_cdb_union cdb;
1217 	union leapraid_sge_io_union sgl;
1218 };
1219 
1220 /**
1221  * union leapraid_scsi_io_cdb_union - SCSI I/O CDB or IEEE simple SGE
1222  *
1223  * @cdb32: 32-byte SCSI CDB.
1224  * @sge: IEEE simple 64-bit SGE.
1225  */
1226 union leapraid_scsi_io_cdb_union {
1227 	u8 cdb32[32];
1228 	struct leapraid_ieee_sge_simple64 sge;
1229 };
1230 
1231 /**
1232  * struct leapraid_scsiio_req - SCSI I/O request
1233  *
1234  * @dev_hdl: Device handle.
1235  * @chain_offset: Offset for chained SGE.
1236  * @func: Function code.
1237  * @r1: Reserved.
1238  * @msg_flg: Message flags.
1239  * @r2: Reserved.
1240  * @sense_buffer_low_add: Lower 32-bit address of sense buffer.
1241  * @dma_flag: DMA flag.
1242  * @r3: Reserved.
1243  * @sense_buffer_len: Sense buffer length.
1244  * @r4: Reserved.
1245  * @sgl_offset0-3: SGL offsets.
1246  * @skip_count: Bytes to skip before transfer.
1247  * @data_len: Length of data transfer.
1248  * @bi_dir_data_len: Bi-directional transfer length.
1249  * @io_flg: I/O flags.
1250  * @eedp_flag: End-to-end data protection flags.
1251  * @eedp_block_size: End-to-end data protection block size.
1252  * @r5: Reserved.
1253  * @secondary_ref_tag: Secondary reference tag.
1254  * @secondary_app_tag: Secondary application tag.
1255  * @app_tag_trans_mask: Application tag mask.
1256  * @lun: Logical Unit Number.
1257  * @ctrl: Control flags.
1258  * @cdb: SCSI Command Descriptor Block or simple SGE.
1259  * @sgl: Scatter-gather list.
1260  */
1261 struct leapraid_scsiio_req {
1262 	__le16 dev_hdl;
1263 	u8 chain_offset;
1264 	u8 func;
1265 	u8 r1[3];
1266 	u8 msg_flg;
1267 	u8 r2[4];
1268 	__le32 sense_buffer_low_add;
1269 	u8 dma_flag;
1270 	u8 r3;
1271 	u8 sense_buffer_len;
1272 	u8 r4;
1273 	u8 sgl_offset0;
1274 	u8 sgl_offset1;
1275 	u8 sgl_offset2;
1276 	u8 sgl_offset3;
1277 	__le32 skip_count;
1278 	__le32 data_len;
1279 	__le32 bi_dir_data_len;
1280 	__le16 io_flg;
1281 	__le16 eedp_flag;
1282 	__le16 eedp_block_size;
1283 	u8 r5[2];
1284 	__le32 secondary_ref_tag;
1285 	__le16 secondary_app_tag;
1286 	__le16 app_tag_trans_mask;
1287 	u8 lun[8];
1288 	__le32 ctrl;
1289 	union leapraid_scsi_io_cdb_union cdb;
1290 	union leapraid_ieee_sge_io_union sgl;
1291 };
1292 
1293 /**
1294  * struct leapraid_scsiio_rep - SCSI I/O response
1295  *
1296  * @dev_hdl: Device handle.
1297  * @msg_len: Length of response message.
1298  * @func: Function code.
1299  * @r1: Reserved.
1300  * @msg_flg: Message flags.
1301  * @r2: Reserved.
1302  * @scsi_status: SCSI status.
1303  * @scsi_state: SCSI state.
1304  * @adapter_status: Adapter status.
1305  * @r3: Reserved.
1306  * @transfer_count: Number of bytes transferred.
1307  * @sense_count: Number of sense bytes.
1308  * @resp_info: Additional response info.
1309  * @task_tag: Task identifier.
1310  * @scsi_status_qualifier: SCSI status qualifier.
1311  * @bi_dir_trans_count: Bi-directional transfer count.
1312  * @r4: Reserved.
1313  */
1314 struct leapraid_scsiio_rep {
1315 	__le16 dev_hdl;
1316 	u8 msg_len;
1317 	u8 func;
1318 	u8 r1[3];
1319 	u8 msg_flg;
1320 	u8 r2[4];
1321 	u8 scsi_status;
1322 	u8 scsi_state;
1323 	__le16 adapter_status;
1324 	u8 r3[4];
1325 	__le32 transfer_count;
1326 	__le32 sense_count;
1327 	__le32 resp_info;
1328 	__le16 task_tag;
1329 	__le16 scsi_status_qualifier;
1330 	__le32 bi_dir_trans_count;
1331 	__le32 r4[3];
1332 };
1333 
1334 /**
1335  * struct leapraid_scsi_tm_req - SCSI Task Management request
1336  *
1337  * @dev_hdl: Device handle.
1338  * @chain_offset: Offset for chained SGE.
1339  * @func: Function code.
1340  * @r1: Reserved.
1341  * @task_type: Task management function type.
1342  * @r2: Reserved.
1343  * @msg_flg: Message flags.
1344  * @r3: Reserved.
1345  * @lun: Logical Unit Number.
1346  * @r4: Reserved.
1347  * @task_mid: Task identifier.
1348  * @r5: Reserved.
1349  */
1350 struct leapraid_scsi_tm_req {
1351 	__le16 dev_hdl;
1352 	u8 chain_offset;
1353 	u8 func;
1354 	u8 r1;
1355 	u8 task_type;
1356 	u8 r2;
1357 	u8 msg_flg;
1358 	u8 r3[4];
1359 	u8 lun[8];
1360 	u8 r4[28];
1361 	__le16 task_mid;
1362 	u8 r5[2];
1363 };
1364 
1365 /**
1366  * struct leapraid_scsi_tm_rep - SCSI Task Management response
1367  *
1368  * @dev_hdl: Device handle.
1369  * @msg_len: Length of response message.
1370  * @func: Function code.
1371  * @resp_code: Response code.
1372  * @task_type: Task management type.
1373  * @r1: Reserved.
1374  * @msg_flag: Message flags.
1375  * @r2: Reserved.
1376  * @adapter_status: Adapter status.
1377  * @r3: Reserved.
1378  * @termination_count: Count of terminated tasks.
1379  * @response_info: Additional response info.
1380  */
1381 struct leapraid_scsi_tm_rep {
1382 	__le16 dev_hdl;
1383 	u8 msg_len;
1384 	u8 func;
1385 	u8 resp_code;
1386 	u8 task_type;
1387 	u8 r1;
1388 	u8 msg_flag;
1389 	u8 r2[6];
1390 	__le16 adapter_status;
1391 	u8 r3[4];
1392 	__le32 termination_count;
1393 	__le32 response_info;
1394 };
1395 
1396 /**
1397  * struct leapraid_sep_req - SEP (SCSI Enclosure Processor) request
1398  *
1399  * @dev_hdl: Device handle.
1400  * @chain_offset: Offset for chained SGE.
1401  * @func: Function code.
1402  * @act: Action to perform.
1403  * @flg: Flags.
1404  * @r1: Reserved.
1405  * @msg_flag: Message flags.
1406  * @r2: Reserved.
1407  * @slot_status: Slot status.
1408  * @r3: Reserved.
1409  * @slot: Slot number.
1410  * @enc_hdl: Enclosure handle.
1411  */
1412 struct leapraid_sep_req {
1413 	__le16 dev_hdl;
1414 	u8 chain_offset;
1415 	u8 func;
1416 	u8 act;
1417 	u8 flg;
1418 	u8 r1;
1419 	u8 msg_flag;
1420 	u8 r2[4];
1421 	__le32 slot_status;
1422 	u8 r3[12];
1423 	__le16 slot;
1424 	__le16 enc_hdl;
1425 };
1426 
1427 /**
1428  * struct leapraid_sep_rep - SEP response
1429  *
1430  * @dev_hdl: Device handle.
1431  * @msg_len: Message length.
1432  * @func: Function code.
1433  * @act: Action performed.
1434  * @flg: Flags.
1435  * @msg_flag: Message flags.
1436  * @r1: Reserved.
1437  * @adapter_status: Adapter status.
1438  * @r2: Reserved.
1439  * @slot_status: Slot status.
1440  * @r3: Reserved.
1441  * @slot: Slot number.
1442  * @enc_hdl: Enclosure handle.
1443  */
1444 struct leapraid_sep_rep {
1445 	__le16 dev_hdl;
1446 	u8 msg_len;
1447 	u8 func;
1448 	u8 act;
1449 	u8 flg;
1450 	u8 r1;
1451 	u8 msg_flag;
1452 	u8 r2[6];
1453 	__le16 adapter_status;
1454 	u8 r3[4];
1455 	__le32 slot_status;
1456 	u8 r4[4];
1457 	__le16 slot;
1458 	__le16 enc_hdl;
1459 };
1460 
1461 /**
1462  * struct leapraid_adapter_init_req - Adapter initialization request
1463  *
1464  * @who_init: Initiator of the initialization.
1465  * @r1: Reserved.
1466  * @chain_offset: Chain offset.
1467  * @func: Function code.
1468  * @r2: Reserved.
1469  * @msg_flg: Message flags.
1470  * @r3: Reserved.
1471  * @msg_ver: Message version.
1472  * @header_ver: Header version.
1473  * @host_buf_addr: Host buffer address (non adapter-ref).
1474  * @r4: Reserved.
1475  * @host_buf_size: Host buffer size (non adapter-ref).
1476  * @host_msix_vectors: Number of host MSI-X vectors.
1477  * @r6: Reserved.
1478  * @req_frame_size: Request frame size.
1479  * @rep_desc_qd: Reply descriptor queue depth.
1480  * @rep_msg_qd: Reply message queue depth.
1481  * @sense_buffer_add_high: High 32-bit of sense buffer address.
1482  * @rep_msg_dma_high: High 32-bit of reply message DMA address.
1483  * @task_desc_base_addr: Base address of task descriptors.
1484  * @rep_desc_q_arr_addr: Address of reply descriptor queue array.
1485  * @rep_msg_addr_dma: Reply message DMA address.
1486  * @time_stamp: Timestamp.
1487  */
1488 struct leapraid_adapter_init_req {
1489 	u8 who_init;
1490 	u8 r1;
1491 	u8 chain_offset;
1492 	u8 func;
1493 	u8 r2[3];
1494 	u8 msg_flg;
1495 	__le32 driver_ver;
1496 	__le16 msg_ver;
1497 	__le16 header_ver;
1498 	__le32 host_buf_addr;
1499 	u8 r4[2];
1500 	u8 host_buf_size;
1501 	u8 host_msix_vectors;
1502 	u8 r6[2];
1503 	__le16 req_frame_size;
1504 	__le16 rep_desc_qd;
1505 	__le16 rep_msg_qd;
1506 	__le32 sense_buffer_add_high;
1507 	__le32 rep_msg_dma_high;
1508 	__le64 task_desc_base_addr;
1509 	__le64 rep_desc_q_arr_addr;
1510 	__le64 rep_msg_addr_dma;
1511 	__le64 time_stamp;
1512 } __packed __aligned(4);
1513 
1514 /**
1515  * struct leapraid_rep_desc_q_arr - Reply descriptor queue array
1516  *
1517  * @rep_desc_base_addr: Base address of the reply descriptors.
1518  * @r1: Reserved.
1519  */
1520 struct leapraid_rep_desc_q_arr {
1521 	__le64 rep_desc_base_addr;
1522 	__le64 r1;
1523 } __packed __aligned(4);
1524 
1525 /**
1526  * struct leapraid_adapter_init_rep - Adapter initialization reply
1527  *
1528  * @who_init: Initiator of the initialization.
1529  * @r1: Reserved.
1530  * @msg_len: Length of reply message.
1531  * @func: Function code.
1532  * @r2: Reserved.
1533  * @msg_flag: Message flags.
1534  * @r3: Reserved.
1535  * @adapter_status: Adapter status.
1536  * @r4: Reserved.
1537  */
1538 struct leapraid_adapter_init_rep {
1539 	u8 who_init;
1540 	u8 r1;
1541 	u8 msg_len;
1542 	u8 func;
1543 	u8 r2[3];
1544 	u8 msg_flag;
1545 	u8 r3[6];
1546 	__le16 adapter_status;
1547 	u8 r4[4];
1548 };
1549 
1550 /**
1551  * struct leapraid_adapter_log_req - Adapter log request
1552  *
1553  * @action: Action code.
1554  * @type: Log type.
1555  * @chain_offset: Offset for chained SGE.
1556  * @func: Function code.
1557  * r1: Reserved.
1558  * @msg_flag: Message flags.
1559  * r2: Reserved.
1560  * @mbox: Mailbox for command-specific parameters.
1561  * @sge: Scatter-gather entry for data buffer.
1562  */
1563 struct leapraid_adapter_log_req {
1564 	u8 action;
1565 	u8 type;
1566 	u8 chain_offset;
1567 	u8 func;
1568 	u8 r1[3];
1569 	u8 msg_flag;
1570 	u8 r2[4];
1571 	union {
1572 		u8	b[12];
1573 		__le16	s[6];
1574 		__le32	w[3];
1575 	} mbox;
1576 	struct leapraid_sge_simple64 sge;
1577 } __packed __aligned(4);
1578 
1579 /**
1580  * struct leapraid_adapter_log_rep - Adapter log reply
1581  *
1582  * @action: Action code echoed.
1583  * @type: Log type echoed.
1584  * @msg_len: Length of message.
1585  * @func: Function code.
1586  * @r1: Reserved.
1587  * @msg_flag: Message flags.
1588  * @r2: Reserved.
1589  * @adapter_status: Status returned by adapter.
1590  */
1591 struct leapraid_adapter_log_rep {
1592 	u8 action;
1593 	u8 type;
1594 	u8 msg_len;
1595 	u8 func;
1596 	u8 r1[3];
1597 	u8 msg_flag;
1598 	u8 r2[6];
1599 	__le16 adapter_status;
1600 };
1601 
1602 /**
1603  * struct leapraid_adapter_features_req - Request adapter features
1604  *
1605  * @r1: Reserved.
1606  * @chain_offset: Offset for chained SGE.
1607  * @func: Function code.
1608  * @r2: Reserved.
1609  * @msg_flag: Message flags.
1610  * @r3: Reserved.
1611  */
1612 struct leapraid_adapter_features_req {
1613 	u8 r1[2];
1614 	u8 chain_offset;
1615 	u8 func;
1616 	u8 r2[3];
1617 	u8 msg_flag;
1618 	u8 r3[4];
1619 };
1620 
1621 /**
1622  * struct leapraid_adapter_features_rep - Adapter features reply
1623  *
1624  * @msg_ver: Message version.
1625  * @msg_len: Length of reply message.
1626  * @func: Function code.
1627  * @header_ver: Header version.
1628  * @r1: Reserved.
1629  * @msg_flag: Message flags.
1630  * @r2: Reserved.
1631  * @adapter_status: Adapter status.
1632  * @r3: Reserved.
1633  * @who_init: Who initialized the adapter.
1634  * @r4: Reserved.
1635  * @max_msix_vectors: Max MSI-X vectors supported.
1636  * @req_slot: Number of request slots.
1637  * @r5: Reserved.
1638  * @adapter_caps: Adapter capabilities.
1639  * @fw_version: Firmware version.
1640  * @sas_wide_max_qdepth: Max wide SAS queue depth.
1641  * @sas_narrow_max_qdepth: Max narrow SAS queue depth.
1642  * @r6: Reserved.
1643  * @hp_slot: Number of high-priority slots.
1644  * @r7: Reserved.
1645  * @max_volumes: Maximum supported volumes.
1646  * @max_dev_hdl: Maximum device handle.
1647  * @r8: Reserved.
1648  * @min_dev_hdl: Minimum device handle.
1649  * @r9: Reserved.
1650  */
1651 struct leapraid_adapter_features_rep {
1652 	__le16 msg_ver;
1653 	u8 msg_len;
1654 	u8 func;
1655 	u16 header_ver;
1656 	u8 r1;
1657 	u8 msg_flag;
1658 	u8 r2[6];
1659 	u16 adapter_status;
1660 	u8 r3[4];
1661 	u8 sata_max_qdepth;
1662 	u8 who_init;
1663 	u8 r4;
1664 	u8 max_msix_vectors;
1665 	__le16 req_slot;
1666 	__le16 product_id;
1667 	__le32 adapter_caps;
1668 	__le32 fw_version;
1669 	__le16 sas_wide_max_qdepth;
1670 	__le16 sas_narrow_max_qdepth;
1671 	u8 r6[10];
1672 	__le16 hp_slot;
1673 	u8 r7[3];
1674 	u8 max_volumes;
1675 	__le16 max_dev_hdl;
1676 	u8 r8[2];
1677 	__le16 min_dev_hdl;
1678 	u8 r9[6];
1679 };
1680 
1681 /**
1682  * struct leapraid_scan_dev_req - Request to scan devices
1683  *
1684  * @r1: Reserved.
1685  * @chain_offset: Offset for chained SGE.
1686  * @func: Function code.
1687  * @r2: Reserved.
1688  * @msg_flag: Message flags.
1689  * @r3: Reserved.
1690  */
1691 struct leapraid_scan_dev_req {
1692 	u8 r1[2];
1693 	u8 chain_offset;
1694 	u8 func;
1695 	u8 r2[3];
1696 	u8 msg_flag;
1697 	u8 r3[4];
1698 };
1699 
1700 /**
1701  * struct leapraid_scan_dev_rep - Scan devices reply
1702  *
1703  * @r1: Reserved.
1704  * @msg_len: Length of message.
1705  * @func: Function code.
1706  * @r2: Reserved.
1707  * @msg_flag: Message flags.
1708  * @r3: Reserved.
1709  * @adapter_status: Adapter status.
1710  * @r4: Reserved.
1711  */
1712 struct leapraid_scan_dev_rep {
1713 	u8 r1[2];
1714 	u8 msg_len;
1715 	u8 func;
1716 	u8 r2[3];
1717 	u8 msg_flag;
1718 	u8 r3[6];
1719 	__le16 adapter_status;
1720 	u8 r4[4];
1721 };
1722 
1723 /**
1724  * struct leapraid_evt_notify_req - Event notification request
1725  *
1726  * @r1: Reserved.
1727  * @chain_offset: Offset for chained SGE.
1728  * @func: Function code.
1729  * @r2: Reserved.
1730  * @msg_flag: Message flags.
1731  * @r3: Reserved.
1732  * @evt_masks: Event masks to enable notifications.
1733  * @r4: Reserved.
1734  */
1735 struct leapraid_evt_notify_req {
1736 	u8 r1[2];
1737 	u8 chain_offset;
1738 	u8 func;
1739 	u8 r2[3];
1740 	u8 msg_flag;
1741 	u8 r3[12];
1742 	__le32 evt_masks[4];
1743 	u8 r4[8];
1744 };
1745 
1746 /**
1747  * struct leapraid_evt_notify_rep - Event notification reply
1748  *
1749  * @evt_data_len: Length of event data.
1750  * @msg_len: Length of message.
1751  * @func: Function code.
1752  * @r1: Reserved.
1753  * @r2: Reserved.
1754  * @msg_flag: Message flags.
1755  * @r3: Reserved.
1756  * @adapter_status: Adapter status.
1757  * @r4: Reserved.
1758  * @evt: Event code.
1759  * @r5: Reserved.
1760  * @evt_data: Event data array.
1761  */
1762 struct leapraid_evt_notify_rep {
1763 	__le16 evt_data_len;
1764 	u8 msg_len;
1765 	u8 func;
1766 	u8 r1[2];
1767 	u8 r2;
1768 	u8 msg_flag;
1769 	u8 r3[6];
1770 	__le16 adapter_status;
1771 	u8 r4[4];
1772 	__le16 evt;
1773 	u8 r5[6];
1774 	__le32 evt_data[];
1775 };
1776 
1777 /**
1778  * struct leapraid_evt_data_sas_dev_status_change - SAS device status change
1779  *
1780  * @task_tag: Task identifier.
1781  * @reason_code: Reason for status change.
1782  * @physical_port: Physical port number.
1783  * @r1: Reserved.
1784  * @dev_hdl: Device handle.
1785  * @r2: Reserved.
1786  * @sas_address: SAS address of device.
1787  * @lun: Logical unit Number.
1788  */
1789 struct leapraid_evt_data_sas_dev_status_change {
1790 	__le16 task_tag;
1791 	u8 reason_code;
1792 	u8 physical_port;
1793 	u8 r1[2];
1794 	__le16 dev_hdl;
1795 	u8 r2[4];
1796 	__le64 sas_address;
1797 	u8 lun[8];
1798 } __packed __aligned(4);
1799 /**
1800  * struct leapraid_evt_data_ir_change - IR (Integrated RAID) change event data
1801  *
1802  * @r1: Reserved.
1803  * @reason_code: Reason for IR change.
1804  * @r2: Reserved.
1805  * @vol_dev_hdl: Volume device handle.
1806  * @phys_disk_dev_hdl: Physical disk device handle.
1807  */
1808 struct leapraid_evt_data_ir_change {
1809 	u8 r1;
1810 	u8 reason_code;
1811 	u8 r2[2];
1812 	__le16 vol_dev_hdl;
1813 	__le16 phys_disk_dev_hdl;
1814 };
1815 
1816 /**
1817  * struct leapraid_evt_data_sas_disc - SAS discovery event data
1818  *
1819  * @r1: Reserved.
1820  * @reason_code: Reason for discovery event.
1821  * @physical_port: Physical port number where event occurred.
1822  * @r2: Reserved.
1823  */
1824 struct leapraid_evt_data_sas_disc {
1825 	u8 r1;
1826 	u8 reason_code;
1827 	u8 physical_port;
1828 	u8 r2[5];
1829 };
1830 
1831 /**
1832  * struct leapraid_evt_sas_topo_phy_entry - SAS topology PHY entry
1833  *
1834  * @attached_dev_hdl: Device handle attached to PHY.
1835  * @link_rate: Current link rate.
1836  * @phy_status: PHY status flags.
1837  */
1838 struct leapraid_evt_sas_topo_phy_entry {
1839 	__le16 attached_dev_hdl;
1840 	u8 link_rate;
1841 	u8 phy_status;
1842 };
1843 
1844 /**
1845  * struct leapraid_evt_data_sas_topo_change_list - SAS topology change list
1846  *
1847  * @encl_hdl: Enclosure handle.
1848  * @exp_dev_hdl: Expander device handle.
1849  * @num_phys: Number of PHYs in this entry.
1850  * @r1: Reserved.
1851  * @entry_num: Number of PHY elements.
1852  * @start_phy_num: Start PHY number.
1853  * @exp_status: Expander status.
1854  * @physical_port: Physical port number.
1855  * @phy: Array of SAS PHY entries.
1856  */
1857 struct leapraid_evt_data_sas_topo_change_list {
1858 	__le16 encl_hdl;
1859 	__le16 exp_dev_hdl;
1860 	u8 num_phys;
1861 	u8 r1[3];
1862 	u8 entry_num;
1863 	u8 start_phy_num;
1864 	u8 exp_status;
1865 	u8 physical_port;
1866 	struct leapraid_evt_sas_topo_phy_entry phy[];
1867 };
1868 
1869 /**
1870  * struct leapraid_evt_data_sas_enc_dev_status_change -
1871  * SAS enclosure device status
1872  *
1873  * @enc_hdl: Enclosure handle.
1874  * @reason_code: Reason code for status change.
1875  * @physical_port: Physical port number.
1876  * @encl_logical_id: Enclosure logical ID.
1877  * @num_slots: Number of slots in enclosure.
1878  * @start_slot: First affected slot.
1879  * @phy_bits: Bitmap of affected PHYs.
1880  */
1881 struct leapraid_evt_data_sas_enc_dev_status_change {
1882 	__le16 enc_hdl;
1883 	u8 reason_code;
1884 	u8 physical_port;
1885 	__le64 encl_logical_id;
1886 	__le16 num_slots;
1887 	__le16 start_slot;
1888 	__le32 phy_bits;
1889 } __packed __aligned(4);
1890 
1891 /**
1892  * struct leapraid_io_unit_ctrl_req - I/O unit control request
1893  *
1894  * @op: Operation code.
1895  * @r1: Reserved.
1896  * @chain_offset: SGE chain offset.
1897  * @func: Function code.
1898  * @dev_hdl: Device handle.
1899  * @adapter_para: Adapter parameter selector.
1900  * @msg_flag: Message flags.
1901  * @r2: Reserved.
1902  * @phy_num: PHY number.
1903  * @r3: Reserved.
1904  * @adapter_para_value: Value for adapter parameter.
1905  * @adapter_para_value2: Optional second parameter value.
1906  * @r4: Reserved.
1907  */
1908 struct leapraid_io_unit_ctrl_req {
1909 	u8 op;
1910 	u8 r1;
1911 	u8 chain_offset;
1912 	u8 func;
1913 	__le16 dev_hdl;
1914 	u8 adapter_para;
1915 	u8 msg_flag;
1916 	u8 r2[6];
1917 	u8 phy_num;
1918 	u8 r3[17];
1919 	__le32 adapter_para_value;
1920 	__le32 adapter_para_value2;
1921 	u8 r4[4];
1922 };
1923 
1924 /**
1925  * struct leapraid_io_unit_ctrl_rep - I/O unit control reply
1926  *
1927  * @op: Operation code echoed.
1928  * @r1: Reserved.
1929  * @func: Function code.
1930  * @dev_hdl: Device handle.
1931  * @r2: Reserved.
1932  */
1933 struct leapraid_io_unit_ctrl_rep {
1934 	u8 op;
1935 	u8 r1[2];
1936 	u8 func;
1937 	__le16 dev_hdl;
1938 	u8 r2[14];
1939 };
1940 
1941 /**
1942  * struct leapraid_raid_act_req - RAID action request
1943  *
1944  * @act: RAID action code.
1945  * @r1: Reserved.
1946  * @func: Function code.
1947  * @r2: Reserved.
1948  * @phys_disk_num: Number of physical disks involved.
1949  * @r3: Reserved.
1950  * @action_data_sge: SGE describing action-specific data.
1951  */
1952 struct leapraid_raid_act_req {
1953 	u8 act;
1954 	u8 r1[2];
1955 	u8 func;
1956 	u8 r2[2];
1957 	u8 phys_disk_num;
1958 	u8 r3[13];
1959 	struct leapraid_sge_simple_union action_data_sge;
1960 };
1961 
1962 /**
1963  * struct leapraid_raid_act_rep - RAID action reply
1964  *
1965  * @act: RAID action code echoed.
1966  * @r1: Reserved.
1967  * @func: Function code.
1968  * @vol_dev_hdl: Volume device handle.
1969  * @r2: Reserved
1970  * @adapter_status: Status returned by adapter.
1971  * @r3: Reserved.
1972  */
1973 struct leapraid_raid_act_rep {
1974 	u8 act;
1975 	u8 r1[2];
1976 	u8 func;
1977 	__le16 vol_dev_hdl;
1978 	u8 r2[8];
1979 	__le16 adapter_status;
1980 	u8 r3[76];
1981 };
1982 
1983 /**
1984  * struct leapraid_smp_passthrough_req - SMP passthrough request
1985  *
1986  * @passthrough_flg: Passthrough flags.
1987  * @physical_port: Target PHY port.
1988  * @r1: Reserved.
1989  * @func: Function code.
1990  * @req_data_len: Request data length.
1991  * @r2: Reserved.
1992  * @sas_address: SAS address of target device.
1993  * @r3: Reserved.
1994  * @sgl: Scatter-gather list describing request buffer.
1995  */
1996 struct leapraid_smp_passthrough_req {
1997 	u8 passthrough_flg;
1998 	u8 physical_port;
1999 	u8 r1;
2000 	u8 func;
2001 	__le16 req_data_len;
2002 	u8 r2[10];
2003 	__le64 sas_address;
2004 	u8 r3[8];
2005 	union leapraid_simple_sge_union sgl;
2006 } __packed __aligned(4);
2007 
2008 /**
2009  * struct leapraid_smp_passthrough_rep - SMP passthrough reply
2010  *
2011  * @passthrough_flg: Passthrough flags echoed.
2012  * @physical_port: Target PHY port.
2013  * @r1: Reserved.
2014  * @func: Function code.
2015  * @resp_data_len: Length of response data.
2016  * @r2: Reserved.
2017  * @adapter_status: Adapter status.
2018  * @r3: Reserved.
2019  */
2020 struct leapraid_smp_passthrough_rep {
2021 	u8 passthrough_flg;
2022 	u8 physical_port;
2023 	u8 r1;
2024 	u8 func;
2025 	__le16 resp_data_len;
2026 	u8 r2[8];
2027 	__le16 adapter_status;
2028 	u8 r3[12];
2029 };
2030 
2031 /**
2032  * struct leapraid_sas_io_unit_ctrl_req - SAS I/O unit control request
2033  *
2034  * @op: Operation code.
2035  * @r1: Reserved.
2036  * @func: Function code.
2037  * @dev_hdl: Device handle.
2038  * @r2: Reserved.
2039  */
2040 struct leapraid_sas_io_unit_ctrl_req {
2041 	u8 op;
2042 	u8 r1[2];
2043 	u8 func;
2044 	__le16 dev_hdl;
2045 	u8 r2[38];
2046 };
2047 
2048 #endif /* LEAPRAID_H */
2049