Commit | Line | Data |
---|---|---|
3e7ee490 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_PRIVATE_H_ | |
26 | #define _VMBUS_PRIVATE_H_ | |
27 | ||
7e8ad49f | 28 | #include "hv.h" |
447fc67e | 29 | #include "vmbus_api.h" |
4df90be5 | 30 | #include "channel.h" |
ff39524b | 31 | #include "channel_mgmt.h" |
8f078ca6 | 32 | #include "ring_buffer.h" |
53af545b | 33 | #include <linux/list.h> |
3e7ee490 | 34 | |
3e7ee490 | 35 | |
454f18a9 BP |
36 | /* |
37 | * Maximum channels is determined by the size of the interrupt page | |
38 | * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt | |
39 | * and the other is receive endpoint interrupt | |
40 | */ | |
f346fdc2 | 41 | #define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */ |
454f18a9 BP |
42 | |
43 | /* The value here must be in multiple of 32 */ | |
44 | /* TODO: Need to make this configurable */ | |
f346fdc2 | 45 | #define MAX_NUM_CHANNELS_SUPPORTED 256 |
454f18a9 | 46 | |
3e7ee490 | 47 | |
da9fcb72 HZ |
48 | enum vmbus_connect_state { |
49 | DISCONNECTED, | |
50 | CONNECTING, | |
51 | CONNECTED, | |
52 | DISCONNECTING | |
5c3e375c | 53 | }; |
3e7ee490 | 54 | |
f346fdc2 | 55 | #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT |
3e7ee490 | 56 | |
da9fcb72 HZ |
57 | struct vmbus_connection { |
58 | enum vmbus_connect_state conn_state; | |
3e7ee490 | 59 | |
da9fcb72 | 60 | atomic_t next_gpadl_handle; |
3e7ee490 | 61 | |
454f18a9 | 62 | /* |
f346fdc2 GKH |
63 | * Represents channel interrupts. Each bit position represents a |
64 | * channel. When a channel sends an interrupt via VMBUS, it finds its | |
65 | * bit in the sendInterruptPage, set it and calls Hv to generate a port | |
66 | * event. The other end receives the port event and parse the | |
67 | * recvInterruptPage to see which bit is set | |
454f18a9 | 68 | */ |
da9fcb72 HZ |
69 | void *int_page; |
70 | void *send_int_page; | |
71 | void *recv_int_page; | |
3e7ee490 | 72 | |
454f18a9 BP |
73 | /* |
74 | * 2 pages - 1st page for parent->child notification and 2nd | |
75 | * is child->parent notification | |
76 | */ | |
da9fcb72 HZ |
77 | void *monitor_pages; |
78 | struct list_head chn_msg_list; | |
dd0813b6 | 79 | spinlock_t channelmsg_lock; |
3e7ee490 | 80 | |
454f18a9 | 81 | /* List of channels */ |
da9fcb72 | 82 | struct list_head chn_list; |
0f5e44ca | 83 | spinlock_t channel_lock; |
3e7ee490 | 84 | |
da9fcb72 | 85 | struct workqueue_struct *work_queue; |
662e66b0 | 86 | }; |
3e7ee490 HJ |
87 | |
88 | ||
da9fcb72 | 89 | struct vmbus_msginfo { |
454f18a9 | 90 | /* Bookkeeping stuff */ |
da9fcb72 | 91 | struct list_head msglist_entry; |
3e7ee490 | 92 | |
454f18a9 | 93 | /* Synchronize the request/response if needed */ |
da9fcb72 | 94 | struct osd_waitevent *wait_event; |
3e7ee490 | 95 | |
454f18a9 | 96 | /* The message itself */ |
da9fcb72 | 97 | unsigned char msg[0]; |
a9a71354 | 98 | }; |
3e7ee490 HJ |
99 | |
100 | ||
da9fcb72 | 101 | extern struct vmbus_connection vmbus_connection; |
3e7ee490 | 102 | |
454f18a9 BP |
103 | /* General vmbus interface */ |
104 | ||
646f1ea3 HZ |
105 | struct hv_device *vmbus_child_device_create(struct hv_guid *type, |
106 | struct hv_guid *instance, | |
cae5b843 | 107 | struct vmbus_channel *channel); |
3e7ee490 | 108 | |
646f1ea3 | 109 | int vmbus_child_dev_add(struct hv_device *device); |
98293a27 GKH |
110 | int vmbus_child_device_register(struct hv_device *root_device_obj, |
111 | struct hv_device *child_device_obj); | |
9d8bd71a | 112 | void vmbus_child_device_unregister(struct hv_device *device_obj); |
3e7ee490 | 113 | |
454f18a9 BP |
114 | /* static void */ |
115 | /* VmbusChildDeviceDestroy( */ | |
3d3b5518 | 116 | /* struct hv_device *); */ |
3e7ee490 | 117 | |
c6977677 | 118 | struct vmbus_channel *relid2channel(u32 relid); |
3e7ee490 | 119 | |
454f18a9 BP |
120 | |
121 | /* Connection interface */ | |
122 | ||
c6977677 | 123 | int vmbus_connect(void); |
f346fdc2 | 124 | |
c6977677 | 125 | int vmbus_disconnect(void); |
f346fdc2 | 126 | |
c6977677 | 127 | int vmbus_post_msg(void *buffer, size_t buflen); |
f346fdc2 | 128 | |
c6977677 | 129 | int vmbus_set_event(u32 child_relid); |
f346fdc2 | 130 | |
c6977677 | 131 | void vmbus_on_event(void); |
3e7ee490 HJ |
132 | |
133 | ||
454f18a9 | 134 | #endif /* _VMBUS_PRIVATE_H_ */ |