x86-64: support native xadd rwsem implementation
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / VmbusApi.h
blobd089bb193e7d236b69d06ba35cbe2f8661924bd8
1 /*
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
12 * more details.
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.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _VMBUS_API_H_
26 #define _VMBUS_API_H_
28 #define MAX_PAGE_BUFFER_COUNT 16
29 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
31 #pragma pack(push, 1)
33 /* Single-page buffer */
34 struct hv_page_buffer {
35 u32 Length;
36 u32 Offset;
37 u64 Pfn;
40 /* Multiple-page buffer */
41 struct hv_multipage_buffer {
42 /* Length and Offset determines the # of pfns in the array */
43 u32 Length;
44 u32 Offset;
45 u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
48 /* 0x18 includes the proprietary packet header */
49 #define MAX_PAGE_BUFFER_PACKET (0x18 + \
50 (sizeof(struct hv_page_buffer) * \
51 MAX_PAGE_BUFFER_COUNT))
52 #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \
53 sizeof(struct hv_multipage_buffer))
56 #pragma pack(pop)
58 struct hv_driver;
59 struct hv_device;
61 struct hv_dev_port_info {
62 u32 InterruptMask;
63 u32 ReadIndex;
64 u32 WriteIndex;
65 u32 BytesAvailToRead;
66 u32 BytesAvailToWrite;
69 struct hv_device_info {
70 u32 ChannelId;
71 u32 ChannelState;
72 struct hv_guid ChannelType;
73 struct hv_guid ChannelInstance;
75 u32 MonitorId;
76 u32 ServerMonitorPending;
77 u32 ServerMonitorLatency;
78 u32 ServerMonitorConnectionId;
79 u32 ClientMonitorPending;
80 u32 ClientMonitorLatency;
81 u32 ClientMonitorConnectionId;
83 struct hv_dev_port_info Inbound;
84 struct hv_dev_port_info Outbound;
87 struct vmbus_channel_interface {
88 int (*Open)(struct hv_device *Device, u32 SendBufferSize,
89 u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
90 void (*ChannelCallback)(void *context),
91 void *Context);
92 void (*Close)(struct hv_device *device);
93 int (*SendPacket)(struct hv_device *Device, const void *Buffer,
94 u32 BufferLen, u64 RequestId, u32 Type, u32 Flags);
95 int (*SendPacketPageBuffer)(struct hv_device *dev,
96 struct hv_page_buffer PageBuffers[],
97 u32 PageCount, void *Buffer, u32 BufferLen,
98 u64 RequestId);
99 int (*SendPacketMultiPageBuffer)(struct hv_device *device,
100 struct hv_multipage_buffer *mpb,
101 void *Buffer,
102 u32 BufferLen,
103 u64 RequestId);
104 int (*RecvPacket)(struct hv_device *dev, void *buf, u32 buflen,
105 u32 *BufferActualLen, u64 *RequestId);
106 int (*RecvPacketRaw)(struct hv_device *dev, void *buf, u32 buflen,
107 u32 *BufferActualLen, u64 *RequestId);
108 int (*EstablishGpadl)(struct hv_device *dev, void *buf, u32 buflen,
109 u32 *GpadlHandle);
110 int (*TeardownGpadl)(struct hv_device *device, u32 GpadlHandle);
111 void (*GetInfo)(struct hv_device *dev, struct hv_device_info *devinfo);
114 /* Base driver object */
115 struct hv_driver {
116 const char *name;
118 /* the device type supported by this driver */
119 struct hv_guid deviceType;
121 int (*OnDeviceAdd)(struct hv_device *device, void *data);
122 int (*OnDeviceRemove)(struct hv_device *device);
123 void (*OnCleanup)(struct hv_driver *driver);
125 struct vmbus_channel_interface VmbusChannelInterface;
128 /* Base device object */
129 struct hv_device {
130 /* the driver for this device */
131 struct hv_driver *Driver;
133 char name[64];
135 /* the device type id of this device */
136 struct hv_guid deviceType;
138 /* the device instance id of this device */
139 struct hv_guid deviceInstance;
141 void *context;
143 /* Device extension; */
144 void *Extension;
147 /* Vmbus driver object */
148 struct vmbus_driver {
149 /* !! Must be the 1st field !! */
150 /* FIXME if ^, then someone is doing somthing stupid */
151 struct hv_driver Base;
153 /* Set by the caller */
154 struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType,
155 struct hv_guid *DeviceInstance,
156 void *Context);
157 void (*OnChildDeviceDestroy)(struct hv_device *device);
158 int (*OnChildDeviceAdd)(struct hv_device *RootDevice,
159 struct hv_device *ChildDevice);
160 void (*OnChildDeviceRemove)(struct hv_device *device);
162 /* Set by the callee */
163 int (*OnIsr)(struct hv_driver *driver);
164 void (*OnMsgDpc)(struct hv_driver *driver);
165 void (*OnEventDpc)(struct hv_driver *driver);
166 void (*GetChannelOffers)(void);
168 void (*GetChannelInterface)(struct vmbus_channel_interface *i);
169 void (*GetChannelInfo)(struct hv_device *dev,
170 struct hv_device_info *devinfo);
173 int VmbusInitialize(struct hv_driver *drv);
175 #endif /* _VMBUS_API_H_ */