blob: c6e2c44a1be9fab78d5aa85f5fbee08457c4d7e0 [file] [log] [blame]
K. Y. Srinivasan5c473402011-05-12 19:34:14 -07001/*
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 */
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -070024
25#ifndef _HYPERV_H
26#define _HYPERV_H
27
K. Y. Srinivasan29394372012-01-27 15:55:58 -080028#include <linux/types.h>
29
30/*
31 * An implementation of HyperV key value pair (KVP) functionality for Linux.
32 *
33 *
34 * Copyright (C) 2010, Novell, Inc.
35 * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
36 *
37 */
38
39/*
40 * Maximum value size - used for both key names and value data, and includes
41 * any applicable NULL terminators.
42 *
43 * Note: This limit is somewhat arbitrary, but falls easily within what is
44 * supported for all native guests (back to Win 2000) and what is reasonable
45 * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
46 * limited to 255 character key names.
47 *
48 * MSDN recommends not storing data values larger than 2048 bytes in the
49 * registry.
50 *
51 * Note: This value is used in defining the KVP exchange message - this value
52 * cannot be modified without affecting the message size and compatibility.
53 */
54
55/*
56 * bytes, including any null terminators
57 */
58#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
59
60
61/*
62 * Maximum key size - the registry limit for the length of an entry name
63 * is 256 characters, including the null terminator
64 */
65
66#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
67
68/*
69 * In Linux, we implement the KVP functionality in two components:
70 * 1) The kernel component which is packaged as part of the hv_utils driver
71 * is responsible for communicating with the host and responsible for
72 * implementing the host/guest protocol. 2) A user level daemon that is
73 * responsible for data gathering.
74 *
75 * Host/Guest Protocol: The host iterates over an index and expects the guest
76 * to assign a key name to the index and also return the value corresponding to
77 * the key. The host will have atmost one KVP transaction outstanding at any
78 * given point in time. The host side iteration stops when the guest returns
79 * an error. Microsoft has specified the following mapping of key names to
80 * host specified index:
81 *
82 * Index Key Name
83 * 0 FullyQualifiedDomainName
84 * 1 IntegrationServicesVersion
85 * 2 NetworkAddressIPv4
86 * 3 NetworkAddressIPv6
87 * 4 OSBuildNumber
88 * 5 OSName
89 * 6 OSMajorVersion
90 * 7 OSMinorVersion
91 * 8 OSVersion
92 * 9 ProcessorArchitecture
93 *
94 * The Windows host expects the Key Name and Key Value to be encoded in utf16.
95 *
96 * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
97 * data gathering functionality in a user mode daemon. The user level daemon
98 * is also responsible for binding the key name to the index as well. The
99 * kernel and user-level daemon communicate using a connector channel.
100 *
101 * The user mode component first registers with the
102 * the kernel component. Subsequently, the kernel component requests, data
103 * for the specified keys. In response to this message the user mode component
104 * fills in the value corresponding to the specified key. We overload the
105 * sequence field in the cn_msg header to define our KVP message types.
106 *
107 *
108 * The kernel component simply acts as a conduit for communication between the
109 * Windows host and the user-level daemon. The kernel component passes up the
110 * index received from the Host to the user-level daemon. If the index is
111 * valid (supported), the corresponding key as well as its
112 * value (both are strings) is returned. If the index is invalid
113 * (not supported), a NULL key string is returned.
114 */
115
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800116
117/*
118 * Registry value types.
119 */
120
121#define REG_SZ 1
K. Y. Srinivasanfa3d5b82012-03-16 08:02:25 -0700122#define REG_U32 4
123#define REG_U64 8
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800124
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700125/*
126 * As we look at expanding the KVP functionality to include
127 * IP injection functionality, we need to maintain binary
128 * compatibility with older daemons.
129 *
130 * The KVP opcodes are defined by the host and it was unfortunate
131 * that I chose to treat the registration operation as part of the
132 * KVP operations defined by the host.
133 * Here is the level of compatibility
134 * (between the user level daemon and the kernel KVP driver) that we
135 * will implement:
136 *
137 * An older daemon will always be supported on a newer driver.
138 * A given user level daemon will require a minimal version of the
139 * kernel driver.
140 * If we cannot handle the version differences, we will fail gracefully
141 * (this can happen when we have a user level daemon that is more
142 * advanced than the KVP driver.
143 *
144 * We will use values used in this handshake for determining if we have
145 * workable user level daemon and the kernel driver. We begin by taking the
146 * registration opcode out of the KVP opcode namespace. We will however,
147 * maintain compatibility with the existing user-level daemon code.
148 */
149
150/*
151 * Daemon code not supporting IP injection (legacy daemon).
152 */
153
154#define KVP_OP_REGISTER 4
155
156/*
157 * Daemon code supporting IP injection.
158 * The KVP opcode field is used to communicate the
159 * registration information; so define a namespace that
160 * will be distinct from the host defined KVP opcode.
161 */
162
163#define KVP_OP_REGISTER1 100
164
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800165enum hv_kvp_exchg_op {
166 KVP_OP_GET = 0,
167 KVP_OP_SET,
168 KVP_OP_DELETE,
169 KVP_OP_ENUMERATE,
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700170 KVP_OP_GET_IP_INFO,
171 KVP_OP_SET_IP_INFO,
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800172 KVP_OP_COUNT /* Number of operations, must be last. */
173};
174
175enum hv_kvp_exchg_pool {
176 KVP_POOL_EXTERNAL = 0,
177 KVP_POOL_GUEST,
178 KVP_POOL_AUTO,
179 KVP_POOL_AUTO_EXTERNAL,
180 KVP_POOL_AUTO_INTERNAL,
181 KVP_POOL_COUNT /* Number of pools, must be last. */
182};
183
K. Y. Srinivasanb47a81d2012-08-13 10:06:52 -0700184/*
185 * Some Hyper-V status codes.
186 */
187
188#define HV_S_OK 0x00000000
189#define HV_E_FAIL 0x80004005
190#define HV_S_CONT 0x80070103
191#define HV_ERROR_NOT_SUPPORTED 0x80070032
192#define HV_ERROR_MACHINE_LOCKED 0x800704F7
193#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F
K. Y. Srinivasan32061b42012-09-05 13:50:13 -0700194#define HV_INVALIDARG 0x80070057
195#define HV_GUID_NOTFOUND 0x80041002
K. Y. Srinivasanb47a81d2012-08-13 10:06:52 -0700196
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700197#define ADDR_FAMILY_NONE 0x00
198#define ADDR_FAMILY_IPV4 0x01
199#define ADDR_FAMILY_IPV6 0x02
200
201#define MAX_ADAPTER_ID_SIZE 128
202#define MAX_IP_ADDR_SIZE 1024
203#define MAX_GATEWAY_SIZE 512
204
205
206struct hv_kvp_ipaddr_value {
207 __u16 adapter_id[MAX_ADAPTER_ID_SIZE];
208 __u8 addr_family;
209 __u8 dhcp_enabled;
210 __u16 ip_addr[MAX_IP_ADDR_SIZE];
211 __u16 sub_net[MAX_IP_ADDR_SIZE];
212 __u16 gate_way[MAX_GATEWAY_SIZE];
213 __u16 dns_addr[MAX_IP_ADDR_SIZE];
214} __attribute__((packed));
215
216
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800217struct hv_kvp_hdr {
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800218 __u8 operation;
219 __u8 pool;
220 __u16 pad;
221} __attribute__((packed));
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800222
223struct hv_kvp_exchg_msg_value {
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800224 __u32 value_type;
225 __u32 key_size;
226 __u32 value_size;
227 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
K. Y. Srinivasane485ceac2012-03-10 15:32:08 -0800228 union {
229 __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
230 __u32 value_u32;
231 __u64 value_u64;
232 };
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800233} __attribute__((packed));
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800234
235struct hv_kvp_msg_enumerate {
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800236 __u32 index;
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800237 struct hv_kvp_exchg_msg_value data;
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800238} __attribute__((packed));
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800239
K. Y. Srinivasane485ceac2012-03-10 15:32:08 -0800240struct hv_kvp_msg_get {
241 struct hv_kvp_exchg_msg_value data;
242};
243
244struct hv_kvp_msg_set {
245 struct hv_kvp_exchg_msg_value data;
246};
247
248struct hv_kvp_msg_delete {
249 __u32 key_size;
250 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
251};
252
253struct hv_kvp_register {
254 __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
255};
256
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800257struct hv_kvp_msg {
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700258 union {
259 struct hv_kvp_hdr kvp_hdr;
260 int error;
261 };
K. Y. Srinivasan2640335432012-02-02 16:56:50 -0800262 union {
K. Y. Srinivasane485ceac2012-03-10 15:32:08 -0800263 struct hv_kvp_msg_get kvp_get;
264 struct hv_kvp_msg_set kvp_set;
265 struct hv_kvp_msg_delete kvp_delete;
266 struct hv_kvp_msg_enumerate kvp_enum_data;
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700267 struct hv_kvp_ipaddr_value kvp_ip_val;
K. Y. Srinivasane485ceac2012-03-10 15:32:08 -0800268 struct hv_kvp_register kvp_register;
K. Y. Srinivasan2640335432012-02-02 16:56:50 -0800269 } body;
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800270} __attribute__((packed));
K. Y. Srinivasan29394372012-01-27 15:55:58 -0800271
K. Y. Srinivasan9b595782012-08-13 10:06:51 -0700272struct hv_kvp_ip_msg {
273 __u8 operation;
274 __u8 pool;
275 struct hv_kvp_ipaddr_value kvp_ip_val;
276} __attribute__((packed));
277
K. Y. Srinivasan59a084a2012-02-02 16:56:48 -0800278#ifdef __KERNEL__
K. Y. Srinivasan8ff3e6f2011-05-12 19:34:27 -0700279#include <linux/scatterlist.h>
280#include <linux/list.h>
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -0700281#include <linux/uuid.h>
K. Y. Srinivasan8ff3e6f2011-05-12 19:34:27 -0700282#include <linux/timer.h>
283#include <linux/workqueue.h>
284#include <linux/completion.h>
285#include <linux/device.h>
K. Y. Srinivasan2e2c1d12011-08-25 09:48:31 -0700286#include <linux/mod_devicetable.h>
K. Y. Srinivasan8ff3e6f2011-05-12 19:34:27 -0700287
288
Haiyang Zhangc31c1512012-02-02 07:18:00 +0000289#define MAX_PAGE_BUFFER_COUNT 19
K. Y. Srinivasana363bf72011-05-12 19:34:16 -0700290#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
291
292#pragma pack(push, 1)
293
294/* Single-page buffer */
295struct hv_page_buffer {
296 u32 len;
297 u32 offset;
298 u64 pfn;
299};
300
301/* Multiple-page buffer */
302struct hv_multipage_buffer {
303 /* Length and Offset determines the # of pfns in the array */
304 u32 len;
305 u32 offset;
306 u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT];
307};
308
309/* 0x18 includes the proprietary packet header */
310#define MAX_PAGE_BUFFER_PACKET (0x18 + \
311 (sizeof(struct hv_page_buffer) * \
312 MAX_PAGE_BUFFER_COUNT))
313#define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \
314 sizeof(struct hv_multipage_buffer))
315
316
317#pragma pack(pop)
318
K. Y. Srinivasan7effffb2011-05-12 19:34:17 -0700319struct hv_ring_buffer {
320 /* Offset in bytes from the start of ring data below */
321 u32 write_index;
322
323 /* Offset in bytes from the start of ring data below */
324 u32 read_index;
325
326 u32 interrupt_mask;
327
K. Y. Srinivasan24166032012-12-01 06:46:39 -0800328 /*
329 * Win8 uses some of the reserved bits to implement
330 * interrupt driven flow management. On the send side
331 * we can request that the receiver interrupt the sender
332 * when the ring transitions from being full to being able
333 * to handle a message of size "pending_send_sz".
334 *
335 * Add necessary state for this enhancement.
K. Y. Srinivasan7effffb2011-05-12 19:34:17 -0700336 */
K. Y. Srinivasan24166032012-12-01 06:46:39 -0800337 u32 pending_send_sz;
338
339 u32 reserved1[12];
340
341 union {
342 struct {
343 u32 feat_pending_send_sz:1;
344 };
345 u32 value;
346 } feature_bits;
347
348 /* Pad it to PAGE_SIZE so that data starts on page boundary */
349 u8 reserved2[4028];
K. Y. Srinivasan7effffb2011-05-12 19:34:17 -0700350
351 /*
352 * Ring data starts here + RingDataStartOffset
353 * !!! DO NOT place any fields below this !!!
354 */
355 u8 buffer[0];
356} __packed;
357
358struct hv_ring_buffer_info {
359 struct hv_ring_buffer *ring_buffer;
360 u32 ring_size; /* Include the shared header */
361 spinlock_t ring_lock;
362
363 u32 ring_datasize; /* < ring_size */
364 u32 ring_data_startoffset;
365};
366
367struct hv_ring_buffer_debug_info {
368 u32 current_interrupt_mask;
369 u32 current_read_index;
370 u32 current_write_index;
371 u32 bytes_avail_toread;
372 u32 bytes_avail_towrite;
373};
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -0700374
Haiyang Zhang33be96e2012-03-27 13:20:45 +0000375
376/*
377 *
378 * hv_get_ringbuffer_availbytes()
379 *
380 * Get number of bytes available to read and to write to
381 * for the specified ring buffer
382 */
383static inline void
384hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
385 u32 *read, u32 *write)
386{
387 u32 read_loc, write_loc, dsize;
388
389 smp_read_barrier_depends();
390
391 /* Capture the read/write indices before they changed */
392 read_loc = rbi->ring_buffer->read_index;
393 write_loc = rbi->ring_buffer->write_index;
394 dsize = rbi->ring_datasize;
395
396 *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
397 read_loc - write_loc;
398 *read = dsize - *write;
399}
400
401
K. Y. Srinivasanf7c6dfd2011-05-12 19:34:18 -0700402/*
403 * We use the same version numbering for all Hyper-V modules.
404 *
405 * Definition of versioning is as follows;
406 *
407 * Major Number Changes for these scenarios;
408 * 1. When a new version of Windows Hyper-V
409 * is released.
410 * 2. A Major change has occurred in the
411 * Linux IC's.
412 * (For example the merge for the first time
413 * into the kernel) Every time the Major Number
414 * changes, the Revision number is reset to 0.
415 * Minor Number Changes when new functionality is added
416 * to the Linux IC's that is not a bug fix.
417 *
418 * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync
419 */
420#define HV_DRV_VERSION "3.1"
421
K. Y. Srinivasaneafa7072012-12-01 06:46:44 -0800422/*
423 * VMBUS version is 32 bit entity broken up into
424 * two 16 bit quantities: major_number. minor_number.
425 *
426 * 0 . 13 (Windows Server 2008)
427 * 1 . 1 (Windows 7)
428 * 2 . 4 (Windows 8)
429 */
430
431#define VERSION_WS2008 ((0 << 16) | (13))
432#define VERSION_WIN7 ((1 << 16) | (1))
433#define VERSION_WIN8 ((2 << 16) | (4))
434
435#define VERSION_INVAL -1
436
K. Y. Srinivasanf7c6dfd2011-05-12 19:34:18 -0700437
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700438/* Make maximum size of pipe payload of 16K */
439#define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384)
440
441/* Define PipeMode values. */
442#define VMBUS_PIPE_TYPE_BYTE 0x00000000
443#define VMBUS_PIPE_TYPE_MESSAGE 0x00000004
444
445/* The size of the user defined data buffer for non-pipe offers. */
446#define MAX_USER_DEFINED_BYTES 120
447
448/* The size of the user defined data buffer for pipe offers. */
449#define MAX_PIPE_USER_DEFINED_BYTES 116
450
451/*
452 * At the center of the Channel Management library is the Channel Offer. This
453 * struct contains the fundamental information about an offer.
454 */
455struct vmbus_channel_offer {
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -0700456 uuid_le if_type;
457 uuid_le if_instance;
K. Y. Srinivasan29423b72012-12-01 06:46:40 -0800458
459 /*
460 * These two fields are not currently used.
461 */
462 u64 reserved1;
463 u64 reserved2;
464
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700465 u16 chn_flags;
466 u16 mmio_megabytes; /* in bytes * 1024 * 1024 */
467
468 union {
469 /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */
470 struct {
471 unsigned char user_def[MAX_USER_DEFINED_BYTES];
472 } std;
473
474 /*
475 * Pipes:
476 * The following sructure is an integrated pipe protocol, which
477 * is implemented on top of standard user-defined data. Pipe
478 * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own
479 * use.
480 */
481 struct {
482 u32 pipe_mode;
483 unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES];
484 } pipe;
485 } u;
K. Y. Srinivasan29423b72012-12-01 06:46:40 -0800486 /*
487 * The sub_channel_index is defined in win8.
488 */
489 u16 sub_channel_index;
490 u16 reserved3;
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700491} __packed;
492
493/* Server Flags */
494#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1
495#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2
496#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4
497#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10
498#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100
499#define VMBUS_CHANNEL_PARENT_OFFER 0x200
500#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400
501
K. Y. Srinivasan50ed40e2011-05-12 19:34:20 -0700502struct vmpacket_descriptor {
503 u16 type;
504 u16 offset8;
505 u16 len8;
506 u16 flags;
507 u64 trans_id;
508} __packed;
509
510struct vmpacket_header {
511 u32 prev_pkt_start_offset;
512 struct vmpacket_descriptor descriptor;
513} __packed;
514
515struct vmtransfer_page_range {
516 u32 byte_count;
517 u32 byte_offset;
518} __packed;
519
520struct vmtransfer_page_packet_header {
521 struct vmpacket_descriptor d;
522 u16 xfer_pageset_id;
K. Y. Srinivasan1508d812012-08-16 08:23:20 -0700523 u8 sender_owns_set;
K. Y. Srinivasan50ed40e2011-05-12 19:34:20 -0700524 u8 reserved;
525 u32 range_cnt;
526 struct vmtransfer_page_range ranges[1];
527} __packed;
528
529struct vmgpadl_packet_header {
530 struct vmpacket_descriptor d;
531 u32 gpadl;
532 u32 reserved;
533} __packed;
534
535struct vmadd_remove_transfer_page_set {
536 struct vmpacket_descriptor d;
537 u32 gpadl;
538 u16 xfer_pageset_id;
539 u16 reserved;
540} __packed;
541
542/*
543 * This structure defines a range in guest physical space that can be made to
544 * look virtually contiguous.
545 */
546struct gpa_range {
547 u32 byte_count;
548 u32 byte_offset;
549 u64 pfn_array[0];
550};
551
552/*
553 * This is the format for an Establish Gpadl packet, which contains a handle by
554 * which this GPADL will be known and a set of GPA ranges associated with it.
555 * This can be converted to a MDL by the guest OS. If there are multiple GPA
556 * ranges, then the resulting MDL will be "chained," representing multiple VA
557 * ranges.
558 */
559struct vmestablish_gpadl {
560 struct vmpacket_descriptor d;
561 u32 gpadl;
562 u32 range_cnt;
563 struct gpa_range range[1];
564} __packed;
565
566/*
567 * This is the format for a Teardown Gpadl packet, which indicates that the
568 * GPADL handle in the Establish Gpadl packet will never be referenced again.
569 */
570struct vmteardown_gpadl {
571 struct vmpacket_descriptor d;
572 u32 gpadl;
573 u32 reserved; /* for alignment to a 8-byte boundary */
574} __packed;
575
576/*
577 * This is the format for a GPA-Direct packet, which contains a set of GPA
578 * ranges, in addition to commands and/or data.
579 */
580struct vmdata_gpa_direct {
581 struct vmpacket_descriptor d;
582 u32 reserved;
583 u32 range_cnt;
584 struct gpa_range range[1];
585} __packed;
586
587/* This is the format for a Additional Data Packet. */
588struct vmadditional_data {
589 struct vmpacket_descriptor d;
590 u64 total_bytes;
591 u32 offset;
592 u32 byte_cnt;
593 unsigned char data[1];
594} __packed;
595
596union vmpacket_largest_possible_header {
597 struct vmpacket_descriptor simple_hdr;
598 struct vmtransfer_page_packet_header xfer_page_hdr;
599 struct vmgpadl_packet_header gpadl_hdr;
600 struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr;
601 struct vmestablish_gpadl establish_gpadl_hdr;
602 struct vmteardown_gpadl teardown_gpadl_hdr;
603 struct vmdata_gpa_direct data_gpa_direct_hdr;
604};
605
606#define VMPACKET_DATA_START_ADDRESS(__packet) \
607 (void *)(((unsigned char *)__packet) + \
608 ((struct vmpacket_descriptor)__packet)->offset8 * 8)
609
610#define VMPACKET_DATA_LENGTH(__packet) \
611 ((((struct vmpacket_descriptor)__packet)->len8 - \
612 ((struct vmpacket_descriptor)__packet)->offset8) * 8)
613
614#define VMPACKET_TRANSFER_MODE(__packet) \
615 (((struct IMPACT)__packet)->type)
616
617enum vmbus_packet_type {
618 VM_PKT_INVALID = 0x0,
619 VM_PKT_SYNCH = 0x1,
620 VM_PKT_ADD_XFER_PAGESET = 0x2,
621 VM_PKT_RM_XFER_PAGESET = 0x3,
622 VM_PKT_ESTABLISH_GPADL = 0x4,
623 VM_PKT_TEARDOWN_GPADL = 0x5,
624 VM_PKT_DATA_INBAND = 0x6,
625 VM_PKT_DATA_USING_XFER_PAGES = 0x7,
626 VM_PKT_DATA_USING_GPADL = 0x8,
627 VM_PKT_DATA_USING_GPA_DIRECT = 0x9,
628 VM_PKT_CANCEL_REQUEST = 0xa,
629 VM_PKT_COMP = 0xb,
630 VM_PKT_DATA_USING_ADDITIONAL_PKT = 0xc,
631 VM_PKT_ADDITIONAL_DATA = 0xd
632};
633
634#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700635
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700636
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700637/* Version 1 messages */
638enum vmbus_channel_message_type {
639 CHANNELMSG_INVALID = 0,
640 CHANNELMSG_OFFERCHANNEL = 1,
641 CHANNELMSG_RESCIND_CHANNELOFFER = 2,
642 CHANNELMSG_REQUESTOFFERS = 3,
643 CHANNELMSG_ALLOFFERS_DELIVERED = 4,
644 CHANNELMSG_OPENCHANNEL = 5,
645 CHANNELMSG_OPENCHANNEL_RESULT = 6,
646 CHANNELMSG_CLOSECHANNEL = 7,
647 CHANNELMSG_GPADL_HEADER = 8,
648 CHANNELMSG_GPADL_BODY = 9,
649 CHANNELMSG_GPADL_CREATED = 10,
650 CHANNELMSG_GPADL_TEARDOWN = 11,
651 CHANNELMSG_GPADL_TORNDOWN = 12,
652 CHANNELMSG_RELID_RELEASED = 13,
653 CHANNELMSG_INITIATE_CONTACT = 14,
654 CHANNELMSG_VERSION_RESPONSE = 15,
655 CHANNELMSG_UNLOAD = 16,
656#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
657 CHANNELMSG_VIEWRANGE_ADD = 17,
658 CHANNELMSG_VIEWRANGE_REMOVE = 18,
659#endif
660 CHANNELMSG_COUNT
661};
662
663struct vmbus_channel_message_header {
664 enum vmbus_channel_message_type msgtype;
665 u32 padding;
666} __packed;
667
668/* Query VMBus Version parameters */
669struct vmbus_channel_query_vmbus_version {
670 struct vmbus_channel_message_header header;
671 u32 version;
672} __packed;
673
674/* VMBus Version Supported parameters */
675struct vmbus_channel_version_supported {
676 struct vmbus_channel_message_header header;
K. Y. Srinivasan1508d812012-08-16 08:23:20 -0700677 u8 version_supported;
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700678} __packed;
679
680/* Offer Channel parameters */
681struct vmbus_channel_offer_channel {
682 struct vmbus_channel_message_header header;
683 struct vmbus_channel_offer offer;
684 u32 child_relid;
685 u8 monitorid;
K. Y. Srinivasan29423b72012-12-01 06:46:40 -0800686 /*
687 * win7 and beyond splits this field into a bit field.
688 */
689 u8 monitor_allocated:1;
690 u8 reserved:7;
691 /*
692 * These are new fields added in win7 and later.
693 * Do not access these fields without checking the
694 * negotiated protocol.
695 *
696 * If "is_dedicated_interrupt" is set, we must not set the
697 * associated bit in the channel bitmap while sending the
698 * interrupt to the host.
699 *
700 * connection_id is to be used in signaling the host.
701 */
702 u16 is_dedicated_interrupt:1;
703 u16 reserved1:15;
704 u32 connection_id;
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700705} __packed;
706
707/* Rescind Offer parameters */
708struct vmbus_channel_rescind_offer {
709 struct vmbus_channel_message_header header;
710 u32 child_relid;
711} __packed;
712
713/*
714 * Request Offer -- no parameters, SynIC message contains the partition ID
715 * Set Snoop -- no parameters, SynIC message contains the partition ID
716 * Clear Snoop -- no parameters, SynIC message contains the partition ID
717 * All Offers Delivered -- no parameters, SynIC message contains the partition
718 * ID
719 * Flush Client -- no parameters, SynIC message contains the partition ID
720 */
721
722/* Open Channel parameters */
723struct vmbus_channel_open_channel {
724 struct vmbus_channel_message_header header;
725
726 /* Identifies the specific VMBus channel that is being opened. */
727 u32 child_relid;
728
729 /* ID making a particular open request at a channel offer unique. */
730 u32 openid;
731
732 /* GPADL for the channel's ring buffer. */
733 u32 ringbuffer_gpadlhandle;
734
735 /* GPADL for the channel's server context save area. */
736 u32 server_contextarea_gpadlhandle;
737
738 /*
739 * The upstream ring buffer begins at offset zero in the memory
740 * described by RingBufferGpadlHandle. The downstream ring buffer
741 * follows it at this offset (in pages).
742 */
743 u32 downstream_ringbuffer_pageoffset;
744
745 /* User-specific data to be passed along to the server endpoint. */
746 unsigned char userdata[MAX_USER_DEFINED_BYTES];
747} __packed;
748
749/* Open Channel Result parameters */
750struct vmbus_channel_open_result {
751 struct vmbus_channel_message_header header;
752 u32 child_relid;
753 u32 openid;
754 u32 status;
755} __packed;
756
757/* Close channel parameters; */
758struct vmbus_channel_close_channel {
759 struct vmbus_channel_message_header header;
760 u32 child_relid;
761} __packed;
762
763/* Channel Message GPADL */
764#define GPADL_TYPE_RING_BUFFER 1
765#define GPADL_TYPE_SERVER_SAVE_AREA 2
766#define GPADL_TYPE_TRANSACTION 8
767
768/*
769 * The number of PFNs in a GPADL message is defined by the number of
770 * pages that would be spanned by ByteCount and ByteOffset. If the
771 * implied number of PFNs won't fit in this packet, there will be a
772 * follow-up packet that contains more.
773 */
774struct vmbus_channel_gpadl_header {
775 struct vmbus_channel_message_header header;
776 u32 child_relid;
777 u32 gpadl;
778 u16 range_buflen;
779 u16 rangecount;
780 struct gpa_range range[0];
781} __packed;
782
783/* This is the followup packet that contains more PFNs. */
784struct vmbus_channel_gpadl_body {
785 struct vmbus_channel_message_header header;
786 u32 msgnumber;
787 u32 gpadl;
788 u64 pfn[0];
789} __packed;
790
791struct vmbus_channel_gpadl_created {
792 struct vmbus_channel_message_header header;
793 u32 child_relid;
794 u32 gpadl;
795 u32 creation_status;
796} __packed;
797
798struct vmbus_channel_gpadl_teardown {
799 struct vmbus_channel_message_header header;
800 u32 child_relid;
801 u32 gpadl;
802} __packed;
803
804struct vmbus_channel_gpadl_torndown {
805 struct vmbus_channel_message_header header;
806 u32 gpadl;
807} __packed;
808
809#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
810struct vmbus_channel_view_range_add {
811 struct vmbus_channel_message_header header;
812 PHYSICAL_ADDRESS viewrange_base;
813 u64 viewrange_length;
814 u32 child_relid;
815} __packed;
816
817struct vmbus_channel_view_range_remove {
818 struct vmbus_channel_message_header header;
819 PHYSICAL_ADDRESS viewrange_base;
820 u32 child_relid;
821} __packed;
822#endif
823
824struct vmbus_channel_relid_released {
825 struct vmbus_channel_message_header header;
826 u32 child_relid;
827} __packed;
828
829struct vmbus_channel_initiate_contact {
830 struct vmbus_channel_message_header header;
831 u32 vmbus_version_requested;
832 u32 padding2;
833 u64 interrupt_page;
834 u64 monitor_page1;
835 u64 monitor_page2;
836} __packed;
837
838struct vmbus_channel_version_response {
839 struct vmbus_channel_message_header header;
K. Y. Srinivasan1508d812012-08-16 08:23:20 -0700840 u8 version_supported;
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700841} __packed;
842
843enum vmbus_channel_state {
844 CHANNEL_OFFER_STATE,
845 CHANNEL_OPENING_STATE,
846 CHANNEL_OPEN_STATE,
847};
848
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700849struct vmbus_channel_debug_info {
850 u32 relid;
851 enum vmbus_channel_state state;
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -0700852 uuid_le interfacetype;
853 uuid_le interface_instance;
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700854 u32 monitorid;
855 u32 servermonitor_pending;
856 u32 servermonitor_latency;
857 u32 servermonitor_connectionid;
858 u32 clientmonitor_pending;
859 u32 clientmonitor_latency;
860 u32 clientmonitor_connectionid;
861
862 struct hv_ring_buffer_debug_info inbound;
863 struct hv_ring_buffer_debug_info outbound;
864};
865
866/*
867 * Represents each channel msg on the vmbus connection This is a
868 * variable-size data structure depending on the msg type itself
869 */
870struct vmbus_channel_msginfo {
871 /* Bookkeeping stuff */
872 struct list_head msglistentry;
873
874 /* So far, this is only used to handle gpadl body message */
875 struct list_head submsglist;
876
877 /* Synchronize the request/response if needed */
878 struct completion waitevent;
879 union {
880 struct vmbus_channel_version_supported version_supported;
881 struct vmbus_channel_open_result open_result;
882 struct vmbus_channel_gpadl_torndown gpadl_torndown;
883 struct vmbus_channel_gpadl_created gpadl_created;
884 struct vmbus_channel_version_response version_response;
885 } response;
886
887 u32 msgsize;
888 /*
889 * The channel message that goes out on the "wire".
890 * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
891 */
892 unsigned char msg[0];
893};
894
K. Y. Srinivasanf9f1db82011-06-06 15:49:58 -0700895struct vmbus_close_msg {
896 struct vmbus_channel_msginfo info;
897 struct vmbus_channel_close_channel msg;
898};
899
K. Y. Srinivasanb3bf60c2012-12-01 06:46:45 -0800900/* Define connection identifier type. */
901union hv_connection_id {
902 u32 asu32;
903 struct {
904 u32 id:24;
905 u32 reserved:8;
906 } u;
907};
908
909/* Definition of the hv_signal_event hypercall input structure. */
910struct hv_input_signal_event {
911 union hv_connection_id connectionid;
912 u16 flag_number;
913 u16 rsvdz;
914};
915
916struct hv_input_signal_event_buffer {
917 u64 align8;
918 struct hv_input_signal_event event;
919};
920
K. Y. Srinivasan7d7c75c2011-06-06 15:49:57 -0700921struct vmbus_channel {
922 struct list_head listentry;
923
924 struct hv_device *device_obj;
925
926 struct work_struct work;
927
928 enum vmbus_channel_state state;
K. Y. Srinivasan7d7c75c2011-06-06 15:49:57 -0700929
930 struct vmbus_channel_offer_channel offermsg;
931 /*
932 * These are based on the OfferMsg.MonitorId.
933 * Save it here for easy access.
934 */
935 u8 monitor_grp;
936 u8 monitor_bit;
937
938 u32 ringbuffer_gpadlhandle;
939
940 /* Allocated memory for ring buffer */
941 void *ringbuffer_pages;
942 u32 ringbuffer_pagecount;
943 struct hv_ring_buffer_info outbound; /* send to parent */
944 struct hv_ring_buffer_info inbound; /* receive from parent */
945 spinlock_t inbound_lock;
946 struct workqueue_struct *controlwq;
947
K. Y. Srinivasanf9f1db82011-06-06 15:49:58 -0700948 struct vmbus_close_msg close_msg;
949
K. Y. Srinivasan7d7c75c2011-06-06 15:49:57 -0700950 /* Channel callback are invoked in this workqueue context */
951 /* HANDLE dataWorkQueue; */
952
953 void (*onchannel_callback)(void *context);
954 void *channel_callback_context;
K. Y. Srinivasan132368b2012-12-01 06:46:33 -0800955
956 /*
957 * A channel can be marked for efficient (batched)
958 * reading:
959 * If batched_reading is set to "true", we read until the
960 * channel is empty and hold off interrupts from the host
961 * during the entire read process.
962 * If batched_reading is set to "false", the client is not
963 * going to perform batched reading.
964 *
965 * By default we will enable batched reading; specific
966 * drivers that don't want this behavior can turn it off.
967 */
968
969 bool batched_reading;
K. Y. Srinivasanb3bf60c2012-12-01 06:46:45 -0800970
971 bool is_dedicated_interrupt;
972 struct hv_input_signal_event_buffer sig_buf;
973 struct hv_input_signal_event *sig_event;
K. Y. Srinivasan7d7c75c2011-06-06 15:49:57 -0700974};
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700975
K. Y. Srinivasan132368b2012-12-01 06:46:33 -0800976static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
977{
978 c->batched_reading = state;
979}
980
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700981void vmbus_onmessage(void *context);
982
983int vmbus_request_offers(void);
984
K. Y. Srinivasanc35470b2011-05-12 19:34:22 -0700985/* The format must be the same as struct vmdata_gpa_direct */
986struct vmbus_channel_packet_page_buffer {
987 u16 type;
988 u16 dataoffset8;
989 u16 length8;
990 u16 flags;
991 u64 transactionid;
992 u32 reserved;
993 u32 rangecount;
994 struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
995} __packed;
996
997/* The format must be the same as struct vmdata_gpa_direct */
998struct vmbus_channel_packet_multipage_buffer {
999 u16 type;
1000 u16 dataoffset8;
1001 u16 length8;
1002 u16 flags;
1003 u64 transactionid;
1004 u32 reserved;
1005 u32 rangecount; /* Always 1 in this case */
1006 struct hv_multipage_buffer range;
1007} __packed;
1008
1009
1010extern int vmbus_open(struct vmbus_channel *channel,
1011 u32 send_ringbuffersize,
1012 u32 recv_ringbuffersize,
1013 void *userdata,
1014 u32 userdatalen,
1015 void(*onchannel_callback)(void *context),
1016 void *context);
1017
1018extern void vmbus_close(struct vmbus_channel *channel);
1019
1020extern int vmbus_sendpacket(struct vmbus_channel *channel,
1021 const void *buffer,
1022 u32 bufferLen,
1023 u64 requestid,
1024 enum vmbus_packet_type type,
1025 u32 flags);
1026
1027extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
1028 struct hv_page_buffer pagebuffers[],
1029 u32 pagecount,
1030 void *buffer,
1031 u32 bufferlen,
1032 u64 requestid);
1033
1034extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
1035 struct hv_multipage_buffer *mpb,
1036 void *buffer,
1037 u32 bufferlen,
1038 u64 requestid);
1039
1040extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
1041 void *kbuffer,
1042 u32 size,
1043 u32 *gpadl_handle);
1044
1045extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
1046 u32 gpadl_handle);
1047
1048extern int vmbus_recvpacket(struct vmbus_channel *channel,
1049 void *buffer,
1050 u32 bufferlen,
1051 u32 *buffer_actual_len,
1052 u64 *requestid);
1053
1054extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
1055 void *buffer,
1056 u32 bufferlen,
1057 u32 *buffer_actual_len,
1058 u64 *requestid);
1059
K. Y. Srinivasanc35470b2011-05-12 19:34:22 -07001060
1061extern void vmbus_get_debug_info(struct vmbus_channel *channel,
1062 struct vmbus_channel_debug_info *debug);
1063
1064extern void vmbus_ontimer(unsigned long data);
1065
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001066struct hv_dev_port_info {
1067 u32 int_mask;
1068 u32 read_idx;
1069 u32 write_idx;
1070 u32 bytes_avail_toread;
1071 u32 bytes_avail_towrite;
1072};
1073
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001074/* Base driver object */
1075struct hv_driver {
1076 const char *name;
1077
1078 /* the device type supported by this driver */
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -07001079 uuid_le dev_type;
K. Y. Srinivasan2e2c1d12011-08-25 09:48:31 -07001080 const struct hv_vmbus_device_id *id_table;
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001081
1082 struct device_driver driver;
1083
K. Y. Srinivasan84946892011-09-13 10:59:38 -07001084 int (*probe)(struct hv_device *, const struct hv_vmbus_device_id *);
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001085 int (*remove)(struct hv_device *);
1086 void (*shutdown)(struct hv_device *);
1087
1088};
1089
1090/* Base device object */
1091struct hv_device {
1092 /* the device type id of this device */
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -07001093 uuid_le dev_type;
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001094
1095 /* the device instance id of this device */
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -07001096 uuid_le dev_instance;
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001097
1098 struct device device;
1099
1100 struct vmbus_channel *channel;
K. Y. Srinivasan35ea09c2011-05-12 19:34:24 -07001101};
1102
K. Y. Srinivasan27b5b3c2011-05-12 19:34:25 -07001103
1104static inline struct hv_device *device_to_hv_device(struct device *d)
1105{
1106 return container_of(d, struct hv_device, device);
1107}
1108
1109static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
1110{
1111 return container_of(d, struct hv_driver, driver);
1112}
1113
K. Y. Srinivasanab101e82011-09-13 10:59:40 -07001114static inline void hv_set_drvdata(struct hv_device *dev, void *data)
1115{
1116 dev_set_drvdata(&dev->device, data);
1117}
1118
1119static inline void *hv_get_drvdata(struct hv_device *dev)
1120{
1121 return dev_get_drvdata(&dev->device);
1122}
K. Y. Srinivasan27b5b3c2011-05-12 19:34:25 -07001123
1124/* Vmbus interface */
Greg Kroah-Hartman768fa212011-08-25 15:07:32 -07001125#define vmbus_driver_register(driver) \
1126 __vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
1127int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
1128 struct module *owner,
1129 const char *mod_name);
1130void vmbus_driver_unregister(struct hv_driver *hv_driver);
K. Y. Srinivasan27b5b3c2011-05-12 19:34:25 -07001131
Greg Kroah-Hartmanc45cf2d2011-08-25 11:41:33 -07001132/**
1133 * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device
1134 *
1135 * This macro is used to create a struct hv_vmbus_device_id that matches a
1136 * specific device.
1137 */
1138#define VMBUS_DEVICE(g0, g1, g2, g3, g4, g5, g6, g7, \
1139 g8, g9, ga, gb, gc, gd, ge, gf) \
1140 .guid = { g0, g1, g2, g3, g4, g5, g6, g7, \
1141 g8, g9, ga, gb, gc, gd, ge, gf },
1142
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001143/*
1144 * Common header for Hyper-V ICs
1145 */
1146
1147#define ICMSGTYPE_NEGOTIATE 0
1148#define ICMSGTYPE_HEARTBEAT 1
1149#define ICMSGTYPE_KVPEXCHANGE 2
1150#define ICMSGTYPE_SHUTDOWN 3
1151#define ICMSGTYPE_TIMESYNC 4
1152#define ICMSGTYPE_VSS 5
1153
1154#define ICMSGHDRFLAG_TRANSACTION 1
1155#define ICMSGHDRFLAG_REQUEST 2
1156#define ICMSGHDRFLAG_RESPONSE 4
1157
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001158
K. Y. Srinivasana29b6432011-09-18 10:31:33 -07001159/*
1160 * While we want to handle util services as regular devices,
1161 * there is only one instance of each of these services; so
1162 * we statically allocate the service specific state.
1163 */
1164
1165struct hv_util_service {
1166 u8 *recv_buffer;
1167 void (*util_cb)(void *);
1168 int (*util_init)(struct hv_util_service *);
1169 void (*util_deinit)(void);
1170};
1171
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001172struct vmbuspipe_hdr {
1173 u32 flags;
1174 u32 msgsize;
1175} __packed;
1176
1177struct ic_version {
1178 u16 major;
1179 u16 minor;
1180} __packed;
1181
1182struct icmsg_hdr {
1183 struct ic_version icverframe;
1184 u16 icmsgtype;
1185 struct ic_version icvermsg;
1186 u16 icmsgsize;
1187 u32 status;
1188 u8 ictransaction_id;
1189 u8 icflags;
1190 u8 reserved[2];
1191} __packed;
1192
1193struct icmsg_negotiate {
1194 u16 icframe_vercnt;
1195 u16 icmsg_vercnt;
1196 u32 reserved;
1197 struct ic_version icversion_data[1]; /* any size array */
1198} __packed;
1199
1200struct shutdown_msg_data {
1201 u32 reason_code;
1202 u32 timeout_seconds;
1203 u32 flags;
1204 u8 display_message[2048];
1205} __packed;
1206
1207struct heartbeat_msg_data {
1208 u64 seq_num;
1209 u32 reserved[8];
1210} __packed;
1211
1212/* Time Sync IC defs */
1213#define ICTIMESYNCFLAG_PROBE 0
1214#define ICTIMESYNCFLAG_SYNC 1
1215#define ICTIMESYNCFLAG_SAMPLE 2
1216
1217#ifdef __x86_64__
1218#define WLTIMEDELTA 116444736000000000L /* in 100ns unit */
1219#else
1220#define WLTIMEDELTA 116444736000000000LL
1221#endif
1222
1223struct ictimesync_data {
1224 u64 parenttime;
1225 u64 childtime;
1226 u64 roundtriptime;
1227 u8 flags;
1228} __packed;
1229
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001230struct hyperv_service_callback {
1231 u8 msg_type;
1232 char *log_msg;
K. Y. Srinivasan358d2ee2011-08-25 09:48:28 -07001233 uuid_le data;
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001234 struct vmbus_channel *channel;
1235 void (*callback) (void *context);
1236};
1237
K. Y. Srinivasanc836d0a2012-05-12 13:44:58 -07001238#define MAX_SRV_VER 0x7ffffff
Greg Kroah-Hartmanda0e9632011-10-11 08:42:28 -06001239extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *,
K. Y. Srinivasanc836d0a2012-05-12 13:44:58 -07001240 struct icmsg_negotiate *, u8 *, int,
1241 int);
K. Y. Srinivasanb1897022011-05-12 19:34:26 -07001242
K. Y. Srinivasan29394372012-01-27 15:55:58 -08001243int hv_kvp_init(struct hv_util_service *);
1244void hv_kvp_deinit(void);
1245void hv_kvp_onchannelcallback(void *);
1246
K. Y. Srinivasan37f72782012-12-01 06:46:41 -08001247/*
1248 * Negotiated version with the Host.
1249 */
1250
1251extern __u32 vmbus_proto_version;
1252
K. Y. Srinivasan29394372012-01-27 15:55:58 -08001253#endif /* __KERNEL__ */
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -07001254#endif /* _HYPERV_H */