Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / hv / vmbus_private.h
CommitLineData
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"
5496c9c3 32#include "channel_interface.h"
8f078ca6 33#include "ring_buffer.h"
53af545b 34#include <linux/list.h>
3e7ee490 35
3e7ee490 36
454f18a9
BP
37/*
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
41 */
f346fdc2 42#define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
454f18a9
BP
43
44/* The value here must be in multiple of 32 */
45/* TODO: Need to make this configurable */
f346fdc2 46#define MAX_NUM_CHANNELS_SUPPORTED 256
454f18a9 47
3e7ee490 48
5c3e375c 49enum VMBUS_CONNECT_STATE {
3e7ee490
HJ
50 Disconnected,
51 Connecting,
52 Connected,
53 Disconnecting
5c3e375c 54};
3e7ee490 55
f346fdc2 56#define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
3e7ee490 57
662e66b0 58struct VMBUS_CONNECTION {
f346fdc2 59 enum VMBUS_CONNECT_STATE ConnectState;
3e7ee490 60
f4888417 61 atomic_t NextGpadlHandle;
3e7ee490 62
454f18a9 63 /*
f346fdc2
GKH
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
454f18a9 69 */
f346fdc2
GKH
70 void *InterruptPage;
71 void *SendInterruptPage;
72 void *RecvInterruptPage;
3e7ee490 73
454f18a9
BP
74 /*
75 * 2 pages - 1st page for parent->child notification and 2nd
76 * is child->parent notification
77 */
f346fdc2 78 void *MonitorPages;
53af545b 79 struct list_head ChannelMsgList;
dd0813b6 80 spinlock_t channelmsg_lock;
3e7ee490 81
454f18a9 82 /* List of channels */
53af545b 83 struct list_head ChannelList;
0f5e44ca 84 spinlock_t channel_lock;
3e7ee490 85
df8d9b1f 86 struct workqueue_struct *WorkQueue;
662e66b0 87};
3e7ee490
HJ
88
89
a9a71354 90struct VMBUS_MSGINFO {
454f18a9 91 /* Bookkeeping stuff */
53af545b 92 struct list_head MsgListEntry;
3e7ee490 93
454f18a9 94 /* Synchronize the request/response if needed */
aedb444a 95 struct osd_waitevent *WaitEvent;
3e7ee490 96
454f18a9 97 /* The message itself */
f346fdc2 98 unsigned char Msg[0];
a9a71354 99};
3e7ee490
HJ
100
101
662e66b0 102extern struct VMBUS_CONNECTION gVmbusConnection;
3e7ee490 103
454f18a9
BP
104/* General vmbus interface */
105
daaa8cc3
GKH
106struct hv_device *VmbusChildDeviceCreate(struct hv_guid *deviceType,
107 struct hv_guid *deviceInstance,
f346fdc2 108 void *context);
3e7ee490 109
f346fdc2 110int VmbusChildDeviceAdd(struct hv_device *Device);
3e7ee490 111
f346fdc2 112void VmbusChildDeviceRemove(struct hv_device *Device);
3e7ee490 113
454f18a9
BP
114/* static void */
115/* VmbusChildDeviceDestroy( */
3d3b5518 116/* struct hv_device *); */
3e7ee490 117
aded7165 118struct vmbus_channel *GetChannelFromRelId(u32 relId);
3e7ee490 119
454f18a9
BP
120
121/* Connection interface */
122
f346fdc2
GKH
123int VmbusConnect(void);
124
125int VmbusDisconnect(void);
126
127int VmbusPostMessage(void *buffer, size_t bufSize);
128
129int VmbusSetEvent(u32 childRelId);
130
131void VmbusOnEvents(void);
3e7ee490
HJ
132
133
454f18a9 134#endif /* _VMBUS_PRIVATE_H_ */