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 | ||
150f9398 | 28 | #include <linux/device.h> |
a3c7fe9a | 29 | #include <linux/workqueue.h> |
150f9398 | 30 | |
ab057781 | 31 | #define MAX_PAGE_BUFFER_COUNT 16 |
454f18a9 BP |
32 | #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ |
33 | ||
54b2b847 | 34 | #pragma pack(push, 1) |
ab057781 | 35 | |
454f18a9 | 36 | /* Single-page buffer */ |
ee3d7ddf | 37 | struct hv_page_buffer { |
ca623ad3 HZ |
38 | u32 len; |
39 | u32 offset; | |
40 | u64 pfn; | |
ee3d7ddf | 41 | }; |
ab057781 | 42 | |
454f18a9 | 43 | /* Multiple-page buffer */ |
ee3d7ddf | 44 | struct hv_multipage_buffer { |
454f18a9 | 45 | /* Length and Offset determines the # of pfns in the array */ |
ca623ad3 HZ |
46 | u32 len; |
47 | u32 offset; | |
48 | u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT]; | |
ee3d7ddf | 49 | }; |
ab057781 | 50 | |
454f18a9 | 51 | /* 0x18 includes the proprietary packet header */ |
54b2b847 | 52 | #define MAX_PAGE_BUFFER_PACKET (0x18 + \ |
ee3d7ddf | 53 | (sizeof(struct hv_page_buffer) * \ |
54b2b847 | 54 | MAX_PAGE_BUFFER_COUNT)) |
ee3d7ddf GKH |
55 | #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \ |
56 | sizeof(struct hv_multipage_buffer)) | |
ab057781 HJ |
57 | |
58 | ||
59 | #pragma pack(pop) | |
60 | ||
775ef25e | 61 | struct hv_driver; |
3d3b5518 NP |
62 | struct hv_device; |
63 | ||
ee3d7ddf | 64 | struct hv_dev_port_info { |
ca623ad3 HZ |
65 | u32 int_mask; |
66 | u32 read_idx; | |
67 | u32 write_idx; | |
68 | u32 bytes_avail_toread; | |
69 | u32 bytes_avail_towrite; | |
ee3d7ddf | 70 | }; |
ab057781 | 71 | |
ee3d7ddf | 72 | struct hv_device_info { |
ca623ad3 HZ |
73 | u32 chn_id; |
74 | u32 chn_state; | |
75 | struct hv_guid chn_type; | |
76 | struct hv_guid chn_instance; | |
77 | ||
78 | u32 monitor_id; | |
79 | u32 server_monitor_pending; | |
80 | u32 server_monitor_latency; | |
81 | u32 server_monitor_conn_id; | |
82 | u32 client_monitor_pending; | |
83 | u32 client_monitor_latency; | |
84 | u32 client_monitor_conn_id; | |
85 | ||
86 | struct hv_dev_port_info inbound; | |
87 | struct hv_dev_port_info outbound; | |
ee3d7ddf | 88 | }; |
ab057781 | 89 | |
454f18a9 | 90 | /* Base driver object */ |
775ef25e | 91 | struct hv_driver { |
54b2b847 GKH |
92 | const char *name; |
93 | ||
94 | /* the device type supported by this driver */ | |
ca623ad3 | 95 | struct hv_guid dev_type; |
ab057781 | 96 | |
150f9398 S |
97 | /* |
98 | * Device type specific drivers (net, blk etc.) | |
99 | * need a mechanism to get a pointer to | |
100 | * device type specific driver structure given | |
101 | * a pointer to the base hyperv driver structure. | |
102 | * The current code solves this problem using | |
103 | * a hack. Support this need explicitly | |
104 | */ | |
105 | void *priv; | |
106 | ||
107 | struct device_driver driver; | |
108 | ||
ca623ad3 HZ |
109 | int (*dev_add)(struct hv_device *device, void *data); |
110 | int (*dev_rm)(struct hv_device *device); | |
111 | void (*cleanup)(struct hv_driver *driver); | |
775ef25e | 112 | }; |
ab057781 | 113 | |
454f18a9 | 114 | /* Base device object */ |
3d3b5518 | 115 | struct hv_device { |
54b2b847 | 116 | /* the driver for this device */ |
ca623ad3 | 117 | struct hv_driver *drv; |
54b2b847 GKH |
118 | |
119 | char name[64]; | |
120 | ||
a3c7fe9a S |
121 | struct work_struct probe_failed_work_item; |
122 | ||
70b0af4f S |
123 | int probe_error; |
124 | ||
54b2b847 | 125 | /* the device type id of this device */ |
ca623ad3 | 126 | struct hv_guid dev_type; |
ab057781 | 127 | |
54b2b847 | 128 | /* the device instance id of this device */ |
ca623ad3 | 129 | struct hv_guid dev_instance; |
54b2b847 | 130 | |
6bad88da S |
131 | struct device device; |
132 | ||
cae5b843 | 133 | struct vmbus_channel *channel; |
54b2b847 GKH |
134 | |
135 | /* Device extension; */ | |
ca623ad3 | 136 | void *ext; |
54b2b847 | 137 | }; |
ab057781 | 138 | |
454f18a9 | 139 | #endif /* _VMBUS_API_H_ */ |