linux/drivers/staging/hv/VmbusPacketFormat.h
<<
>>
Prefs
   1/*
   2 *
   3 * Copyright (c) 2009, 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 *
  22 */
  23
  24#ifndef _VMBUSPACKETFORMAT_H_
  25
  26struct vmpacket_descriptor {
  27        u16 Type;
  28        u16 DataOffset8;
  29        u16 Length8;
  30        u16 Flags;
  31        u64 TransactionId;
  32} __attribute__((packed));
  33
  34struct vmpacket_header {
  35        u32 PreviousPacketStartOffset;
  36        struct vmpacket_descriptor Descriptor;
  37} __attribute__((packed));
  38
  39struct vmtransfer_page_range {
  40        u32 ByteCount;
  41        u32 ByteOffset;
  42} __attribute__((packed));
  43
  44struct vmtransfer_page_packet_header {
  45        struct vmpacket_descriptor d;
  46        u16 TransferPageSetId;
  47        bool SenderOwnsSet;
  48        u8 Reserved;
  49        u32 RangeCount;
  50        struct vmtransfer_page_range Ranges[1];
  51} __attribute__((packed));
  52
  53struct vmgpadl_packet_header {
  54        struct vmpacket_descriptor d;
  55        u32 Gpadl;
  56        u32 Reserved;
  57} __attribute__((packed));
  58
  59struct vmadd_remove_transfer_page_set {
  60        struct vmpacket_descriptor d;
  61        u32 Gpadl;
  62        u16 TransferPageSetId;
  63        u16 Reserved;
  64} __attribute__((packed));
  65
  66/*
  67 * This structure defines a range in guest physical space that can be made to
  68 * look virtually contiguous.
  69 */
  70struct gpa_range {
  71        u32 ByteCount;
  72        u32 ByteOffset;
  73        u64 PfnArray[0];
  74};
  75
  76/*
  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
  81 * ranges.
  82 */
  83struct vmestablish_gpadl {
  84        struct vmpacket_descriptor d;
  85        u32 Gpadl;
  86        u32 RangeCount;
  87        struct gpa_range Range[1];
  88} __attribute__((packed));
  89
  90/*
  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.
  93 */
  94struct vmteardown_gpadl {
  95        struct vmpacket_descriptor d;
  96        u32 Gpadl;
  97        u32 Reserved;   /* for alignment to a 8-byte boundary */
  98} __attribute__((packed));
  99
 100/*
 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.
 103 */
 104struct vmdata_gpa_direct {
 105        struct vmpacket_descriptor d;
 106        u32 Reserved;
 107        u32 RangeCount;
 108        struct gpa_range Range[1];
 109} __attribute__((packed));
 110
 111/* This is the format for a Additional Data Packet. */
 112struct vmadditional_data {
 113        struct vmpacket_descriptor d;
 114        u64 TotalBytes;
 115        u32 ByteOffset;
 116        u32 ByteCount;
 117        unsigned char Data[1];
 118} __attribute__((packed));
 119
 120union 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;
 128};
 129
 130#define VMPACKET_DATA_START_ADDRESS(__packet)   \
 131        (void *)(((unsigned char *)__packet) +  \
 132         ((struct vmpacket_descriptor)__packet)->DataOffset8 * 8)
 133
 134#define VMPACKET_DATA_LENGTH(__packet)          \
 135        ((((struct vmpacket_descriptor)__packet)->Length8 -     \
 136          ((struct vmpacket_descriptor)__packet)->DataOffset8) * 8)
 137
 138#define VMPACKET_TRANSFER_MODE(__packet)        \
 139        (((struct IMPACT)__packet)->Type)
 140
 141enum 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
 156};
 157
 158#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED     1
 159
 160#endif
 161