2009-07-13 23:02:34 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009, Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Haiyang Zhang <haiyangz@microsoft.com>
|
|
|
|
* Hank Janssen <hjanssen@microsoft.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _VMBUS_PRIVATE_H_
|
|
|
|
#define _VMBUS_PRIVATE_H_
|
|
|
|
|
|
|
|
#include "Hv.h"
|
2009-07-14 00:09:34 +00:00
|
|
|
#include "include/VmbusApi.h"
|
2009-07-13 23:02:34 +00:00
|
|
|
#include "Channel.h"
|
|
|
|
#include "ChannelMgmt.h"
|
|
|
|
#include "ChannelInterface.h"
|
2009-07-27 20:47:24 +00:00
|
|
|
/* #include "ChannelMessages.h" */
|
2009-07-13 23:02:34 +00:00
|
|
|
#include "RingBuffer.h"
|
2009-07-27 20:47:24 +00:00
|
|
|
/* #include "Packet.h" */
|
2009-07-14 00:09:34 +00:00
|
|
|
#include "include/List.h"
|
2009-07-13 23:02:34 +00:00
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Defines */
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum channels is determined by the size of the interrupt page
|
|
|
|
* which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
|
|
|
|
* and the other is receive endpoint interrupt
|
|
|
|
*/
|
|
|
|
#define MAX_NUM_CHANNELS (PAGE_SIZE >> 1) << 3 /* 16348 channels */
|
|
|
|
|
|
|
|
/* The value here must be in multiple of 32 */
|
|
|
|
/* TODO: Need to make this configurable */
|
2009-07-13 23:02:34 +00:00
|
|
|
#define MAX_NUM_CHANNELS_SUPPORTED 256
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Data types */
|
|
|
|
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:41 +00:00
|
|
|
enum VMBUS_CONNECT_STATE {
|
2009-07-13 23:02:34 +00:00
|
|
|
Disconnected,
|
|
|
|
Connecting,
|
|
|
|
Connected,
|
|
|
|
Disconnecting
|
2009-07-27 20:47:41 +00:00
|
|
|
};
|
2009-07-13 23:02:34 +00:00
|
|
|
|
|
|
|
#define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
|
|
|
|
|
2009-07-27 20:47:42 +00:00
|
|
|
struct VMBUS_CONNECTION {
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:41 +00:00
|
|
|
enum VMBUS_CONNECT_STATE ConnectState;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-29 21:00:12 +00:00
|
|
|
atomic_t NextGpadlHandle;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/*
|
|
|
|
* Represents channel interrupts. Each bit position represents
|
|
|
|
* a channel. When a channel sends an interrupt via VMBUS, it
|
|
|
|
* finds its bit in the sendInterruptPage, set it and calls Hv
|
|
|
|
* to generate a port event. The other end receives the port
|
|
|
|
* event and parse the recvInterruptPage to see which bit is
|
|
|
|
* set
|
|
|
|
*/
|
2009-07-14 22:07:21 +00:00
|
|
|
void * InterruptPage;
|
|
|
|
void * SendInterruptPage;
|
|
|
|
void * RecvInterruptPage;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/*
|
|
|
|
* 2 pages - 1st page for parent->child notification and 2nd
|
|
|
|
* is child->parent notification
|
|
|
|
*/
|
2009-07-14 22:07:21 +00:00
|
|
|
void * MonitorPages;
|
2009-07-13 23:02:34 +00:00
|
|
|
LIST_ENTRY ChannelMsgList;
|
2009-07-15 21:56:45 +00:00
|
|
|
spinlock_t channelmsg_lock;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* List of channels */
|
2009-07-13 23:02:34 +00:00
|
|
|
LIST_ENTRY ChannelList;
|
2009-07-15 21:57:16 +00:00
|
|
|
spinlock_t channel_lock;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:45 +00:00
|
|
|
struct workqueue_struct *WorkQueue;
|
2009-07-27 20:47:42 +00:00
|
|
|
};
|
2009-07-13 23:02:34 +00:00
|
|
|
|
|
|
|
|
2009-07-27 20:47:43 +00:00
|
|
|
struct VMBUS_MSGINFO {
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Bookkeeping stuff */
|
2009-07-13 23:02:34 +00:00
|
|
|
LIST_ENTRY MsgListEntry;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Synchronize the request/response if needed */
|
2009-07-28 17:46:24 +00:00
|
|
|
struct osd_waitevent *WaitEvent;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* The message itself */
|
2009-07-13 23:02:34 +00:00
|
|
|
unsigned char Msg[0];
|
2009-07-27 20:47:43 +00:00
|
|
|
};
|
2009-07-13 23:02:34 +00:00
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Externs */
|
|
|
|
|
2009-07-27 20:47:42 +00:00
|
|
|
extern struct VMBUS_CONNECTION gVmbusConnection;
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* General vmbus interface */
|
|
|
|
|
2009-07-28 15:32:53 +00:00
|
|
|
static struct hv_device*
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusChildDeviceCreate(
|
|
|
|
GUID deviceType,
|
|
|
|
GUID deviceInstance,
|
|
|
|
void *context);
|
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static int
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusChildDeviceAdd(
|
2009-07-28 15:32:53 +00:00
|
|
|
struct hv_device *Device);
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static void
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusChildDeviceRemove(
|
2009-07-28 15:32:53 +00:00
|
|
|
struct hv_device *Device);
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* static void */
|
|
|
|
/* VmbusChildDeviceDestroy( */
|
2009-07-28 15:32:53 +00:00
|
|
|
/* struct hv_device *); */
|
2009-07-13 23:02:34 +00:00
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static VMBUS_CHANNEL*
|
2009-07-13 23:02:34 +00:00
|
|
|
GetChannelFromRelId(
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 relId
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Connection interface */
|
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static int
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusConnect(
|
2009-07-14 22:07:21 +00:00
|
|
|
void
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static int
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusDisconnect(
|
2009-07-14 22:07:21 +00:00
|
|
|
void
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static int
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusPostMessage(
|
2009-07-14 22:06:28 +00:00
|
|
|
void * buffer,
|
2009-07-14 22:14:20 +00:00
|
|
|
size_t bufSize
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
2009-07-14 22:05:36 +00:00
|
|
|
static int
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusSetEvent(
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 childRelId
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
2009-07-14 22:07:21 +00:00
|
|
|
static void
|
2009-07-13 23:02:34 +00:00
|
|
|
VmbusOnEvents(
|
2009-07-14 22:07:21 +00:00
|
|
|
void
|
2009-07-13 23:02:34 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
#endif /* _VMBUS_PRIVATE_H_ */
|