Commit 454f18a9 authored by Bill Pemberton's avatar Bill Pemberton Committed by Greg Kroah-Hartman

Staging: hv: Remove C99 comments

Remove C99 // comments with traditional /* */ comments
Signed-off-by: default avatarBill Pemberton <wfp5p@virginia.edu>
Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 226408a4
......@@ -26,12 +26,12 @@
static const char* gBlkDriverName="blkvsc";
//{32412632-86cb-44a2-9b5c-50d1417354f5}
/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
static const GUID gBlkVscDeviceType={
.Data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5}
};
// Static routines
/* Static routines */
static int
BlkVscOnDeviceAdd(
DEVICE_OBJECT *Device,
......@@ -49,21 +49,21 @@ BlkVscInitialize(
DPRINT_ENTER(BLKVSC);
// Make sure we are at least 2 pages since 1 page is used for control
/* Make sure we are at least 2 pages since 1 page is used for control */
ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1));
Driver->name = gBlkDriverName;
memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(GUID));
storDriver->RequestExtSize = sizeof(STORVSC_REQUEST_EXTENSION);
// Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices)
// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + u64)
/* Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) */
/* by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + u64) */
storDriver->MaxOutstandingRequestsPerChannel =
((storDriver->RingBufferSize - PAGE_SIZE) / ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET + sizeof(VSTOR_PACKET) + sizeof(u64),sizeof(u64)));
DPRINT_INFO(BLKVSC, "max io outstd %u", storDriver->MaxOutstandingRequestsPerChannel);
// Setup the dispatch table
/* Setup the dispatch table */
storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd;
storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove;
storDriver->Base.OnCleanup = StorVscOnCleanup;
......@@ -95,8 +95,8 @@ BlkVscOnDeviceAdd(
return ret;
}
// We need to use the device instance guid to set the path and target id. For IDE devices, the
// device instance id is formatted as <bus id> - <device id> - 8899 - 000000000000.
/* We need to use the device instance guid to set the path and target id. For IDE devices, the */
/* device instance id is formatted as <bus id> - <device id> - 8899 - 000000000000. */
deviceInfo->PathId = Device->deviceInstance.Data[3] << 24 | Device->deviceInstance.Data[2] << 16 |
Device->deviceInstance.Data[1] << 8 |Device->deviceInstance.Data[0];
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
#pragma pack(push,1)
// The format must be the same as VMDATA_GPA_DIRECT
/* The format must be the same as VMDATA_GPA_DIRECT */
typedef struct _VMBUS_CHANNEL_PACKET_PAGE_BUFFER {
u16 Type;
u16 DataOffset8;
......@@ -44,7 +44,7 @@ typedef struct _VMBUS_CHANNEL_PACKET_PAGE_BUFFER {
} VMBUS_CHANNEL_PACKET_PAGE_BUFFER;
// The format must be the same as VMDATA_GPA_DIRECT
/* The format must be the same as VMDATA_GPA_DIRECT */
typedef struct _VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER {
u16 Type;
u16 DataOffset8;
......@@ -52,15 +52,15 @@ typedef struct _VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER {
u16 Flags;
u64 TransactionId;
u32 Reserved;
u32 RangeCount; // Always 1 in this case
u32 RangeCount; /* Always 1 in this case */
MULTIPAGE_BUFFER Range;
} VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER;
#pragma pack(pop)
//
// Routines
//
/* Routines */
static int
VmbusChannelOpen(
......@@ -110,8 +110,8 @@ VmbusChannelSendPacketMultiPageBuffer(
static int
VmbusChannelEstablishGpadl(
VMBUS_CHANNEL *Channel,
void * Kbuffer, // from kmalloc()
u32 Size, // page-size multiple
void * Kbuffer, /* from kmalloc() */
u32 Size, /* page-size multiple */
u32 *GpadlHandle
);
......@@ -154,4 +154,4 @@ static void
VmbusChannelOnTimer(
void *Context
);
#endif //_CHANNEL_H_
#endif /* _CHANNEL_H_ */
......@@ -38,4 +38,4 @@ GetChannelInfo(
DEVICE_INFO *DeviceInfo
);
#endif // _CHANNEL_INTERFACE_H_
#endif /* _CHANNEL_INTERFACE_H_ */
......@@ -27,13 +27,7 @@
#include "VmbusPrivate.h"
//
// Defines
//
//
// Data types
//
/* Data types */
typedef void (*PFN_CHANNEL_MESSAGE_HANDLER)(VMBUS_CHANNEL_MESSAGE_HEADER* msg);
......@@ -42,9 +36,7 @@ typedef struct _VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY {
PFN_CHANNEL_MESSAGE_HANDLER messageHandler;
} VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY;
//
// Internal routines
//
/* Internal routines */
static void
VmbusChannelOnOffer(
......@@ -91,25 +83,23 @@ VmbusChannelProcessRescindOffer(
);
//
// Globals
//
/* Globals */
#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 4
const GUID gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED]= {
//{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}
{.Data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f}},// Storage - SCSI
//{F8615163-DF3E-46c5-913F-F2D2F965ED0E}
{.Data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E}}, // Network
//{CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A}
{.Data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}}, // Input
//{32412632-86cb-44a2-9b5c-50d1417354f5}
{.Data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5}}, // IDE
/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
{.Data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f}},/* Storage - SCSI */
/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
{.Data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E}}, /* Network */
/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
{.Data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}}, /* Input */
/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
{.Data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5}}, /* IDE */
};
// Channel message dispatch table
/* Channel message dispatch table */
VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY gChannelMessageTable[ChannelMessageCount]= {
{ChannelMessageInvalid, NULL},
{ChannelMessageOfferChannel, VmbusChannelOnOffer},
......@@ -158,7 +148,7 @@ VMBUS_CHANNEL* AllocVmbusChannel(void)
return NULL;
}
//channel->dataWorkQueue = WorkQueueCreate("data");
/* channel->dataWorkQueue = WorkQueueCreate("data"); */
channel->ControlWQ = WorkQueueCreate("control");
if (!channel->ControlWQ)
{
......@@ -207,8 +197,8 @@ void FreeVmbusChannel(VMBUS_CHANNEL* Channel)
{
TimerClose(Channel->PollTimer);
// We have to release the channel's workqueue/thread in the vmbus's workqueue/thread context
// ie we can't destroy ourselves.
/* We have to release the channel's workqueue/thread in the vmbus's workqueue/thread context */
/* ie we can't destroy ourselves. */
WorkQueueQueueWorkItem(gVmbusConnection.WorkQueue, ReleaseVmbusChannel, (void*)Channel);
}
......@@ -237,7 +227,7 @@ VmbusChannelProcessOffer(
DPRINT_ENTER(VMBUS);
// Make sure this is a new offer
/* Make sure this is a new offer */
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList)
......@@ -266,8 +256,8 @@ VmbusChannelProcessOffer(
return;
}
// Start the process of binding this offer to the driver
// We need to set the DeviceObject field before calling VmbusChildDeviceAdd()
/* Start the process of binding this offer to the driver */
/* We need to set the DeviceObject field before calling VmbusChildDeviceAdd() */
newChannel->DeviceObject = VmbusChildDeviceCreate(
newChannel->OfferMsg.Offer.InterfaceType,
newChannel->OfferMsg.Offer.InterfaceInstance,
......@@ -275,8 +265,12 @@ VmbusChannelProcessOffer(
DPRINT_DBG(VMBUS, "child device object allocated - %p", newChannel->DeviceObject);
// Add the new device to the bus. This will kick off device-driver binding
// which eventually invokes the device driver's AddDevice() method.
/*
* Add the new device to the bus. This will kick off device-driver
* binding which eventually invokes the device driver's AddDevice()
* method.
*/
ret = VmbusChildDeviceAdd(newChannel->DeviceObject);
if (ret != 0)
{
......@@ -291,8 +285,11 @@ VmbusChannelProcessOffer(
}
else
{
// This state is used to indicate a successful open so that when we do close the channel normally,
// we can cleanup properly
/*
* This state is used to indicate a successful open
* so that when we do close the channel normally, we
* can cleanup properly
*/
newChannel->State = CHANNEL_OPEN_STATE;
}
DPRINT_EXIT(VMBUS);
......@@ -377,7 +374,7 @@ VmbusChannelOnOffer(
guidType->Data[3], guidType->Data[2], guidType->Data[1], guidType->Data[0], guidType->Data[5], guidType->Data[4], guidType->Data[7], guidType->Data[6], guidType->Data[8], guidType->Data[9], guidType->Data[10], guidType->Data[11], guidType->Data[12], guidType->Data[13], guidType->Data[14], guidType->Data[15],
guidInstance->Data[3], guidInstance->Data[2], guidInstance->Data[1], guidInstance->Data[0], guidInstance->Data[5], guidInstance->Data[4], guidInstance->Data[7], guidInstance->Data[6], guidInstance->Data[8], guidInstance->Data[9], guidInstance->Data[10], guidInstance->Data[11], guidInstance->Data[12], guidInstance->Data[13], guidInstance->Data[14], guidInstance->Data[15]);
// Allocate the channel object and save this offer.
/* Allocate the channel object and save this offer. */
newChannel = AllocVmbusChannel();
if (!newChannel)
{
......@@ -391,7 +388,7 @@ VmbusChannelOnOffer(
newChannel->MonitorGroup = (u8)offer->MonitorId / 32;
newChannel->MonitorBit = (u8)offer->MonitorId % 32;
// TODO: Make sure the offer comes from our parent partition
/* TODO: Make sure the offer comes from our parent partition */
WorkQueueQueueWorkItem(newChannel->ControlWQ, VmbusChannelProcessOffer, newChannel);
DPRINT_EXIT(VMBUS);
......@@ -479,7 +476,7 @@ VmbusChannelOnOpenResult(
DPRINT_DBG(VMBUS, "vmbus open result - %d", result->Status);
// Find the open msg, copy the result and signal/unblock the wait event
/* Find the open msg, copy the result and signal/unblock the wait event */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
......@@ -533,7 +530,7 @@ VmbusChannelOnGpadlCreated(
DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d", gpadlCreated->CreationStatus);
// Find the establish msg, copy the result and signal/unblock the wait event
/* Find the establish msg, copy the result and signal/unblock the wait event */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
......@@ -586,7 +583,7 @@ VmbusChannelOnGpadlTorndown(
DPRINT_ENTER(VMBUS);
// Find the open msg, copy the result and signal/unblock the wait event
/* Find the open msg, copy the result and signal/unblock the wait event */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
......@@ -702,7 +699,7 @@ VmbusOnChannelMessage(
DPRINT_ERR(VMBUS, "Unhandled channel message type %d", hdr->MessageType);
}
// Free the msg that was allocated in VmbusOnMsgDPC()
/* Free the msg that was allocated in VmbusOnMsgDPC() */
kfree(msg);
DPRINT_EXIT(VMBUS);
}
......@@ -751,7 +748,7 @@ VmbusChannelRequestOffers(
goto Cleanup;
}
//WaitEventWait(msgInfo->waitEvent);
/* WaitEventWait(msgInfo->waitEvent); */
/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
......@@ -819,5 +816,4 @@ VmbusChannelReleaseUnattachedChannels(
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
}
// eof
/* eof */
......@@ -47,27 +47,27 @@ typedef struct _VMBUS_CHANNEL {
DEVICE_OBJECT* DeviceObject;
HANDLE PollTimer; // SA-111 workaround
HANDLE PollTimer; /* SA-111 workaround */
VMBUS_CHANNEL_STATE State;
VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
// These are based on the OfferMsg.MonitorId. Save it here for easy access.
/* These are based on the OfferMsg.MonitorId. Save it here for easy access. */
u8 MonitorGroup;
u8 MonitorBit;
u32 RingBufferGpadlHandle;
// Allocated memory for ring buffer
/* Allocated memory for ring buffer */
void * RingBufferPages;
u32 RingBufferPageCount;
RING_BUFFER_INFO Outbound; // send to parent
RING_BUFFER_INFO Inbound; // receive from parent
RING_BUFFER_INFO Outbound; /* send to parent */
RING_BUFFER_INFO Inbound; /* receive from parent */
spinlock_t inbound_lock;
HANDLE ControlWQ;
// Channel callback are invoked in this workqueue context
//HANDLE dataWorkQueue;
/* Channel callback are invoked in this workqueue context */
/* HANDLE dataWorkQueue; */
PFN_CHANNEL_CALLBACK OnChannelCallback;
void * ChannelCallbackContext;
......@@ -102,31 +102,31 @@ typedef union {
} VMBUS_CHANNEL_MESSAGE_RESPONSE;
// Represents each channel msg on the vmbus connection
// This is a variable-size data structure depending on
// the msg type itself
/*
* Represents each channel msg on the vmbus connection This is a
* variable-size data structure depending on the msg type itself
*/
typedef struct _VMBUS_CHANNEL_MSGINFO {
// Bookkeeping stuff
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
// So far, this is only used to handle gpadl body message
/* So far, this is only used to handle gpadl body message */
LIST_ENTRY SubMsgList;
// Synchronize the request/response if needed
/* Synchronize the request/response if needed */
HANDLE WaitEvent;
VMBUS_CHANNEL_MESSAGE_RESPONSE Response;
u32 MessageSize;
// The channel message that goes out on the "wire".
// It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
/* The channel message that goes out on the "wire". */
/* It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header */
unsigned char Msg[0];
} VMBUS_CHANNEL_MSGINFO;
//
// Routines
//
/* Routines */
static VMBUS_CHANNEL*
AllocVmbusChannel(
......@@ -153,4 +153,4 @@ VmbusChannelReleaseUnattachedChannels(
void
);
#endif //_CHANNEL_MGMT_H_
#endif /* _CHANNEL_MGMT_H_ */
......@@ -26,9 +26,7 @@
#include "VmbusPrivate.h"
//
// Globals
//
/* Globals */
VMBUS_CONNECTION gVmbusConnection = {
......@@ -57,11 +55,11 @@ VmbusConnect(
DPRINT_ENTER(VMBUS);
// Make sure we are not connecting or connected
/* Make sure we are not connecting or connected */
if (gVmbusConnection.ConnectState != Disconnected)
return -1;
// Initialize the vmbus connection
/* Initialize the vmbus connection */
gVmbusConnection.ConnectState = Connecting;
gVmbusConnection.WorkQueue = WorkQueueCreate("vmbusQ");
......@@ -71,7 +69,10 @@ VmbusConnect(
INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelList);
spin_lock_init(&gVmbusConnection.channel_lock);
// Setup the vmbus event connection for channel interrupt abstraction stuff
/*
* Setup the vmbus event connection for channel interrupt
* abstraction stuff
*/
gVmbusConnection.InterruptPage = PageAlloc(1);
if (gVmbusConnection.InterruptPage == NULL)
{
......@@ -82,7 +83,10 @@ VmbusConnect(
gVmbusConnection.RecvInterruptPage = gVmbusConnection.InterruptPage;
gVmbusConnection.SendInterruptPage = (void*)((unsigned long)gVmbusConnection.InterruptPage + (PAGE_SIZE >> 1));
// Setup the monitor notification facility. The 1st page for parent->child and the 2nd page for child->parent
/* Setup the monitor
* notification facility. The 1st page for parent->child and
* the 2nd page for child->parent
*/
gVmbusConnection.MonitorPages = PageAlloc(2);
if (gVmbusConnection.MonitorPages == NULL)
{
......@@ -106,8 +110,10 @@ VmbusConnect(
msg->MonitorPage1 = GetPhysicalAddress(gVmbusConnection.MonitorPages);
msg->MonitorPage2 = GetPhysicalAddress((void *)((unsigned long)gVmbusConnection.MonitorPages + PAGE_SIZE));
// Add to list before we send the request since we may receive the response
// before returning from this routine
/*
* Add to list before we send the request since we may
* receive the response before returning from this routine
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
......@@ -124,12 +130,12 @@ VmbusConnect(
goto Cleanup;
}
// Wait for the connection response
/* Wait for the connection response */
WaitEventWait(msgInfo->WaitEvent);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
// Check if successful
/* Check if successful */
if (msgInfo->Response.VersionResponse.VersionSupported)
{
DPRINT_INFO(VMBUS, "Vmbus connected!!");
......@@ -202,7 +208,7 @@ VmbusDisconnect(
DPRINT_ENTER(VMBUS);
// Make sure we are connected
/* Make sure we are connected */
if (gVmbusConnection.ConnectState != Connected)
return -1;
......@@ -219,7 +225,7 @@ VmbusDisconnect(
PageFree(gVmbusConnection.InterruptPage, 1);
// TODO: iterate thru the msg list and free up
/* TODO: iterate thru the msg list and free up */
WorkQueueClose(gVmbusConnection.WorkQueue);
......@@ -296,14 +302,16 @@ VmbusProcessChannelEvent(
ASSERT(relId > 0);
// Find the channel based on this relid and invokes
// the channel callback to process the event
/*
* Find the channel based on this relid and invokes the
* channel callback to process the event
*/
channel = GetChannelFromRelId(relId);
if (channel)
{
VmbusChannelOnChannelEvent(channel);
//WorkQueueQueueWorkItem(channel->dataWorkQueue, VmbusChannelOnChannelEvent, (void*)channel);
/* WorkQueueQueueWorkItem(channel->dataWorkQueue, VmbusChannelOnChannelEvent, (void*)channel); */
}
else
{
......@@ -327,16 +335,16 @@ VmbusOnEvents(
)
{
int dword;
//int maxdword = PAGE_SIZE >> 3; // receive size is 1/2 page and divide that by 4 bytes
/* int maxdword = PAGE_SIZE >> 3; // receive size is 1/2 page and divide that by 4 bytes */
int maxdword = MAX_NUM_CHANNELS_SUPPORTED >> 5;
int bit;
int relid;
u32* recvInterruptPage = gVmbusConnection.RecvInterruptPage;
//VMBUS_CHANNEL_MESSAGE* receiveMsg;
/* VMBUS_CHANNEL_MESSAGE* receiveMsg; */
DPRINT_ENTER(VMBUS);
// Check events
/* Check events */
if (recvInterruptPage)
{
for (dword = 0; dword < maxdword; dword++)
......@@ -351,15 +359,15 @@ VmbusOnEvents(
DPRINT_DBG(VMBUS, "event detected for relid - %d", relid);
if (relid == 0) // special case - vmbus channel protocol msg
if (relid == 0) /* special case - vmbus channel protocol msg */
{
DPRINT_DBG(VMBUS, "invalid relid - %d", relid);
continue; }
else
{
//QueueWorkItem(VmbusProcessEvent, (void*)relid);
//ret = WorkQueueQueueWorkItem(gVmbusConnection.workQueue, VmbusProcessChannelEvent, (void*)relid);
/* QueueWorkItem(VmbusProcessEvent, (void*)relid); */
/* ret = WorkQueueQueueWorkItem(gVmbusConnection.workQueue, VmbusProcessChannelEvent, (void*)relid); */
VmbusProcessChannelEvent((void*)(unsigned long)relid);
}
}
......@@ -418,7 +426,7 @@ VmbusSetEvent(u32 childRelId)
DPRINT_ENTER(VMBUS);
// Each u32 represents 32 channels
/* Each u32 represents 32 channels */
BitSet((u32*)gVmbusConnection.SendInterruptPage + (childRelId >> 5), childRelId & 31);
ret = HvSignalEvent();
......@@ -427,4 +435,4 @@ VmbusSetEvent(u32 childRelId)
return ret;
}
// EOF
/* EOF */
......@@ -25,11 +25,9 @@
#include "include/logging.h"
#include "VmbusPrivate.h"
//
// Globals
//
/* Globals */
// The one and only
/* The one and only */
HV_CONTEXT gHvContext={
.SynICInitialized = false,
.HypercallPage = NULL,
......@@ -90,10 +88,11 @@ HvQueryHypervisorInfo (
unsigned int maxLeaf;
unsigned int op;
//
// Its assumed that this is called after confirming that Viridian is present.
// Query id and revision.
//
/*
* Its assumed that this is called after confirming that Viridian
* is present. Query id and revision.
*/
eax = 0;
ebx = 0;
......@@ -211,7 +210,7 @@ HvDoHypercall (
DPRINT_DBG(VMBUS, "Hypercall <return %llx>", hvStatusLo | ((u64)hvStatusHi << 32));
return (hvStatusLo | ((u64)hvStatusHi << 32));
#endif // x86_64
#endif /* x86_64 */
}
/*++
......@@ -249,26 +248,26 @@ HvInit (
DPRINT_INFO(VMBUS, "Windows hypervisor detected! Retrieving more info...");
maxLeaf = HvQueryHypervisorInfo();
//HvQueryHypervisorFeatures(maxLeaf);
/* HvQueryHypervisorFeatures(maxLeaf); */
// Determine if we are running on xenlinux (ie x2v shim) or native linux
/* Determine if we are running on xenlinux (ie x2v shim) or native linux */
gHvContext.GuestId = ReadMsr(HV_X64_MSR_GUEST_OS_ID);
if (gHvContext.GuestId == 0)
{
// Write our OS info
/* Write our OS info */
WriteMsr(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
gHvContext.GuestId = HV_LINUX_GUEST_ID;
}
// See if the hypercall page is already set
/* See if the hypercall page is already set */
hypercallMsr.AsUINT64 = ReadMsr(HV_X64_MSR_HYPERCALL);
if (gHvContext.GuestId == HV_LINUX_GUEST_ID)
{
// Allocate the hypercall page memory
//virtAddr = PageAlloc(1);
/* Allocate the hypercall page memory */
/* virtAddr = PageAlloc(1); */
virtAddr = VirtualAllocExec(PAGE_SIZE);
if (!virtAddr)
......@@ -278,11 +277,11 @@ HvInit (
}
hypercallMsr.Enable = 1;
//hypercallMsr.GuestPhysicalAddress = Logical2PhysicalAddr(virtAddr) >> PAGE_SHIFT;
/* hypercallMsr.GuestPhysicalAddress = Logical2PhysicalAddr(virtAddr) >> PAGE_SHIFT; */
hypercallMsr.GuestPhysicalAddress = Virtual2Physical(virtAddr) >> PAGE_SHIFT;
WriteMsr(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
// Confirm that hypercall page did get setup.
/* Confirm that hypercall page did get setup. */
hypercallMsr.AsUINT64 = 0;
hypercallMsr.AsUINT64 = ReadMsr(HV_X64_MSR_HYPERCALL);
......@@ -304,7 +303,7 @@ HvInit (
gHvContext.HypercallPage,
(u64)hypercallMsr.GuestPhysicalAddress << PAGE_SHIFT);
// Setup the global signal event param for the signal event hypercall
/* Setup the global signal event param for the signal event hypercall */
gHvContext.SignalEventBuffer = kmalloc(sizeof(HV_INPUT_SIGNAL_EVENT_BUFFER), GFP_KERNEL);
if (!gHvContext.SignalEventBuffer)
{
......@@ -317,7 +316,7 @@ HvInit (
gHvContext.SignalEventParam->FlagNumber = 0;
gHvContext.SignalEventParam->RsvdZ = 0;
//DPRINT_DBG(VMBUS, "My id %llu", HvGetCurrentPartitionId());
/* DPRINT_DBG(VMBUS, "My id %llu", HvGetCurrentPartitionId()); */
DPRINT_EXIT(VMBUS);
......@@ -490,12 +489,12 @@ HvSynicInit (
return ret;
}
// Check the version
/* Check the version */
version = ReadMsr(HV_X64_MSR_SVERSION);
DPRINT_INFO(VMBUS, "SynIC version: %llx", version);
// TODO: Handle SMP
/* TODO: Handle SMP */
if (gHvContext.GuestId == HV_XENLINUX_GUEST_ID)
{
DPRINT_INFO(VMBUS, "Skipping SIMP and SIEFP setup since it is already set.");
......@@ -505,7 +504,7 @@ HvSynicInit (
DPRINT_DBG(VMBUS, "Simp: %llx, Sifep: %llx", simp.AsUINT64, siefp.AsUINT64);
// Determine if we are running on xenlinux (ie x2v shim) or native linux
/* Determine if we are running on xenlinux (ie x2v shim) or native linux */
guestID = ReadMsr(HV_X64_MSR_GUEST_OS_ID);
if (guestID == HV_LINUX_GUEST_ID)
......@@ -536,9 +535,7 @@ HvSynicInit (
goto Cleanup;
}
//
// Setup the Synic's message page
//
/* Setup the Synic's message page */
simp.AsUINT64 = ReadMsr(HV_X64_MSR_SIMP);
simp.SimpEnabled = 1;
simp.BaseSimpGpa = GetPhysicalAddress(gHvContext.synICMessagePage[0]) >> PAGE_SHIFT;
......@@ -547,9 +544,7 @@ HvSynicInit (
WriteMsr(HV_X64_MSR_SIMP, simp.AsUINT64);
//
// Setup the Synic's event page
//
/* Setup the Synic's event page */
siefp.AsUINT64 = ReadMsr(HV_X64_MSR_SIEFP);
siefp.SiefpEnabled = 1;
siefp.BaseSiefpGpa = GetPhysicalAddress(gHvContext.synICEventPage[0]) >> PAGE_SHIFT;
......@@ -558,19 +553,15 @@ HvSynicInit (
WriteMsr(HV_X64_MSR_SIEFP, siefp.AsUINT64);
}
//
// Setup the interception SINT.
//
//WriteMsr((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX),
// interceptionSint.AsUINT64);
//
// Setup the shared SINT.
//
/* Setup the interception SINT. */
/* WriteMsr((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */
/* interceptionSint.AsUINT64); */
/* Setup the shared SINT. */
sharedSint.AsUINT64 = ReadMsr(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT);
sharedSint.AsUINT64 = 0;
sharedSint.Vector = irqVector; //HV_SHARED_SINT_IDT_VECTOR + 0x20;
sharedSint.Vector = irqVector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
sharedSint.Masked = false;
sharedSint.AutoEoi = true;
......@@ -578,7 +569,7 @@ HvSynicInit (
WriteMsr(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
// Enable the global synic bit
/* Enable the global synic bit */
sctrl.AsUINT64 = ReadMsr(HV_X64_MSR_SCONTROL);
sctrl.Enable = 1;
......@@ -642,11 +633,14 @@ HvSynicCleanup(
sharedSint.Masked = 1;
// Disable the interrupt
/* Disable the interrupt */
WriteMsr(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
// Disable and free the resources only if we are running as native linux
// since in xenlinux, we are sharing the resources with the x2v shim
/*
* Disable and free the resources only if we are running as
* native linux since in xenlinux, we are sharing the
* resources with the x2v shim
*/
if (gHvContext.GuestId == HV_LINUX_GUEST_ID)
{
simp.AsUINT64 = ReadMsr(HV_X64_MSR_SIMP);
......@@ -669,4 +663,4 @@ HvSynicCleanup(
}
// eof
/* eof */
......@@ -29,17 +29,17 @@
#include "include/HvTypes.h"
#include "include/HvStatus.h"
//#include "HvVmApi.h"
//#include "HvKeApi.h"
//#include "HvMmApi.h"
//#include "HvCpuApi.h"
/* #include "HvVmApi.h" */
/* #include "HvKeApi.h" */
/* #include "HvMmApi.h" */
/* #include "HvCpuApi.h" */
#include "include/HvHalApi.h"
#include "include/HvVpApi.h"
//#include "HvTrApi.h"
/* #include "HvTrApi.h" */
#include "include/HvSynicApi.h"
//#include "HvAmApi.h"
//#include "HvHkApi.h"
//#include "HvValApi.h"
/* #include "HvAmApi.h" */
/* #include "HvHkApi.h" */
/* #include "HvValApi.h" */
#include "include/HvHcApi.h"
#include "include/HvPtApi.h"
......@@ -53,9 +53,9 @@ enum
VMBUS_MONITOR_PORT_ID = 3,
VMBUS_MESSAGE_SINT = 2
};
//
// #defines
//
/* #defines */
#define HV_PRESENT_BIT 0x80000000
#define HV_XENLINUX_GUEST_ID_LO 0x00000000
......@@ -75,9 +75,9 @@ enum
#define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
//
// Service definitions
//
/* Service definitions */
#define HV_SERVICE_PARENT_PORT (0)
#define HV_SERVICE_PARENT_CONNECTION (0)
......@@ -95,10 +95,10 @@ enum
#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
//#define VMBUS_REVISION_NUMBER 6
//#define VMBUS_PORT_ID 11 // Our local vmbus's port and connection id. Anything >0 is fine
/* #define VMBUS_REVISION_NUMBER 6 */
/* #define VMBUS_PORT_ID 11 // Our local vmbus's port and connection id. Anything >0 is fine */
// 628180B8-308D-4c5e-B7DB-1BEB62E62EF4
/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
static const GUID VMBUS_SERVICE_ID = {.Data = {0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c, 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4} };
#define MAX_NUM_CPUS 1
......@@ -110,14 +110,14 @@ typedef struct {
} HV_INPUT_SIGNAL_EVENT_BUFFER;
typedef struct {
u64 GuestId; // XenLinux or native Linux. If XenLinux, the hypercall and synic pages has already been initialized
u64 GuestId; /* XenLinux or native Linux. If XenLinux, the hypercall and synic pages has already been initialized */
void* HypercallPage;
bool SynICInitialized;
// This is used as an input param to HvCallSignalEvent hypercall. The input param is immutable
// in our usage and must be dynamic mem (vs stack or global).
/* This is used as an input param to HvCallSignalEvent hypercall. The input param is immutable */
/* in our usage and must be dynamic mem (vs stack or global). */
HV_INPUT_SIGNAL_EVENT_BUFFER *SignalEventBuffer;
HV_INPUT_SIGNAL_EVENT *SignalEventParam; // 8-bytes aligned of the buffer above
HV_INPUT_SIGNAL_EVENT *SignalEventParam; /* 8-bytes aligned of the buffer above */
HANDLE synICMessagePage[MAX_NUM_CPUS];
HANDLE synICEventPage[MAX_NUM_CPUS];
......@@ -126,9 +126,9 @@ typedef struct {
extern HV_CONTEXT gHvContext;
//
// Inline routines
//
/* Inline routines */
static inline unsigned long long ReadMsr(int msr)
{
unsigned long long val;
......@@ -145,9 +145,9 @@ static inline void WriteMsr(int msr, u64 val)
return;
}
//
// Hv Interface
//
/* Hv Interface */
static int
HvInit(
void
......@@ -181,4 +181,4 @@ HvSynicCleanup(
void
);
#endif // __HV_H__
#endif /* __HV_H__ */
This diff is collapsed.
......@@ -30,62 +30,62 @@
#include "include/List.h"
#include "include/NetVscApi.h"
//
// #defines
//
//#define NVSC_MIN_PROTOCOL_VERSION 1
//#define NVSC_MAX_PROTOCOL_VERSION 1
#define NETVSC_SEND_BUFFER_SIZE 64*1024 // 64K
/* #defines */
/* #define NVSC_MIN_PROTOCOL_VERSION 1 */
/* #define NVSC_MAX_PROTOCOL_VERSION 1 */
#define NETVSC_SEND_BUFFER_SIZE 64*1024 /* 64K */
#define NETVSC_SEND_BUFFER_ID 0xface
#define NETVSC_RECEIVE_BUFFER_SIZE 1024*1024 // 1MB
#define NETVSC_RECEIVE_BUFFER_SIZE 1024*1024 /* 1MB */
#define NETVSC_RECEIVE_BUFFER_ID 0xcafe
#define NETVSC_RECEIVE_SG_COUNT 1
// Preallocated receive packets
/* Preallocated receive packets */
#define NETVSC_RECEIVE_PACKETLIST_COUNT 256
//
// Data types
//
// Per netvsc channel-specific
/* Data types */
/* Per netvsc channel-specific */
typedef struct _NETVSC_DEVICE {
DEVICE_OBJECT *Device;
int RefCount;
int NumOutstandingSends;
// List of free preallocated NETVSC_PACKET to represent receive packet
/* List of free preallocated NETVSC_PACKET to represent receive packet */
LIST_ENTRY ReceivePacketList;
spinlock_t receive_packet_list_lock;
// Send buffer allocated by us but manages by NetVSP
/* Send buffer allocated by us but manages by NetVSP */
void * SendBuffer;
u32 SendBufferSize;
u32 SendBufferGpadlHandle;
u32 SendSectionSize;
// Receive buffer allocated by us but manages by NetVSP
/* Receive buffer allocated by us but manages by NetVSP */
void * ReceiveBuffer;
u32 ReceiveBufferSize;
u32 ReceiveBufferGpadlHandle;
u32 ReceiveSectionCount;
PNVSP_1_RECEIVE_BUFFER_SECTION ReceiveSections;
// Used for NetVSP initialization protocol
/* Used for NetVSP initialization protocol */
HANDLE ChannelInitEvent;
NVSP_MESSAGE ChannelInitPacket;
NVSP_MESSAGE RevokePacket;
//unsigned char HwMacAddr[HW_MACADDR_LEN];
/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
// Holds rndis device info
/* Holds rndis device info */
void *Extension;
} NETVSC_DEVICE;
#endif // _NETVSC_H_
#endif /* _NETVSC_H_ */
......@@ -25,11 +25,11 @@
#include "include/logging.h"
#include "RingBuffer.h"
//
// #defines
//
// Amount of space to write to
/* #defines */
/* Amount of space to write to */
#define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r))?((z) - ((w) - (r))):((r) - (w))
......@@ -48,7 +48,7 @@ GetRingBufferAvailBytes(RING_BUFFER_INFO *rbi, u32 *read, u32 *write)
{
u32 read_loc,write_loc;
// Capture the read/write indices before they changed
/* Capture the read/write indices before they changed */
read_loc = rbi->RingBuffer->ReadIndex;
write_loc = rbi->RingBuffer->WriteIndex;
......@@ -221,9 +221,9 @@ DumpRingInfo(RING_BUFFER_INFO* RingInfo, char *Prefix)
RingInfo->RingBuffer->WriteIndex);
}
//
// Internal routines
//
/* Internal routines */
static u32
CopyToRingBuffer(
RING_BUFFER_INFO *RingInfo,
......@@ -376,10 +376,10 @@ RingBufferWrite(
DPRINT_DBG(VMBUS, "Writing %u bytes...", totalBytesToWrite);
//DumpRingInfo(OutRingInfo, "BEFORE ");
/* DumpRingInfo(OutRingInfo, "BEFORE "); */
// If there is only room for the packet, assume it is full. Otherwise, the next time around, we think the ring buffer
// is empty since the read index == write index
/* If there is only room for the packet, assume it is full. Otherwise, the next time around, we think the ring buffer */
/* is empty since the read index == write index */
if (byteAvailToWrite <= totalBytesToWrite)
{
DPRINT_DBG(VMBUS, "No more space left on outbound ring buffer (needed %u, avail %u)", totalBytesToWrite, byteAvailToWrite);
......@@ -391,7 +391,7 @@ RingBufferWrite(
return -1;
}
// Write to the ring buffer
/* Write to the ring buffer */
nextWriteLocation = GetNextWriteLocation(OutRingInfo);
for (i=0; i < SgBufferCount; i++)
......@@ -402,7 +402,7 @@ RingBufferWrite(
SgBuffers[i].Length);
}
// Set previous packet start
/* Set previous packet start */
prevIndices = GetRingBufferIndices(OutRingInfo);
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
......@@ -410,13 +410,13 @@ RingBufferWrite(
&prevIndices,
sizeof(u64));
// Make sure we flush all writes before updating the writeIndex
/* Make sure we flush all writes before updating the writeIndex */
mb();
// Now, update the write location
/* Now, update the write location */
SetNextWriteLocation(OutRingInfo, nextWriteLocation);
//DumpRingInfo(OutRingInfo, "AFTER ");
/* DumpRingInfo(OutRingInfo, "AFTER "); */
spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags);
......@@ -451,17 +451,17 @@ RingBufferPeek(
GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite);
// Make sure there is something to read
/* Make sure there is something to read */
if (bytesAvailToRead < BufferLen )
{
//DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen);
/* DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); */
spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
return -1;
}
// Convert to byte offset
/* Convert to byte offset */
nextReadLocation = GetNextReadLocation(InRingInfo);
nextReadLocation = CopyFromRingBuffer(InRingInfo,
......@@ -506,9 +506,9 @@ RingBufferRead(
DPRINT_DBG(VMBUS, "Reading %u bytes...", BufferLen);
//DumpRingInfo(InRingInfo, "BEFORE ");
/* DumpRingInfo(InRingInfo, "BEFORE "); */
// Make sure there is something to read
/* Make sure there is something to read */
if (bytesAvailToRead < BufferLen )
{
DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen);
......@@ -530,14 +530,14 @@ RingBufferRead(
sizeof(u64),
nextReadLocation);
// Make sure all reads are done before we update the read index since
// the writer may start writing to the read area once the read index is updated
/* Make sure all reads are done before we update the read index since */
/* the writer may start writing to the read area once the read index is updated */
mb();
// Update the read index
/* Update the read index */
SetNextReadLocation(InRingInfo, nextReadLocation);
//DumpRingInfo(InRingInfo, "AFTER ");
/* DumpRingInfo(InRingInfo, "AFTER "); */
spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
......@@ -566,7 +566,7 @@ CopyToRingBuffer(
u32 ringBufferSize=GetRingBufferSize(RingInfo);
u32 fragLen;
if (SrcLen > ringBufferSize - StartWriteOffset) // wrap-around detected!
if (SrcLen > ringBufferSize - StartWriteOffset) /* wrap-around detected! */
{
DPRINT_DBG(VMBUS, "wrap-around detected!");
......@@ -608,7 +608,7 @@ CopyFromRingBuffer(
u32 fragLen;
if (DestLen > ringBufferSize - StartReadOffset) // wrap-around detected at the src
if (DestLen > ringBufferSize - StartReadOffset) /* wrap-around detected at the src */
{
DPRINT_DBG(VMBUS, "src wrap-around detected!");
......@@ -629,4 +629,4 @@ CopyFromRingBuffer(
}
// eof
/* eof */
......@@ -33,24 +33,24 @@ typedef struct _SG_BUFFER_LIST {
} SG_BUFFER_LIST;
typedef struct _RING_BUFFER {
volatile u32 WriteIndex; // Offset in bytes from the start of ring data below
volatile u32 ReadIndex; // Offset in bytes from the start of ring data below
volatile u32 WriteIndex; /* Offset in bytes from the start of ring data below */
volatile u32 ReadIndex; /* Offset in bytes from the start of ring data below */
volatile u32 InterruptMask;
u8 Reserved[4084]; // Pad it to PAGE_SIZE so that data starts on page boundary
// NOTE: The InterruptMask field is used only for channels but since our vmbus connection
// also uses this data structure and its data starts here, we commented out this field.
// volatile u32 InterruptMask;
// Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!!
u8 Reserved[4084]; /* Pad it to PAGE_SIZE so that data starts on page boundary */
/* NOTE: The InterruptMask field is used only for channels but since our vmbus connection */
/* also uses this data structure and its data starts here, we commented out this field. */
/* volatile u32 InterruptMask; */
/* Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! */
u8 Buffer[0];
} __attribute__((packed)) RING_BUFFER;
typedef struct _RING_BUFFER_INFO {
RING_BUFFER* RingBuffer;
u32 RingSize; // Include the shared header
u32 RingSize; /* Include the shared header */
spinlock_t ring_lock;
u32 RingDataSize; // < ringSize
u32 RingDataSize; /* < ringSize */
u32 RingDataStartOffset;
} RING_BUFFER_INFO;
......@@ -65,9 +65,9 @@ typedef struct _RING_BUFFER_DEBUG_INFO {
}RING_BUFFER_DEBUG_INFO;
//
// Interface
//
/* Interface */
static int
RingBufferInit(
......@@ -120,4 +120,4 @@ RingBufferGetDebugInfo(
RING_BUFFER_DEBUG_INFO *DebugInfo
);
#endif // _RING_BUFFER_H_
#endif /* _RING_BUFFER_H_ */
This diff is collapsed.
......@@ -49,13 +49,13 @@
//
// Interface
//
/* Interface */
int
RndisFilterInit(
NETVSC_DRIVER_OBJECT *Driver
);
#endif // _RNDISFILTER_H_
#endif /* _RNDISFILTER_H_ */
This diff is collapsed.
......@@ -27,29 +27,31 @@
#include "VersionInfo.h"
#include "VmbusPrivate.h"
//
// Globals
//
/* Globals */
static const char* gDriverName="vmbus";
// Windows vmbus does not defined this. We defined this to be consistent with other devices
//{c5295816-f63a-4d5f-8d1a-4daf999ca185}
/* Windows vmbus does not defined this.
* We defined this to be consistent with other devices
*/
/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
static const GUID gVmbusDeviceType={
.Data = {0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d, 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85}
};
//{ac3760fc-9adf-40aa-9427-a70ed6de95c5}
/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */
static const GUID gVmbusDeviceId={
.Data = {0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40, 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5}
};
static DRIVER_OBJECT* gDriver; // vmbus driver object
static DEVICE_OBJECT* gDevice; // vmbus root device
static DRIVER_OBJECT* gDriver; /* vmbus driver object */
static DEVICE_OBJECT* gDevice; /* vmbus root device */
//
// Internal routines
//
/* Internal routines */
static void
VmbusGetChannelInterface(
......@@ -129,7 +131,7 @@ VmbusInitialize(
drv->name = gDriverName;
memcpy(&drv->deviceType, &gVmbusDeviceType, sizeof(GUID));
// Setup dispatch table
/* Setup dispatch table */
driver->Base.OnDeviceAdd = VmbusOnDeviceAdd;
driver->Base.OnDeviceRemove = VmbusOnDeviceRemove;
driver->Base.OnCleanup = VmbusOnCleanup;
......@@ -140,7 +142,7 @@ VmbusInitialize(
driver->GetChannelInterface = VmbusGetChannelInterface;
driver->GetChannelInfo = VmbusGetChannelInfo;
// Hypervisor initialization...setup hypercall page..etc
/* Hypervisor initialization...setup hypercall page..etc */
ret = HvInit();
if (ret != 0)
{
......@@ -283,15 +285,18 @@ VmbusChildDeviceRemove(
Release the child device from the vmbus
--*/
//void
//VmbusChildDeviceDestroy(
// DEVICE_OBJECT* ChildDevice
// )
//{
// VMBUS_DRIVER_OBJECT* vmbusDriver = (VMBUS_DRIVER_OBJECT*)gDriver;
//
// vmbusDriver->OnChildDeviceDestroy(ChildDevice);
//}
/* **************
void
VmbusChildDeviceDestroy(
DEVICE_OBJECT* ChildDevice
)
{
VMBUS_DRIVER_OBJECT* vmbusDriver = (VMBUS_DRIVER_OBJECT*)gDriver;
vmbusDriver->OnChildDeviceDestroy(ChildDevice);
}
************* */
/*++
......@@ -318,14 +323,14 @@ VmbusOnDeviceAdd(
memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(GUID));
memcpy(&gDevice->deviceInstance, &gVmbusDeviceId, sizeof(GUID));
//strcpy(dev->name, "vmbus");
// SynIC setup...
/* strcpy(dev->name, "vmbus"); */
/* SynIC setup... */
ret = HvSynicInit(*irqvector);
// Connect to VMBus in the root partition
/* Connect to VMBus in the root partition */
ret = VmbusConnect();
//VmbusSendEvent(device->localPortId+1);
/* VmbusSendEvent(device->localPortId+1); */
DPRINT_EXIT(VMBUS);
return ret;
......@@ -375,7 +380,7 @@ VmbusOnCleanup(
DRIVER_OBJECT* drv
)
{
//VMBUS_DRIVER_OBJECT* driver = (VMBUS_DRIVER_OBJECT*)drv;
/* VMBUS_DRIVER_OBJECT* driver = (VMBUS_DRIVER_OBJECT*)drv; */
DPRINT_ENTER(VMBUS);
......@@ -405,7 +410,7 @@ VmbusOnMsgDPC(
HV_MESSAGE *copied;
while (1)
{
if (msg->Header.MessageType == HvMessageTypeNone) // no msg
if (msg->Header.MessageType == HvMessageTypeNone) /* no msg */
{
break;
}
......@@ -423,14 +428,22 @@ VmbusOnMsgDPC(
msg->Header.MessageType = HvMessageTypeNone;
// Make sure the write to MessageType (ie set to HvMessageTypeNone) happens
// before we read the MessagePending and EOMing. Otherwise, the EOMing will not deliver
// any more messages since there is no empty slot
/*
* Make sure the write to MessageType (ie set to
* HvMessageTypeNone) happens before we read the
* MessagePending and EOMing. Otherwise, the EOMing
* will not deliver any more messages since there is
* no empty slot
*/
mb();
if (msg->Header.MessageFlags.MessagePending)
{
// This will cause message queue rescan to possibly deliver another msg from the hypervisor
/*
* This will cause message queue rescan to
* possibly deliver another msg from the
* hypervisor
*/
WriteMsr(HV_X64_MSR_EOM, 0);
}
}
......@@ -450,7 +463,7 @@ VmbusOnEventDPC(
DRIVER_OBJECT* drv
)
{
// TODO: Process any events
/* TODO: Process any events */
VmbusOnEvents();
}
......@@ -469,33 +482,33 @@ VmbusOnISR(
DRIVER_OBJECT* drv
)
{
//VMBUS_DRIVER_OBJECT* driver = (VMBUS_DRIVER_OBJECT*)drv;
/* VMBUS_DRIVER_OBJECT* driver = (VMBUS_DRIVER_OBJECT*)drv; */
int ret=0;
//struct page* page;
/* struct page* page; */
void *page_addr;
HV_MESSAGE* msg;
HV_SYNIC_EVENT_FLAGS* event;
//page = SynICMessagePage[0];
//page_addr = page_address(page);
/* page = SynICMessagePage[0]; */
/* page_addr = page_address(page); */
page_addr = gHvContext.synICMessagePage[0];
msg = (HV_MESSAGE*)page_addr + VMBUS_MESSAGE_SINT;
DPRINT_ENTER(VMBUS);
// Check if there are actual msgs to be process
/* Check if there are actual msgs to be process */
if (msg->Header.MessageType != HvMessageTypeNone)
{
DPRINT_DBG(VMBUS, "received msg type %d size %d", msg->Header.MessageType, msg->Header.PayloadSize);
ret |= 0x1;
}
// TODO: Check if there are events to be process
/* TODO: Check if there are events to be process */
page_addr = gHvContext.synICEventPage[0];
event = (HV_SYNIC_EVENT_FLAGS*)page_addr + VMBUS_MESSAGE_SINT;
// Since we are a child, we only need to check bit 0
/* Since we are a child, we only need to check bit 0 */
if (BitTestAndClear(&event->Flags32[0], 0))
{
DPRINT_DBG(VMBUS, "received event %d", event->Flags32[0]);
......@@ -506,4 +519,4 @@ VmbusOnISR(
return ret;
}
// eof
/* eof */
......@@ -30,26 +30,29 @@
#include "Channel.h"
#include "ChannelMgmt.h"
#include "ChannelInterface.h"
//#include "ChannelMessages.h"
/* #include "ChannelMessages.h" */
#include "RingBuffer.h"
//#include "Packet.h"
/* #include "Packet.h" */
#include "include/List.h"
//
// Defines
//
// 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
/* Defines */
// The value here must be in multiple of 32
// TODO: Need to make this configurable
/*
* 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 */
#define MAX_NUM_CHANNELS_SUPPORTED 256
//
// Data types
//
/* Data types */
typedef enum {
Disconnected,
......@@ -66,23 +69,27 @@ typedef struct _VMBUS_CONNECTION {
u32 NextGpadlHandle;
// 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
/*
* 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
*/
void * InterruptPage;
void * SendInterruptPage;
void * RecvInterruptPage;
// 2 pages - 1st page for parent->child notification and 2nd is child->parent notification
/*
* 2 pages - 1st page for parent->child notification and 2nd
* is child->parent notification
*/
void * MonitorPages;
LIST_ENTRY ChannelMsgList;
spinlock_t channelmsg_lock;
// List of channels
/* List of channels */
LIST_ENTRY ChannelList;
spinlock_t channel_lock;
......@@ -91,25 +98,25 @@ typedef struct _VMBUS_CONNECTION {
typedef struct _VMBUS_MSGINFO {
// Bookkeeping stuff
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
// Synchronize the request/response if needed
/* Synchronize the request/response if needed */
HANDLE WaitEvent;
// The message itself
/* The message itself */
unsigned char Msg[0];
} VMBUS_MSGINFO;
//
// Externs
//
/* Externs */
extern VMBUS_CONNECTION gVmbusConnection;
//
// General vmbus interface
//
/* General vmbus interface */
static DEVICE_OBJECT*
VmbusChildDeviceCreate(
GUID deviceType,
......@@ -124,18 +131,18 @@ static void
VmbusChildDeviceRemove(
DEVICE_OBJECT* Device);
//static void
//VmbusChildDeviceDestroy(
// DEVICE_OBJECT*);
/* static void */
/* VmbusChildDeviceDestroy( */
/* DEVICE_OBJECT*); */
static VMBUS_CHANNEL*
GetChannelFromRelId(
u32 relId
);
//
// Connection interface
//
/* Connection interface */
static int
VmbusConnect(
void
......@@ -163,4 +170,4 @@ VmbusOnEvents(
);
#endif // _VMBUS_PRIVATE_H_
#endif /* _VMBUS_PRIVATE_H_ */
This diff is collapsed.
......@@ -31,9 +31,9 @@ typedef u32 NTSTATUS;
#pragma pack(push,1)
//
// Version 1 messages
//
/* Version 1 messages */
typedef enum _VMBUS_CHANNEL_MESSAGE_TYPE
{
......@@ -61,9 +61,9 @@ typedef enum _VMBUS_CHANNEL_MESSAGE_TYPE
ChannelMessageCount
} VMBUS_CHANNEL_MESSAGE_TYPE, *PVMBUS_CHANNEL_MESSAGE_TYPE;
// begin_wpp config
// CUSTOM_TYPE(ChannelMessageType, ItemEnum(_VMBUS_CHANNEL_MESSAGE_TYPE));
// end_wpp
/* begin_wpp config */
/* CUSTOM_TYPE(ChannelMessageType, ItemEnum(_VMBUS_CHANNEL_MESSAGE_TYPE)); */
/* end_wpp */
typedef struct _VMBUS_CHANNEL_MESSAGE_HEADER
{
......@@ -71,21 +71,21 @@ typedef struct _VMBUS_CHANNEL_MESSAGE_HEADER
u32 Padding;
} VMBUS_CHANNEL_MESSAGE_HEADER, *PVMBUS_CHANNEL_MESSAGE_HEADER;
// Query VMBus Version parameters
/* Query VMBus Version parameters */
typedef struct _VMBUS_CHANNEL_QUERY_VMBUS_VERSION
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
u32 Version;
} VMBUS_CHANNEL_QUERY_VMBUS_VERSION, *PVMBUS_CHANNEL_QUERY_VMBUS_VERSION;
// VMBus Version Supported parameters
/* VMBus Version Supported parameters */
typedef struct _VMBUS_CHANNEL_VERSION_SUPPORTED
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
bool VersionSupported;
} VMBUS_CHANNEL_VERSION_SUPPORTED, *PVMBUS_CHANNEL_VERSION_SUPPORTED;
// Offer Channel parameters
/* Offer Channel parameters */
typedef struct _VMBUS_CHANNEL_OFFER_CHANNEL
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
......@@ -95,67 +95,69 @@ typedef struct _VMBUS_CHANNEL_OFFER_CHANNEL
bool MonitorAllocated;
} VMBUS_CHANNEL_OFFER_CHANNEL, *PVMBUS_CHANNEL_OFFER_CHANNEL;
//
// Make sure VMBUS_CHANNEL_OFFER_CHANNEL fits into Synic message.
//
/* Make sure VMBUS_CHANNEL_OFFER_CHANNEL fits into Synic message. */
C_ASSERT(sizeof(VMBUS_CHANNEL_OFFER_CHANNEL) <= MAXIMUM_SYNIC_MESSAGE_BYTES);
// Rescind Offer parameters
/* Rescind Offer parameters */
typedef struct _VMBUS_CHANNEL_RESCIND_OFFER
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
u32 ChildRelId;
} VMBUS_CHANNEL_RESCIND_OFFER, *PVMBUS_CHANNEL_RESCIND_OFFER;
// Request Offer -- no parameters, SynIC message contains the partition ID
// Set Snoop -- no parameters, SynIC message contains the partition ID
// Clear Snoop -- no parameters, SynIC message contains the partition ID
// All Offers Delivered -- no parameters, SynIC message contains the partition ID
// Flush Client -- no parameters, SynIC message contains the partition ID
/* Request Offer -- no parameters, SynIC message contains the partition ID */
/* Set Snoop -- no parameters, SynIC message contains the partition ID */
/* Clear Snoop -- no parameters, SynIC message contains the partition ID */
/* All Offers Delivered -- no parameters, SynIC message contains the partition ID */
/* Flush Client -- no parameters, SynIC message contains the partition ID */
// Open Channel parameters
/* Open Channel parameters */
typedef struct _VMBUS_CHANNEL_OPEN_CHANNEL
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
//
// Identifies the specific VMBus channel that is being opened.
//
/* Identifies the specific VMBus channel that is being opened. */
u32 ChildRelId;
//
// ID making a particular open request at a channel offer unique.
//
/* ID making a particular open request at a channel offer unique. */
u32 OpenId;
//
// GPADL for the channel's ring buffer.
//
/* GPADL for the channel's ring buffer. */
GPADL_HANDLE RingBufferGpadlHandle;
//
// GPADL for the channel's server context save area.
//
/* GPADL for the channel's server context save area. */
GPADL_HANDLE ServerContextAreaGpadlHandle;
//
// The upstream ring buffer begins at offset zero in the memory described
// by RingBufferGpadlHandle. The downstream ring buffer follows it at this
// offset (in pages).
//
/*
* The upstream ring buffer begins at offset zero in the memory
* described by RingBufferGpadlHandle. The downstream ring buffer
* follows it at this offset (in pages).
*/
u32 DownstreamRingBufferPageOffset;
//
// User-specific data to be passed along to the server endpoint.
//
/* User-specific data to be passed along to the server endpoint. */
unsigned char UserData[MAX_USER_DEFINED_BYTES];
} VMBUS_CHANNEL_OPEN_CHANNEL, *PVMBUS_CHANNEL_OPEN_CHANNEL;
// Reopen Channel parameters;
/* Reopen Channel parameters; */
typedef VMBUS_CHANNEL_OPEN_CHANNEL VMBUS_CHANNEL_REOPEN_CHANNEL, *PVMBUS_CHANNEL_REOPEN_CHANNEL;
// Open Channel Result parameters
/* Open Channel Result parameters */
typedef struct _VMBUS_CHANNEL_OPEN_RESULT
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
......@@ -164,24 +166,26 @@ typedef struct _VMBUS_CHANNEL_OPEN_RESULT
NTSTATUS Status;
} VMBUS_CHANNEL_OPEN_RESULT, *PVMBUS_CHANNEL_OPEN_RESULT;
// Close channel parameters;
/* Close channel parameters; */
typedef struct _VMBUS_CHANNEL_CLOSE_CHANNEL
{
VMBUS_CHANNEL_MESSAGE_HEADER Header;
u32 ChildRelId;
} VMBUS_CHANNEL_CLOSE_CHANNEL, *PVMBUS_CHANNEL_CLOSE_CHANNEL;
// Channel Message GPADL
/* Channel Message GPADL */
#define GPADL_TYPE_RING_BUFFER 1
#define GPADL_TYPE_SERVER_SAVE_AREA 2
#define GPADL_TYPE_TRANSACTION 8
//
// The number of PFNs in a GPADL message is defined by the number of pages
// that would be spanned by ByteCount and ByteOffset. If the implied number
// of PFNs won't fit in this packet, there will be a follow-up packet that
// contains more.
//
/*
* The number of PFNs in a GPADL message is defined by the number of
* pages that would be spanned by ByteCount and ByteOffset. If the
* implied number of PFNs won't fit in this packet, there will be a
* follow-up packet that contains more.
*/
typedef struct _VMBUS_CHANNEL_GPADL_HEADER
{
......@@ -194,9 +198,9 @@ typedef struct _VMBUS_CHANNEL_GPADL_HEADER
} VMBUS_CHANNEL_GPADL_HEADER, *PVMBUS_CHANNEL_GPADL_HEADER;
//
// This is the followup packet that contains more PFNs.
//
/* This is the followup packet that contains more PFNs. */
typedef struct _VMBUS_CHANNEL_GPADL_BODY
{
......@@ -269,10 +273,10 @@ typedef struct _VMBUS_CHANNEL_VERSION_RESPONSE
typedef VMBUS_CHANNEL_MESSAGE_HEADER VMBUS_CHANNEL_UNLOAD, *PVMBUS_CHANNEL_UNLOAD;
//
// Kind of a table to use the preprocessor to get us the right type for a
// specified message ID. Used with ChAllocateSendMessage()
//
/* Kind of a table to use the preprocessor to get us the right type for a */
/* specified message ID. Used with ChAllocateSendMessage() */
#define ChannelMessageQueryVmbusVersion_TYPE VMBUS_CHANNEL_MESSAGE_HEADER
#define ChannelMessageVmbusVersionSupported_TYPE VMBUS_CHANNEL_VERSION_SUPPORTED
#define ChannelMessageOfferChannel_TYPE VMBUS_CHANNEL_OFFER_CHANNEL
......@@ -295,18 +299,17 @@ typedef VMBUS_CHANNEL_MESSAGE_HEADER VMBUS_CHANNEL_UNLOAD, *PVMBUS_CHANNEL_UNLOA
#define ChannelMessageVersionResponse_TYPE VMBUS_CHANNEL_VERSION_RESPONSE
#define ChannelMessageUnload_TYPE VMBUS_CHANNEL_UNLOAD
//
// Preprocessor wrapper to ChAllocateSendMessageSize() converting the return
// value to the correct pointer and calculate the needed size.
//
// Argument:
//
// Id - the numberic ID (type VMBUS_CHANNEL_MESSAGE_TYPE) of the message to
// send.
//
/* Preprocessor wrapper to ChAllocateSendMessageSize() converting the return */
/* value to the correct pointer and calculate the needed size. */
/* Argument: */
/* Id - the numberic ID (type VMBUS_CHANNEL_MESSAGE_TYPE) of the message to */
/* send. */
#define ChAllocateSendMessage(Id, Fn, Context) \
(Id##_TYPE*)ChAllocateSendMessageSized(sizeof(Id##_TYPE), Id, Fn, Context)
#pragma pack(pop)
......@@ -25,8 +25,8 @@
#pragma once
//
// Time in the hypervisor is measured in 100 nanosecond units
//
/* Time in the hypervisor is measured in 100 nanosecond units */
typedef u64 HV_NANO100_TIME, *PHV_NANO100_TIME;
typedef u64 HV_NANO100_DURATION, *PHV_NANO100_DURATION;
......@@ -24,9 +24,9 @@
#pragma once
//
// Declare the various hypercall operations.
//
/* Declare the various hypercall operations. */
typedef enum _HV_CALL_CODE
{
......@@ -34,9 +34,9 @@ typedef enum _HV_CALL_CODE
HvCallSignalEvent = 0x005d,
} HV_CALL_CODE, *PHV_CALL_CODE;
//
// Definition of the HvPostMessage hypercall input structure.
//
/* Definition of the HvPostMessage hypercall input structure. */
typedef struct _HV_INPUT_POST_MESSAGE
{
......@@ -48,9 +48,9 @@ typedef struct _HV_INPUT_POST_MESSAGE
} HV_INPUT_POST_MESSAGE, *PHV_INPUT_POST_MESSAGE;
//
// Definition of the HvSignalEvent hypercall input structure.
//
/* Definition of the HvSignalEvent hypercall input structure. */
typedef struct _HV_INPUT_SIGNAL_EVENT
{
......
......@@ -24,15 +24,15 @@
#pragma once
//
// Versioning definitions used for guests reporting themselves to the
// hypervisor, and visa versa.
// ==================================================================
//
//
// Version info reported by guest OS's
//
/* Versioning definitions used for guests reporting themselves to the */
/* hypervisor, and visa versa. */
/* ================================================================== */
/* Version info reported by guest OS's */
typedef enum _HV_GUEST_OS_VENDOR
{
HvGuestOsVendorMicrosoft = 0x0001
......@@ -50,9 +50,9 @@ typedef enum _HV_GUEST_OS_MICROSOFT_IDS
} HV_GUEST_OS_MICROSOFT_IDS, *PHV_GUEST_OS_MICROSOFT_IDS;
//
// Declare the MSR used to identify the guest OS.
//
/* Declare the MSR used to identify the guest OS. */
#define HV_X64_MSR_GUEST_OS_ID 0x40000000
typedef union _HV_X64_MSR_GUEST_OS_ID_CONTENTS
......@@ -61,17 +61,17 @@ typedef union _HV_X64_MSR_GUEST_OS_ID_CONTENTS
struct
{
u64 BuildNumber : 16;
u64 ServiceVersion : 8; // Service Pack, etc.
u64 ServiceVersion : 8; /* Service Pack, etc. */
u64 MinorVersion : 8;
u64 MajorVersion : 8;
u64 OsId : 8; // HV_GUEST_OS_MICROSOFT_IDS (If Vendor=MS)
u64 VendorId : 16; // HV_GUEST_OS_VENDOR
u64 OsId : 8; /* HV_GUEST_OS_MICROSOFT_IDS (If Vendor=MS) */
u64 VendorId : 16; /* HV_GUEST_OS_VENDOR */
};
} HV_X64_MSR_GUEST_OS_ID_CONTENTS, *PHV_X64_MSR_GUEST_OS_ID_CONTENTS;
//
// Declare the MSR used to setup pages used to communicate with the hypervisor.
//
/* Declare the MSR used to setup pages used to communicate with the hypervisor. */
#define HV_X64_MSR_HYPERCALL 0x40000001
typedef union _HV_X64_MSR_HYPERCALL_CONTENTS
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,16 +23,16 @@
#pragma once
//
// Virtual Processor Indices
//
/* Virtual Processor Indices */
typedef u32 HV_VP_INDEX, *PHV_VP_INDEX;
//
// The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
// is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
// ==========================================================================
//
/* The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent */
/* is set by CPUID(HvCpuIdFunctionVersionAndFeatures). */
/* ========================================================================== */
typedef enum _HV_CPUID_FUNCTION
{
......@@ -40,9 +40,9 @@ typedef enum _HV_CPUID_FUNCTION
HvCpuIdFunctionHvVendorAndMaxFunction = 0x40000000,
HvCpuIdFunctionHvInterface = 0x40000001,
//
// The remaining functions depend on the value of HvCpuIdFunctionInterface
//
/* The remaining functions depend on the value of HvCpuIdFunctionInterface */
HvCpuIdFunctionMsHvVersion = 0x40000002,
HvCpuIdFunctionMsHvFeatures = 0x40000003,
HvCpuIdFunctionMsHvEnlightenmentInformation = 0x40000004,
......
......@@ -36,10 +36,10 @@
typedef DLIST_ENTRY LIST_ENTRY;
typedef DLIST_ENTRY *PLIST_ENTRY;
//typedef struct LIST_ENTRY {
// struct LIST_ENTRY * volatile Flink;
// struct LIST_ENTRY * volatile Blink;
//} LIST_ENTRY, *PLIST_ENTRY;
/* typedef struct LIST_ENTRY { */
/* struct LIST_ENTRY * volatile Flink; */
/* struct LIST_ENTRY * volatile Blink; */
/* } LIST_ENTRY, *PLIST_ENTRY; */
......
......@@ -27,22 +27,22 @@
#include "VmbusApi.h"
//
// Defines
//
/* Defines */
#define NETVSC_DEVICE_RING_BUFFER_SIZE 64*PAGE_SIZE
#define HW_MACADDR_LEN 6
//
// Fwd declaration
//
/* Fwd declaration */
typedef struct _NETVSC_PACKET *PNETVSC_PACKET;
//
// Data types
//
/* Data types */
typedef int (*PFN_ON_OPEN)(DEVICE_OBJECT *Device);
typedef int (*PFN_ON_CLOSE)(DEVICE_OBJECT *Device);
......@@ -54,27 +54,33 @@ typedef void (*PFN_ON_SENDRECVCOMPLETION)(void * Context);
typedef int (*PFN_ON_RECVCALLBACK)(DEVICE_OBJECT *dev, PNETVSC_PACKET packet);
typedef void (*PFN_ON_LINKSTATUS_CHANGED)(DEVICE_OBJECT *dev, u32 Status);
// Represent the xfer page packet which contains 1 or more netvsc packet
/* Represent the xfer page packet which contains 1 or more netvsc packet */
typedef struct _XFERPAGE_PACKET {
DLIST_ENTRY ListEntry;
// # of netvsc packets this xfer packet contains
/* # of netvsc packets this xfer packet contains */
u32 Count;
} XFERPAGE_PACKET;
// The number of pages which are enough to cover jumbo frame buffer.
/* The number of pages which are enough to cover jumbo frame buffer. */
#define NETVSC_PACKET_MAXPAGE 4
// Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame within the RNDIS
/*
* Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
* within the RNDIS
*/
typedef struct _NETVSC_PACKET {
// Bookkeeping stuff
/* Bookkeeping stuff */
DLIST_ENTRY ListEntry;
DEVICE_OBJECT *Device;
bool IsDataPacket;
// Valid only for receives when we break a xfer page packet into multiple netvsc packets
/*
* Valid only for receives when we break a xfer page packet
* into multiple netvsc packets
*/
XFERPAGE_PACKET *XferPagePacket;
union {
......@@ -90,40 +96,42 @@ typedef struct _NETVSC_PACKET {
} Send;
} Completion;
// This points to the memory after PageBuffers
/* This points to the memory after PageBuffers */
void * Extension;
u32 TotalDataBufferLength;
// Points to the send/receive buffer where the ethernet frame is
/* Points to the send/receive buffer where the ethernet frame is */
u32 PageBufferCount;
PAGE_BUFFER PageBuffers[NETVSC_PACKET_MAXPAGE];
} NETVSC_PACKET;
// Represents the net vsc driver
/* Represents the net vsc driver */
typedef struct _NETVSC_DRIVER_OBJECT {
DRIVER_OBJECT Base; // Must be the first field
DRIVER_OBJECT Base; /* Must be the first field */
u32 RingBufferSize;
u32 RequestExtSize;
// Additional num of page buffers to allocate
/* Additional num of page buffers to allocate */
u32 AdditionalRequestPageBufferCount;
// This is set by the caller to allow us to callback when we receive a packet
// from the "wire"
/*
* This is set by the caller to allow us to callback when we
* receive a packet from the "wire"
*/
PFN_ON_RECVCALLBACK OnReceiveCallback;
PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged;
// Specific to this driver
/* Specific to this driver */
PFN_ON_OPEN OnOpen;
PFN_ON_CLOSE OnClose;
PFN_ON_SEND OnSend;
//PFN_ON_RECVCOMPLETION OnReceiveCompletion;
/* PFN_ON_RECVCOMPLETION OnReceiveCompletion; */
//PFN_QUERY_LINKSTATUS QueryLinkStatus;
/* PFN_QUERY_LINKSTATUS QueryLinkStatus; */
void* Context;
} NETVSC_DRIVER_OBJECT;
......@@ -131,15 +139,15 @@ typedef struct _NETVSC_DRIVER_OBJECT {
typedef struct _NETVSC_DEVICE_INFO {
unsigned char MacAddr[6];
bool LinkState; // 0 - link up, 1 - link down
bool LinkState; /* 0 - link up, 1 - link down */
} NETVSC_DEVICE_INFO;
//
// Interface
//
/* Interface */
int
NetVscInitialize(
DRIVER_OBJECT* drv
);
#endif // _NETVSC_API_H_
#endif /* _NETVSC_API_H_ */
This diff is collapsed.
This diff is collapsed.
......@@ -25,8 +25,8 @@
#ifndef _LOGGING_H_
#define _LOGGING_H_
//#include <linux/init.h>
//#include <linux/module.h>
/* #include <linux/init.h> */
/* #include <linux/module.h> */
#include "osd.h"
......@@ -52,7 +52,7 @@
INPUTVSC_DRV|\
BLKVSC_DRV)
// Logging Level
/* Logging Level */
#define ERROR_LVL 3
#define WARNING_LVL 4
#define INFO_LVL 6
......@@ -117,4 +117,4 @@ extern unsigned int vmbus_loglevel;
#define DPRINT_EXIT(mod)
#endif
#endif //_LOGGING_H_
#endif /* _LOGGING_H_ */
This diff is collapsed.
......@@ -25,9 +25,9 @@
#ifndef _OSD_H_
#define _OSD_H_
//
// Defines
//
/* Defines */
#define ALIGN_UP(value, align) ( ((value) & (align-1))? ( ((value) + (align-1)) & ~(align-1) ): (value) )
......@@ -42,10 +42,10 @@ typedef struct _DLIST_ENTRY {
struct _DLIST_ENTRY *Blink;
} DLIST_ENTRY;
//
// Other types
//
//typedef unsigned char GUID[16];
/* Other types */
/* typedef unsigned char GUID[16]; */
typedef void* HANDLE;
typedef struct {
......@@ -95,9 +95,9 @@ static inline void do_cpuid(unsigned int op, unsigned int *eax, unsigned int *eb
__asm__ __volatile__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (op), "c" (ecx));
}
//
// Osd routines
//
/* Osd routines */
extern void BitSet(unsigned int* addr, int value);
extern void BitClear(unsigned int* addr, int value);
extern int BitTest(unsigned int* addr, int value);
......@@ -127,7 +127,7 @@ extern void WaitEventClose(HANDLE hWait);
extern void WaitEventSet(HANDLE hWait);
extern int WaitEventWait(HANDLE hWait);
// If >0, hWait got signaled. If ==0, timeout. If < 0, error
/* If >0, hWait got signaled. If ==0, timeout. If < 0, error */
extern int WaitEventWaitEx(HANDLE hWait, u32 TimeoutInMs);
......@@ -149,4 +149,4 @@ extern int WorkQueueQueueWorkItem(HANDLE hWorkQueue, PFN_WORKITEM_CALLBACK workI
extern void QueueWorkItem(PFN_WORKITEM_CALLBACK workItem, void* context);
#endif // _OSD_H_
#endif /* _OSD_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment