xref: /openbmc/linux/drivers/scsi/esas2r/atvda.h (revision da1d9caf)
1 /*  linux/drivers/scsi/esas2r/atvda.h
2  *       ATTO VDA interface definitions
3  *
4  *  Copyright (c) 2001-2013 ATTO Technology, Inc.
5  *  (mailto:linuxdrivers@attotech.com)
6  */
7 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8 /*
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; version 2 of the License.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  NO WARRANTY
19  *  THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20  *  CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21  *  LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22  *  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23  *  solely responsible for determining the appropriateness of using and
24  *  distributing the Program and assumes all risks associated with its
25  *  exercise of rights under this Agreement, including but not limited to
26  *  the risks and costs of program errors, damage to or loss of data,
27  *  programs or equipment, and unavailability or interruption of operations.
28  *
29  *  DISCLAIMER OF LIABILITY
30  *  NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
31  *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
33  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35  *  USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
36  *  HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
37  *
38  *  You should have received a copy of the GNU General Public License
39  *  along with this program; if not, write to the Free Software
40  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
41  */
42 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
43 
44 
45 #ifndef ATVDA_H
46 #define ATVDA_H
47 
48 struct __packed atto_dev_addr {
49 	u64 dev_port;
50 	u64 hba_port;
51 	u8 lun;
52 	u8 flags;
53 	   #define VDA_DEVADDRF_SATA   0x01
54 	   #define VDA_DEVADDRF_SSD    0x02
55 	u8 link_speed; /* VDALINKSPEED_xxx */
56 	u8 pad[1];
57 };
58 
59 /* dev_addr2 was added for 64-bit alignment */
60 
61 struct __packed atto_dev_addr2 {
62 	u64 dev_port;
63 	u64 hba_port;
64 	u8 lun;
65 	u8 flags;
66 	u8 link_speed;
67 	u8 pad[5];
68 };
69 
70 struct __packed atto_vda_sge {
71 	u32 length;
72 	u64 address;
73 };
74 
75 
76 /* VDA request function codes */
77 
78 #define VDA_FUNC_SCSI     0x00
79 #define VDA_FUNC_FLASH    0x01
80 #define VDA_FUNC_DIAG     0x02
81 #define VDA_FUNC_AE       0x03
82 #define VDA_FUNC_CLI      0x04
83 #define VDA_FUNC_IOCTL    0x05
84 #define VDA_FUNC_CFG      0x06
85 #define VDA_FUNC_MGT      0x07
86 #define VDA_FUNC_GSV      0x08
87 
88 
89 /* VDA request status values.  for host driver considerations, values for
90  * SCSI requests start at zero.  other requests may use these values as well. */
91 
92 #define RS_SUCCESS          0x00        /*! successful completion            */
93 #define RS_INV_FUNC         0x01        /*! invalid command function         */
94 #define RS_BUSY             0x02        /*! insufficient resources           */
95 #define RS_SEL              0x03        /*! no target at target_id           */
96 #define RS_NO_LUN           0x04        /*! invalid LUN                      */
97 #define RS_TIMEOUT          0x05        /*! request timeout                  */
98 #define RS_OVERRUN          0x06        /*! data overrun                     */
99 #define RS_UNDERRUN         0x07        /*! data underrun                    */
100 #define RS_SCSI_ERROR       0x08        /*! SCSI error occurred              */
101 #define RS_ABORTED          0x0A        /*! command aborted                  */
102 #define RS_RESID_MISM       0x0B        /*! residual length incorrect        */
103 #define RS_TM_FAILED        0x0C        /*! task management failed           */
104 #define RS_RESET            0x0D        /*! aborted due to bus reset         */
105 #define RS_ERR_DMA_SG       0x0E        /*! error reading SG list            */
106 #define RS_ERR_DMA_DATA     0x0F        /*! error transferring data          */
107 #define RS_UNSUPPORTED      0x10        /*! unsupported request              */
108 #define RS_SEL2             0x70        /*! internal generated RS_SEL        */
109 #define RS_VDA_BASE         0x80        /*! base of VDA-specific errors      */
110 #define RS_MGT_BASE         0x80        /*! base of VDA management errors    */
111 #define RS_SCAN_FAIL        (RS_MGT_BASE + 0x00)
112 #define RS_DEV_INVALID      (RS_MGT_BASE + 0x01)
113 #define RS_DEV_ASSIGNED     (RS_MGT_BASE + 0x02)
114 #define RS_DEV_REMOVE       (RS_MGT_BASE + 0x03)
115 #define RS_DEV_LOST         (RS_MGT_BASE + 0x04)
116 #define RS_SCAN_GEN         (RS_MGT_BASE + 0x05)
117 #define RS_GRP_INVALID      (RS_MGT_BASE + 0x08)
118 #define RS_GRP_EXISTS       (RS_MGT_BASE + 0x09)
119 #define RS_GRP_LIMIT        (RS_MGT_BASE + 0x0A)
120 #define RS_GRP_INTLV        (RS_MGT_BASE + 0x0B)
121 #define RS_GRP_SPAN         (RS_MGT_BASE + 0x0C)
122 #define RS_GRP_TYPE         (RS_MGT_BASE + 0x0D)
123 #define RS_GRP_MEMBERS      (RS_MGT_BASE + 0x0E)
124 #define RS_GRP_COMMIT       (RS_MGT_BASE + 0x0F)
125 #define RS_GRP_REBUILD      (RS_MGT_BASE + 0x10)
126 #define RS_GRP_REBUILD_TYPE (RS_MGT_BASE + 0x11)
127 #define RS_GRP_BLOCK_SIZE   (RS_MGT_BASE + 0x12)
128 #define RS_CFG_SAVE         (RS_MGT_BASE + 0x14)
129 #define RS_PART_LAST        (RS_MGT_BASE + 0x18)
130 #define RS_ELEM_INVALID     (RS_MGT_BASE + 0x19)
131 #define RS_PART_MAPPED      (RS_MGT_BASE + 0x1A)
132 #define RS_PART_TARGET      (RS_MGT_BASE + 0x1B)
133 #define RS_PART_LUN         (RS_MGT_BASE + 0x1C)
134 #define RS_PART_DUP         (RS_MGT_BASE + 0x1D)
135 #define RS_PART_NOMAP       (RS_MGT_BASE + 0x1E)
136 #define RS_PART_MAX         (RS_MGT_BASE + 0x1F)
137 #define RS_PART_CAP         (RS_MGT_BASE + 0x20)
138 #define RS_PART_STATE       (RS_MGT_BASE + 0x21)
139 #define RS_TEST_IN_PROG     (RS_MGT_BASE + 0x22)
140 #define RS_METRICS_ERROR    (RS_MGT_BASE + 0x23)
141 #define RS_HS_ERROR         (RS_MGT_BASE + 0x24)
142 #define RS_NO_METRICS_TEST  (RS_MGT_BASE + 0x25)
143 #define RS_BAD_PARAM        (RS_MGT_BASE + 0x26)
144 #define RS_GRP_MEMBER_SIZE  (RS_MGT_BASE + 0x27)
145 #define RS_FLS_BASE         0xB0        /*! base of VDA errors               */
146 #define RS_FLS_ERR_AREA     (RS_FLS_BASE + 0x00)
147 #define RS_FLS_ERR_BUSY     (RS_FLS_BASE + 0x01)
148 #define RS_FLS_ERR_RANGE    (RS_FLS_BASE + 0x02)
149 #define RS_FLS_ERR_BEGIN    (RS_FLS_BASE + 0x03)
150 #define RS_FLS_ERR_CHECK    (RS_FLS_BASE + 0x04)
151 #define RS_FLS_ERR_FAIL     (RS_FLS_BASE + 0x05)
152 #define RS_FLS_ERR_RSRC     (RS_FLS_BASE + 0x06)
153 #define RS_FLS_ERR_NOFILE   (RS_FLS_BASE + 0x07)
154 #define RS_FLS_ERR_FSIZE    (RS_FLS_BASE + 0x08)
155 #define RS_CFG_BASE         0xC0        /*! base of VDA configuration errors */
156 #define RS_CFG_ERR_BUSY     (RS_CFG_BASE + 0)
157 #define RS_CFG_ERR_SGE      (RS_CFG_BASE + 1)
158 #define RS_CFG_ERR_DATE     (RS_CFG_BASE + 2)
159 #define RS_CFG_ERR_TIME     (RS_CFG_BASE + 3)
160 #define RS_DEGRADED         0xFB        /*! degraded mode                    */
161 #define RS_CLI_INTERNAL     0xFC        /*! VDA CLI internal error           */
162 #define RS_VDA_INTERNAL     0xFD        /*! catch-all                        */
163 #define RS_PENDING          0xFE        /*! pending, not started             */
164 #define RS_STARTED          0xFF        /*! started                          */
165 
166 
167 /* flash request subfunctions.  these are used in both the IOCTL and the
168  * driver-firmware interface (VDA_FUNC_FLASH). */
169 
170 #define VDA_FLASH_BEGINW  0x00
171 #define VDA_FLASH_READ    0x01
172 #define VDA_FLASH_WRITE   0x02
173 #define VDA_FLASH_COMMIT  0x03
174 #define VDA_FLASH_CANCEL  0x04
175 #define VDA_FLASH_INFO    0x05
176 #define VDA_FLASH_FREAD   0x06
177 #define VDA_FLASH_FWRITE  0x07
178 #define VDA_FLASH_FINFO   0x08
179 
180 
181 /* IOCTL request subfunctions.  these identify the payload type for
182  * VDA_FUNC_IOCTL.
183  */
184 
185 #define VDA_IOCTL_HBA     0x00
186 #define VDA_IOCTL_CSMI    0x01
187 #define VDA_IOCTL_SMP     0x02
188 
189 struct __packed atto_vda_devinfo {
190 	struct atto_dev_addr dev_addr;
191 	u8 vendor_id[8];
192 	u8 product_id[16];
193 	u8 revision[4];
194 	u64 capacity;
195 	u32 block_size;
196 	u8 dev_type;
197 
198 	union {
199 		u8 dev_status;
200 	    #define VDADEVSTAT_INVALID   0x00
201 	    #define VDADEVSTAT_CORRUPT   VDADEVSTAT_INVALID
202 	    #define VDADEVSTAT_ASSIGNED  0x01
203 	    #define VDADEVSTAT_SPARE     0x02
204 	    #define VDADEVSTAT_UNAVAIL   0x03
205 	    #define VDADEVSTAT_PT_MAINT  0x04
206 	    #define VDADEVSTAT_LCLSPARE  0x05
207 	    #define VDADEVSTAT_UNUSEABLE 0x06
208 	    #define VDADEVSTAT_AVAIL     0xFF
209 
210 		u8 op_ctrl;
211 	    #define VDA_DEV_OP_CTRL_START   0x01
212 	    #define VDA_DEV_OP_CTRL_HALT    0x02
213 	    #define VDA_DEV_OP_CTRL_RESUME  0x03
214 	    #define VDA_DEV_OP_CTRL_CANCEL  0x04
215 	};
216 
217 	u8 member_state;
218 	#define VDAMBRSTATE_ONLINE   0x00
219 	#define VDAMBRSTATE_DEGRADED 0x01
220 	#define VDAMBRSTATE_UNAVAIL  0x02
221 	#define VDAMBRSTATE_FAULTED  0x03
222 	#define VDAMBRSTATE_MISREAD  0x04
223 	#define VDAMBRSTATE_INCOMPAT 0x05
224 
225 	u8 operation;
226 	#define VDAOP_NONE           0x00
227 	#define VDAOP_REBUILD        0x01
228 	#define VDAOP_ERASE          0x02
229 	#define VDAOP_PATTERN        0x03
230 	#define VDAOP_CONVERSION     0x04
231 	#define VDAOP_FULL_INIT      0x05
232 	#define VDAOP_QUICK_INIT     0x06
233 	#define VDAOP_SECT_SCAN      0x07
234 	#define VDAOP_SECT_SCAN_PARITY      0x08
235 	#define VDAOP_SECT_SCAN_PARITY_FIX  0x09
236 	#define VDAOP_RECOV_REBUILD  0x0A
237 
238 	u8 op_status;
239 	#define VDAOPSTAT_OK         0x00
240 	#define VDAOPSTAT_FAULTED    0x01
241 	#define VDAOPSTAT_HALTED     0x02
242 	#define VDAOPSTAT_INT        0x03
243 
244 	u8 progress; /* 0 - 100% */
245 	u16 ses_dev_index;
246 	#define VDASESDI_INVALID     0xFFFF
247 
248 	u8 serial_no[32];
249 
250 	union {
251 		u16 target_id;
252 	#define VDATGTID_INVALID     0xFFFF
253 
254 		u16 features_mask;
255 	};
256 
257 	u16 lun;
258 	u16 features;
259 	#define VDADEVFEAT_ENC_SERV  0x0001
260 	#define VDADEVFEAT_IDENT     0x0002
261 	#define VDADEVFEAT_DH_SUPP   0x0004
262 	#define VDADEVFEAT_PHYS_ID   0x0008
263 
264 	u8 ses_element_id;
265 	u8 link_speed;
266 	#define VDALINKSPEED_UNKNOWN 0x00
267 	#define VDALINKSPEED_1GB     0x01
268 	#define VDALINKSPEED_1_5GB   0x02
269 	#define VDALINKSPEED_2GB     0x03
270 	#define VDALINKSPEED_3GB     0x04
271 	#define VDALINKSPEED_4GB     0x05
272 	#define VDALINKSPEED_6GB     0x06
273 	#define VDALINKSPEED_8GB     0x07
274 
275 	u16 phys_target_id;
276 	u8 reserved[2];
277 };
278 
279 
280 /*! struct atto_vda_devinfo2 is a replacement for atto_vda_devinfo.  it
281  * extends beyond the 0x70 bytes allowed in atto_vda_mgmt_req; therefore,
282  * the entire structure is DMaed between the firmware and host buffer and
283  * the data will always be in little endian format.
284  */
285 
286 struct __packed atto_vda_devinfo2 {
287 	struct atto_dev_addr dev_addr;
288 	u8 vendor_id[8];
289 	u8 product_id[16];
290 	u8 revision[4];
291 	u64 capacity;
292 	u32 block_size;
293 	u8 dev_type;
294 	u8 dev_status;
295 	u8 member_state;
296 	u8 operation;
297 	u8 op_status;
298 	u8 progress;
299 	u16 ses_dev_index;
300 	u8 serial_no[32];
301 	union {
302 		u16 target_id;
303 		u16 features_mask;
304 	};
305 
306 	u16 lun;
307 	u16 features;
308 	u8 ses_element_id;
309 	u8 link_speed;
310 	u16 phys_target_id;
311 	u8 reserved[2];
312 
313 /* This is where fields specific to struct atto_vda_devinfo2 begin.  Note
314  * that the structure version started at one so applications that unionize this
315  * structure with atto_vda_dev_info can differentiate them if desired.
316  */
317 
318 	u8 version;
319 	#define VDADEVINFO_VERSION0         0x00
320 	#define VDADEVINFO_VERSION1         0x01
321 	#define VDADEVINFO_VERSION2         0x02
322 	#define VDADEVINFO_VERSION3         0x03
323 	#define VDADEVINFO_VERSION          VDADEVINFO_VERSION3
324 
325 	u8 reserved2[3];
326 
327 	/* sector scanning fields */
328 
329 	u32 ss_curr_errors;
330 	u64 ss_curr_scanned;
331 	u32 ss_curr_recvrd;
332 	u32 ss_scan_length;
333 	u32 ss_total_errors;
334 	u32 ss_total_recvrd;
335 	u32 ss_num_scans;
336 
337 	/* grp_name was added in version 2 of this structure. */
338 
339 	char grp_name[15];
340 	u8 reserved3[4];
341 
342 	/* dev_addr_list was added in version 3 of this structure. */
343 
344 	u8 num_dev_addr;
345 	struct atto_dev_addr2 dev_addr_list[8];
346 };
347 
348 
349 struct __packed atto_vda_grp_info {
350 	u8 grp_index;
351 	#define VDA_MAX_RAID_GROUPS         32
352 
353 	char grp_name[15];
354 	u64 capacity;
355 	u32 block_size;
356 	u32 interleave;
357 	u8 type;
358 	#define VDA_GRP_TYPE_RAID0          0
359 	#define VDA_GRP_TYPE_RAID1          1
360 	#define VDA_GRP_TYPE_RAID4          4
361 	#define VDA_GRP_TYPE_RAID5          5
362 	#define VDA_GRP_TYPE_RAID6          6
363 	#define VDA_GRP_TYPE_RAID10         10
364 	#define VDA_GRP_TYPE_RAID40         40
365 	#define VDA_GRP_TYPE_RAID50         50
366 	#define VDA_GRP_TYPE_RAID60         60
367 	#define VDA_GRP_TYPE_DVRAID_HS      252
368 	#define VDA_GRP_TYPE_DVRAID_NOHS    253
369 	#define VDA_GRP_TYPE_JBOD           254
370 	#define VDA_GRP_TYPE_SPARE          255
371 
372 	union {
373 		u8 status;
374 	    #define VDA_GRP_STAT_INVALID  0x00
375 	    #define VDA_GRP_STAT_NEW      0x01
376 	    #define VDA_GRP_STAT_WAITING  0x02
377 	    #define VDA_GRP_STAT_ONLINE   0x03
378 	    #define VDA_GRP_STAT_DEGRADED 0x04
379 	    #define VDA_GRP_STAT_OFFLINE  0x05
380 	    #define VDA_GRP_STAT_DELETED  0x06
381 	    #define VDA_GRP_STAT_RECOV_BASIC    0x07
382 	    #define VDA_GRP_STAT_RECOV_EXTREME  0x08
383 
384 		u8 op_ctrl;
385 	    #define VDA_GRP_OP_CTRL_START   0x01
386 	    #define VDA_GRP_OP_CTRL_HALT    0x02
387 	    #define VDA_GRP_OP_CTRL_RESUME  0x03
388 	    #define VDA_GRP_OP_CTRL_CANCEL  0x04
389 	};
390 
391 	u8 rebuild_state;
392 	#define VDA_RBLD_NONE      0x00
393 	#define VDA_RBLD_REBUILD   0x01
394 	#define VDA_RBLD_ERASE     0x02
395 	#define VDA_RBLD_PATTERN   0x03
396 	#define VDA_RBLD_CONV      0x04
397 	#define VDA_RBLD_FULL_INIT 0x05
398 	#define VDA_RBLD_QUICK_INIT 0x06
399 	#define VDA_RBLD_SECT_SCAN 0x07
400 	#define VDA_RBLD_SECT_SCAN_PARITY     0x08
401 	#define VDA_RBLD_SECT_SCAN_PARITY_FIX 0x09
402 	#define VDA_RBLD_RECOV_REBUILD 0x0A
403 	#define VDA_RBLD_RECOV_BASIC   0x0B
404 	#define VDA_RBLD_RECOV_EXTREME 0x0C
405 
406 	u8 span_depth;
407 	u8 progress;
408 	u8 mirror_width;
409 	u8 stripe_width;
410 	u8 member_cnt;
411 
412 	union {
413 		u16 members[32];
414 	#define VDA_MEMBER_MISSING  0xFFFF
415 	#define VDA_MEMBER_NEW      0xFFFE
416 		u16 features_mask;
417 	};
418 
419 	u16 features;
420 	#define VDA_GRP_FEAT_HOTSWAP    0x0001
421 	#define VDA_GRP_FEAT_SPDRD_MASK 0x0006
422 	#define VDA_GRP_FEAT_SPDRD_DIS  0x0000
423 	#define VDA_GRP_FEAT_SPDRD_ENB  0x0002
424 	#define VDA_GRP_FEAT_SPDRD_AUTO 0x0004
425 	#define VDA_GRP_FEAT_IDENT      0x0008
426 	#define VDA_GRP_FEAT_RBLDPRI_MASK 0x0030
427 	#define VDA_GRP_FEAT_RBLDPRI_LOW  0x0010
428 	#define VDA_GRP_FEAT_RBLDPRI_SAME 0x0020
429 	#define VDA_GRP_FEAT_RBLDPRI_HIGH 0x0030
430 	#define VDA_GRP_FEAT_WRITE_CACHE  0x0040
431 	#define VDA_GRP_FEAT_RBLD_RESUME  0x0080
432 	#define VDA_GRP_FEAT_SECT_RESUME  0x0100
433 	#define VDA_GRP_FEAT_INIT_RESUME  0x0200
434 	#define VDA_GRP_FEAT_SSD          0x0400
435 	#define VDA_GRP_FEAT_BOOT_DEV     0x0800
436 
437 	/*
438 	 * for backward compatibility, a prefetch value of zero means the
439 	 * setting is ignored/unsupported.  therefore, the firmware supported
440 	 * 0-6 values are incremented to 1-7.
441 	 */
442 
443 	u8 prefetch;
444 	u8 op_status;
445 	#define VDAGRPOPSTAT_MASK       0x0F
446 	#define VDAGRPOPSTAT_INVALID    0x00
447 	#define VDAGRPOPSTAT_OK         0x01
448 	#define VDAGRPOPSTAT_FAULTED    0x02
449 	#define VDAGRPOPSTAT_HALTED     0x03
450 	#define VDAGRPOPSTAT_INT        0x04
451 	#define VDAGRPOPPROC_MASK       0xF0
452 	#define VDAGRPOPPROC_STARTABLE  0x10
453 	#define VDAGRPOPPROC_CANCELABLE 0x20
454 	#define VDAGRPOPPROC_RESUMABLE  0x40
455 	#define VDAGRPOPPROC_HALTABLE   0x80
456 	u8 over_provision;
457 	u8 reserved[3];
458 
459 };
460 
461 
462 struct __packed atto_vdapart_info {
463 	u8 part_no;
464 	#define VDA_MAX_PARTITIONS   128
465 
466 	char grp_name[15];
467 	u64 part_size;
468 	u64 start_lba;
469 	u32 block_size;
470 	u16 target_id;
471 	u8 LUN;
472 	char serial_no[41];
473 	u8 features;
474 	#define VDAPI_FEAT_WRITE_CACHE   0x01
475 
476 	u8 reserved[7];
477 };
478 
479 
480 struct __packed atto_vda_dh_info {
481 	u8 req_type;
482 	#define VDADH_RQTYPE_CACHE      0x01
483 	#define VDADH_RQTYPE_FETCH      0x02
484 	#define VDADH_RQTYPE_SET_STAT   0x03
485 	#define VDADH_RQTYPE_GET_STAT   0x04
486 
487 	u8 req_qual;
488 	#define VDADH_RQQUAL_SMART      0x01
489 	#define VDADH_RQQUAL_MEDDEF     0x02
490 	#define VDADH_RQQUAL_INFOEXC    0x04
491 
492 	u8 num_smart_attribs;
493 	u8 status;
494 	#define VDADH_STAT_DISABLE      0x00
495 	#define VDADH_STAT_ENABLE       0x01
496 
497 	u32 med_defect_cnt;
498 	u32 info_exc_cnt;
499 	u8 smart_status;
500 	#define VDADH_SMARTSTAT_OK      0x00
501 	#define VDADH_SMARTSTAT_ERR     0x01
502 
503 	u8 reserved[35];
504 	struct atto_vda_sge sge[1];
505 };
506 
507 
508 struct __packed atto_vda_dh_smart {
509 	u8 attrib_id;
510 	u8 current_val;
511 	u8 worst;
512 	u8 threshold;
513 	u8 raw_data[6];
514 	u8 raw_attrib_status;
515 	#define VDADHSM_RAWSTAT_PREFAIL_WARRANTY        0x01
516 	#define VDADHSM_RAWSTAT_ONLINE_COLLECTION       0x02
517 	#define VDADHSM_RAWSTAT_PERFORMANCE_ATTR        0x04
518 	#define VDADHSM_RAWSTAT_ERROR_RATE_ATTR         0x08
519 	#define VDADHSM_RAWSTAT_EVENT_COUNT_ATTR        0x10
520 	#define VDADHSM_RAWSTAT_SELF_PRESERVING_ATTR    0x20
521 
522 	u8 calc_attrib_status;
523 	#define VDADHSM_CALCSTAT_UNKNOWN                0x00
524 	#define VDADHSM_CALCSTAT_GOOD                   0x01
525 	#define VDADHSM_CALCSTAT_PREFAIL                0x02
526 	#define VDADHSM_CALCSTAT_OLDAGE                 0x03
527 
528 	u8 reserved[4];
529 };
530 
531 
532 struct __packed atto_vda_metrics_info {
533 	u8 data_version;
534 	#define VDAMET_VERSION0         0x00
535 	#define VDAMET_VERSION          VDAMET_VERSION0
536 
537 	u8 metrics_action;
538 	#define VDAMET_METACT_NONE      0x00
539 	#define VDAMET_METACT_START     0x01
540 	#define VDAMET_METACT_STOP      0x02
541 	#define VDAMET_METACT_RETRIEVE  0x03
542 	#define VDAMET_METACT_CLEAR     0x04
543 
544 	u8 test_action;
545 	#define VDAMET_TSTACT_NONE              0x00
546 	#define VDAMET_TSTACT_STRT_INIT         0x01
547 	#define VDAMET_TSTACT_STRT_READ         0x02
548 	#define VDAMET_TSTACT_STRT_VERIFY       0x03
549 	#define VDAMET_TSTACT_STRT_INIT_VERIFY  0x04
550 	#define VDAMET_TSTACT_STOP              0x05
551 
552 	u8 num_dev_indexes;
553 	#define VDAMET_ALL_DEVICES      0xFF
554 
555 	u16 dev_indexes[32];
556 	u8 reserved[12];
557 	struct atto_vda_sge sge[1];
558 };
559 
560 
561 struct __packed atto_vda_metrics_data {
562 	u16 dev_index;
563 	u16 length;
564 	#define VDAMD_LEN_LAST          0x8000
565 	#define VDAMD_LEN_MASK          0x0FFF
566 
567 	u32 flags;
568 	#define VDAMDF_RUN          0x00000007
569 	#define VDAMDF_RUN_READ     0x00000001
570 	#define VDAMDF_RUN_WRITE    0x00000002
571 	#define VDAMDF_RUN_ALL      0x00000004
572 	#define VDAMDF_READ         0x00000010
573 	#define VDAMDF_WRITE        0x00000020
574 	#define VDAMDF_ALL          0x00000040
575 	#define VDAMDF_DRIVETEST    0x40000000
576 	#define VDAMDF_NEW          0x80000000
577 
578 	u64 total_read_data;
579 	u64 total_write_data;
580 	u64 total_read_io;
581 	u64 total_write_io;
582 	u64 read_start_time;
583 	u64 read_stop_time;
584 	u64 write_start_time;
585 	u64 write_stop_time;
586 	u64 read_maxio_time;
587 	u64 wpvdadmetricsdatarite_maxio_time;
588 	u64 read_totalio_time;
589 	u64 write_totalio_time;
590 	u64 read_total_errs;
591 	u64 write_total_errs;
592 	u64 read_recvrd_errs;
593 	u64 write_recvrd_errs;
594 	u64 miscompares;
595 };
596 
597 
598 struct __packed atto_vda_schedule_info {
599 	u8 schedule_type;
600 	#define VDASI_SCHTYPE_ONETIME   0x01
601 	#define VDASI_SCHTYPE_DAILY     0x02
602 	#define VDASI_SCHTYPE_WEEKLY    0x03
603 
604 	u8 operation;
605 	#define VDASI_OP_NONE           0x00
606 	#define VDASI_OP_CREATE         0x01
607 	#define VDASI_OP_CANCEL         0x02
608 
609 	u8 hour;
610 	u8 minute;
611 	u8 day;
612 	#define VDASI_DAY_NONE          0x00
613 
614 	u8 progress;
615 	#define VDASI_PROG_NONE         0xFF
616 
617 	u8 event_type;
618 	#define VDASI_EVTTYPE_SECT_SCAN             0x01
619 	#define VDASI_EVTTYPE_SECT_SCAN_PARITY      0x02
620 	#define VDASI_EVTTYPE_SECT_SCAN_PARITY_FIX  0x03
621 
622 	u8 recurrences;
623 	#define VDASI_RECUR_FOREVER     0x00
624 
625 	u32 id;
626 	#define VDASI_ID_NONE           0x00
627 
628 	char grp_name[15];
629 	u8 reserved[85];
630 };
631 
632 
633 struct __packed atto_vda_n_vcache_info {
634 	u8 super_cap_status;
635 	#define VDANVCI_SUPERCAP_NOT_PRESENT       0x00
636 	#define VDANVCI_SUPERCAP_FULLY_CHARGED     0x01
637 	#define VDANVCI_SUPERCAP_NOT_CHARGED       0x02
638 
639 	u8 nvcache_module_status;
640 	#define VDANVCI_NVCACHEMODULE_NOT_PRESENT  0x00
641 	#define VDANVCI_NVCACHEMODULE_PRESENT      0x01
642 
643 	u8 protection_mode;
644 	#define VDANVCI_PROTMODE_HI_PROTECT        0x00
645 	#define VDANVCI_PROTMODE_HI_PERFORM        0x01
646 
647 	u8 reserved[109];
648 };
649 
650 
651 struct __packed atto_vda_buzzer_info {
652 	u8 status;
653 	#define VDABUZZI_BUZZER_OFF           0x00
654 	#define VDABUZZI_BUZZER_ON            0x01
655 	#define VDABUZZI_BUZZER_LAST          0x02
656 
657 	u8 reserved[3];
658 	u32 duration;
659 	#define VDABUZZI_DURATION_INDEFINITE  0xffffffff
660 
661 	u8 reserved2[104];
662 };
663 
664 
665 struct  __packed atto_vda_adapter_info {
666 	u8 version;
667 	#define VDAADAPINFO_VERSION0         0x00
668 	#define VDAADAPINFO_VERSION          VDAADAPINFO_VERSION0
669 
670 	u8 reserved;
671 	signed short utc_offset;
672 	u32 utc_time;
673 	u32 features;
674 	#define VDA_ADAP_FEAT_IDENT     0x0001
675 	#define VDA_ADAP_FEAT_BUZZ_ERR  0x0002
676 	#define VDA_ADAP_FEAT_UTC_TIME  0x0004
677 
678 	u32 valid_features;
679 	char active_config[33];
680 	u8 temp_count;
681 	u8 fan_count;
682 	u8 reserved3[61];
683 };
684 
685 
686 struct __packed atto_vda_temp_info {
687 	u8 temp_index;
688 	u8 max_op_temp;
689 	u8 min_op_temp;
690 	u8 op_temp_warn;
691 	u8 temperature;
692 	u8 type;
693 	#define VDA_TEMP_TYPE_CPU  1
694 
695 	u8 reserved[106];
696 };
697 
698 
699 struct __packed atto_vda_fan_info {
700 	u8 fan_index;
701 	u8 status;
702 	#define VDA_FAN_STAT_UNKNOWN 0
703 	#define VDA_FAN_STAT_NORMAL  1
704 	#define VDA_FAN_STAT_FAIL    2
705 
706 	u16 crit_pvdafaninfothreshold;
707 	u16 warn_threshold;
708 	u16 speed;
709 	u8 reserved[104];
710 };
711 
712 
713 /* VDA management commands */
714 
715 #define VDAMGT_DEV_SCAN         0x00
716 #define VDAMGT_DEV_INFO         0x01
717 #define VDAMGT_DEV_CLEAN        0x02
718 #define VDAMGT_DEV_IDENTIFY     0x03
719 #define VDAMGT_DEV_IDENTSTOP    0x04
720 #define VDAMGT_DEV_PT_INFO      0x05
721 #define VDAMGT_DEV_FEATURES     0x06
722 #define VDAMGT_DEV_PT_FEATURES  0x07
723 #define VDAMGT_DEV_HEALTH_REQ   0x08
724 #define VDAMGT_DEV_METRICS      0x09
725 #define VDAMGT_DEV_INFO2        0x0A
726 #define VDAMGT_DEV_OPERATION    0x0B
727 #define VDAMGT_DEV_INFO2_BYADDR 0x0C
728 #define VDAMGT_GRP_INFO         0x10
729 #define VDAMGT_GRP_CREATE       0x11
730 #define VDAMGT_GRP_DELETE       0x12
731 #define VDAMGT_ADD_STORAGE      0x13
732 #define VDAMGT_MEMBER_ADD       0x14
733 #define VDAMGT_GRP_COMMIT       0x15
734 #define VDAMGT_GRP_REBUILD      0x16
735 #define VDAMGT_GRP_COMMIT_INIT  0x17
736 #define VDAMGT_QUICK_RAID       0x18
737 #define VDAMGT_GRP_FEATURES     0x19
738 #define VDAMGT_GRP_COMMIT_INIT_AUTOMAP  0x1A
739 #define VDAMGT_QUICK_RAID_INIT_AUTOMAP  0x1B
740 #define VDAMGT_GRP_OPERATION    0x1C
741 #define VDAMGT_CFG_SAVE         0x20
742 #define VDAMGT_LAST_ERROR       0x21
743 #define VDAMGT_ADAP_INFO        0x22
744 #define VDAMGT_ADAP_FEATURES    0x23
745 #define VDAMGT_TEMP_INFO        0x24
746 #define VDAMGT_FAN_INFO         0x25
747 #define VDAMGT_PART_INFO        0x30
748 #define VDAMGT_PART_MAP         0x31
749 #define VDAMGT_PART_UNMAP       0x32
750 #define VDAMGT_PART_AUTOMAP     0x33
751 #define VDAMGT_PART_SPLIT       0x34
752 #define VDAMGT_PART_MERGE       0x35
753 #define VDAMGT_SPARE_LIST       0x40
754 #define VDAMGT_SPARE_ADD        0x41
755 #define VDAMGT_SPARE_REMOVE     0x42
756 #define VDAMGT_LOCAL_SPARE_ADD  0x43
757 #define VDAMGT_SCHEDULE_EVENT   0x50
758 #define VDAMGT_SCHEDULE_INFO    0x51
759 #define VDAMGT_NVCACHE_INFO     0x60
760 #define VDAMGT_NVCACHE_SET      0x61
761 #define VDAMGT_BUZZER_INFO      0x70
762 #define VDAMGT_BUZZER_SET       0x71
763 
764 
765 struct __packed atto_vda_ae_hdr {
766 	u8 bylength;
767 	u8 byflags;
768 	#define VDAAE_HDRF_EVENT_ACK    0x01
769 
770 	u8 byversion;
771 	#define VDAAE_HDR_VER_0         0
772 
773 	u8 bytype;
774 	#define VDAAE_HDR_TYPE_RAID     1
775 	#define VDAAE_HDR_TYPE_LU       2
776 	#define VDAAE_HDR_TYPE_DISK     3
777 	#define VDAAE_HDR_TYPE_RESET    4
778 	#define VDAAE_HDR_TYPE_LOG_INFO 5
779 	#define VDAAE_HDR_TYPE_LOG_WARN 6
780 	#define VDAAE_HDR_TYPE_LOG_CRIT 7
781 	#define VDAAE_HDR_TYPE_LOG_FAIL 8
782 	#define VDAAE_HDR_TYPE_NVC      9
783 	#define VDAAE_HDR_TYPE_TLG_INFO 10
784 	#define VDAAE_HDR_TYPE_TLG_WARN 11
785 	#define VDAAE_HDR_TYPE_TLG_CRIT 12
786 	#define VDAAE_HDR_TYPE_PWRMGT   13
787 	#define VDAAE_HDR_TYPE_MUTE     14
788 	#define VDAAE_HDR_TYPE_DEV      15
789 };
790 
791 
792 struct  __packed atto_vda_ae_raid {
793 	struct atto_vda_ae_hdr hdr;
794 	u32 dwflags;
795 	#define VDAAE_GROUP_STATE   0x00000001
796 	#define VDAAE_RBLD_STATE    0x00000002
797 	#define VDAAE_RBLD_PROG     0x00000004
798 	#define VDAAE_MEMBER_CHG    0x00000008
799 	#define VDAAE_PART_CHG      0x00000010
800 	#define VDAAE_MEM_STATE_CHG 0x00000020
801 
802 	u8 bygroup_state;
803 	#define VDAAE_RAID_INVALID  0
804 	#define VDAAE_RAID_NEW      1
805 	#define VDAAE_RAID_WAITING  2
806 	#define VDAAE_RAID_ONLINE   3
807 	#define VDAAE_RAID_DEGRADED 4
808 	#define VDAAE_RAID_OFFLINE  5
809 	#define VDAAE_RAID_DELETED  6
810 	#define VDAAE_RAID_BASIC    7
811 	#define VDAAE_RAID_EXTREME  8
812 	#define VDAAE_RAID_UNKNOWN  9
813 
814 	u8 byrebuild_state;
815 	#define VDAAE_RBLD_NONE       0
816 	#define VDAAE_RBLD_REBUILD    1
817 	#define VDAAE_RBLD_ERASE      2
818 	#define VDAAE_RBLD_PATTERN    3
819 	#define VDAAE_RBLD_CONV       4
820 	#define VDAAE_RBLD_FULL_INIT  5
821 	#define VDAAE_RBLD_QUICK_INIT 6
822 	#define VDAAE_RBLD_SECT_SCAN  7
823 	#define VDAAE_RBLD_SECT_SCAN_PARITY     8
824 	#define VDAAE_RBLD_SECT_SCAN_PARITY_FIX 9
825 	#define VDAAE_RBLD_RECOV_REBUILD 10
826 	#define VDAAE_RBLD_UNKNOWN    11
827 
828 	u8 byrebuild_progress;
829 	u8 op_status;
830 	#define VDAAE_GRPOPSTAT_MASK       0x0F
831 	#define VDAAE_GRPOPSTAT_INVALID    0x00
832 	#define VDAAE_GRPOPSTAT_OK         0x01
833 	#define VDAAE_GRPOPSTAT_FAULTED    0x02
834 	#define VDAAE_GRPOPSTAT_HALTED     0x03
835 	#define VDAAE_GRPOPSTAT_INT        0x04
836 	#define VDAAE_GRPOPPROC_MASK       0xF0
837 	#define VDAAE_GRPOPPROC_STARTABLE  0x10
838 	#define VDAAE_GRPOPPROC_CANCELABLE 0x20
839 	#define VDAAE_GRPOPPROC_RESUMABLE  0x40
840 	#define VDAAE_GRPOPPROC_HALTABLE   0x80
841 	char acname[15];
842 	u8 byreserved;
843 	u8 byreserved2[0x80 - 0x1C];
844 };
845 
846 
847 struct __packed atto_vda_ae_lu_tgt_lun {
848 	u16 wtarget_id;
849 	u8 bylun;
850 	u8 byreserved;
851 };
852 
853 
854 struct __packed atto_vda_ae_lu_tgt_lun_raid {
855 	u16 wtarget_id;
856 	u8 bylun;
857 	u8 byreserved;
858 	u32 dwinterleave;
859 	u32 dwblock_size;
860 };
861 
862 
863 struct __packed atto_vda_ae_lu {
864 	struct atto_vda_ae_hdr hdr;
865 	u32 dwevent;
866 	#define VDAAE_LU_DISC        0x00000001
867 	#define VDAAE_LU_LOST        0x00000002
868 	#define VDAAE_LU_STATE       0x00000004
869 	#define VDAAE_LU_PASSTHROUGH 0x10000000
870 	#define VDAAE_LU_PHYS_ID     0x20000000
871 
872 	u8 bystate;
873 	#define VDAAE_LU_UNDEFINED        0
874 	#define VDAAE_LU_NOT_PRESENT      1
875 	#define VDAAE_LU_OFFLINE          2
876 	#define VDAAE_LU_ONLINE           3
877 	#define VDAAE_LU_DEGRADED         4
878 	#define VDAAE_LU_FACTORY_DISABLED 5
879 	#define VDAAE_LU_DELETED          6
880 	#define VDAAE_LU_BUSSCAN          7
881 	#define VDAAE_LU_UNKNOWN          8
882 
883 	u8 byreserved;
884 	u16 wphys_target_id;
885 
886 	union {
887 		struct atto_vda_ae_lu_tgt_lun tgtlun;
888 		struct atto_vda_ae_lu_tgt_lun_raid tgtlun_raid;
889 	} id;
890 };
891 
892 
893 struct __packed atto_vda_ae_disk {
894 	struct atto_vda_ae_hdr hdr;
895 };
896 
897 
898 #define VDAAE_LOG_STRSZ 64
899 
900 struct __packed atto_vda_ae_log {
901 	struct atto_vda_ae_hdr hdr;
902 	char aclog_ascii[VDAAE_LOG_STRSZ];
903 };
904 
905 
906 #define VDAAE_TLG_STRSZ 56
907 
908 struct __packed atto_vda_ae_timestamp_log {
909 	struct atto_vda_ae_hdr hdr;
910 	u32 dwtimestamp;
911 	char aclog_ascii[VDAAE_TLG_STRSZ];
912 };
913 
914 
915 struct __packed atto_vda_ae_nvc {
916 	struct atto_vda_ae_hdr hdr;
917 };
918 
919 
920 struct __packed atto_vda_ae_dev {
921 	struct atto_vda_ae_hdr hdr;
922 	struct atto_dev_addr devaddr;
923 };
924 
925 
926 union atto_vda_ae {
927 	struct atto_vda_ae_hdr hdr;
928 	struct atto_vda_ae_disk disk;
929 	struct atto_vda_ae_lu lu;
930 	struct atto_vda_ae_raid raid;
931 	struct atto_vda_ae_log log;
932 	struct atto_vda_ae_timestamp_log tslog;
933 	struct atto_vda_ae_nvc nvcache;
934 	struct atto_vda_ae_dev dev;
935 };
936 
937 
938 struct __packed atto_vda_date_and_time {
939 	u8 flags;
940 	#define VDA_DT_DAY_MASK   0x07
941 	#define VDA_DT_DAY_NONE   0x00
942 	#define VDA_DT_DAY_SUN    0x01
943 	#define VDA_DT_DAY_MON    0x02
944 	#define VDA_DT_DAY_TUE    0x03
945 	#define VDA_DT_DAY_WED    0x04
946 	#define VDA_DT_DAY_THU    0x05
947 	#define VDA_DT_DAY_FRI    0x06
948 	#define VDA_DT_DAY_SAT    0x07
949 	#define VDA_DT_PM         0x40
950 	#define VDA_DT_MILITARY   0x80
951 
952 	u8 seconds;
953 	u8 minutes;
954 	u8 hours;
955 	u8 day;
956 	u8 month;
957 	u16 year;
958 };
959 
960 #define SGE_LEN_LIMIT   0x003FFFFF      /*! mask of segment length            */
961 #define SGE_LEN_MAX     0x003FF000      /*! maximum segment length            */
962 #define SGE_LAST        0x01000000      /*! last entry                        */
963 #define SGE_ADDR_64     0x04000000      /*! 64-bit addressing flag            */
964 #define SGE_CHAIN       0x80000000      /*! chain descriptor flag             */
965 #define SGE_CHAIN_LEN   0x0000FFFF      /*! mask of length in chain entries   */
966 #define SGE_CHAIN_SZ    0x00FF0000      /*! mask of size of chained buffer    */
967 
968 
969 struct __packed atto_vda_cfg_init {
970 	struct atto_vda_date_and_time date_time;
971 	u32 sgl_page_size;
972 	u32 vda_version;
973 	u32 fw_version;
974 	u32 fw_build;
975 	u32 fw_release;
976 	u32 epoch_time;
977 	u32 ioctl_tunnel;
978 	#define VDA_ITF_MEM_RW           0x00000001
979 	#define VDA_ITF_TRACE            0x00000002
980 	#define VDA_ITF_SCSI_PASS_THRU   0x00000004
981 	#define VDA_ITF_GET_DEV_ADDR     0x00000008
982 	#define VDA_ITF_PHY_CTRL         0x00000010
983 	#define VDA_ITF_CONN_CTRL        0x00000020
984 	#define VDA_ITF_GET_DEV_INFO     0x00000040
985 
986 	u32 num_targets_backend;
987 	u8 reserved[0x48];
988 };
989 
990 
991 /* configuration commands */
992 
993 #define VDA_CFG_INIT          0x00
994 #define VDA_CFG_GET_INIT      0x01
995 #define VDA_CFG_GET_INIT2     0x02
996 
997 
998 /*! physical region descriptor (PRD) aka scatter/gather entry */
999 
1000 struct __packed atto_physical_region_description {
1001 	u64 address;
1002 	u32 ctl_len;
1003 	#define PRD_LEN_LIMIT       0x003FFFFF
1004 	#define PRD_LEN_MAX         0x003FF000
1005 	#define PRD_NXT_PRD_CNT     0x0000007F
1006 	#define PRD_CHAIN           0x01000000
1007 	#define PRD_DATA            0x00000000
1008 	#define PRD_INT_SEL         0xF0000000
1009 	  #define PRD_INT_SEL_F0    0x00000000
1010 	  #define PRD_INT_SEL_F1    0x40000000
1011 	  #define PRD_INT_SEL_F2    0x80000000
1012 	  #define PRD_INT_SEL_F3    0xc0000000
1013 	  #define PRD_INT_SEL_SRAM  0x10000000
1014 	  #define PRD_INT_SEL_PBSR  0x20000000
1015 
1016 };
1017 
1018 /* Request types. NOTE that ALL requests have the same layout for the first
1019  * few bytes.
1020  */
1021 struct __packed atto_vda_req_header {
1022 	u32 length;
1023 	u8 function;
1024 	u8 variable1;
1025 	u8 chain_offset;
1026 	u8 sg_list_offset;
1027 	u32 handle;
1028 };
1029 
1030 
1031 #define FCP_CDB_SIZE    16
1032 
1033 struct __packed atto_vda_scsi_req {
1034 	u32 length;
1035 	u8 function;  /* VDA_FUNC_SCSI */
1036 	u8 sense_len;
1037 	u8 chain_offset;
1038 	u8 sg_list_offset;
1039 	u32 handle;
1040 	u32 flags;
1041      #define FCP_CMND_LUN_MASK    0x000000FF
1042      #define FCP_CMND_TA_MASK     0x00000700
1043       #define FCP_CMND_TA_SIMPL_Q 0x00000000
1044       #define FCP_CMND_TA_HEAD_Q  0x00000100
1045       #define FCP_CMND_TA_ORDRD_Q 0x00000200
1046       #define FCP_CMND_TA_ACA     0x00000400
1047      #define FCP_CMND_PRI_MASK    0x00007800
1048      #define FCP_CMND_TM_MASK     0x00FF0000
1049       #define FCP_CMND_ATS        0x00020000
1050       #define FCP_CMND_CTS        0x00040000
1051       #define FCP_CMND_LRS        0x00100000
1052       #define FCP_CMND_TRS        0x00200000
1053       #define FCP_CMND_CLA        0x00400000
1054       #define FCP_CMND_TRM        0x00800000
1055      #define FCP_CMND_DATA_DIR    0x03000000
1056       #define FCP_CMND_WRD        0x01000000
1057       #define FCP_CMND_RDD        0x02000000
1058 
1059 	u8 cdb[FCP_CDB_SIZE];
1060 	union {
1061 		struct __packed {
1062 			u64 ppsense_buf;
1063 			u16 target_id;
1064 			u8 iblk_cnt_prd;
1065 			u8 reserved;
1066 		};
1067 
1068 		struct atto_physical_region_description sense_buff_prd;
1069 	};
1070 
1071 	union {
1072 		struct atto_vda_sge sge[1];
1073 
1074 		u32 abort_handle;
1075 		u32 dwords[245];
1076 		struct atto_physical_region_description prd[1];
1077 	} u;
1078 };
1079 
1080 
1081 struct __packed atto_vda_flash_req {
1082 	u32 length;
1083 	u8 function; /* VDA_FUNC_FLASH */
1084 	u8 sub_func;
1085 	u8 chain_offset;
1086 	u8 sg_list_offset;
1087 	u32 handle;
1088 	u32 flash_addr;
1089 	u8 checksum;
1090 	u8 rsvd[3];
1091 
1092 	union {
1093 		struct {
1094 			char file_name[16]; /* 8.3 fname, NULL term, wc=* */
1095 			struct atto_vda_sge sge[1];
1096 		} file;
1097 
1098 		struct atto_vda_sge sge[1];
1099 		struct atto_physical_region_description prde[2];
1100 	} data;
1101 };
1102 
1103 
1104 struct __packed atto_vda_diag_req {
1105 	u32 length;
1106 	u8 function; /* VDA_FUNC_DIAG */
1107 	u8 sub_func;
1108 	#define VDA_DIAG_STATUS   0x00
1109 	#define VDA_DIAG_RESET    0x01
1110 	#define VDA_DIAG_PAUSE    0x02
1111 	#define VDA_DIAG_RESUME   0x03
1112 	#define VDA_DIAG_READ     0x04
1113 	#define VDA_DIAG_WRITE    0x05
1114 
1115 	u8 chain_offset;
1116 	u8 sg_list_offset;
1117 	u32 handle;
1118 	u32 rsvd;
1119 	u64 local_addr;
1120 	struct atto_vda_sge sge[1];
1121 };
1122 
1123 
1124 struct __packed atto_vda_ae_req {
1125 	u32 length;
1126 	u8 function; /* VDA_FUNC_AE */
1127 	u8 reserved1;
1128 	u8 chain_offset;
1129 	u8 sg_list_offset;
1130 	u32 handle;
1131 
1132 	union {
1133 		struct atto_vda_sge sge[1];
1134 		struct atto_physical_region_description prde[1];
1135 	};
1136 };
1137 
1138 
1139 struct __packed atto_vda_cli_req {
1140 	u32 length;
1141 	u8 function; /* VDA_FUNC_CLI */
1142 	u8 reserved1;
1143 	u8 chain_offset;
1144 	u8 sg_list_offset;
1145 	u32 handle;
1146 	u32 cmd_rsp_len;
1147 	struct atto_vda_sge sge[1];
1148 };
1149 
1150 
1151 struct __packed atto_vda_ioctl_req {
1152 	u32 length;
1153 	u8 function; /* VDA_FUNC_IOCTL */
1154 	u8 sub_func;
1155 	u8 chain_offset;
1156 	u8 sg_list_offset;
1157 	u32 handle;
1158 
1159 	union {
1160 		struct atto_vda_sge reserved_sge;
1161 		struct atto_physical_region_description reserved_prde;
1162 	};
1163 
1164 	union {
1165 		struct {
1166 			u32 ctrl_code;
1167 			u16 target_id;
1168 			u8 lun;
1169 			u8 reserved;
1170 		} csmi;
1171 	};
1172 
1173 	union {
1174 		struct atto_vda_sge sge[1];
1175 		struct atto_physical_region_description prde[1];
1176 	};
1177 };
1178 
1179 
1180 struct __packed atto_vda_cfg_req {
1181 	u32 length;
1182 	u8 function; /* VDA_FUNC_CFG */
1183 	u8 sub_func;
1184 	u8 rsvd1;
1185 	u8 sg_list_offset;
1186 	u32 handle;
1187 
1188 	union {
1189 		u8 bytes[116];
1190 		struct atto_vda_cfg_init init;
1191 		struct atto_vda_sge sge;
1192 		struct atto_physical_region_description prde;
1193 	} data;
1194 };
1195 
1196 
1197 struct __packed atto_vda_mgmt_req {
1198 	u32 length;
1199 	u8 function; /* VDA_FUNC_MGT */
1200 	u8 mgt_func;
1201 	u8 chain_offset;
1202 	u8 sg_list_offset;
1203 	u32 handle;
1204 	u8 scan_generation;
1205 	u8 payld_sglst_offset;
1206 	u16 dev_index;
1207 	u32 payld_length;
1208 	u32 pad;
1209 	union {
1210 		struct atto_vda_sge sge[2];
1211 		struct atto_physical_region_description prde[2];
1212 	};
1213 	struct atto_vda_sge payld_sge[1];
1214 };
1215 
1216 
1217 union atto_vda_req {
1218 	struct atto_vda_scsi_req scsi;
1219 	struct atto_vda_flash_req flash;
1220 	struct atto_vda_diag_req diag;
1221 	struct atto_vda_ae_req ae;
1222 	struct atto_vda_cli_req cli;
1223 	struct atto_vda_ioctl_req ioctl;
1224 	struct atto_vda_cfg_req cfg;
1225 	struct atto_vda_mgmt_req mgt;
1226 	u8 bytes[1024];
1227 };
1228 
1229 /* Outbound response structures */
1230 
1231 struct __packed atto_vda_scsi_rsp {
1232 	u8 scsi_stat;
1233 	u8 sense_len;
1234 	u8 rsvd[2];
1235 	u32 residual_length;
1236 };
1237 
1238 struct __packed atto_vda_flash_rsp {
1239 	u32 file_size;
1240 };
1241 
1242 struct __packed atto_vda_ae_rsp {
1243 	u32 length;
1244 };
1245 
1246 struct __packed atto_vda_cli_rsp {
1247 	u32 cmd_rsp_len;
1248 };
1249 
1250 struct __packed atto_vda_ioctl_rsp {
1251 	union {
1252 		struct {
1253 			u32 csmi_status;
1254 			u16 target_id;
1255 			u8 lun;
1256 			u8 reserved;
1257 		} csmi;
1258 	};
1259 };
1260 
1261 struct __packed atto_vda_cfg_rsp {
1262 	u16 vda_version;
1263 	u16 fw_release;
1264 	u32 fw_build;
1265 };
1266 
1267 struct __packed atto_vda_mgmt_rsp {
1268 	u32 length;
1269 	u16 dev_index;
1270 	u8 scan_generation;
1271 };
1272 
1273 union atto_vda_func_rsp {
1274 	struct atto_vda_scsi_rsp scsi_rsp;
1275 	struct atto_vda_flash_rsp flash_rsp;
1276 	struct atto_vda_ae_rsp ae_rsp;
1277 	struct atto_vda_cli_rsp cli_rsp;
1278 	struct atto_vda_ioctl_rsp ioctl_rsp;
1279 	struct atto_vda_cfg_rsp cfg_rsp;
1280 	struct atto_vda_mgmt_rsp mgt_rsp;
1281 	u32 dwords[2];
1282 };
1283 
1284 struct __packed atto_vda_ob_rsp {
1285 	u32 handle;
1286 	u8 req_stat;
1287 	u8 rsvd[3];
1288 
1289 	union atto_vda_func_rsp
1290 		func_rsp;
1291 };
1292 
1293 struct __packed atto_vda_ae_data {
1294 	u8 event_data[256];
1295 };
1296 
1297 struct __packed atto_vda_mgmt_data {
1298 	union {
1299 		u8 bytes[112];
1300 		struct atto_vda_devinfo dev_info;
1301 		struct atto_vda_grp_info grp_info;
1302 		struct atto_vdapart_info part_info;
1303 		struct atto_vda_dh_info dev_health_info;
1304 		struct atto_vda_metrics_info metrics_info;
1305 		struct atto_vda_schedule_info sched_info;
1306 		struct atto_vda_n_vcache_info nvcache_info;
1307 		struct atto_vda_buzzer_info buzzer_info;
1308 	} data;
1309 };
1310 
1311 union atto_vda_rsp_data {
1312 	struct atto_vda_ae_data ae_data;
1313 	struct atto_vda_mgmt_data mgt_data;
1314 	u8 sense_data[252];
1315 	#define SENSE_DATA_SZ   252;
1316 	u8 bytes[256];
1317 };
1318 
1319 #endif
1320