]>
Commit | Line | Data |
---|---|---|
5c473400 S |
1 | /* |
2 | * | |
3 | * Copyright (c) 2011, Microsoft Corporation. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms and conditions of the GNU General Public License, | |
7 | * version 2, as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
16 | * Place - Suite 330, Boston, MA 02111-1307 USA. | |
17 | * | |
18 | * Authors: | |
19 | * Haiyang Zhang <haiyangz@microsoft.com> | |
20 | * Hank Janssen <hjanssen@microsoft.com> | |
21 | * K. Y. Srinivasan <kys@microsoft.com> | |
22 | * | |
23 | */ | |
3f335ea2 S |
24 | |
25 | #ifndef _HYPERV_H | |
26 | #define _HYPERV_H | |
27 | ||
28 | struct hv_guid { | |
29 | unsigned char data[16]; | |
30 | }; | |
31 | ||
a363bf7b S |
32 | #define MAX_PAGE_BUFFER_COUNT 16 |
33 | #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ | |
34 | ||
35 | #pragma pack(push, 1) | |
36 | ||
37 | /* Single-page buffer */ | |
38 | struct hv_page_buffer { | |
39 | u32 len; | |
40 | u32 offset; | |
41 | u64 pfn; | |
42 | }; | |
43 | ||
44 | /* Multiple-page buffer */ | |
45 | struct hv_multipage_buffer { | |
46 | /* Length and Offset determines the # of pfns in the array */ | |
47 | u32 len; | |
48 | u32 offset; | |
49 | u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT]; | |
50 | }; | |
51 | ||
52 | /* 0x18 includes the proprietary packet header */ | |
53 | #define MAX_PAGE_BUFFER_PACKET (0x18 + \ | |
54 | (sizeof(struct hv_page_buffer) * \ | |
55 | MAX_PAGE_BUFFER_COUNT)) | |
56 | #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \ | |
57 | sizeof(struct hv_multipage_buffer)) | |
58 | ||
59 | ||
60 | #pragma pack(pop) | |
61 | ||
7effffb7 S |
62 | struct hv_ring_buffer { |
63 | /* Offset in bytes from the start of ring data below */ | |
64 | u32 write_index; | |
65 | ||
66 | /* Offset in bytes from the start of ring data below */ | |
67 | u32 read_index; | |
68 | ||
69 | u32 interrupt_mask; | |
70 | ||
71 | /* Pad it to PAGE_SIZE so that data starts on page boundary */ | |
72 | u8 reserved[4084]; | |
73 | ||
74 | /* NOTE: | |
75 | * The interrupt_mask field is used only for channels but since our | |
76 | * vmbus connection also uses this data structure and its data starts | |
77 | * here, we commented out this field. | |
78 | */ | |
79 | ||
80 | /* | |
81 | * Ring data starts here + RingDataStartOffset | |
82 | * !!! DO NOT place any fields below this !!! | |
83 | */ | |
84 | u8 buffer[0]; | |
85 | } __packed; | |
86 | ||
87 | struct hv_ring_buffer_info { | |
88 | struct hv_ring_buffer *ring_buffer; | |
89 | u32 ring_size; /* Include the shared header */ | |
90 | spinlock_t ring_lock; | |
91 | ||
92 | u32 ring_datasize; /* < ring_size */ | |
93 | u32 ring_data_startoffset; | |
94 | }; | |
95 | ||
96 | struct hv_ring_buffer_debug_info { | |
97 | u32 current_interrupt_mask; | |
98 | u32 current_read_index; | |
99 | u32 current_write_index; | |
100 | u32 bytes_avail_toread; | |
101 | u32 bytes_avail_towrite; | |
102 | }; | |
3f335ea2 | 103 | |
f7c6dfda S |
104 | /* |
105 | * We use the same version numbering for all Hyper-V modules. | |
106 | * | |
107 | * Definition of versioning is as follows; | |
108 | * | |
109 | * Major Number Changes for these scenarios; | |
110 | * 1. When a new version of Windows Hyper-V | |
111 | * is released. | |
112 | * 2. A Major change has occurred in the | |
113 | * Linux IC's. | |
114 | * (For example the merge for the first time | |
115 | * into the kernel) Every time the Major Number | |
116 | * changes, the Revision number is reset to 0. | |
117 | * Minor Number Changes when new functionality is added | |
118 | * to the Linux IC's that is not a bug fix. | |
119 | * | |
120 | * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync | |
121 | */ | |
122 | #define HV_DRV_VERSION "3.1" | |
123 | ||
124 | ||
517d8dc6 S |
125 | /* |
126 | * A revision number of vmbus that is used for ensuring both ends on a | |
127 | * partition are using compatible versions. | |
128 | */ | |
129 | #define VMBUS_REVISION_NUMBER 13 | |
130 | ||
131 | /* Make maximum size of pipe payload of 16K */ | |
132 | #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384) | |
133 | ||
134 | /* Define PipeMode values. */ | |
135 | #define VMBUS_PIPE_TYPE_BYTE 0x00000000 | |
136 | #define VMBUS_PIPE_TYPE_MESSAGE 0x00000004 | |
137 | ||
138 | /* The size of the user defined data buffer for non-pipe offers. */ | |
139 | #define MAX_USER_DEFINED_BYTES 120 | |
140 | ||
141 | /* The size of the user defined data buffer for pipe offers. */ | |
142 | #define MAX_PIPE_USER_DEFINED_BYTES 116 | |
143 | ||
144 | /* | |
145 | * At the center of the Channel Management library is the Channel Offer. This | |
146 | * struct contains the fundamental information about an offer. | |
147 | */ | |
148 | struct vmbus_channel_offer { | |
149 | struct hv_guid if_type; | |
150 | struct hv_guid if_instance; | |
151 | u64 int_latency; /* in 100ns units */ | |
152 | u32 if_revision; | |
153 | u32 server_ctx_size; /* in bytes */ | |
154 | u16 chn_flags; | |
155 | u16 mmio_megabytes; /* in bytes * 1024 * 1024 */ | |
156 | ||
157 | union { | |
158 | /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */ | |
159 | struct { | |
160 | unsigned char user_def[MAX_USER_DEFINED_BYTES]; | |
161 | } std; | |
162 | ||
163 | /* | |
164 | * Pipes: | |
165 | * The following sructure is an integrated pipe protocol, which | |
166 | * is implemented on top of standard user-defined data. Pipe | |
167 | * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own | |
168 | * use. | |
169 | */ | |
170 | struct { | |
171 | u32 pipe_mode; | |
172 | unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES]; | |
173 | } pipe; | |
174 | } u; | |
175 | u32 padding; | |
176 | } __packed; | |
177 | ||
178 | /* Server Flags */ | |
179 | #define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1 | |
180 | #define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2 | |
181 | #define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4 | |
182 | #define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10 | |
183 | #define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 | |
184 | #define VMBUS_CHANNEL_PARENT_OFFER 0x200 | |
185 | #define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 | |
186 | ||
187 | ||
3f335ea2 | 188 | #endif /* _HYPERV_H */ |