Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / hv / vmbus_api.h
CommitLineData
ab057781
HJ
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
25#ifndef _VMBUS_API_H_
26#define _VMBUS_API_H_
27
ab057781 28#define MAX_PAGE_BUFFER_COUNT 16
454f18a9
BP
29#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
30
54b2b847 31#pragma pack(push, 1)
ab057781 32
454f18a9 33/* Single-page buffer */
ee3d7ddf 34struct hv_page_buffer {
54b2b847
GKH
35 u32 Length;
36 u32 Offset;
37 u64 Pfn;
ee3d7ddf 38};
ab057781 39
454f18a9 40/* Multiple-page buffer */
ee3d7ddf 41struct hv_multipage_buffer {
454f18a9 42 /* Length and Offset determines the # of pfns in the array */
54b2b847
GKH
43 u32 Length;
44 u32 Offset;
45 u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
ee3d7ddf 46};
ab057781 47
454f18a9 48/* 0x18 includes the proprietary packet header */
54b2b847 49#define MAX_PAGE_BUFFER_PACKET (0x18 + \
ee3d7ddf 50 (sizeof(struct hv_page_buffer) * \
54b2b847 51 MAX_PAGE_BUFFER_COUNT))
ee3d7ddf
GKH
52#define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \
53 sizeof(struct hv_multipage_buffer))
ab057781
HJ
54
55
56#pragma pack(pop)
57
775ef25e 58struct hv_driver;
3d3b5518
NP
59struct hv_device;
60
ee3d7ddf 61struct hv_dev_port_info {
54b2b847
GKH
62 u32 InterruptMask;
63 u32 ReadIndex;
64 u32 WriteIndex;
65 u32 BytesAvailToRead;
66 u32 BytesAvailToWrite;
ee3d7ddf 67};
ab057781 68
ee3d7ddf 69struct hv_device_info {
54b2b847
GKH
70 u32 ChannelId;
71 u32 ChannelState;
caf26a31
GKH
72 struct hv_guid ChannelType;
73 struct hv_guid ChannelInstance;
ab057781 74
54b2b847
GKH
75 u32 MonitorId;
76 u32 ServerMonitorPending;
77 u32 ServerMonitorLatency;
78 u32 ServerMonitorConnectionId;
79 u32 ClientMonitorPending;
80 u32 ClientMonitorLatency;
81 u32 ClientMonitorConnectionId;
ab057781 82
ee3d7ddf
GKH
83 struct hv_dev_port_info Inbound;
84 struct hv_dev_port_info Outbound;
85};
ab057781 86
3e189519
HJ
87/**
88 * struct vmbus_channel_interface - Contains member functions for vmbus channel
89 * @Open: Open the channel
90 * @Close: Close the channel
91 * @SendPacket: Send a packet over the channel
92 * @SendPacketPageBuffer: Send a single page buffer over the channel
93 * @SendPacketMultiPageBuffer: Send a multiple page buffers
94 * @RecvPacket: Receive packet
95 * @RecvPacketRaw: Receive Raw packet
96 * @EstablishGpadl: Set up GPADL for ringbuffer
97 * @TeardownGpadl: Teardown GPADL for ringbuffer
98 * @GetInfo: Get info about the channel
99 *
100 * This structure contains function pointer to control vmbus channel
101 * behavior. None of these functions is externally callable, but they
102 * are used for normal vmbus channel internal behavior.
103 * Only used by Hyper-V drivers.
104 */
ee3d7ddf 105struct vmbus_channel_interface {
74982610
GKH
106 int (*Open)(struct hv_device *Device, u32 SendBufferSize,
107 u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
108 void (*ChannelCallback)(void *context),
109 void *Context);
110 void (*Close)(struct hv_device *device);
111 int (*SendPacket)(struct hv_device *Device, const void *Buffer,
112 u32 BufferLen, u64 RequestId, u32 Type, u32 Flags);
113 int (*SendPacketPageBuffer)(struct hv_device *dev,
114 struct hv_page_buffer PageBuffers[],
115 u32 PageCount, void *Buffer, u32 BufferLen,
116 u64 RequestId);
117 int (*SendPacketMultiPageBuffer)(struct hv_device *device,
118 struct hv_multipage_buffer *mpb,
119 void *Buffer,
120 u32 BufferLen,
121 u64 RequestId);
122 int (*RecvPacket)(struct hv_device *dev, void *buf, u32 buflen,
123 u32 *BufferActualLen, u64 *RequestId);
124 int (*RecvPacketRaw)(struct hv_device *dev, void *buf, u32 buflen,
125 u32 *BufferActualLen, u64 *RequestId);
126 int (*EstablishGpadl)(struct hv_device *dev, void *buf, u32 buflen,
127 u32 *GpadlHandle);
128 int (*TeardownGpadl)(struct hv_device *device, u32 GpadlHandle);
129 void (*GetInfo)(struct hv_device *dev, struct hv_device_info *devinfo);
ee3d7ddf 130};
ab057781 131
454f18a9 132/* Base driver object */
775ef25e 133struct hv_driver {
54b2b847
GKH
134 const char *name;
135
136 /* the device type supported by this driver */
137 struct hv_guid deviceType;
ab057781 138
74982610
GKH
139 int (*OnDeviceAdd)(struct hv_device *device, void *data);
140 int (*OnDeviceRemove)(struct hv_device *device);
141 void (*OnCleanup)(struct hv_driver *driver);
ab057781 142
ee3d7ddf 143 struct vmbus_channel_interface VmbusChannelInterface;
775ef25e 144};
ab057781 145
454f18a9 146/* Base device object */
3d3b5518 147struct hv_device {
54b2b847
GKH
148 /* the driver for this device */
149 struct hv_driver *Driver;
150
151 char name[64];
152
153 /* the device type id of this device */
154 struct hv_guid deviceType;
ab057781 155
54b2b847
GKH
156 /* the device instance id of this device */
157 struct hv_guid deviceInstance;
158
159 void *context;
160
161 /* Device extension; */
162 void *Extension;
163};
ab057781 164
454f18a9 165/* Vmbus driver object */
ee3d7ddf 166struct vmbus_driver {
54b2b847
GKH
167 /* !! Must be the 1st field !! */
168 /* FIXME if ^, then someone is doing somthing stupid */
169 struct hv_driver Base;
ab057781 170
454f18a9 171 /* Set by the caller */
74982610
GKH
172 struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType,
173 struct hv_guid *DeviceInstance,
174 void *Context);
175 void (*OnChildDeviceDestroy)(struct hv_device *device);
176 int (*OnChildDeviceAdd)(struct hv_device *RootDevice,
177 struct hv_device *ChildDevice);
178 void (*OnChildDeviceRemove)(struct hv_device *device);
ab057781 179
454f18a9 180 /* Set by the callee */
74982610
GKH
181 int (*OnIsr)(struct hv_driver *driver);
182 void (*OnMsgDpc)(struct hv_driver *driver);
183 void (*OnEventDpc)(struct hv_driver *driver);
184 void (*GetChannelOffers)(void);
185
186 void (*GetChannelInterface)(struct vmbus_channel_interface *i);
187 void (*GetChannelInfo)(struct hv_device *dev,
188 struct hv_device_info *devinfo);
ee3d7ddf 189};
ab057781 190
54b2b847 191int VmbusInitialize(struct hv_driver *drv);
ab057781 192
454f18a9 193#endif /* _VMBUS_API_H_ */