2009-07-14 00:19:28 +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 _VMBUS_API_H_
|
|
|
|
#define _VMBUS_API_H_
|
|
|
|
|
|
|
|
#include "osd.h"
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
|
|
|
|
/* Defines */
|
|
|
|
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
#define MAX_PAGE_BUFFER_COUNT 16
|
2009-07-27 22:47:24 +02:00
|
|
|
#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
|
|
|
|
|
|
|
|
/* Data types */
|
|
|
|
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
#pragma pack(push,1)
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Single-page buffer */
|
2009-07-14 00:19:28 +02:00
|
|
|
typedef struct _PAGE_BUFFER {
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 Length;
|
|
|
|
u32 Offset;
|
2009-07-15 00:10:26 +02:00
|
|
|
u64 Pfn;
|
2009-07-14 00:19:28 +02:00
|
|
|
} PAGE_BUFFER;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Multiple-page buffer */
|
2009-07-14 00:19:28 +02:00
|
|
|
typedef struct _MULTIPAGE_BUFFER {
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Length and Offset determines the # of pfns in the array */
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 Length;
|
|
|
|
u32 Offset;
|
2009-07-15 00:10:26 +02:00
|
|
|
u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
|
2009-07-14 00:19:28 +02:00
|
|
|
}MULTIPAGE_BUFFER;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* 0x18 includes the proprietary packet header */
|
2009-07-14 00:19:28 +02:00
|
|
|
#define MAX_PAGE_BUFFER_PACKET (0x18 + (sizeof(PAGE_BUFFER) * MAX_PAGE_BUFFER_COUNT))
|
|
|
|
#define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + sizeof(MULTIPAGE_BUFFER))
|
|
|
|
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2009-07-29 14:09:45 +02:00
|
|
|
struct hv_driver;
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* All drivers */
|
2009-07-28 17:32:53 +02:00
|
|
|
typedef int (*PFN_ON_DEVICEADD)(struct hv_device *Device, void* AdditionalInfo);
|
|
|
|
typedef int (*PFN_ON_DEVICEREMOVE)(struct hv_device *Device);
|
2009-07-14 00:19:28 +02:00
|
|
|
typedef char** (*PFN_ON_GETDEVICEIDS)(void);
|
2009-07-29 14:09:45 +02:00
|
|
|
typedef void (*PFN_ON_CLEANUP)(struct hv_driver *Driver);
|
2009-07-14 00:19:28 +02:00
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Vmbus extensions */
|
2009-07-29 14:09:45 +02:00
|
|
|
/* typedef int (*PFN_ON_MATCH)(struct hv_device *dev, struct hv_driver *drv); */
|
2009-07-28 17:32:53 +02:00
|
|
|
/* typedef int (*PFN_ON_PROBE)(struct hv_device *dev); */
|
2009-07-29 14:09:45 +02:00
|
|
|
typedef int (*PFN_ON_ISR)(struct hv_driver *drv);
|
|
|
|
typedef void (*PFN_ON_DPC)(struct hv_driver *drv);
|
2009-07-14 00:19:28 +02:00
|
|
|
typedef void (*PFN_GET_CHANNEL_OFFERS)(void);
|
|
|
|
|
2009-07-28 17:32:53 +02:00
|
|
|
typedef struct hv_device *(*PFN_ON_CHILDDEVICE_CREATE)(GUID DeviceType, GUID DeviceInstance, void *Context);
|
|
|
|
typedef void (*PFN_ON_CHILDDEVICE_DESTROY)(struct hv_device *Device);
|
|
|
|
typedef int (*PFN_ON_CHILDDEVICE_ADD)(struct hv_device *RootDevice, struct hv_device *ChildDevice);
|
|
|
|
typedef void (*PFN_ON_CHILDDEVICE_REMOVE)(struct hv_device *Device);
|
2009-07-14 00:19:28 +02:00
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Vmbus channel interface */
|
2009-07-15 00:06:28 +02:00
|
|
|
typedef void (*VMBUS_CHANNEL_CALLBACK)(void * context);
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_OPEN)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 SendBufferSize,
|
|
|
|
u32 RecvRingBufferSize,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * UserData,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 UserDataLen,
|
2009-07-14 00:19:28 +02:00
|
|
|
VMBUS_CHANNEL_CALLBACK ChannelCallback,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * Context
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef void (*VMBUS_CHANNEL_CLOSE)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_SEND_PACKET)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-15 00:06:28 +02:00
|
|
|
const void * Buffer,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 BufferLen,
|
2009-07-15 00:10:26 +02:00
|
|
|
u64 RequestId,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 Type,
|
|
|
|
u32 Flags
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-14 00:19:28 +02:00
|
|
|
PAGE_BUFFER PageBuffers[],
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 PageCount,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * Buffer,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 BufferLen,
|
2009-07-15 00:10:26 +02:00
|
|
|
u64 RequestId
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-14 00:19:28 +02:00
|
|
|
MULTIPAGE_BUFFER *MultiPageBuffer,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * Buffer,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 BufferLen,
|
2009-07-15 00:10:26 +02:00
|
|
|
u64 RequestId
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_RECV_PACKET)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * Buffer,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 BufferLen,
|
|
|
|
u32* BufferActualLen,
|
2009-07-15 00:10:26 +02:00
|
|
|
u64* RequestId
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-15 00:06:28 +02:00
|
|
|
void * Buffer,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 BufferLen,
|
|
|
|
u32* BufferActualLen,
|
2009-07-15 00:10:26 +02:00
|
|
|
u64* RequestId
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-27 22:47:24 +02:00
|
|
|
void * Buffer, /* from kmalloc() */
|
|
|
|
u32 BufferLen, /* page-size multiple */
|
2009-07-15 00:09:36 +02:00
|
|
|
u32* GpadlHandle
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL)(
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device *Device,
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 GpadlHandle
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _PORT_INFO {
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 InterruptMask;
|
|
|
|
u32 ReadIndex;
|
|
|
|
u32 WriteIndex;
|
|
|
|
u32 BytesAvailToRead;
|
|
|
|
u32 BytesAvailToWrite;
|
2009-07-14 00:19:28 +02:00
|
|
|
} PORT_INFO;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _DEVICE_INFO {
|
2009-07-15 00:09:36 +02:00
|
|
|
u32 ChannelId;
|
|
|
|
u32 ChannelState;
|
2009-07-14 00:19:28 +02:00
|
|
|
GUID ChannelType;
|
|
|
|
GUID ChannelInstance;
|
|
|
|
|
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 00:19:28 +02:00
|
|
|
|
|
|
|
PORT_INFO Inbound;
|
|
|
|
PORT_INFO Outbound;
|
|
|
|
} DEVICE_INFO;
|
|
|
|
|
2009-07-28 17:32:53 +02:00
|
|
|
typedef void (*VMBUS_GET_CHANNEL_INFO)(struct hv_device *Device, DEVICE_INFO* DeviceInfo);
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
typedef struct _VMBUS_CHANNEL_INTERFACE {
|
|
|
|
VMBUS_CHANNEL_OPEN Open;
|
|
|
|
VMBUS_CHANNEL_CLOSE Close;
|
|
|
|
VMBUS_CHANNEL_SEND_PACKET SendPacket;
|
|
|
|
VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER SendPacketPageBuffer;
|
|
|
|
VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER SendPacketMultiPageBuffer;
|
|
|
|
VMBUS_CHANNEL_RECV_PACKET RecvPacket;
|
|
|
|
VMBUS_CHANNEL_RECV_PACKET_PAW RecvPacketRaw;
|
|
|
|
VMBUS_CHANNEL_ESTABLISH_GPADL EstablishGpadl;
|
|
|
|
VMBUS_CHANNEL_TEARDOWN_GPADL TeardownGpadl;
|
|
|
|
VMBUS_GET_CHANNEL_INFO GetInfo;
|
|
|
|
} VMBUS_CHANNEL_INTERFACE;
|
|
|
|
|
|
|
|
typedef void (*VMBUS_GET_CHANNEL_INTERFACE)(VMBUS_CHANNEL_INTERFACE *Interface);
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Base driver object */
|
2009-07-29 14:09:45 +02:00
|
|
|
struct hv_driver {
|
2009-07-14 00:19:28 +02:00
|
|
|
const char* name;
|
2009-07-27 22:47:24 +02:00
|
|
|
GUID deviceType; /* the device type supported by this driver */
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
PFN_ON_DEVICEADD OnDeviceAdd;
|
|
|
|
PFN_ON_DEVICEREMOVE OnDeviceRemove;
|
2009-07-27 22:47:24 +02:00
|
|
|
PFN_ON_GETDEVICEIDS OnGetDeviceIds; /* device ids supported by this driver */
|
2009-07-14 00:19:28 +02:00
|
|
|
PFN_ON_CLEANUP OnCleanup;
|
|
|
|
|
|
|
|
VMBUS_CHANNEL_INTERFACE VmbusChannelInterface;
|
2009-07-29 14:09:45 +02:00
|
|
|
};
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Base device object */
|
2009-07-28 17:32:53 +02:00
|
|
|
struct hv_device {
|
2009-07-29 14:09:45 +02:00
|
|
|
struct hv_driver *Driver; /* the driver for this device */
|
2009-07-14 00:19:28 +02:00
|
|
|
char name[64];
|
2009-07-27 22:47:24 +02:00
|
|
|
GUID deviceType; /* the device type id of this device */
|
|
|
|
GUID deviceInstance; /* the device instance id of this device */
|
2009-07-14 00:19:28 +02:00
|
|
|
void* context;
|
2009-07-27 22:47:24 +02:00
|
|
|
void* Extension; /* Device extension; */
|
2009-07-28 17:32:53 +02:00
|
|
|
};
|
2009-07-14 00:19:28 +02:00
|
|
|
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Vmbus driver object */
|
2009-07-14 00:19:28 +02:00
|
|
|
typedef struct _VMBUS_DRIVER_OBJECT {
|
2009-07-29 14:09:45 +02:00
|
|
|
struct hv_driver Base; /* !! Must be the 1st field !! */
|
2009-07-14 00:19:28 +02:00
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Set by the caller */
|
2009-07-14 00:19:28 +02:00
|
|
|
PFN_ON_CHILDDEVICE_CREATE OnChildDeviceCreate;
|
|
|
|
PFN_ON_CHILDDEVICE_DESTROY OnChildDeviceDestroy;
|
|
|
|
PFN_ON_CHILDDEVICE_ADD OnChildDeviceAdd;
|
|
|
|
PFN_ON_CHILDDEVICE_REMOVE OnChildDeviceRemove;
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
/* Set by the callee */
|
|
|
|
/* PFN_ON_MATCH OnMatch; */
|
|
|
|
/* PFN_ON_PROBE OnProbe; */
|
2009-07-14 00:19:28 +02:00
|
|
|
PFN_ON_ISR OnIsr;
|
|
|
|
PFN_ON_DPC OnMsgDpc;
|
|
|
|
PFN_ON_DPC OnEventDpc;
|
|
|
|
PFN_GET_CHANNEL_OFFERS GetChannelOffers;
|
|
|
|
|
|
|
|
VMBUS_GET_CHANNEL_INTERFACE GetChannelInterface;
|
|
|
|
VMBUS_GET_CHANNEL_INFO GetChannelInfo;
|
|
|
|
} VMBUS_DRIVER_OBJECT;
|
|
|
|
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
|
|
|
|
/* Interface */
|
|
|
|
|
2009-07-14 00:19:28 +02:00
|
|
|
int
|
|
|
|
VmbusInitialize(
|
2009-07-29 14:09:45 +02:00
|
|
|
struct hv_driver *drv
|
2009-07-14 00:19:28 +02:00
|
|
|
);
|
|
|
|
|
2009-07-27 22:47:24 +02:00
|
|
|
#endif /* _VMBUS_API_H_ */
|