Back to home page

OSCL-LXR

 
 

    


0001 /*  linux/drivers/scsi/esas2r/atvda.h
0002  *       ATTO VDA interface definitions
0003  *
0004  *  Copyright (c) 2001-2013 ATTO Technology, Inc.
0005  *  (mailto:linuxdrivers@attotech.com)
0006  */
0007 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0008 /*
0009  *  This program is free software; you can redistribute it and/or modify
0010  *  it under the terms of the GNU General Public License as published by
0011  *  the Free Software Foundation; version 2 of the License.
0012  *
0013  *  This program is distributed in the hope that it will be useful,
0014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016  *  GNU General Public License for more details.
0017  *
0018  *  NO WARRANTY
0019  *  THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
0020  *  CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
0021  *  LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
0022  *  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
0023  *  solely responsible for determining the appropriateness of using and
0024  *  distributing the Program and assumes all risks associated with its
0025  *  exercise of rights under this Agreement, including but not limited to
0026  *  the risks and costs of program errors, damage to or loss of data,
0027  *  programs or equipment, and unavailability or interruption of operations.
0028  *
0029  *  DISCLAIMER OF LIABILITY
0030  *  NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
0031  *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0032  *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
0033  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
0034  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0035  *  USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
0036  *  HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
0037  *
0038  *  You should have received a copy of the GNU General Public License
0039  *  along with this program; if not, write to the Free Software
0040  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0041  */
0042 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0043 
0044 
0045 #ifndef ATVDA_H
0046 #define ATVDA_H
0047 
0048 struct __packed atto_dev_addr {
0049     u64 dev_port;
0050     u64 hba_port;
0051     u8 lun;
0052     u8 flags;
0053        #define VDA_DEVADDRF_SATA   0x01
0054        #define VDA_DEVADDRF_SSD    0x02
0055     u8 link_speed; /* VDALINKSPEED_xxx */
0056     u8 pad[1];
0057 };
0058 
0059 /* dev_addr2 was added for 64-bit alignment */
0060 
0061 struct __packed atto_dev_addr2 {
0062     u64 dev_port;
0063     u64 hba_port;
0064     u8 lun;
0065     u8 flags;
0066     u8 link_speed;
0067     u8 pad[5];
0068 };
0069 
0070 struct __packed atto_vda_sge {
0071     u32 length;
0072     u64 address;
0073 };
0074 
0075 
0076 /* VDA request function codes */
0077 
0078 #define VDA_FUNC_SCSI     0x00
0079 #define VDA_FUNC_FLASH    0x01
0080 #define VDA_FUNC_DIAG     0x02
0081 #define VDA_FUNC_AE       0x03
0082 #define VDA_FUNC_CLI      0x04
0083 #define VDA_FUNC_IOCTL    0x05
0084 #define VDA_FUNC_CFG      0x06
0085 #define VDA_FUNC_MGT      0x07
0086 #define VDA_FUNC_GSV      0x08
0087 
0088 
0089 /* VDA request status values.  for host driver considerations, values for
0090  * SCSI requests start at zero.  other requests may use these values as well. */
0091 
0092 #define RS_SUCCESS          0x00        /*! successful completion            */
0093 #define RS_INV_FUNC         0x01        /*! invalid command function         */
0094 #define RS_BUSY             0x02        /*! insufficient resources           */
0095 #define RS_SEL              0x03        /*! no target at target_id           */
0096 #define RS_NO_LUN           0x04        /*! invalid LUN                      */
0097 #define RS_TIMEOUT          0x05        /*! request timeout                  */
0098 #define RS_OVERRUN          0x06        /*! data overrun                     */
0099 #define RS_UNDERRUN         0x07        /*! data underrun                    */
0100 #define RS_SCSI_ERROR       0x08        /*! SCSI error occurred              */
0101 #define RS_ABORTED          0x0A        /*! command aborted                  */
0102 #define RS_RESID_MISM       0x0B        /*! residual length incorrect        */
0103 #define RS_TM_FAILED        0x0C        /*! task management failed           */
0104 #define RS_RESET            0x0D        /*! aborted due to bus reset         */
0105 #define RS_ERR_DMA_SG       0x0E        /*! error reading SG list            */
0106 #define RS_ERR_DMA_DATA     0x0F        /*! error transferring data          */
0107 #define RS_UNSUPPORTED      0x10        /*! unsupported request              */
0108 #define RS_SEL2             0x70        /*! internal generated RS_SEL        */
0109 #define RS_VDA_BASE         0x80        /*! base of VDA-specific errors      */
0110 #define RS_MGT_BASE         0x80        /*! base of VDA management errors    */
0111 #define RS_SCAN_FAIL        (RS_MGT_BASE + 0x00)
0112 #define RS_DEV_INVALID      (RS_MGT_BASE + 0x01)
0113 #define RS_DEV_ASSIGNED     (RS_MGT_BASE + 0x02)
0114 #define RS_DEV_REMOVE       (RS_MGT_BASE + 0x03)
0115 #define RS_DEV_LOST         (RS_MGT_BASE + 0x04)
0116 #define RS_SCAN_GEN         (RS_MGT_BASE + 0x05)
0117 #define RS_GRP_INVALID      (RS_MGT_BASE + 0x08)
0118 #define RS_GRP_EXISTS       (RS_MGT_BASE + 0x09)
0119 #define RS_GRP_LIMIT        (RS_MGT_BASE + 0x0A)
0120 #define RS_GRP_INTLV        (RS_MGT_BASE + 0x0B)
0121 #define RS_GRP_SPAN         (RS_MGT_BASE + 0x0C)
0122 #define RS_GRP_TYPE         (RS_MGT_BASE + 0x0D)
0123 #define RS_GRP_MEMBERS      (RS_MGT_BASE + 0x0E)
0124 #define RS_GRP_COMMIT       (RS_MGT_BASE + 0x0F)
0125 #define RS_GRP_REBUILD      (RS_MGT_BASE + 0x10)
0126 #define RS_GRP_REBUILD_TYPE (RS_MGT_BASE + 0x11)
0127 #define RS_GRP_BLOCK_SIZE   (RS_MGT_BASE + 0x12)
0128 #define RS_CFG_SAVE         (RS_MGT_BASE + 0x14)
0129 #define RS_PART_LAST        (RS_MGT_BASE + 0x18)
0130 #define RS_ELEM_INVALID     (RS_MGT_BASE + 0x19)
0131 #define RS_PART_MAPPED      (RS_MGT_BASE + 0x1A)
0132 #define RS_PART_TARGET      (RS_MGT_BASE + 0x1B)
0133 #define RS_PART_LUN         (RS_MGT_BASE + 0x1C)
0134 #define RS_PART_DUP         (RS_MGT_BASE + 0x1D)
0135 #define RS_PART_NOMAP       (RS_MGT_BASE + 0x1E)
0136 #define RS_PART_MAX         (RS_MGT_BASE + 0x1F)
0137 #define RS_PART_CAP         (RS_MGT_BASE + 0x20)
0138 #define RS_PART_STATE       (RS_MGT_BASE + 0x21)
0139 #define RS_TEST_IN_PROG     (RS_MGT_BASE + 0x22)
0140 #define RS_METRICS_ERROR    (RS_MGT_BASE + 0x23)
0141 #define RS_HS_ERROR         (RS_MGT_BASE + 0x24)
0142 #define RS_NO_METRICS_TEST  (RS_MGT_BASE + 0x25)
0143 #define RS_BAD_PARAM        (RS_MGT_BASE + 0x26)
0144 #define RS_GRP_MEMBER_SIZE  (RS_MGT_BASE + 0x27)
0145 #define RS_FLS_BASE         0xB0        /*! base of VDA errors               */
0146 #define RS_FLS_ERR_AREA     (RS_FLS_BASE + 0x00)
0147 #define RS_FLS_ERR_BUSY     (RS_FLS_BASE + 0x01)
0148 #define RS_FLS_ERR_RANGE    (RS_FLS_BASE + 0x02)
0149 #define RS_FLS_ERR_BEGIN    (RS_FLS_BASE + 0x03)
0150 #define RS_FLS_ERR_CHECK    (RS_FLS_BASE + 0x04)
0151 #define RS_FLS_ERR_FAIL     (RS_FLS_BASE + 0x05)
0152 #define RS_FLS_ERR_RSRC     (RS_FLS_BASE + 0x06)
0153 #define RS_FLS_ERR_NOFILE   (RS_FLS_BASE + 0x07)
0154 #define RS_FLS_ERR_FSIZE    (RS_FLS_BASE + 0x08)
0155 #define RS_CFG_BASE         0xC0        /*! base of VDA configuration errors */
0156 #define RS_CFG_ERR_BUSY     (RS_CFG_BASE + 0)
0157 #define RS_CFG_ERR_SGE      (RS_CFG_BASE + 1)
0158 #define RS_CFG_ERR_DATE     (RS_CFG_BASE + 2)
0159 #define RS_CFG_ERR_TIME     (RS_CFG_BASE + 3)
0160 #define RS_DEGRADED         0xFB        /*! degraded mode                    */
0161 #define RS_CLI_INTERNAL     0xFC        /*! VDA CLI internal error           */
0162 #define RS_VDA_INTERNAL     0xFD        /*! catch-all                        */
0163 #define RS_PENDING          0xFE        /*! pending, not started             */
0164 #define RS_STARTED          0xFF        /*! started                          */
0165 
0166 
0167 /* flash request subfunctions.  these are used in both the IOCTL and the
0168  * driver-firmware interface (VDA_FUNC_FLASH). */
0169 
0170 #define VDA_FLASH_BEGINW  0x00
0171 #define VDA_FLASH_READ    0x01
0172 #define VDA_FLASH_WRITE   0x02
0173 #define VDA_FLASH_COMMIT  0x03
0174 #define VDA_FLASH_CANCEL  0x04
0175 #define VDA_FLASH_INFO    0x05
0176 #define VDA_FLASH_FREAD   0x06
0177 #define VDA_FLASH_FWRITE  0x07
0178 #define VDA_FLASH_FINFO   0x08
0179 
0180 
0181 /* IOCTL request subfunctions.  these identify the payload type for
0182  * VDA_FUNC_IOCTL.
0183  */
0184 
0185 #define VDA_IOCTL_HBA     0x00
0186 #define VDA_IOCTL_CSMI    0x01
0187 #define VDA_IOCTL_SMP     0x02
0188 
0189 struct __packed atto_vda_devinfo {
0190     struct atto_dev_addr dev_addr;
0191     u8 vendor_id[8];
0192     u8 product_id[16];
0193     u8 revision[4];
0194     u64 capacity;
0195     u32 block_size;
0196     u8 dev_type;
0197 
0198     union {
0199         u8 dev_status;
0200         #define VDADEVSTAT_INVALID   0x00
0201         #define VDADEVSTAT_CORRUPT   VDADEVSTAT_INVALID
0202         #define VDADEVSTAT_ASSIGNED  0x01
0203         #define VDADEVSTAT_SPARE     0x02
0204         #define VDADEVSTAT_UNAVAIL   0x03
0205         #define VDADEVSTAT_PT_MAINT  0x04
0206         #define VDADEVSTAT_LCLSPARE  0x05
0207         #define VDADEVSTAT_UNUSEABLE 0x06
0208         #define VDADEVSTAT_AVAIL     0xFF
0209 
0210         u8 op_ctrl;
0211         #define VDA_DEV_OP_CTRL_START   0x01
0212         #define VDA_DEV_OP_CTRL_HALT    0x02
0213         #define VDA_DEV_OP_CTRL_RESUME  0x03
0214         #define VDA_DEV_OP_CTRL_CANCEL  0x04
0215     };
0216 
0217     u8 member_state;
0218     #define VDAMBRSTATE_ONLINE   0x00
0219     #define VDAMBRSTATE_DEGRADED 0x01
0220     #define VDAMBRSTATE_UNAVAIL  0x02
0221     #define VDAMBRSTATE_FAULTED  0x03
0222     #define VDAMBRSTATE_MISREAD  0x04
0223     #define VDAMBRSTATE_INCOMPAT 0x05
0224 
0225     u8 operation;
0226     #define VDAOP_NONE           0x00
0227     #define VDAOP_REBUILD        0x01
0228     #define VDAOP_ERASE          0x02
0229     #define VDAOP_PATTERN        0x03
0230     #define VDAOP_CONVERSION     0x04
0231     #define VDAOP_FULL_INIT      0x05
0232     #define VDAOP_QUICK_INIT     0x06
0233     #define VDAOP_SECT_SCAN      0x07
0234     #define VDAOP_SECT_SCAN_PARITY      0x08
0235     #define VDAOP_SECT_SCAN_PARITY_FIX  0x09
0236     #define VDAOP_RECOV_REBUILD  0x0A
0237 
0238     u8 op_status;
0239     #define VDAOPSTAT_OK         0x00
0240     #define VDAOPSTAT_FAULTED    0x01
0241     #define VDAOPSTAT_HALTED     0x02
0242     #define VDAOPSTAT_INT        0x03
0243 
0244     u8 progress; /* 0 - 100% */
0245     u16 ses_dev_index;
0246     #define VDASESDI_INVALID     0xFFFF
0247 
0248     u8 serial_no[32];
0249 
0250     union {
0251         u16 target_id;
0252     #define VDATGTID_INVALID     0xFFFF
0253 
0254         u16 features_mask;
0255     };
0256 
0257     u16 lun;
0258     u16 features;
0259     #define VDADEVFEAT_ENC_SERV  0x0001
0260     #define VDADEVFEAT_IDENT     0x0002
0261     #define VDADEVFEAT_DH_SUPP   0x0004
0262     #define VDADEVFEAT_PHYS_ID   0x0008
0263 
0264     u8 ses_element_id;
0265     u8 link_speed;
0266     #define VDALINKSPEED_UNKNOWN 0x00
0267     #define VDALINKSPEED_1GB     0x01
0268     #define VDALINKSPEED_1_5GB   0x02
0269     #define VDALINKSPEED_2GB     0x03
0270     #define VDALINKSPEED_3GB     0x04
0271     #define VDALINKSPEED_4GB     0x05
0272     #define VDALINKSPEED_6GB     0x06
0273     #define VDALINKSPEED_8GB     0x07
0274 
0275     u16 phys_target_id;
0276     u8 reserved[2];
0277 };
0278 
0279 
0280 /*! struct atto_vda_devinfo2 is a replacement for atto_vda_devinfo.  it
0281  * extends beyond the 0x70 bytes allowed in atto_vda_mgmt_req; therefore,
0282  * the entire structure is DMaed between the firmware and host buffer and
0283  * the data will always be in little endian format.
0284  */
0285 
0286 struct __packed atto_vda_devinfo2 {
0287     struct atto_dev_addr dev_addr;
0288     u8 vendor_id[8];
0289     u8 product_id[16];
0290     u8 revision[4];
0291     u64 capacity;
0292     u32 block_size;
0293     u8 dev_type;
0294     u8 dev_status;
0295     u8 member_state;
0296     u8 operation;
0297     u8 op_status;
0298     u8 progress;
0299     u16 ses_dev_index;
0300     u8 serial_no[32];
0301     union {
0302         u16 target_id;
0303         u16 features_mask;
0304     };
0305 
0306     u16 lun;
0307     u16 features;
0308     u8 ses_element_id;
0309     u8 link_speed;
0310     u16 phys_target_id;
0311     u8 reserved[2];
0312 
0313 /* This is where fields specific to struct atto_vda_devinfo2 begin.  Note
0314  * that the structure version started at one so applications that unionize this
0315  * structure with atto_vda_dev_info can differentiate them if desired.
0316  */
0317 
0318     u8 version;
0319     #define VDADEVINFO_VERSION0         0x00
0320     #define VDADEVINFO_VERSION1         0x01
0321     #define VDADEVINFO_VERSION2         0x02
0322     #define VDADEVINFO_VERSION3         0x03
0323     #define VDADEVINFO_VERSION          VDADEVINFO_VERSION3
0324 
0325     u8 reserved2[3];
0326 
0327     /* sector scanning fields */
0328 
0329     u32 ss_curr_errors;
0330     u64 ss_curr_scanned;
0331     u32 ss_curr_recvrd;
0332     u32 ss_scan_length;
0333     u32 ss_total_errors;
0334     u32 ss_total_recvrd;
0335     u32 ss_num_scans;
0336 
0337     /* grp_name was added in version 2 of this structure. */
0338 
0339     char grp_name[15];
0340     u8 reserved3[4];
0341 
0342     /* dev_addr_list was added in version 3 of this structure. */
0343 
0344     u8 num_dev_addr;
0345     struct atto_dev_addr2 dev_addr_list[8];
0346 };
0347 
0348 
0349 struct __packed atto_vda_grp_info {
0350     u8 grp_index;
0351     #define VDA_MAX_RAID_GROUPS         32
0352 
0353     char grp_name[15];
0354     u64 capacity;
0355     u32 block_size;
0356     u32 interleave;
0357     u8 type;
0358     #define VDA_GRP_TYPE_RAID0          0
0359     #define VDA_GRP_TYPE_RAID1          1
0360     #define VDA_GRP_TYPE_RAID4          4
0361     #define VDA_GRP_TYPE_RAID5          5
0362     #define VDA_GRP_TYPE_RAID6          6
0363     #define VDA_GRP_TYPE_RAID10         10
0364     #define VDA_GRP_TYPE_RAID40         40
0365     #define VDA_GRP_TYPE_RAID50         50
0366     #define VDA_GRP_TYPE_RAID60         60
0367     #define VDA_GRP_TYPE_DVRAID_HS      252
0368     #define VDA_GRP_TYPE_DVRAID_NOHS    253
0369     #define VDA_GRP_TYPE_JBOD           254
0370     #define VDA_GRP_TYPE_SPARE          255
0371 
0372     union {
0373         u8 status;
0374         #define VDA_GRP_STAT_INVALID  0x00
0375         #define VDA_GRP_STAT_NEW      0x01
0376         #define VDA_GRP_STAT_WAITING  0x02
0377         #define VDA_GRP_STAT_ONLINE   0x03
0378         #define VDA_GRP_STAT_DEGRADED 0x04
0379         #define VDA_GRP_STAT_OFFLINE  0x05
0380         #define VDA_GRP_STAT_DELETED  0x06
0381         #define VDA_GRP_STAT_RECOV_BASIC    0x07
0382         #define VDA_GRP_STAT_RECOV_EXTREME  0x08
0383 
0384         u8 op_ctrl;
0385         #define VDA_GRP_OP_CTRL_START   0x01
0386         #define VDA_GRP_OP_CTRL_HALT    0x02
0387         #define VDA_GRP_OP_CTRL_RESUME  0x03
0388         #define VDA_GRP_OP_CTRL_CANCEL  0x04
0389     };
0390 
0391     u8 rebuild_state;
0392     #define VDA_RBLD_NONE      0x00
0393     #define VDA_RBLD_REBUILD   0x01
0394     #define VDA_RBLD_ERASE     0x02
0395     #define VDA_RBLD_PATTERN   0x03
0396     #define VDA_RBLD_CONV      0x04
0397     #define VDA_RBLD_FULL_INIT 0x05
0398     #define VDA_RBLD_QUICK_INIT 0x06
0399     #define VDA_RBLD_SECT_SCAN 0x07
0400     #define VDA_RBLD_SECT_SCAN_PARITY     0x08
0401     #define VDA_RBLD_SECT_SCAN_PARITY_FIX 0x09
0402     #define VDA_RBLD_RECOV_REBUILD 0x0A
0403     #define VDA_RBLD_RECOV_BASIC   0x0B
0404     #define VDA_RBLD_RECOV_EXTREME 0x0C
0405 
0406     u8 span_depth;
0407     u8 progress;
0408     u8 mirror_width;
0409     u8 stripe_width;
0410     u8 member_cnt;
0411 
0412     union {
0413         u16 members[32];
0414     #define VDA_MEMBER_MISSING  0xFFFF
0415     #define VDA_MEMBER_NEW      0xFFFE
0416         u16 features_mask;
0417     };
0418 
0419     u16 features;
0420     #define VDA_GRP_FEAT_HOTSWAP    0x0001
0421     #define VDA_GRP_FEAT_SPDRD_MASK 0x0006
0422     #define VDA_GRP_FEAT_SPDRD_DIS  0x0000
0423     #define VDA_GRP_FEAT_SPDRD_ENB  0x0002
0424     #define VDA_GRP_FEAT_SPDRD_AUTO 0x0004
0425     #define VDA_GRP_FEAT_IDENT      0x0008
0426     #define VDA_GRP_FEAT_RBLDPRI_MASK 0x0030
0427     #define VDA_GRP_FEAT_RBLDPRI_LOW  0x0010
0428     #define VDA_GRP_FEAT_RBLDPRI_SAME 0x0020
0429     #define VDA_GRP_FEAT_RBLDPRI_HIGH 0x0030
0430     #define VDA_GRP_FEAT_WRITE_CACHE  0x0040
0431     #define VDA_GRP_FEAT_RBLD_RESUME  0x0080
0432     #define VDA_GRP_FEAT_SECT_RESUME  0x0100
0433     #define VDA_GRP_FEAT_INIT_RESUME  0x0200
0434     #define VDA_GRP_FEAT_SSD          0x0400
0435     #define VDA_GRP_FEAT_BOOT_DEV     0x0800
0436 
0437     /*
0438      * for backward compatibility, a prefetch value of zero means the
0439      * setting is ignored/unsupported.  therefore, the firmware supported
0440      * 0-6 values are incremented to 1-7.
0441      */
0442 
0443     u8 prefetch;
0444     u8 op_status;
0445     #define VDAGRPOPSTAT_MASK       0x0F
0446     #define VDAGRPOPSTAT_INVALID    0x00
0447     #define VDAGRPOPSTAT_OK         0x01
0448     #define VDAGRPOPSTAT_FAULTED    0x02
0449     #define VDAGRPOPSTAT_HALTED     0x03
0450     #define VDAGRPOPSTAT_INT        0x04
0451     #define VDAGRPOPPROC_MASK       0xF0
0452     #define VDAGRPOPPROC_STARTABLE  0x10
0453     #define VDAGRPOPPROC_CANCELABLE 0x20
0454     #define VDAGRPOPPROC_RESUMABLE  0x40
0455     #define VDAGRPOPPROC_HALTABLE   0x80
0456     u8 over_provision;
0457     u8 reserved[3];
0458 
0459 };
0460 
0461 
0462 struct __packed atto_vdapart_info {
0463     u8 part_no;
0464     #define VDA_MAX_PARTITIONS   128
0465 
0466     char grp_name[15];
0467     u64 part_size;
0468     u64 start_lba;
0469     u32 block_size;
0470     u16 target_id;
0471     u8 LUN;
0472     char serial_no[41];
0473     u8 features;
0474     #define VDAPI_FEAT_WRITE_CACHE   0x01
0475 
0476     u8 reserved[7];
0477 };
0478 
0479 
0480 struct __packed atto_vda_dh_info {
0481     u8 req_type;
0482     #define VDADH_RQTYPE_CACHE      0x01
0483     #define VDADH_RQTYPE_FETCH      0x02
0484     #define VDADH_RQTYPE_SET_STAT   0x03
0485     #define VDADH_RQTYPE_GET_STAT   0x04
0486 
0487     u8 req_qual;
0488     #define VDADH_RQQUAL_SMART      0x01
0489     #define VDADH_RQQUAL_MEDDEF     0x02
0490     #define VDADH_RQQUAL_INFOEXC    0x04
0491 
0492     u8 num_smart_attribs;
0493     u8 status;
0494     #define VDADH_STAT_DISABLE      0x00
0495     #define VDADH_STAT_ENABLE       0x01
0496 
0497     u32 med_defect_cnt;
0498     u32 info_exc_cnt;
0499     u8 smart_status;
0500     #define VDADH_SMARTSTAT_OK      0x00
0501     #define VDADH_SMARTSTAT_ERR     0x01
0502 
0503     u8 reserved[35];
0504     struct atto_vda_sge sge[1];
0505 };
0506 
0507 
0508 struct __packed atto_vda_dh_smart {
0509     u8 attrib_id;
0510     u8 current_val;
0511     u8 worst;
0512     u8 threshold;
0513     u8 raw_data[6];
0514     u8 raw_attrib_status;
0515     #define VDADHSM_RAWSTAT_PREFAIL_WARRANTY        0x01
0516     #define VDADHSM_RAWSTAT_ONLINE_COLLECTION       0x02
0517     #define VDADHSM_RAWSTAT_PERFORMANCE_ATTR        0x04
0518     #define VDADHSM_RAWSTAT_ERROR_RATE_ATTR         0x08
0519     #define VDADHSM_RAWSTAT_EVENT_COUNT_ATTR        0x10
0520     #define VDADHSM_RAWSTAT_SELF_PRESERVING_ATTR    0x20
0521 
0522     u8 calc_attrib_status;
0523     #define VDADHSM_CALCSTAT_UNKNOWN                0x00
0524     #define VDADHSM_CALCSTAT_GOOD                   0x01
0525     #define VDADHSM_CALCSTAT_PREFAIL                0x02
0526     #define VDADHSM_CALCSTAT_OLDAGE                 0x03
0527 
0528     u8 reserved[4];
0529 };
0530 
0531 
0532 struct __packed atto_vda_metrics_info {
0533     u8 data_version;
0534     #define VDAMET_VERSION0         0x00
0535     #define VDAMET_VERSION          VDAMET_VERSION0
0536 
0537     u8 metrics_action;
0538     #define VDAMET_METACT_NONE      0x00
0539     #define VDAMET_METACT_START     0x01
0540     #define VDAMET_METACT_STOP      0x02
0541     #define VDAMET_METACT_RETRIEVE  0x03
0542     #define VDAMET_METACT_CLEAR     0x04
0543 
0544     u8 test_action;
0545     #define VDAMET_TSTACT_NONE              0x00
0546     #define VDAMET_TSTACT_STRT_INIT         0x01
0547     #define VDAMET_TSTACT_STRT_READ         0x02
0548     #define VDAMET_TSTACT_STRT_VERIFY       0x03
0549     #define VDAMET_TSTACT_STRT_INIT_VERIFY  0x04
0550     #define VDAMET_TSTACT_STOP              0x05
0551 
0552     u8 num_dev_indexes;
0553     #define VDAMET_ALL_DEVICES      0xFF
0554 
0555     u16 dev_indexes[32];
0556     u8 reserved[12];
0557     struct atto_vda_sge sge[1];
0558 };
0559 
0560 
0561 struct __packed atto_vda_metrics_data {
0562     u16 dev_index;
0563     u16 length;
0564     #define VDAMD_LEN_LAST          0x8000
0565     #define VDAMD_LEN_MASK          0x0FFF
0566 
0567     u32 flags;
0568     #define VDAMDF_RUN          0x00000007
0569     #define VDAMDF_RUN_READ     0x00000001
0570     #define VDAMDF_RUN_WRITE    0x00000002
0571     #define VDAMDF_RUN_ALL      0x00000004
0572     #define VDAMDF_READ         0x00000010
0573     #define VDAMDF_WRITE        0x00000020
0574     #define VDAMDF_ALL          0x00000040
0575     #define VDAMDF_DRIVETEST    0x40000000
0576     #define VDAMDF_NEW          0x80000000
0577 
0578     u64 total_read_data;
0579     u64 total_write_data;
0580     u64 total_read_io;
0581     u64 total_write_io;
0582     u64 read_start_time;
0583     u64 read_stop_time;
0584     u64 write_start_time;
0585     u64 write_stop_time;
0586     u64 read_maxio_time;
0587     u64 wpvdadmetricsdatarite_maxio_time;
0588     u64 read_totalio_time;
0589     u64 write_totalio_time;
0590     u64 read_total_errs;
0591     u64 write_total_errs;
0592     u64 read_recvrd_errs;
0593     u64 write_recvrd_errs;
0594     u64 miscompares;
0595 };
0596 
0597 
0598 struct __packed atto_vda_schedule_info {
0599     u8 schedule_type;
0600     #define VDASI_SCHTYPE_ONETIME   0x01
0601     #define VDASI_SCHTYPE_DAILY     0x02
0602     #define VDASI_SCHTYPE_WEEKLY    0x03
0603 
0604     u8 operation;
0605     #define VDASI_OP_NONE           0x00
0606     #define VDASI_OP_CREATE         0x01
0607     #define VDASI_OP_CANCEL         0x02
0608 
0609     u8 hour;
0610     u8 minute;
0611     u8 day;
0612     #define VDASI_DAY_NONE          0x00
0613 
0614     u8 progress;
0615     #define VDASI_PROG_NONE         0xFF
0616 
0617     u8 event_type;
0618     #define VDASI_EVTTYPE_SECT_SCAN             0x01
0619     #define VDASI_EVTTYPE_SECT_SCAN_PARITY      0x02
0620     #define VDASI_EVTTYPE_SECT_SCAN_PARITY_FIX  0x03
0621 
0622     u8 recurrences;
0623     #define VDASI_RECUR_FOREVER     0x00
0624 
0625     u32 id;
0626     #define VDASI_ID_NONE           0x00
0627 
0628     char grp_name[15];
0629     u8 reserved[85];
0630 };
0631 
0632 
0633 struct __packed atto_vda_n_vcache_info {
0634     u8 super_cap_status;
0635     #define VDANVCI_SUPERCAP_NOT_PRESENT       0x00
0636     #define VDANVCI_SUPERCAP_FULLY_CHARGED     0x01
0637     #define VDANVCI_SUPERCAP_NOT_CHARGED       0x02
0638 
0639     u8 nvcache_module_status;
0640     #define VDANVCI_NVCACHEMODULE_NOT_PRESENT  0x00
0641     #define VDANVCI_NVCACHEMODULE_PRESENT      0x01
0642 
0643     u8 protection_mode;
0644     #define VDANVCI_PROTMODE_HI_PROTECT        0x00
0645     #define VDANVCI_PROTMODE_HI_PERFORM        0x01
0646 
0647     u8 reserved[109];
0648 };
0649 
0650 
0651 struct __packed atto_vda_buzzer_info {
0652     u8 status;
0653     #define VDABUZZI_BUZZER_OFF           0x00
0654     #define VDABUZZI_BUZZER_ON            0x01
0655     #define VDABUZZI_BUZZER_LAST          0x02
0656 
0657     u8 reserved[3];
0658     u32 duration;
0659     #define VDABUZZI_DURATION_INDEFINITE  0xffffffff
0660 
0661     u8 reserved2[104];
0662 };
0663 
0664 
0665 struct  __packed atto_vda_adapter_info {
0666     u8 version;
0667     #define VDAADAPINFO_VERSION0         0x00
0668     #define VDAADAPINFO_VERSION          VDAADAPINFO_VERSION0
0669 
0670     u8 reserved;
0671     signed short utc_offset;
0672     u32 utc_time;
0673     u32 features;
0674     #define VDA_ADAP_FEAT_IDENT     0x0001
0675     #define VDA_ADAP_FEAT_BUZZ_ERR  0x0002
0676     #define VDA_ADAP_FEAT_UTC_TIME  0x0004
0677 
0678     u32 valid_features;
0679     char active_config[33];
0680     u8 temp_count;
0681     u8 fan_count;
0682     u8 reserved3[61];
0683 };
0684 
0685 
0686 struct __packed atto_vda_temp_info {
0687     u8 temp_index;
0688     u8 max_op_temp;
0689     u8 min_op_temp;
0690     u8 op_temp_warn;
0691     u8 temperature;
0692     u8 type;
0693     #define VDA_TEMP_TYPE_CPU  1
0694 
0695     u8 reserved[106];
0696 };
0697 
0698 
0699 struct __packed atto_vda_fan_info {
0700     u8 fan_index;
0701     u8 status;
0702     #define VDA_FAN_STAT_UNKNOWN 0
0703     #define VDA_FAN_STAT_NORMAL  1
0704     #define VDA_FAN_STAT_FAIL    2
0705 
0706     u16 crit_pvdafaninfothreshold;
0707     u16 warn_threshold;
0708     u16 speed;
0709     u8 reserved[104];
0710 };
0711 
0712 
0713 /* VDA management commands */
0714 
0715 #define VDAMGT_DEV_SCAN         0x00
0716 #define VDAMGT_DEV_INFO         0x01
0717 #define VDAMGT_DEV_CLEAN        0x02
0718 #define VDAMGT_DEV_IDENTIFY     0x03
0719 #define VDAMGT_DEV_IDENTSTOP    0x04
0720 #define VDAMGT_DEV_PT_INFO      0x05
0721 #define VDAMGT_DEV_FEATURES     0x06
0722 #define VDAMGT_DEV_PT_FEATURES  0x07
0723 #define VDAMGT_DEV_HEALTH_REQ   0x08
0724 #define VDAMGT_DEV_METRICS      0x09
0725 #define VDAMGT_DEV_INFO2        0x0A
0726 #define VDAMGT_DEV_OPERATION    0x0B
0727 #define VDAMGT_DEV_INFO2_BYADDR 0x0C
0728 #define VDAMGT_GRP_INFO         0x10
0729 #define VDAMGT_GRP_CREATE       0x11
0730 #define VDAMGT_GRP_DELETE       0x12
0731 #define VDAMGT_ADD_STORAGE      0x13
0732 #define VDAMGT_MEMBER_ADD       0x14
0733 #define VDAMGT_GRP_COMMIT       0x15
0734 #define VDAMGT_GRP_REBUILD      0x16
0735 #define VDAMGT_GRP_COMMIT_INIT  0x17
0736 #define VDAMGT_QUICK_RAID       0x18
0737 #define VDAMGT_GRP_FEATURES     0x19
0738 #define VDAMGT_GRP_COMMIT_INIT_AUTOMAP  0x1A
0739 #define VDAMGT_QUICK_RAID_INIT_AUTOMAP  0x1B
0740 #define VDAMGT_GRP_OPERATION    0x1C
0741 #define VDAMGT_CFG_SAVE         0x20
0742 #define VDAMGT_LAST_ERROR       0x21
0743 #define VDAMGT_ADAP_INFO        0x22
0744 #define VDAMGT_ADAP_FEATURES    0x23
0745 #define VDAMGT_TEMP_INFO        0x24
0746 #define VDAMGT_FAN_INFO         0x25
0747 #define VDAMGT_PART_INFO        0x30
0748 #define VDAMGT_PART_MAP         0x31
0749 #define VDAMGT_PART_UNMAP       0x32
0750 #define VDAMGT_PART_AUTOMAP     0x33
0751 #define VDAMGT_PART_SPLIT       0x34
0752 #define VDAMGT_PART_MERGE       0x35
0753 #define VDAMGT_SPARE_LIST       0x40
0754 #define VDAMGT_SPARE_ADD        0x41
0755 #define VDAMGT_SPARE_REMOVE     0x42
0756 #define VDAMGT_LOCAL_SPARE_ADD  0x43
0757 #define VDAMGT_SCHEDULE_EVENT   0x50
0758 #define VDAMGT_SCHEDULE_INFO    0x51
0759 #define VDAMGT_NVCACHE_INFO     0x60
0760 #define VDAMGT_NVCACHE_SET      0x61
0761 #define VDAMGT_BUZZER_INFO      0x70
0762 #define VDAMGT_BUZZER_SET       0x71
0763 
0764 
0765 struct __packed atto_vda_ae_hdr {
0766     u8 bylength;
0767     u8 byflags;
0768     #define VDAAE_HDRF_EVENT_ACK    0x01
0769 
0770     u8 byversion;
0771     #define VDAAE_HDR_VER_0         0
0772 
0773     u8 bytype;
0774     #define VDAAE_HDR_TYPE_RAID     1
0775     #define VDAAE_HDR_TYPE_LU       2
0776     #define VDAAE_HDR_TYPE_DISK     3
0777     #define VDAAE_HDR_TYPE_RESET    4
0778     #define VDAAE_HDR_TYPE_LOG_INFO 5
0779     #define VDAAE_HDR_TYPE_LOG_WARN 6
0780     #define VDAAE_HDR_TYPE_LOG_CRIT 7
0781     #define VDAAE_HDR_TYPE_LOG_FAIL 8
0782     #define VDAAE_HDR_TYPE_NVC      9
0783     #define VDAAE_HDR_TYPE_TLG_INFO 10
0784     #define VDAAE_HDR_TYPE_TLG_WARN 11
0785     #define VDAAE_HDR_TYPE_TLG_CRIT 12
0786     #define VDAAE_HDR_TYPE_PWRMGT   13
0787     #define VDAAE_HDR_TYPE_MUTE     14
0788     #define VDAAE_HDR_TYPE_DEV      15
0789 };
0790 
0791 
0792 struct  __packed atto_vda_ae_raid {
0793     struct atto_vda_ae_hdr hdr;
0794     u32 dwflags;
0795     #define VDAAE_GROUP_STATE   0x00000001
0796     #define VDAAE_RBLD_STATE    0x00000002
0797     #define VDAAE_RBLD_PROG     0x00000004
0798     #define VDAAE_MEMBER_CHG    0x00000008
0799     #define VDAAE_PART_CHG      0x00000010
0800     #define VDAAE_MEM_STATE_CHG 0x00000020
0801 
0802     u8 bygroup_state;
0803     #define VDAAE_RAID_INVALID  0
0804     #define VDAAE_RAID_NEW      1
0805     #define VDAAE_RAID_WAITING  2
0806     #define VDAAE_RAID_ONLINE   3
0807     #define VDAAE_RAID_DEGRADED 4
0808     #define VDAAE_RAID_OFFLINE  5
0809     #define VDAAE_RAID_DELETED  6
0810     #define VDAAE_RAID_BASIC    7
0811     #define VDAAE_RAID_EXTREME  8
0812     #define VDAAE_RAID_UNKNOWN  9
0813 
0814     u8 byrebuild_state;
0815     #define VDAAE_RBLD_NONE       0
0816     #define VDAAE_RBLD_REBUILD    1
0817     #define VDAAE_RBLD_ERASE      2
0818     #define VDAAE_RBLD_PATTERN    3
0819     #define VDAAE_RBLD_CONV       4
0820     #define VDAAE_RBLD_FULL_INIT  5
0821     #define VDAAE_RBLD_QUICK_INIT 6
0822     #define VDAAE_RBLD_SECT_SCAN  7
0823     #define VDAAE_RBLD_SECT_SCAN_PARITY     8
0824     #define VDAAE_RBLD_SECT_SCAN_PARITY_FIX 9
0825     #define VDAAE_RBLD_RECOV_REBUILD 10
0826     #define VDAAE_RBLD_UNKNOWN    11
0827 
0828     u8 byrebuild_progress;
0829     u8 op_status;
0830     #define VDAAE_GRPOPSTAT_MASK       0x0F
0831     #define VDAAE_GRPOPSTAT_INVALID    0x00
0832     #define VDAAE_GRPOPSTAT_OK         0x01
0833     #define VDAAE_GRPOPSTAT_FAULTED    0x02
0834     #define VDAAE_GRPOPSTAT_HALTED     0x03
0835     #define VDAAE_GRPOPSTAT_INT        0x04
0836     #define VDAAE_GRPOPPROC_MASK       0xF0
0837     #define VDAAE_GRPOPPROC_STARTABLE  0x10
0838     #define VDAAE_GRPOPPROC_CANCELABLE 0x20
0839     #define VDAAE_GRPOPPROC_RESUMABLE  0x40
0840     #define VDAAE_GRPOPPROC_HALTABLE   0x80
0841     char acname[15];
0842     u8 byreserved;
0843     u8 byreserved2[0x80 - 0x1C];
0844 };
0845 
0846 
0847 struct __packed atto_vda_ae_lu_tgt_lun {
0848     u16 wtarget_id;
0849     u8 bylun;
0850     u8 byreserved;
0851 };
0852 
0853 
0854 struct __packed atto_vda_ae_lu_tgt_lun_raid {
0855     u16 wtarget_id;
0856     u8 bylun;
0857     u8 byreserved;
0858     u32 dwinterleave;
0859     u32 dwblock_size;
0860 };
0861 
0862 
0863 struct __packed atto_vda_ae_lu {
0864     struct atto_vda_ae_hdr hdr;
0865     u32 dwevent;
0866     #define VDAAE_LU_DISC        0x00000001
0867     #define VDAAE_LU_LOST        0x00000002
0868     #define VDAAE_LU_STATE       0x00000004
0869     #define VDAAE_LU_PASSTHROUGH 0x10000000
0870     #define VDAAE_LU_PHYS_ID     0x20000000
0871 
0872     u8 bystate;
0873     #define VDAAE_LU_UNDEFINED        0
0874     #define VDAAE_LU_NOT_PRESENT      1
0875     #define VDAAE_LU_OFFLINE          2
0876     #define VDAAE_LU_ONLINE           3
0877     #define VDAAE_LU_DEGRADED         4
0878     #define VDAAE_LU_FACTORY_DISABLED 5
0879     #define VDAAE_LU_DELETED          6
0880     #define VDAAE_LU_BUSSCAN          7
0881     #define VDAAE_LU_UNKNOWN          8
0882 
0883     u8 byreserved;
0884     u16 wphys_target_id;
0885 
0886     union {
0887         struct atto_vda_ae_lu_tgt_lun tgtlun;
0888         struct atto_vda_ae_lu_tgt_lun_raid tgtlun_raid;
0889     } id;
0890 };
0891 
0892 
0893 struct __packed atto_vda_ae_disk {
0894     struct atto_vda_ae_hdr hdr;
0895 };
0896 
0897 
0898 #define VDAAE_LOG_STRSZ 64
0899 
0900 struct __packed atto_vda_ae_log {
0901     struct atto_vda_ae_hdr hdr;
0902     char aclog_ascii[VDAAE_LOG_STRSZ];
0903 };
0904 
0905 
0906 #define VDAAE_TLG_STRSZ 56
0907 
0908 struct __packed atto_vda_ae_timestamp_log {
0909     struct atto_vda_ae_hdr hdr;
0910     u32 dwtimestamp;
0911     char aclog_ascii[VDAAE_TLG_STRSZ];
0912 };
0913 
0914 
0915 struct __packed atto_vda_ae_nvc {
0916     struct atto_vda_ae_hdr hdr;
0917 };
0918 
0919 
0920 struct __packed atto_vda_ae_dev {
0921     struct atto_vda_ae_hdr hdr;
0922     struct atto_dev_addr devaddr;
0923 };
0924 
0925 
0926 union atto_vda_ae {
0927     struct atto_vda_ae_hdr hdr;
0928     struct atto_vda_ae_disk disk;
0929     struct atto_vda_ae_lu lu;
0930     struct atto_vda_ae_raid raid;
0931     struct atto_vda_ae_log log;
0932     struct atto_vda_ae_timestamp_log tslog;
0933     struct atto_vda_ae_nvc nvcache;
0934     struct atto_vda_ae_dev dev;
0935 };
0936 
0937 
0938 struct __packed atto_vda_date_and_time {
0939     u8 flags;
0940     #define VDA_DT_DAY_MASK   0x07
0941     #define VDA_DT_DAY_NONE   0x00
0942     #define VDA_DT_DAY_SUN    0x01
0943     #define VDA_DT_DAY_MON    0x02
0944     #define VDA_DT_DAY_TUE    0x03
0945     #define VDA_DT_DAY_WED    0x04
0946     #define VDA_DT_DAY_THU    0x05
0947     #define VDA_DT_DAY_FRI    0x06
0948     #define VDA_DT_DAY_SAT    0x07
0949     #define VDA_DT_PM         0x40
0950     #define VDA_DT_MILITARY   0x80
0951 
0952     u8 seconds;
0953     u8 minutes;
0954     u8 hours;
0955     u8 day;
0956     u8 month;
0957     u16 year;
0958 };
0959 
0960 #define SGE_LEN_LIMIT   0x003FFFFF      /*! mask of segment length            */
0961 #define SGE_LEN_MAX     0x003FF000      /*! maximum segment length            */
0962 #define SGE_LAST        0x01000000      /*! last entry                        */
0963 #define SGE_ADDR_64     0x04000000      /*! 64-bit addressing flag            */
0964 #define SGE_CHAIN       0x80000000      /*! chain descriptor flag             */
0965 #define SGE_CHAIN_LEN   0x0000FFFF      /*! mask of length in chain entries   */
0966 #define SGE_CHAIN_SZ    0x00FF0000      /*! mask of size of chained buffer    */
0967 
0968 
0969 struct __packed atto_vda_cfg_init {
0970     struct atto_vda_date_and_time date_time;
0971     u32 sgl_page_size;
0972     u32 vda_version;
0973     u32 fw_version;
0974     u32 fw_build;
0975     u32 fw_release;
0976     u32 epoch_time;
0977     u32 ioctl_tunnel;
0978     #define VDA_ITF_MEM_RW           0x00000001
0979     #define VDA_ITF_TRACE            0x00000002
0980     #define VDA_ITF_SCSI_PASS_THRU   0x00000004
0981     #define VDA_ITF_GET_DEV_ADDR     0x00000008
0982     #define VDA_ITF_PHY_CTRL         0x00000010
0983     #define VDA_ITF_CONN_CTRL        0x00000020
0984     #define VDA_ITF_GET_DEV_INFO     0x00000040
0985 
0986     u32 num_targets_backend;
0987     u8 reserved[0x48];
0988 };
0989 
0990 
0991 /* configuration commands */
0992 
0993 #define VDA_CFG_INIT          0x00
0994 #define VDA_CFG_GET_INIT      0x01
0995 #define VDA_CFG_GET_INIT2     0x02
0996 
0997 
0998 /*! physical region descriptor (PRD) aka scatter/gather entry */
0999 
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