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