Staging: hv: rename ChannelMgmt.c and .h to channel_mgmt.c and .h
[linux/fpc-iii.git] / drivers / staging / hv / VmbusPrivate.h
blob6e82183e9d503a85ebd43118bffcb016b95b3ce2
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
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.
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.
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.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _VMBUS_PRIVATE_H_
26 #define _VMBUS_PRIVATE_H_
28 #include "hv.h"
29 #include "VmbusApi.h"
30 #include "channel.h"
31 #include "channel_mgmt.h"
32 #include "ChannelInterface.h"
33 #include "ring_buffer.h"
34 #include <linux/list.h>
38 * Maximum channels is determined by the size of the interrupt page
39 * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
40 * and the other is receive endpoint interrupt
42 #define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
44 /* The value here must be in multiple of 32 */
45 /* TODO: Need to make this configurable */
46 #define MAX_NUM_CHANNELS_SUPPORTED 256
49 enum VMBUS_CONNECT_STATE {
50 Disconnected,
51 Connecting,
52 Connected,
53 Disconnecting
56 #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
58 struct VMBUS_CONNECTION {
59 enum VMBUS_CONNECT_STATE ConnectState;
61 atomic_t NextGpadlHandle;
64 * Represents channel interrupts. Each bit position represents a
65 * channel. When a channel sends an interrupt via VMBUS, it finds its
66 * bit in the sendInterruptPage, set it and calls Hv to generate a port
67 * event. The other end receives the port event and parse the
68 * recvInterruptPage to see which bit is set
70 void *InterruptPage;
71 void *SendInterruptPage;
72 void *RecvInterruptPage;
75 * 2 pages - 1st page for parent->child notification and 2nd
76 * is child->parent notification
78 void *MonitorPages;
79 struct list_head ChannelMsgList;
80 spinlock_t channelmsg_lock;
82 /* List of channels */
83 struct list_head ChannelList;
84 spinlock_t channel_lock;
86 struct workqueue_struct *WorkQueue;
90 struct VMBUS_MSGINFO {
91 /* Bookkeeping stuff */
92 struct list_head MsgListEntry;
94 /* Synchronize the request/response if needed */
95 struct osd_waitevent *WaitEvent;
97 /* The message itself */
98 unsigned char Msg[0];
102 extern struct VMBUS_CONNECTION gVmbusConnection;
104 /* General vmbus interface */
106 struct hv_device *VmbusChildDeviceCreate(struct hv_guid *deviceType,
107 struct hv_guid *deviceInstance,
108 void *context);
110 int VmbusChildDeviceAdd(struct hv_device *Device);
112 void VmbusChildDeviceRemove(struct hv_device *Device);
114 /* static void */
115 /* VmbusChildDeviceDestroy( */
116 /* struct hv_device *); */
118 struct vmbus_channel *GetChannelFromRelId(u32 relId);
121 /* Connection interface */
123 int VmbusConnect(void);
125 int VmbusDisconnect(void);
127 int VmbusPostMessage(void *buffer, size_t bufSize);
129 int VmbusSetEvent(u32 childRelId);
131 void VmbusOnEvents(void);
134 #endif /* _VMBUS_PRIVATE_H_ */