3 * Copyright (c) 2009, Microsoft Corporation.
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.
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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
24 #ifndef _VMBUSPACKETFORMAT_H_
26 struct vmpacket_descriptor
{
32 } __attribute__((packed
));
34 struct vmpacket_header
{
35 u32 PreviousPacketStartOffset
;
36 struct vmpacket_descriptor Descriptor
;
37 } __attribute__((packed
));
39 struct vmtransfer_page_range
{
42 } __attribute__((packed
));
44 struct vmtransfer_page_packet_header
{
45 struct vmpacket_descriptor d
;
46 u16 TransferPageSetId
;
50 struct vmtransfer_page_range Ranges
[1];
51 } __attribute__((packed
));
53 struct vmgpadl_packet_header
{
54 struct vmpacket_descriptor d
;
57 } __attribute__((packed
));
59 struct vmadd_remove_transfer_page_set
{
60 struct vmpacket_descriptor d
;
62 u16 TransferPageSetId
;
64 } __attribute__((packed
));
67 * This structure defines a range in guest physical space that can be made to
68 * look virtually contiguous.
77 * This is the format for an Establish Gpadl packet, which contains a handle by
78 * which this GPADL will be known and a set of GPA ranges associated with it.
79 * This can be converted to a MDL by the guest OS. If there are multiple GPA
80 * ranges, then the resulting MDL will be "chained," representing multiple VA
83 struct vmestablish_gpadl
{
84 struct vmpacket_descriptor d
;
87 struct gpa_range Range
[1];
88 } __attribute__((packed
));
91 * This is the format for a Teardown Gpadl packet, which indicates that the
92 * GPADL handle in the Establish Gpadl packet will never be referenced again.
94 struct vmteardown_gpadl
{
95 struct vmpacket_descriptor d
;
97 u32 Reserved
; /* for alignment to a 8-byte boundary */
98 } __attribute__((packed
));
101 * This is the format for a GPA-Direct packet, which contains a set of GPA
102 * ranges, in addition to commands and/or data.
104 struct vmdata_gpa_direct
{
105 struct vmpacket_descriptor d
;
108 struct gpa_range Range
[1];
109 } __attribute__((packed
));
111 /* This is the format for a Additional Data Packet. */
112 struct vmadditional_data
{
113 struct vmpacket_descriptor d
;
117 unsigned char Data
[1];
118 } __attribute__((packed
));
120 union vmpacket_largest_possible_header
{
121 struct vmpacket_descriptor SimpleHeader
;
122 struct vmtransfer_page_packet_header TransferPageHeader
;
123 struct vmgpadl_packet_header GpadlHeader
;
124 struct vmadd_remove_transfer_page_set AddRemoveTransferPageHeader
;
125 struct vmestablish_gpadl EstablishGpadlHeader
;
126 struct vmteardown_gpadl TeardownGpadlHeader
;
127 struct vmdata_gpa_direct DataGpaDirectHeader
;
130 #define VMPACKET_DATA_START_ADDRESS(__packet) \
131 (void *)(((unsigned char *)__packet) + \
132 ((struct vmpacket_descriptor)__packet)->DataOffset8 * 8)
134 #define VMPACKET_DATA_LENGTH(__packet) \
135 ((((struct vmpacket_descriptor)__packet)->Length8 - \
136 ((struct vmpacket_descriptor)__packet)->DataOffset8) * 8)
138 #define VMPACKET_TRANSFER_MODE(__packet) \
139 (((struct IMPACT)__packet)->Type)
141 enum vmbus_packet_type
{
142 VmbusPacketTypeInvalid
= 0x0,
143 VmbusPacketTypeSynch
= 0x1,
144 VmbusPacketTypeAddTransferPageSet
= 0x2,
145 VmbusPacketTypeRemoveTransferPageSet
= 0x3,
146 VmbusPacketTypeEstablishGpadl
= 0x4,
147 VmbusPacketTypeTearDownGpadl
= 0x5,
148 VmbusPacketTypeDataInBand
= 0x6,
149 VmbusPacketTypeDataUsingTransferPages
= 0x7,
150 VmbusPacketTypeDataUsingGpadl
= 0x8,
151 VmbusPacketTypeDataUsingGpaDirect
= 0x9,
152 VmbusPacketTypeCancelRequest
= 0xa,
153 VmbusPacketTypeCompletion
= 0xb,
154 VmbusPacketTypeDataUsingAdditionalPackets
= 0xc,
155 VmbusPacketTypeAdditionalData
= 0xd
158 #define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1