]>
Commit | Line | Data |
---|---|---|
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 | 34 | struct hv_page_buffer { |
54b2b847 GKH |
35 | u32 Length; |
36 | u32 Offset; | |
37 | u64 Pfn; | |
ee3d7ddf | 38 | }; |
ab057781 | 39 | |
454f18a9 | 40 | /* Multiple-page buffer */ |
ee3d7ddf | 41 | struct 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 | 58 | struct hv_driver; |
3d3b5518 NP |
59 | struct hv_device; |
60 | ||
ee3d7ddf | 61 | struct 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 | 69 | struct 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 | |
454f18a9 | 87 | /* Base driver object */ |
775ef25e | 88 | struct hv_driver { |
54b2b847 GKH |
89 | const char *name; |
90 | ||
91 | /* the device type supported by this driver */ | |
92 | struct hv_guid deviceType; | |
ab057781 | 93 | |
74982610 GKH |
94 | int (*OnDeviceAdd)(struct hv_device *device, void *data); |
95 | int (*OnDeviceRemove)(struct hv_device *device); | |
96 | void (*OnCleanup)(struct hv_driver *driver); | |
775ef25e | 97 | }; |
ab057781 | 98 | |
454f18a9 | 99 | /* Base device object */ |
3d3b5518 | 100 | struct hv_device { |
54b2b847 GKH |
101 | /* the driver for this device */ |
102 | struct hv_driver *Driver; | |
103 | ||
104 | char name[64]; | |
105 | ||
106 | /* the device type id of this device */ | |
107 | struct hv_guid deviceType; | |
ab057781 | 108 | |
54b2b847 GKH |
109 | /* the device instance id of this device */ |
110 | struct hv_guid deviceInstance; | |
111 | ||
cae5b843 | 112 | struct vmbus_channel *channel; |
54b2b847 GKH |
113 | |
114 | /* Device extension; */ | |
115 | void *Extension; | |
116 | }; | |
ab057781 | 117 | |
454f18a9 | 118 | /* Vmbus driver object */ |
ee3d7ddf | 119 | struct vmbus_driver { |
54b2b847 GKH |
120 | /* !! Must be the 1st field !! */ |
121 | /* FIXME if ^, then someone is doing somthing stupid */ | |
122 | struct hv_driver Base; | |
ab057781 | 123 | |
454f18a9 | 124 | /* Set by the caller */ |
74982610 GKH |
125 | void (*OnChildDeviceDestroy)(struct hv_device *device); |
126 | int (*OnChildDeviceAdd)(struct hv_device *RootDevice, | |
127 | struct hv_device *ChildDevice); | |
128 | void (*OnChildDeviceRemove)(struct hv_device *device); | |
ab057781 | 129 | |
454f18a9 | 130 | /* Set by the callee */ |
74982610 GKH |
131 | int (*OnIsr)(struct hv_driver *driver); |
132 | void (*OnMsgDpc)(struct hv_driver *driver); | |
133 | void (*OnEventDpc)(struct hv_driver *driver); | |
134 | void (*GetChannelOffers)(void); | |
ee3d7ddf | 135 | }; |
ab057781 | 136 | |
54b2b847 | 137 | int VmbusInitialize(struct hv_driver *drv); |
ab057781 | 138 | |
454f18a9 | 139 | #endif /* _VMBUS_API_H_ */ |