2 * Copyright (c) 2009-2012 Microsoft Corp.
3 * Copyright (c) 2012 NetApp Inc.
4 * Copyright (c) 2012 Citrix Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __HV_VSTORAGE_H__
32 #define __HV_VSTORAGE_H__
35 * Major/minor macros. Minor version is in LSB, meaning that earlier flat
36 * version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1).
39 #define VMSTOR_PROTOCOL_MAJOR(VERSION_) (((VERSION_) >> 8) & 0xff)
40 #define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_) ) & 0xff)
41 #define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \
47 #define VMSTOR_INVALID_PROTOCOL_VERSION -1
52 * V1 RC < 2008/1/31 1.0
53 * V1 RC > 2008/1/31 2.0
58 #define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(5, 1)
61 * Packet structure ops describing virtual storage requests.
63 enum vstor_packet_ops {
64 VSTOR_OPERATION_COMPLETEIO = 1,
65 VSTOR_OPERATION_REMOVEDEVICE = 2,
66 VSTOR_OPERATION_EXECUTESRB = 3,
67 VSTOR_OPERATION_RESETLUN = 4,
68 VSTOR_OPERATION_RESETADAPTER = 5,
69 VSTOR_OPERATION_RESETBUS = 6,
70 VSTOR_OPERATION_BEGININITIALIZATION = 7,
71 VSTOR_OPERATION_ENDINITIALIZATION = 8,
72 VSTOR_OPERATION_QUERYPROTOCOLVERSION = 9,
73 VSTOR_OPERATION_QUERYPROPERTIES = 10,
74 VSTOR_OPERATION_ENUMERATE_BUS = 11,
75 VSTOR_OPERATION_FCHBA_DATA = 12,
76 VSTOR_OPERATION_CREATE_MULTI_CHANNELS = 13,
77 VSTOR_OPERATION_MAXIMUM = 13
82 * Platform neutral description of a scsi request -
83 * this remains the same across the write regardless of 32/64 bit
84 * note: it's patterned off the Windows DDK SCSI_PASS_THROUGH structure
87 #define CDB16GENERIC_LENGTH 0x10
88 #define SENSE_BUFFER_SIZE 0x14
89 #define MAX_DATA_BUFFER_LENGTH_WITH_PADDING 0x14
91 #define POST_WIN7_STORVSC_SENSE_BUFFER_SIZE 0x14
92 #define PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE 0x12
95 struct vmscsi_win8_extension {
97 * The following were added in Windows 8
101 uint8_t queue_action;
103 uint32_t time_out_value;
104 uint32_t queue_sort_ey;
112 /* HBA number, set to the order number detected by initiator. */
114 /* SCSI bus number or bus_id, different from CAM's path_id. */
121 uint8_t sense_info_len;
125 uint32_t transfer_len;
128 uint8_t cdb[CDB16GENERIC_LENGTH];
130 uint8_t sense_data[SENSE_BUFFER_SIZE];
132 uint8_t reserved_array[MAX_DATA_BUFFER_LENGTH_WITH_PADDING];
136 * The following was added in win8.
138 struct vmscsi_win8_extension win8_extension;
143 * This structure is sent during the initialization phase to get the different
144 * properties of the channel.
147 struct vmstor_chan_props {
152 uint16_t max_channel_cnt;
155 * Note: port number is only really known on the client side
159 uint32_t max_transfer_bytes;
162 * This id is unique for each channel and will correspond with
163 * vendor specific data in the inquiry_ata
170 * This structure is sent during the storage protocol negotiations.
173 struct vmstor_proto_ver
176 * Major (MSW) and minor (LSW) version numbers.
178 uint16_t major_minor;
180 uint16_t revision; /* always zero */
184 * Channel Property Flags
187 #define STORAGE_CHANNEL_REMOVABLE_FLAG 0x1
188 #define STORAGE_CHANNEL_EMULATED_IDE_FLAG 0x2
191 struct vstor_packet {
193 * Requested operation type
195 enum vstor_packet_ops operation;
198 * Flags - see below for values
203 * Status of the request returned from the server side.
210 * Structure used to forward SCSI commands from the client to
213 struct vmscsi_req vm_srb;
216 * Structure used to query channel properties.
218 struct vmstor_chan_props chan_props;
221 * Used during version negotiations.
223 struct vmstor_proto_ver version;
226 * Number of multichannels to create
228 uint16_t multi_channels_cnt;
235 * SRB (SCSI Request Block) Status Codes
237 #define SRB_STATUS_PENDING 0x00
238 #define SRB_STATUS_SUCCESS 0x01
239 #define SRB_STATUS_ABORTED 0x02
240 #define SRB_STATUS_ABORT_FAILED 0x03
241 #define SRB_STATUS_ERROR 0x04
242 #define SRB_STATUS_BUSY 0x05
245 * SRB Status Masks (can be combined with above status codes)
247 #define SRB_STATUS_QUEUE_FROZEN 0x40
248 #define SRB_STATUS_AUTOSENSE_VALID 0x80
256 * This flag indicates that the server should send back a completion for this
259 #define REQUEST_COMPLETION_FLAG 0x1
262 * This is the set of flags that the vsc can set in any packets it sends
264 #define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG)
266 #endif /* __HV_VSTORAGE_H__ */