]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/staging/hv/vmbus_api.h
2af42e55007633e1c8b94051bf3634017a8d07d2
[mv-sheeva.git] / drivers / staging / hv / vmbus_api.h
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
28 #define MAX_PAGE_BUFFER_COUNT                           16
29 #define MAX_MULTIPAGE_BUFFER_COUNT                      32 /* 128K */
30
31 #pragma pack(push, 1)
32
33 /* Single-page buffer */
34 struct hv_page_buffer {
35         u32 Length;
36         u32 Offset;
37         u64 Pfn;
38 };
39
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];
46 };
47
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))
54
55
56 #pragma pack(pop)
57
58 struct hv_driver;
59 struct hv_device;
60
61 struct hv_dev_port_info {
62         u32 InterruptMask;
63         u32 ReadIndex;
64         u32 WriteIndex;
65         u32 BytesAvailToRead;
66         u32 BytesAvailToWrite;
67 };
68
69 struct hv_device_info {
70         u32 ChannelId;
71         u32 ChannelState;
72         struct hv_guid ChannelType;
73         struct hv_guid ChannelInstance;
74
75         u32 MonitorId;
76         u32 ServerMonitorPending;
77         u32 ServerMonitorLatency;
78         u32 ServerMonitorConnectionId;
79         u32 ClientMonitorPending;
80         u32 ClientMonitorLatency;
81         u32 ClientMonitorConnectionId;
82
83         struct hv_dev_port_info Inbound;
84         struct hv_dev_port_info Outbound;
85 };
86
87 /* Base driver object */
88 struct hv_driver {
89         const char *name;
90
91         /* the device type supported by this driver */
92         struct hv_guid deviceType;
93
94         int (*OnDeviceAdd)(struct hv_device *device, void *data);
95         int (*OnDeviceRemove)(struct hv_device *device);
96         void (*OnCleanup)(struct hv_driver *driver);
97 };
98
99 /* Base device object */
100 struct hv_device {
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;
108
109         /* the device instance id of this device */
110         struct hv_guid deviceInstance;
111
112         struct vmbus_channel *channel;
113
114         /* Device extension; */
115         void *Extension;
116 };
117
118 /* Vmbus driver object */
119 struct vmbus_driver {
120         /* !! Must be the 1st field !! */
121         /* FIXME if ^, then someone is doing somthing stupid */
122         struct hv_driver Base;
123
124         /* Set by the caller */
125         struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType,
126                                                 struct hv_guid *DeviceInstance,
127                                                 struct vmbus_channel *channel);
128         void (*OnChildDeviceDestroy)(struct hv_device *device);
129         int (*OnChildDeviceAdd)(struct hv_device *RootDevice,
130                                 struct hv_device *ChildDevice);
131         void (*OnChildDeviceRemove)(struct hv_device *device);
132
133         /* Set by the callee */
134         int (*OnIsr)(struct hv_driver *driver);
135         void (*OnMsgDpc)(struct hv_driver *driver);
136         void (*OnEventDpc)(struct hv_driver *driver);
137         void (*GetChannelOffers)(void);
138 };
139
140 int VmbusInitialize(struct hv_driver *drv);
141
142 #endif /* _VMBUS_API_H_ */