2009-07-14 01:02:34 +02: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 _CHANNEL_MGMT_H_
|
|
|
|
#define _CHANNEL_MGMT_H_
|
|
|
|
|
2009-07-14 02:09:34 +02:00
|
|
|
#include "include/osd.h"
|
|
|
|
#include "include/List.h"
|
2009-07-14 01:02:34 +02:00
|
|
|
#include "RingBuffer.h"
|
|
|
|
|
2009-07-14 02:09:34 +02:00
|
|
|
#include "include/VmbusChannelInterface.h"
|
|
|
|
#include "include/ChannelMessages.h"
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-15 00:06:28 +02:00
|
|
|
typedef void (*PFN_CHANNEL_CALLBACK)(void * context);
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CHANNEL_OFFER_STATE,
|
|
|
|
CHANNEL_OPENING_STATE,
|
|
|
|
CHANNEL_OPEN_STATE,
|
|
|
|
} VMBUS_CHANNEL_STATE;
|
|
|
|
|
|
|
|
typedef struct _VMBUS_CHANNEL {
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
|
|
|
|
DEVICE_OBJECT* DeviceObject;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
HANDLE PollTimer; /* SA-111 workaround */
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
VMBUS_CHANNEL_STATE State;
|
|
|
|
|
|
|
|
VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
|
2009-07-27 22:47:24 +02:00
|
|
|
/* These are based on the OfferMsg.MonitorId. Save it here for easy access. */
|
2009-07-15 00:08:20 +02:00
|
|
|
u8 MonitorGroup;
|
|
|
|
u8 MonitorBit;
|
2009-07-14 01:02:34 +02:00
|
|
|
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 RingBufferGpadlHandle;
|
2009-07-14 01:02:34 +02:00
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Allocated memory for ring buffer */
|
2009-07-15 00:07:21 +02:00
|
|
|
void * RingBufferPages;
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 RingBufferPageCount;
|
2009-07-27 22:47:24 +02:00
|
|
|
RING_BUFFER_INFO Outbound; /* send to parent */
|
|
|
|
RING_BUFFER_INFO Inbound; /* receive from parent */
|
2009-07-15 23:48:32 +02:00
|
|
|
spinlock_t inbound_lock;
|
2009-07-14 01:02:34 +02:00
|
|
|
HANDLE ControlWQ;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Channel callback are invoked in this workqueue context */
|
|
|
|
/* HANDLE dataWorkQueue; */
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
PFN_CHANNEL_CALLBACK OnChannelCallback;
|
2009-07-15 00:06:28 +02:00
|
|
|
void * ChannelCallbackContext;
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
} VMBUS_CHANNEL;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _VMBUS_CHANNEL_DEBUG_INFO {
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 RelId;
|
2009-07-14 01:02:34 +02:00
|
|
|
VMBUS_CHANNEL_STATE State;
|
|
|
|
GUID InterfaceType;
|
|
|
|
GUID InterfaceInstance;
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 MonitorId;
|
|
|
|
u32 ServerMonitorPending;
|
|
|
|
u32 ServerMonitorLatency;
|
|
|
|
u32 ServerMonitorConnectionId;
|
|
|
|
u32 ClientMonitorPending;
|
|
|
|
u32 ClientMonitorLatency;
|
|
|
|
u32 ClientMonitorConnectionId;
|
2009-07-14 01:02:34 +02:00
|
|
|
|
|
|
|
RING_BUFFER_DEBUG_INFO Inbound;
|
|
|
|
RING_BUFFER_DEBUG_INFO Outbound;
|
|
|
|
} VMBUS_CHANNEL_DEBUG_INFO;
|
|
|
|
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
VMBUS_CHANNEL_VERSION_SUPPORTED VersionSupported;
|
|
|
|
VMBUS_CHANNEL_OPEN_RESULT OpenResult;
|
|
|
|
VMBUS_CHANNEL_GPADL_TORNDOWN GpadlTorndown;
|
|
|
|
VMBUS_CHANNEL_GPADL_CREATED GpadlCreated;
|
|
|
|
VMBUS_CHANNEL_VERSION_RESPONSE VersionResponse;
|
|
|
|
} VMBUS_CHANNEL_MESSAGE_RESPONSE;
|
|
|
|
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/*
|
|
|
|
* Represents each channel msg on the vmbus connection This is a
|
|
|
|
* variable-size data structure depending on the msg type itself
|
|
|
|
*/
|
|
|
|
|
2009-07-14 01:02:34 +02:00
|
|
|
typedef struct _VMBUS_CHANNEL_MSGINFO {
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Bookkeeping stuff */
|
2009-07-14 01:02:34 +02:00
|
|
|
LIST_ENTRY MsgListEntry;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* So far, this is only used to handle gpadl body message */
|
2009-07-14 01:02:34 +02:00
|
|
|
LIST_ENTRY SubMsgList;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Synchronize the request/response if needed */
|
2009-07-14 01:02:34 +02:00
|
|
|
HANDLE WaitEvent;
|
|
|
|
|
|
|
|
VMBUS_CHANNEL_MESSAGE_RESPONSE Response;
|
|
|
|
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 MessageSize;
|
2009-07-27 22:47:24 +02:00
|
|
|
/* The channel message that goes out on the "wire". */
|
|
|
|
/* It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header */
|
2009-07-14 01:02:34 +02:00
|
|
|
unsigned char Msg[0];
|
|
|
|
} VMBUS_CHANNEL_MSGINFO;
|
|
|
|
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Routines */
|
2009-07-14 01:02:34 +02:00
|
|
|
|
2009-07-15 00:05:36 +02:00
|
|
|
static VMBUS_CHANNEL*
|
2009-07-14 01:02:34 +02:00
|
|
|
AllocVmbusChannel(
|
|
|
|
void
|
|
|
|
);
|
|
|
|
|
2009-07-15 00:05:36 +02:00
|
|
|
static void
|
2009-07-14 01:02:34 +02:00
|
|
|
FreeVmbusChannel(
|
|
|
|
VMBUS_CHANNEL *Channel
|
|
|
|
);
|
|
|
|
|
2009-07-15 00:05:36 +02:00
|
|
|
static void
|
2009-07-14 01:02:34 +02:00
|
|
|
VmbusOnChannelMessage(
|
|
|
|
void *Context
|
|
|
|
);
|
|
|
|
|
2009-07-15 00:05:36 +02:00
|
|
|
static int
|
2009-07-14 01:02:34 +02:00
|
|
|
VmbusChannelRequestOffers(
|
|
|
|
void
|
|
|
|
);
|
|
|
|
|
2009-07-15 00:05:36 +02:00
|
|
|
static void
|
2009-07-14 01:02:34 +02:00
|
|
|
VmbusChannelReleaseUnattachedChannels(
|
|
|
|
void
|
|
|
|
);
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
#endif /* _CHANNEL_MGMT_H_ */
|