1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#ifndef _STORVSC_API_H_
#define _STORVSC_API_H_
#include "VmbusApi.h"
/* Defines */
#define STORVSC_RING_BUFFER_SIZE 10*PAGE_SIZE
#define BLKVSC_RING_BUFFER_SIZE 20*PAGE_SIZE
#define STORVSC_MAX_IO_REQUESTS 64
/*
* In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
* reality, the path/target is not used (ie always set to 0) so our
* scsi host adapter essentially has 1 bus with 1 target that contains
* up to 256 luns.
*/
#define STORVSC_MAX_LUNS_PER_TARGET 64
#define STORVSC_MAX_TARGETS 1
#define STORVSC_MAX_CHANNELS 1
/* Fwd decl */
/* struct VMBUS_CHANNEL; */
struct hv_storvsc_request;
/* Data types */
typedef int (*PFN_ON_IO_REQUEST)(struct hv_device *Device, struct hv_storvsc_request *Request);
typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(struct hv_storvsc_request *Request);
typedef int (*PFN_ON_HOST_RESET)(struct hv_device *Device);
typedef void (*PFN_ON_HOST_RESCAN)(struct hv_device *Device);
/* Matches Windows-end */
typedef enum _STORVSC_REQUEST_TYPE{
WRITE_TYPE,
READ_TYPE,
UNKNOWN_TYPE,
} STORVSC_REQUEST_TYPE;
struct hv_storvsc_request {
STORVSC_REQUEST_TYPE Type;
u32 Host;
u32 Bus;
u32 TargetId;
u32 LunId;
u8 * Cdb;
u32 CdbLen;
u32 Status;
u32 BytesXfer;
unsigned char* SenseBuffer;
u32 SenseBufferSize;
void * Context;
PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
/* This points to the memory after DataBuffer */
void * Extension;
MULTIPAGE_BUFFER DataBuffer;
};
/* Represents the block vsc driver */
typedef struct _STORVSC_DRIVER_OBJECT {
struct hv_driver Base; /* Must be the first field */
/* Set by caller (in bytes) */
u32 RingBufferSize;
/* Allocate this much private extension for each I/O request */
u32 RequestExtSize;
/* Maximum # of requests in flight per channel/device */
u32 MaxOutstandingRequestsPerChannel;
/* Set by the caller to allow us to re-enumerate the bus on the host */
PFN_ON_HOST_RESCAN OnHostRescan;
/* Specific to this driver */
PFN_ON_IO_REQUEST OnIORequest;
PFN_ON_HOST_RESET OnHostReset;
} STORVSC_DRIVER_OBJECT;
typedef struct _STORVSC_DEVICE_INFO {
unsigned int PortNumber;
unsigned char PathId;
unsigned char TargetId;
} STORVSC_DEVICE_INFO;
/* Interface */
int
StorVscInitialize(
struct hv_driver *Driver
);
int
BlkVscInitialize(
struct hv_driver *Driver
);
#endif /* _STORVSC_API_H_ */
|