提交 454f18a9 编写于 作者: B Bill Pemberton 提交者: Greg Kroah-Hartman

Staging: hv: Remove C99 comments

Remove C99 // comments with traditional /* */ comments
Signed-off-by: NBill Pemberton <wfp5p@virginia.edu>
Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 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];
......
......@@ -27,13 +27,11 @@
#include "VmbusPrivate.h"
//
// Internal routines
//
/* Internal routines */
static int
VmbusChannelCreateGpadlHeader(
void * Kbuffer, // must be phys and virt contiguous
u32 Size, // page-size multiple
void * Kbuffer, /* must be phys and virt contiguous */
u32 Size, /* page-size multiple */
VMBUS_CHANNEL_MSGINFO **msgInfo,
u32 *MessageCount
);
......@@ -105,11 +103,11 @@ VmbusChannelSetEvent(
if (Channel->OfferMsg.MonitorAllocated)
{
// Each u32 represents 32 channels
/* Each u32 represents 32 channels */
BitSet((u32*)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >> 5), Channel->OfferMsg.ChildRelId & 31);
monitorPage = (HV_MONITOR_PAGE*)gVmbusConnection.MonitorPages;
monitorPage++; // Get the child to parent monitor page
monitorPage++; /* Get the child to parent monitor page */
BitSet((u32*) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit);
}
......@@ -133,11 +131,11 @@ VmbusChannelClearEvent(
if (Channel->OfferMsg.MonitorAllocated)
{
// Each u32 represents 32 channels
/* Each u32 represents 32 channels */
BitClear((u32*)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >> 5), Channel->OfferMsg.ChildRelId & 31);
monitorPage = (HV_MONITOR_PAGE*)gVmbusConnection.MonitorPages;
monitorPage++; // Get the child to parent monitor page
monitorPage++; /* Get the child to parent monitor page */
BitClear((u32*) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit);
}
......@@ -164,7 +162,7 @@ VmbusChannelGetDebugInfo(
HV_MONITOR_PAGE *monitorPage;
u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
//u32 monitorBit = 1 << monitorOffset;
/* u32 monitorBit = 1 << monitorOffset; */
DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
DebugInfo->State = Channel->State;
......@@ -218,16 +216,16 @@ VmbusChannelOpen(
DPRINT_ENTER(VMBUS);
// Aligned to page size
/* Aligned to page size */
ASSERT(!(SendRingBufferSize & (PAGE_SIZE -1)));
ASSERT(!(RecvRingBufferSize & (PAGE_SIZE -1)));
NewChannel->OnChannelCallback = pfnOnChannelCallback;
NewChannel->ChannelCallbackContext = Context;
// Allocate the ring buffer
/* Allocate the ring buffer */
out = PageAlloc((SendRingBufferSize + RecvRingBufferSize) >> PAGE_SHIFT);
//out = kzalloc(sendRingBufferSize + recvRingBufferSize, GFP_KERNEL);
/* out = kzalloc(sendRingBufferSize + recvRingBufferSize, GFP_KERNEL); */
ASSERT(out);
ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0);
......@@ -240,7 +238,7 @@ VmbusChannelOpen(
RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
// Establish the gpadl for the ring buffer
/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...", NewChannel);
NewChannel->RingBufferGpadlHandle = 0;
......@@ -260,7 +258,7 @@ VmbusChannelOpen(
NewChannel->Inbound.RingSize,
SendRingBufferSize);
// Create and init the channel open message
/* Create and init the channel open message */
openInfo = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_OPEN_CHANNEL), GFP_KERNEL);
ASSERT(openInfo != NULL);
......@@ -268,12 +266,12 @@ VmbusChannelOpen(
openMsg = (VMBUS_CHANNEL_OPEN_CHANNEL*)openInfo->Msg;
openMsg->Header.MessageType = ChannelMessageOpenChannel;
openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; // FIXME
openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
ASSERT(openMsg->RingBufferGpadlHandle);
openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >> PAGE_SHIFT;
openMsg->ServerContextAreaGpadlHandle = 0; // TODO
openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
ASSERT(UserDataLen <= MAX_USER_DEFINED_BYTES);
if (UserDataLen)
......@@ -294,7 +292,7 @@ VmbusChannelOpen(
goto Cleanup;
}
// FIXME: Need to time-out here
/* FIXME: Need to time-out here */
WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
......@@ -392,8 +390,8 @@ static void DumpGpadlHeader(
--*/
static int
VmbusChannelCreateGpadlHeader(
void * Kbuffer, // from kmalloc()
u32 Size, // page-size multiple
void * Kbuffer, /* from kmalloc() */
u32 Size, /* page-size multiple */
VMBUS_CHANNEL_MSGINFO **MsgInfo,
u32 *MessageCount)
{
......@@ -408,19 +406,19 @@ VmbusChannelCreateGpadlHeader(
int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
//ASSERT( (kbuffer & (PAGE_SIZE-1)) == 0);
/* ASSERT( (kbuffer & (PAGE_SIZE-1)) == 0); */
ASSERT( (Size & (PAGE_SIZE-1)) == 0);
pageCount = Size >> PAGE_SHIFT;
pfn = GetPhysicalAddress(Kbuffer) >> PAGE_SHIFT;
// do we need a gpadl body msg
/* do we need a gpadl body msg */
pfnSize = MAX_SIZE_CHANNEL_MESSAGE - sizeof(VMBUS_CHANNEL_GPADL_HEADER) - sizeof(GPA_RANGE);
pfnCount = pfnSize / sizeof(u64);
if (pageCount > pfnCount) // we need a gpadl body
if (pageCount > pfnCount) /* we need a gpadl body */
{
// fill in the header
/* fill in the header */
msgSize = sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_GPADL_HEADER) + sizeof(GPA_RANGE) + pfnCount*sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL);
......@@ -442,11 +440,11 @@ VmbusChannelCreateGpadlHeader(
pfnSum = pfnCount;
pfnLeft = pageCount - pfnCount;
// how many pfns can we fit
/* how many pfns can we fit */
pfnSize = MAX_SIZE_CHANNEL_MESSAGE - sizeof(VMBUS_CHANNEL_GPADL_BODY);
pfnCount = pfnSize / sizeof(u64);
// fill in the body
/* fill in the body */
while (pfnLeft)
{
if (pfnLeft > pfnCount)
......@@ -465,14 +463,14 @@ VmbusChannelCreateGpadlHeader(
(*MessageCount)++;
gpadlBody = (VMBUS_CHANNEL_GPADL_BODY*)msgBody->Msg;
// FIXME: Gpadl is u32 and we are using a pointer which could be 64-bit
//gpadlBody->Gpadl = kbuffer;
/* FIXME: Gpadl is u32 and we are using a pointer which could be 64-bit */
/* gpadlBody->Gpadl = kbuffer; */
for (i=0; i<pfnCurr; i++)
{
gpadlBody->Pfn[i] = pfn + pfnSum + i;
}
// add to msg header
/* add to msg header */
INSERT_TAIL_LIST(&msgHeader->SubMsgList, &msgBody->MsgListEntry);
pfnSum += pfnCurr;
pfnLeft -= pfnCurr;
......@@ -480,7 +478,7 @@ VmbusChannelCreateGpadlHeader(
}
else
{
// everything fits in a header
/* everything fits in a header */
msgSize = sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_GPADL_HEADER) + sizeof(GPA_RANGE) + pageCount*sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL);
msgHeader->MessageSize=msgSize;
......@@ -515,15 +513,15 @@ VmbusChannelCreateGpadlHeader(
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
)
{
int ret=0;
VMBUS_CHANNEL_GPADL_HEADER* gpadlMsg;
VMBUS_CHANNEL_GPADL_BODY* gpadlBody;
//VMBUS_CHANNEL_GPADL_CREATED* gpadlCreated;
/* VMBUS_CHANNEL_GPADL_CREATED* gpadlCreated; */
VMBUS_CHANNEL_MSGINFO *msgInfo;
VMBUS_CHANNEL_MSGINFO *subMsgInfo;
......@@ -585,7 +583,7 @@ VmbusChannelEstablishGpadl(
}
WaitEventWait(msgInfo->WaitEvent);
// At this point, we received the gpadl created msg
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created (relid %d, status %d handle %x)",
Channel->OfferMsg.ChildRelId,
msgInfo->Response.GpadlCreated.CreationStatus,
......@@ -650,12 +648,12 @@ VmbusChannelTeardownGpadl(
ret = VmbusPostMessage(msg, sizeof(VMBUS_CHANNEL_GPADL_TEARDOWN));
if (ret != 0)
{
// TODO:
/* TODO: */
}
WaitEventWait(info->WaitEvent);
// Received a torndown response
/* Received a torndown response */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&info->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
......@@ -690,15 +688,15 @@ VmbusChannelClose(
DPRINT_ENTER(VMBUS);
// Stop callback and cancel the timer asap
/* Stop callback and cancel the timer asap */
Channel->OnChannelCallback = NULL;
TimerStop(Channel->PollTimer);
// Send a closing message
/* Send a closing message */
info = kmalloc(sizeof(VMBUS_CHANNEL_MSGINFO) + sizeof(VMBUS_CHANNEL_CLOSE_CHANNEL), GFP_KERNEL);
ASSERT(info != NULL);
//info->waitEvent = WaitEventCreate();
/* info->waitEvent = WaitEventCreate(); */
msg = (VMBUS_CHANNEL_CLOSE_CHANNEL*)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
......@@ -707,18 +705,18 @@ VmbusChannelClose(
ret = VmbusPostMessage(msg, sizeof(VMBUS_CHANNEL_CLOSE_CHANNEL));
if (ret != 0)
{
// TODO:
/* TODO: */
}
// Tear down the gpadl for the channel's ring buffer
/* Tear down the gpadl for the channel's ring buffer */
if (Channel->RingBufferGpadlHandle)
{
VmbusChannelTeardownGpadl(Channel, Channel->RingBufferGpadlHandle);
}
// TODO: Send a msg to release the childRelId
/* TODO: Send a msg to release the childRelId */
// Cleanup the ring buffers for this channel
/* Cleanup the ring buffers for this channel */
RingBufferCleanup(&Channel->Outbound);
RingBufferCleanup(&Channel->Inbound);
......@@ -726,8 +724,13 @@ VmbusChannelClose(
kfree(info);
// If we are closing the channel during an error path in opening the channel, don't free the channel
// since the caller will free the channel
/*
* If we are closing the channel during an error path in
* opening the channel, don't free the channel since the
* caller will free the channel
*/
if (Channel->State == CHANNEL_OPEN_STATE)
{
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
......@@ -774,12 +777,12 @@ VmbusChannelSendPacket(
ASSERT((packetLenAligned - packetLen) < sizeof(u64));
// Setup the descriptor
desc.Type = Type;//VmbusPacketTypeDataInBand;
desc.Flags = Flags;//VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
desc.DataOffset8 = sizeof(VMPACKET_DESCRIPTOR) >> 3; // in 8-bytes granularity
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
/* Setup the descriptor */
desc.Type = Type; /* VmbusPacketTypeDataInBand; */
desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
desc.DataOffset8 = sizeof(VMPACKET_DESCRIPTOR) >> 3; /* in 8-bytes granularity */
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
bufferList[0].Data = &desc;
bufferList[0].Length = sizeof(VMPACKET_DESCRIPTOR);
......@@ -795,7 +798,7 @@ VmbusChannelSendPacket(
bufferList,
3);
// TODO: We should determine if this is optional
/* TODO: We should determine if this is optional */
if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
{
VmbusChannelSetEvent(Channel);
......@@ -841,19 +844,19 @@ VmbusChannelSendPacketPageBuffer(
DumpVmbusChannel(Channel);
// Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the largest size we support
/* Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the largest size we support */
descSize = sizeof(VMBUS_CHANNEL_PACKET_PAGE_BUFFER) - ((MAX_PAGE_BUFFER_COUNT - PageCount)*sizeof(PAGE_BUFFER));
packetLen = descSize + BufferLen;
packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
ASSERT((packetLenAligned - packetLen) < sizeof(u64));
// Setup the descriptor
/* Setup the descriptor */
desc.Type = VmbusPacketTypeDataUsingGpaDirect;
desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
desc.DataOffset8 = descSize >> 3; // in 8-bytes grandularity
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
desc.RangeCount = PageCount;
for (i=0; i<PageCount; i++)
......@@ -877,7 +880,7 @@ VmbusChannelSendPacketPageBuffer(
bufferList,
3);
// TODO: We should determine if this is optional
/* TODO: We should determine if this is optional */
if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
{
VmbusChannelSetEvent(Channel);
......@@ -926,19 +929,19 @@ VmbusChannelSendPacketMultiPageBuffer(
ASSERT(PfnCount > 0);
ASSERT(PfnCount <= MAX_MULTIPAGE_BUFFER_COUNT);
// Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is the largest size we support
/* Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is the largest size we support */
descSize = sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER) - ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount)*sizeof(u64));
packetLen = descSize + BufferLen;
packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
ASSERT((packetLenAligned - packetLen) < sizeof(u64));
// Setup the descriptor
/* Setup the descriptor */
desc.Type = VmbusPacketTypeDataUsingGpaDirect;
desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
desc.DataOffset8 = descSize >> 3; // in 8-bytes grandularity
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
desc.RangeCount = 1;
desc.Range.Length = MultiPageBuffer->Length;
......@@ -960,7 +963,7 @@ VmbusChannelSendPacketMultiPageBuffer(
bufferList,
3);
// TODO: We should determine if this is optional
/* TODO: We should determine if this is optional */
if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
{
VmbusChannelSetEvent(Channel);
......@@ -981,7 +984,7 @@ VmbusChannelSendPacketMultiPageBuffer(
Retrieve the user packet on the specified channel
--*/
// TODO: Do we ever receive a gpa direct packet other than the ones we send ?
/* TODO: Do we ever receive a gpa direct packet other than the ones we send ? */
int
VmbusChannelRecvPacket(
VMBUS_CHANNEL *Channel,
......@@ -1009,16 +1012,16 @@ VmbusChannelRecvPacket(
{
spin_unlock_irqrestore(&Channel->inbound_lock, flags);
//DPRINT_DBG(VMBUS, "nothing to read!!");
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
DPRINT_EXIT(VMBUS);
return 0;
}
//VmbusChannelClearEvent(Channel);
/* VmbusChannelClearEvent(Channel); */
packetLen = desc.Length8 << 3;
userLen = packetLen - (desc.DataOffset8 << 3);
//ASSERT(userLen > 0);
/* ASSERT(userLen > 0); */
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d flag %d tid %llx pktlen %d datalen %d> ",
Channel,
......@@ -1041,7 +1044,7 @@ VmbusChannelRecvPacket(
*RequestId = desc.TransactionId;
// Copy over the packet to the user buffer
/* Copy over the packet to the user buffer */
ret = RingBufferRead(&Channel->Inbound, Buffer, userLen, (desc.DataOffset8 << 3));
spin_unlock_irqrestore(&Channel->inbound_lock, flags);
......@@ -1087,12 +1090,12 @@ VmbusChannelRecvPacketRaw(
{
spin_unlock_irqrestore(&Channel->inbound_lock, flags);
//DPRINT_DBG(VMBUS, "nothing to read!!");
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
DPRINT_EXIT(VMBUS);
return 0;
}
//VmbusChannelClearEvent(Channel);
/* VmbusChannelClearEvent(Channel); */
packetLen = desc.Length8 << 3;
userLen = packetLen - (desc.DataOffset8 << 3);
......@@ -1117,7 +1120,7 @@ VmbusChannelRecvPacketRaw(
*RequestId = desc.TransactionId;
// Copy over the entire packet to the user buffer
/* Copy over the entire packet to the user buffer */
ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
spin_unlock_irqrestore(&Channel->inbound_lock, flags);
......@@ -1199,4 +1202,4 @@ DumpVmbusChannel(
}
// eof
/* eof */
......@@ -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,18 +302,20 @@ 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
{
DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relId);
DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relId);
}
}
......@@ -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;
......@@ -103,18 +102,18 @@ HvQueryHypervisorInfo (
do_cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
(ebx & 0xFF),
((ebx >> 8) & 0xFF),
((ebx >> 16) & 0xFF),
((ebx >> 24) & 0xFF),
(ecx & 0xFF),
((ecx >> 8) & 0xFF),
((ecx >> 16) & 0xFF),
((ecx >> 24) & 0xFF),
(edx & 0xFF),
((edx >> 8) & 0xFF),
((edx >> 16) & 0xFF),
((edx >> 24) & 0xFF));
(ebx & 0xFF),
((ebx >> 8) & 0xFF),
((ebx >> 16) & 0xFF),
((ebx >> 24) & 0xFF),
(ecx & 0xFF),
((ecx >> 8) & 0xFF),
((ecx >> 16) & 0xFF),
((ecx >> 24) & 0xFF),
(edx & 0xFF),
((edx >> 8) & 0xFF),
((edx >> 16) & 0xFF),
((edx >> 24) & 0xFF));
maxLeaf = eax;
eax = 0;
......@@ -125,25 +124,25 @@ HvQueryHypervisorInfo (
do_cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "Interface ID: %c%c%c%c",
(eax & 0xFF),
((eax >> 8) & 0xFF),
((eax >> 16) & 0xFF),
((eax >> 24) & 0xFF));
(eax & 0xFF),
((eax >> 8) & 0xFF),
((eax >> 16) & 0xFF),
((eax >> 24) & 0xFF));
if (maxLeaf >= HvCpuIdFunctionMsHvVersion) {
eax = 0;
ebx = 0;
ecx = 0;
edx = 0;
op = HvCpuIdFunctionMsHvVersion;
do_cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",
eax,
ebx >> 16,
ebx & 0xFFFF,
ecx,
edx >> 24,
edx & 0xFFFFFF);
eax = 0;
ebx = 0;
ecx = 0;
edx = 0;
op = HvCpuIdFunctionMsHvVersion;
do_cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",
eax,
ebx >> 16,
ebx & 0xFFFF,
ecx,
edx >> 24,
edx & 0xFFFFFF);
}
return maxLeaf;
}
......@@ -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,31 +553,27 @@ 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.Masked = false;
sharedSint.AutoEoi = true;
sharedSint.Vector = irqVector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
sharedSint.Masked = false;
sharedSint.AutoEoi = true;
DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx", sharedSint.AsUINT64);
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;
WriteMsr(HV_X64_MSR_SCONTROL, sctrl.AsUINT64);
WriteMsr(HV_X64_MSR_SCONTROL, sctrl.AsUINT64);
gHvContext.SynICInitialized = true;
......@@ -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__ */
此差异已折叠。
......@@ -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_ */
......@@ -28,12 +28,12 @@
#include "include/NetVscApi.h"
#include "RndisFilter.h"
//
// Data types
//
/* Data types */
typedef struct _RNDIS_FILTER_DRIVER_OBJECT {
// The original driver
/* The original driver */
NETVSC_DRIVER_OBJECT InnerDriver;
} RNDIS_FILTER_DRIVER_OBJECT;
......@@ -63,14 +63,14 @@ typedef struct _RNDIS_REQUEST {
LIST_ENTRY ListEntry;
HANDLE WaitEvent;
// FIXME: We assumed a fixed size response here. If we do ever need to handle a bigger response,
// we can either define a max response message or add a response buffer variable above this field
/* FIXME: We assumed a fixed size response here. If we do ever need to handle a bigger response, */
/* we can either define a max response message or add a response buffer variable above this field */
RNDIS_MESSAGE ResponseMessage;
// Simplify allocation by having a netvsc packet inline
/* Simplify allocation by having a netvsc packet inline */
NETVSC_PACKET Packet;
PAGE_BUFFER Buffer;
// FIXME: We assumed a fixed size request here.
/* FIXME: We assumed a fixed size request here. */
RNDIS_MESSAGE RequestMessage;
} RNDIS_REQUEST;
......@@ -82,9 +82,9 @@ typedef struct _RNDIS_FILTER_PACKET {
RNDIS_MESSAGE Message;
} RNDIS_FILTER_PACKET;
//
// Internal routines
//
/* Internal routines */
static int
RndisFilterSendRequest(
RNDIS_DEVICE *Device,
......@@ -197,11 +197,11 @@ RndisFilterOnSendRequestCompletion(
void *Context
);
//
// Global var
//
// The one and only
/* Global var */
/* The one and only */
RNDIS_FILTER_DRIVER_OBJECT gRndisFilter;
static inline RNDIS_DEVICE* GetRndisDevice(void)
......@@ -252,12 +252,12 @@ static inline RNDIS_REQUEST* GetRndisRequest(RNDIS_DEVICE *Device, u32 MessageTy
rndisMessage->NdisMessageType = MessageType;
rndisMessage->MessageLength = MessageLength;
// Set the request id. This field is always after the rndis header for request/response packet types so
// we just used the SetRequest as a template
/* Set the request id. This field is always after the rndis header for request/response packet types so */
/* we just used the SetRequest as a template */
set = &rndisMessage->Message.SetRequest;
set->RequestId = InterlockedIncrement((int*)&Device->NewRequestId);
// Add to the request list
/* Add to the request list */
spin_lock_irqsave(&Device->request_lock, flags);
INSERT_TAIL_LIST(&Device->RequestList, &request->ListEntry);
spin_unlock_irqrestore(&Device->request_lock, flags);
......@@ -349,7 +349,7 @@ RndisFilterSendRequest(
DPRINT_ENTER(NETVSC);
// Setup the packet to send it
/* Setup the packet to send it */
packet = &Request->Packet;
packet->IsDataPacket = false;
......@@ -360,7 +360,7 @@ RndisFilterSendRequest(
packet->PageBuffers[0].Length = Request->RequestMessage.MessageLength;
packet->PageBuffers[0].Offset = (unsigned long)&Request->RequestMessage & (PAGE_SIZE -1);
packet->Completion.Send.SendCompletionContext = Request;//packet;
packet->Completion.Send.SendCompletionContext = Request;/* packet; */
packet->Completion.Send.OnSendCompletion = RndisFilterOnSendRequestCompletion;
packet->Completion.Send.SendCompletionTid = (unsigned long)Device;
......@@ -389,7 +389,7 @@ RndisFilterReceiveResponse(
{
request = CONTAINING_RECORD(curr, RNDIS_REQUEST, ListEntry);
// All request/response message contains RequestId as the 1st field
/* All request/response message contains RequestId as the 1st field */
if (request->RequestMessage.Message.InitializeRequest.RequestId == Response->Message.InitializeComplete.RequestId)
{
DPRINT_DBG(NETVSC, "found rndis request for this response (id 0x%x req type 0x%x res type 0x%x)",
......@@ -411,7 +411,7 @@ RndisFilterReceiveResponse(
{
DPRINT_ERR(NETVSC, "rndis response buffer overflow detected (size %u max %u)", Response->MessageLength, sizeof(RNDIS_FILTER_PACKET));
if (Response->NdisMessageType == REMOTE_NDIS_RESET_CMPLT) // does not have a request id field
if (Response->NdisMessageType == REMOTE_NDIS_RESET_CMPLT) /* does not have a request id field */
{
request->ResponseMessage.Message.ResetComplete.Status = STATUS_BUFFER_OVERFLOW;
}
......@@ -450,7 +450,7 @@ RndisFilterReceiveIndicateStatus(
}
else
{
// TODO:
/* TODO: */
}
}
......@@ -466,15 +466,15 @@ RndisFilterReceiveData(
DPRINT_ENTER(NETVSC);
// empty ethernet frame ??
/* empty ethernet frame ?? */
ASSERT(Packet->PageBuffers[0].Length > RNDIS_MESSAGE_SIZE(RNDIS_PACKET));
rndisPacket = &Message->Message.Packet;
// FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this
// netvsc packet (ie TotalDataBufferLength != MessageLength)
/* FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this */
/* netvsc packet (ie TotalDataBufferLength != MessageLength) */
// Remove the rndis header and pass it back up the stack
/* Remove the rndis header and pass it back up the stack */
dataOffset = RNDIS_HEADER_SIZE + rndisPacket->DataOffset;
Packet->TotalDataBufferLength -= dataOffset;
......@@ -502,7 +502,7 @@ RndisFilterOnReceive(
DPRINT_ENTER(NETVSC);
ASSERT(netDevice);
//Make sure the rndis device state is initialized
/* Make sure the rndis device state is initialized */
if (!netDevice->Extension)
{
DPRINT_ERR(NETVSC, "got rndis message but no rndis device...dropping this message!");
......@@ -522,9 +522,9 @@ RndisFilterOnReceive(
rndisHeader = (void*)((unsigned long)rndisHeader + Packet->PageBuffers[0].Offset);
// Make sure we got a valid rndis message
// FIXME: There seems to be a bug in set completion msg where its MessageLength is 16 bytes but
// the ByteCount field in the xfer page range shows 52 bytes
/* Make sure we got a valid rndis message */
/* FIXME: There seems to be a bug in set completion msg where its MessageLength is 16 bytes but */
/* the ByteCount field in the xfer page range shows 52 bytes */
#if 0
if ( Packet->TotalDataBufferLength != rndisHeader->MessageLength )
{
......@@ -551,21 +551,21 @@ RndisFilterOnReceive(
switch (rndisMessage.NdisMessageType)
{
// data msg
/* data msg */
case REMOTE_NDIS_PACKET_MSG:
RndisFilterReceiveData(rndisDevice, &rndisMessage, Packet);
break;
// completion msgs
/* completion msgs */
case REMOTE_NDIS_INITIALIZE_CMPLT:
case REMOTE_NDIS_QUERY_CMPLT:
case REMOTE_NDIS_SET_CMPLT:
//case REMOTE_NDIS_RESET_CMPLT:
//case REMOTE_NDIS_KEEPALIVE_CMPLT:
/* case REMOTE_NDIS_RESET_CMPLT: */
/* case REMOTE_NDIS_KEEPALIVE_CMPLT: */
RndisFilterReceiveResponse(rndisDevice, &rndisMessage);
break;
// notification msgs
/* notification msgs */
case REMOTE_NDIS_INDICATE_STATUS_MSG:
RndisFilterReceiveIndicateStatus(rndisDevice, &rndisMessage);
break;
......@@ -605,7 +605,7 @@ RndisFilterQueryDevice(
goto Cleanup;
}
// Setup the rndis query
/* Setup the rndis query */
query = &request->RequestMessage.Message.QueryRequest;
query->Oid = Oid;
query->InformationBufferOffset = sizeof(RNDIS_QUERY_REQUEST);
......@@ -620,7 +620,7 @@ RndisFilterQueryDevice(
WaitEventWait(request->WaitEvent);
// Copy the response back
/* Copy the response back */
queryComplete = &request->ResponseMessage.Message.QueryComplete;
if (queryComplete->InformationBufferLength > inresultSize)
......@@ -694,7 +694,7 @@ RndisFilterSetPacketFilter(
goto Cleanup;
}
// Setup the rndis set
/* Setup the rndis set */
set = &request->RequestMessage.Message.SetRequest;
set->Oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER;
set->InformationBufferLength = sizeof(u32);
......@@ -713,7 +713,7 @@ RndisFilterSetPacketFilter(
{
ret = -1;
DPRINT_ERR(NETVSC, "timeout before we got a set response...");
// We cant deallocate the request since we may still receive a send completion for it.
/* We cant deallocate the request since we may still receive a send completion for it. */
goto Exit;
}
else
......@@ -747,9 +747,9 @@ RndisFilterInit(
DPRINT_DBG(NETVSC, "sizeof(RNDIS_FILTER_PACKET) == %d", sizeof(RNDIS_FILTER_PACKET));
Driver->RequestExtSize = sizeof(RNDIS_FILTER_PACKET);
Driver->AdditionalRequestPageBufferCount = 1; // For rndis header
Driver->AdditionalRequestPageBufferCount = 1; /* For rndis header */
//Driver->Context = rndisDriver;
/* Driver->Context = rndisDriver; */
memset(&gRndisFilter, 0, sizeof(RNDIS_FILTER_DRIVER_OBJECT));
......@@ -758,7 +758,7 @@ RndisFilterInit(
ASSERT(Driver->OnLinkStatusChanged);
rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
// Save the original dispatch handlers before we override it
/* Save the original dispatch handlers before we override it */
gRndisFilter.InnerDriver.Base.OnDeviceAdd = Driver->Base.OnDeviceAdd;
gRndisFilter.InnerDriver.Base.OnDeviceRemove = Driver->Base.OnDeviceRemove;
gRndisFilter.InnerDriver.Base.OnCleanup = Driver->Base.OnCleanup;
......@@ -769,14 +769,14 @@ RndisFilterInit(
gRndisFilter.InnerDriver.OnReceiveCallback = Driver->OnReceiveCallback;
gRndisFilter.InnerDriver.OnLinkStatusChanged = Driver->OnLinkStatusChanged;
// Override
/* Override */
Driver->Base.OnDeviceAdd = RndisFilterOnDeviceAdd;
Driver->Base.OnDeviceRemove = RndisFilterOnDeviceRemove;
Driver->Base.OnCleanup = RndisFilterOnCleanup;
Driver->OnSend = RndisFilterOnSend;
Driver->OnOpen = RndisFilterOnOpen;
Driver->OnClose = RndisFilterOnClose;
//Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus;
/* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */
Driver->OnReceiveCallback = RndisFilterOnReceive;
DPRINT_EXIT(NETVSC);
......@@ -804,11 +804,11 @@ RndisFilterInitDevice(
goto Cleanup;
}
// Setup the rndis set
/* Setup the rndis set */
init = &request->RequestMessage.Message.InitializeRequest;
init->MajorVersion = RNDIS_MAJOR_VERSION;
init->MinorVersion = RNDIS_MINOR_VERSION;
init->MaxTransferSize = 2048; // FIXME: Use 1536 - rounded ethernet frame size
init->MaxTransferSize = 2048; /* FIXME: Use 1536 - rounded ethernet frame size */
Device->State = RNDIS_DEV_INITIALIZING;
......@@ -854,18 +854,18 @@ RndisFilterHaltDevice(
DPRINT_ENTER(NETVSC);
// Attempt to do a rndis device halt
/* Attempt to do a rndis device halt */
request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG, RNDIS_MESSAGE_SIZE(RNDIS_HALT_REQUEST));
if (!request)
{
goto Cleanup;
}
// Setup the rndis set
/* Setup the rndis set */
halt = &request->RequestMessage.Message.HaltRequest;
halt->RequestId = InterlockedIncrement((int*)&Device->NewRequestId);
// Ignore return since this msg is optional.
/* Ignore return since this msg is optional. */
RndisFilterSendRequest(Device, request);
Device->State = RNDIS_DEV_UNINITIALIZED;
......@@ -948,9 +948,9 @@ RndisFilterOnDeviceAdd(
DPRINT_DBG(NETVSC, "rndis device object allocated - %p", rndisDevice);
// Let the inner driver handle this first to create the netvsc channel
// NOTE! Once the channel is created, we may get a receive callback
// (RndisFilterOnReceive()) before this call is completed
/* Let the inner driver handle this first to create the netvsc channel */
/* NOTE! Once the channel is created, we may get a receive callback */
/* (RndisFilterOnReceive()) before this call is completed */
ret = gRndisFilter.InnerDriver.Base.OnDeviceAdd(Device, AdditionalInfo);
if (ret != 0)
{
......@@ -959,9 +959,9 @@ RndisFilterOnDeviceAdd(
return ret;
}
//
// Initialize the rndis device
//
/* Initialize the rndis device */
netDevice = (NETVSC_DEVICE*)Device->Extension;
ASSERT(netDevice);
ASSERT(netDevice->Device);
......@@ -969,18 +969,18 @@ RndisFilterOnDeviceAdd(
netDevice->Extension = rndisDevice;
rndisDevice->NetDevice = netDevice;
// Send the rndis initialization message
/* Send the rndis initialization message */
ret = RndisFilterInitDevice(rndisDevice);
if (ret != 0)
{
// TODO: If rndis init failed, we will need to shut down the channel
/* TODO: If rndis init failed, we will need to shut down the channel */
}
// Get the mac address
/* Get the mac address */
ret = RndisFilterQueryDeviceMac(rndisDevice);
if (ret != 0)
{
// TODO: shutdown rndis device and the channel
/* TODO: shutdown rndis device and the channel */
}
DPRINT_INFO(NETVSC, "Device 0x%p mac addr %02x%02x%02x%02x%02x%02x",
......@@ -1015,13 +1015,13 @@ RndisFilterOnDeviceRemove(
DPRINT_ENTER(NETVSC);
// Halt and release the rndis device
/* Halt and release the rndis device */
RndisFilterHaltDevice(rndisDevice);
PutRndisDevice(rndisDevice);
netDevice->Extension = NULL;
// Pass control to inner driver to remove the device
/* Pass control to inner driver to remove the device */
gRndisFilter.InnerDriver.Base.OnDeviceRemove(Device);
DPRINT_EXIT(NETVSC);
......@@ -1091,7 +1091,7 @@ RndisFilterOnSend(
DPRINT_ENTER(NETVSC);
// Add the rndis header
/* Add the rndis header */
filterPacket = (RNDIS_FILTER_PACKET*)Packet->Extension;
ASSERT(filterPacket);
......@@ -1112,18 +1112,18 @@ RndisFilterOnSend(
Packet->PageBuffers[0].Offset = (unsigned long)rndisMessage & (PAGE_SIZE-1);
Packet->PageBuffers[0].Length = rndisMessageSize;
// Save the packet send completion and context
/* Save the packet send completion and context */
filterPacket->OnCompletion = Packet->Completion.Send.OnSendCompletion;
filterPacket->CompletionContext = Packet->Completion.Send.SendCompletionContext;
// Use ours
/* Use ours */
Packet->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion;
Packet->Completion.Send.SendCompletionContext = filterPacket;
ret = gRndisFilter.InnerDriver.OnSend(Device, Packet);
if (ret != 0)
{
// Reset the completion to originals to allow retries from above
/* Reset the completion to originals to allow retries from above */
Packet->Completion.Send.OnSendCompletion = filterPacket->OnCompletion;
Packet->Completion.Send.SendCompletionContext = filterPacket->CompletionContext;
}
......@@ -1141,7 +1141,7 @@ RndisFilterOnSendCompletion(
DPRINT_ENTER(NETVSC);
// Pass it back to the original handler
/* Pass it back to the original handler */
filterPacket->OnCompletion(filterPacket->CompletionContext);
DPRINT_EXIT(NETVSC);
......@@ -1155,6 +1155,6 @@ RndisFilterOnSendRequestCompletion(
{
DPRINT_ENTER(NETVSC);
// Noop
/* Noop */
DPRINT_EXIT(NETVSC);
}
......@@ -49,13 +49,13 @@
//
// Interface
//
/* Interface */
int
RndisFilterInit(
NETVSC_DRIVER_OBJECT *Driver
);
#endif // _RNDISFILTER_H_
#endif /* _RNDISFILTER_H_ */
......@@ -32,45 +32,48 @@
#include "include/vstorage.h"
//
// #defines
//
//
// Data types
//
/* #defines */
/* Data types */
typedef struct _STORVSC_REQUEST_EXTENSION {
//LIST_ENTRY ListEntry;
/* LIST_ENTRY ListEntry; */
STORVSC_REQUEST *Request;
DEVICE_OBJECT *Device;
// Synchronize the request/response if needed
/* Synchronize the request/response if needed */
HANDLE WaitEvent;
VSTOR_PACKET VStorPacket;
} STORVSC_REQUEST_EXTENSION;
// A storvsc device is a device object that contains a vmbus channel
/* A storvsc device is a device object that contains a vmbus channel */
typedef struct _STORVSC_DEVICE{
DEVICE_OBJECT *Device;
int RefCount; // 0 indicates the device is being destroyed
int RefCount; /* 0 indicates the device is being destroyed */
int NumOutstandingRequests;
// Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0
// and the port is set by us
/*
* Each unique Port/Path/Target represents 1 channel ie scsi
* controller. In reality, the pathid, targetid is always 0
* and the port is set by us
*/
unsigned int PortNumber;
unsigned char PathId;
unsigned char TargetId;
//LIST_ENTRY OutstandingRequestList;
//HANDLE OutstandingRequestLock;
/* LIST_ENTRY OutstandingRequestList; */
/* HANDLE OutstandingRequestLock; */
// Used for vsc/vsp channel reset process
/* Used for vsc/vsp channel reset process */
STORVSC_REQUEST_EXTENSION InitRequest;
STORVSC_REQUEST_EXTENSION ResetRequest;
......@@ -78,19 +81,19 @@ typedef struct _STORVSC_DEVICE{
} STORVSC_DEVICE;
//
// Globals
//
/* Globals */
static const char* gDriverName="storvsc";
//{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}
/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
static const GUID gStorVscDeviceType={
.Data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f}
};
//
// Internal routines
//
/* Internal routines */
static int
StorVscOnDeviceAdd(
DEVICE_OBJECT *Device,
......@@ -150,8 +153,8 @@ static inline STORVSC_DEVICE* AllocStorDevice(DEVICE_OBJECT *Device)
if (!storDevice)
return NULL;
// Set to 2 to allow both inbound and outbound traffics
// (ie GetStorDevice() and MustGetStorDevice()) to proceed.
/* Set to 2 to allow both inbound and outbound traffics */
/* (ie GetStorDevice() and MustGetStorDevice()) to proceed. */
InterlockedCompareExchange(&storDevice->RefCount, 2, 0);
storDevice->Device = Device;
......@@ -166,7 +169,7 @@ static inline void FreeStorDevice(STORVSC_DEVICE *Device)
kfree(Device);
}
// Get the stordevice object iff exists and its refcount > 1
/* Get the stordevice object iff exists and its refcount > 1 */
static inline STORVSC_DEVICE* GetStorDevice(DEVICE_OBJECT *Device)
{
STORVSC_DEVICE *storDevice;
......@@ -184,7 +187,7 @@ static inline STORVSC_DEVICE* GetStorDevice(DEVICE_OBJECT *Device)
return storDevice;
}
// Get the stordevice object iff exists and its refcount > 0
/* Get the stordevice object iff exists and its refcount > 0 */
static inline STORVSC_DEVICE* MustGetStorDevice(DEVICE_OBJECT *Device)
{
STORVSC_DEVICE *storDevice;
......@@ -213,7 +216,7 @@ static inline void PutStorDevice(DEVICE_OBJECT *Device)
ASSERT(storDevice->RefCount);
}
// Drop ref count to 1 to effectively disable GetStorDevice()
/* Drop ref count to 1 to effectively disable GetStorDevice() */
static inline STORVSC_DEVICE* ReleaseStorDevice(DEVICE_OBJECT *Device)
{
STORVSC_DEVICE *storDevice;
......@@ -221,7 +224,7 @@ static inline STORVSC_DEVICE* ReleaseStorDevice(DEVICE_OBJECT *Device)
storDevice = (STORVSC_DEVICE*)Device->Extension;
ASSERT(storDevice);
// Busy wait until the ref drop to 2, then set it to 1
/* Busy wait until the ref drop to 2, then set it to 1 */
while (InterlockedCompareExchange(&storDevice->RefCount, 1, 2) != 2)
{
udelay(100);
......@@ -230,7 +233,7 @@ static inline STORVSC_DEVICE* ReleaseStorDevice(DEVICE_OBJECT *Device)
return storDevice;
}
// Drop ref count to 0. No one can use StorDevice object.
/* Drop ref count to 0. No one can use StorDevice object. */
static inline STORVSC_DEVICE* FinalReleaseStorDevice(DEVICE_OBJECT *Device)
{
STORVSC_DEVICE *storDevice;
......@@ -238,7 +241,7 @@ static inline STORVSC_DEVICE* FinalReleaseStorDevice(DEVICE_OBJECT *Device)
storDevice = (STORVSC_DEVICE*)Device->Extension;
ASSERT(storDevice);
// Busy wait until the ref drop to 1, then set it to 0
/* Busy wait until the ref drop to 1, then set it to 0 */
while (InterlockedCompareExchange(&storDevice->RefCount, 0, 1) != 1)
{
udelay(100);
......@@ -271,7 +274,7 @@ StorVscInitialize(
DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%d sizeof(STORVSC_REQUEST_EXTENSION)=%d sizeof(VSTOR_PACKET)=%d, sizeof(VMSCSI_REQUEST)=%d",
sizeof(STORVSC_REQUEST), sizeof(STORVSC_REQUEST_EXTENSION), sizeof(VSTOR_PACKET), sizeof(VMSCSI_REQUEST));
// 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 = gDriverName;
......@@ -279,14 +282,18 @@ StorVscInitialize(
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(STORVSC, "max io %u, currently %u\n", storDriver->MaxOutstandingRequestsPerChannel, STORVSC_MAX_IO_REQUESTS);
// Setup the dispatch table
/* Setup the dispatch table */
storDriver->Base.OnDeviceAdd = StorVscOnDeviceAdd;
storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove;
storDriver->Base.OnCleanup = StorVscOnCleanup;
......@@ -316,7 +323,7 @@ StorVscOnDeviceAdd(
{
int ret=0;
STORVSC_DEVICE *storDevice;
//VMSTORAGE_CHANNEL_PROPERTIES *props;
/* VMSTORAGE_CHANNEL_PROPERTIES *props; */
STORVSC_DEVICE_INFO *deviceInfo = (STORVSC_DEVICE_INFO*)AdditionalInfo;
DPRINT_ENTER(STORVSC);
......@@ -328,21 +335,25 @@ StorVscOnDeviceAdd(
goto Cleanup;
}
// Save the channel properties to our storvsc channel
//props = (VMSTORAGE_CHANNEL_PROPERTIES*) channel->offerMsg.Offer.u.Standard.UserDefined;
/* Save the channel properties to our storvsc channel */
/* props = (VMSTORAGE_CHANNEL_PROPERTIES*) channel->offerMsg.Offer.u.Standard.UserDefined; */
/* FIXME: */
/*
* If we support more than 1 scsi channel, we need to set the
* port number here to the scsi channel but how do we get the
* scsi channel prior to the bus scan
*/
// FIXME:
// If we support more than 1 scsi channel, we need to set the port number here
// to the scsi channel but how do we get the scsi channel prior to the bus scan
/*storChannel->PortNumber = 0;
/* storChannel->PortNumber = 0;
storChannel->PathId = props->PathId;
storChannel->TargetId = props->TargetId;*/
storChannel->TargetId = props->TargetId; */
storDevice->PortNumber = deviceInfo->PortNumber;
// Send it back up
/* Send it back up */
ret = StorVscConnectToVsp(Device);
//deviceInfo->PortNumber = storDevice->PortNumber;
/* deviceInfo->PortNumber = storDevice->PortNumber; */
deviceInfo->PathId = storDevice->PathId;
deviceInfo->TargetId = storDevice->TargetId;
......@@ -372,7 +383,7 @@ static int StorVscChannelInit(DEVICE_OBJECT *Device)
request = &storDevice->InitRequest;
vstorPacket = &request->VStorPacket;
// Now, initiate the vsc/vsp initialization protocol on the open channel
/* Now, initiate the vsc/vsp initialization protocol on the open channel */
memset(request, sizeof(STORVSC_REQUEST_EXTENSION), 0);
request->WaitEvent = WaitEventCreate();
......@@ -408,7 +419,7 @@ static int StorVscChannelInit(DEVICE_OBJECT *Device)
DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
// reuse the packet for version range supported
/* reuse the packet for version range supported */
memset(vstorPacket, sizeof(VSTOR_PACKET), 0);
vstorPacket->Operation = VStorOperationQueryProtocolVersion;
vstorPacket->Flags = REQUEST_COMPLETION_FLAG;
......@@ -430,14 +441,14 @@ static int StorVscChannelInit(DEVICE_OBJECT *Device)
WaitEventWait(request->WaitEvent);
// TODO: Check returned version
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
{
DPRINT_ERR(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION failed (op %d status 0x%lx)", vstorPacket->Operation, vstorPacket->Status);
goto Cleanup;
}
// Query channel properties
/* Query channel properties */
DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
memset(vstorPacket, sizeof(VSTOR_PACKET), 0);
......@@ -460,14 +471,14 @@ static int StorVscChannelInit(DEVICE_OBJECT *Device)
WaitEventWait(request->WaitEvent);
// TODO: Check returned version
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status != 0)
{
DPRINT_ERR(STORVSC, "QUERY_PROPERTIES_OPERATION failed (op %d status 0x%lx)", vstorPacket->Operation, vstorPacket->Status);
goto Cleanup;
}
//storDevice->PortNumber = vstorPacket->StorageChannelProperties.PortNumber;
/* storDevice->PortNumber = vstorPacket->StorageChannelProperties.PortNumber; */
storDevice->PathId = vstorPacket->StorageChannelProperties.PathId;
storDevice->TargetId = vstorPacket->StorageChannelProperties.TargetId;
......@@ -528,7 +539,7 @@ StorVscConnectToVsp(
memset(&props, sizeof(VMSTORAGE_CHANNEL_PROPERTIES), 0);
// Open the channel
/* Open the channel */
ret = Device->Driver->VmbusChannelInterface.Open(Device,
storDriver->RingBufferSize,
storDriver->RingBufferSize,
......@@ -575,8 +586,11 @@ StorVscOnDeviceRemove(
storDevice = ReleaseStorDevice(Device);
// At this point, all outbound traffic should be disable. We only allow inbound traffic (responses) to proceed
// so that outstanding requests can be completed.
/*
* At this point, all outbound traffic should be disable. We
* only allow inbound traffic (responses) to proceed so that
* outstanding requests can be completed.
*/
while (storDevice->NumOutstandingRequests)
{
DPRINT_INFO(STORVSC, "waiting for %d requests to complete...", storDevice->NumOutstandingRequests);
......@@ -590,7 +604,7 @@ StorVscOnDeviceRemove(
DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice);
// Close the channel
/* Close the channel */
Device->Driver->VmbusChannelInterface.Close(Device);
FreeStorDevice(storDevice);
......@@ -599,22 +613,23 @@ StorVscOnDeviceRemove(
return ret;
}
/* ***************
static void
StorVscOnTargetRescan(
void *Context
)
{
DEVICE_OBJECT *device=(DEVICE_OBJECT*)Context;
STORVSC_DRIVER_OBJECT *storDriver;
//static void
//StorVscOnTargetRescan(
// void *Context
// )
//{
// DEVICE_OBJECT *device=(DEVICE_OBJECT*)Context;
// STORVSC_DRIVER_OBJECT *storDriver;
//
// DPRINT_ENTER(STORVSC);
//
// storDriver = (STORVSC_DRIVER_OBJECT*) device->Driver;
// storDriver->OnHostRescan(device);
//
// DPRINT_EXIT(STORVSC);
//}
DPRINT_ENTER(STORVSC);
storDriver = (STORVSC_DRIVER_OBJECT*) device->Driver;
storDriver->OnHostRescan(device);
DPRINT_EXIT(STORVSC);
}
*********** */
int
StorVscOnHostReset(
......@@ -660,13 +675,16 @@ StorVscOnHostReset(
goto Cleanup;
}
// FIXME: Add a timeout
/* FIXME: Add a timeout */
WaitEventWait(request->WaitEvent);
WaitEventClose(request->WaitEvent);
DPRINT_INFO(STORVSC, "host adapter reset completed");
// At this point, all outstanding requests in the adapter should have been flushed out and return to us
/*
* At this point, all outstanding requests in the adapter
* should have been flushed out and return to us
*/
Cleanup:
PutStorDevice(Device);
......@@ -729,7 +747,7 @@ StorVscOnIORequest(
vstorPacket->VmSrb.SenseInfoLength = SENSE_BUFFER_SIZE;
// Copy over the scsi command descriptor block
/* Copy over the scsi command descriptor block */
vstorPacket->VmSrb.CdbLength = Request->CdbLen;
memcpy(&vstorPacket->VmSrb.Cdb, Request->Cdb, Request->CdbLen);
......@@ -827,7 +845,7 @@ StorVscOnIOCompletion(
ASSERT(request->OnIOCompletion != NULL);
// Copy over the status...etc
/* Copy over the status...etc */
request->Status = VStorPacket->VmSrb.ScsiStatus;
if (request->Status != 0 || VStorPacket->VmSrb.SrbStatus != 1)
......@@ -838,9 +856,9 @@ StorVscOnIOCompletion(
VStorPacket->VmSrb.SrbStatus);
}
if ((request->Status & 0xFF) == 0x02) // CHECK_CONDITION
if ((request->Status & 0xFF) == 0x02) /* CHECK_CONDITION */
{
if (VStorPacket->VmSrb.SrbStatus & 0x80) // autosense data available
if (VStorPacket->VmSrb.SrbStatus & 0x80) /* autosense data available */
{
DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data valid - len %d\n",
RequestExt, VStorPacket->VmSrb.SenseInfoLength);
......@@ -854,7 +872,7 @@ StorVscOnIOCompletion(
}
}
// TODO:
/* TODO: */
request->BytesXfer = VStorPacket->VmSrb.DataTransferLength;
request->OnIOCompletion(request);
......@@ -882,17 +900,17 @@ StorVscOnReceive(
StorVscOnIOCompletion(Device, VStorPacket, RequestExt);
break;
//case ENUMERATE_DEVICE_OPERATION:
/* case ENUMERATE_DEVICE_OPERATION: */
// DPRINT_INFO(STORVSC, "ENUMERATE_DEVICE_OPERATION");
/* DPRINT_INFO(STORVSC, "ENUMERATE_DEVICE_OPERATION"); */
// StorVscOnTargetRescan(Device);
// break;
/* StorVscOnTargetRescan(Device); */
/* break; */
case VStorOperationRemoveDevice:
case VStorOperationRemoveDevice:
DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
// TODO:
/* TODO: */
break;
default:
......@@ -937,15 +955,15 @@ StorVscOnChannelCallback(
{
DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx", bytesRecvd, requestId);
//ASSERT(bytesRecvd == sizeof(VSTOR_PACKET));
/* ASSERT(bytesRecvd == sizeof(VSTOR_PACKET)); */
request = (STORVSC_REQUEST_EXTENSION*)(unsigned long)requestId;
ASSERT(request);
//if (vstorPacket.Flags & SYNTHETIC_FLAG)
/* if (vstorPacket.Flags & SYNTHETIC_FLAG) */
if ((request == &storDevice->InitRequest) || (request == &storDevice->ResetRequest))
{
//DPRINT_INFO(STORVSC, "reset completion - operation %u status %u", vstorPacket.Operation, vstorPacket.Status);
/* DPRINT_INFO(STORVSC, "reset completion - operation %u status %u", vstorPacket.Operation, vstorPacket.Status); */
memcpy(&request->VStorPacket, packet, sizeof(VSTOR_PACKET));
......@@ -958,7 +976,7 @@ StorVscOnChannelCallback(
}
else
{
//DPRINT_DBG(STORVSC, "nothing else to read...");
/* DPRINT_DBG(STORVSC, "nothing else to read..."); */
break;
}
} while (1);
......
......@@ -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_ */
此差异已折叠。
......@@ -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
......
......@@ -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_ */
......@@ -27,33 +27,35 @@
#include "VmbusApi.h"
//
// Defines
//
/* Defines */
#define STORVSC_RING_BUFFER_SIZE 10*PAGE_SIZE
#define BLKVSC_RING_BUFFER_SIZE 20*PAGE_SIZE
#define STORVSC_MAX_IO_REQUESTS 64
// In Hyper-V, each port/path/target maps to 1 scsi host adapter.
// In reality, the path/target is not used (ie always set to 0) so
// our scsi host adapter essentially has 1 bus with 1 target that contains
// up to 256 luns.
/*
* In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
* reality, the path/target is not used (ie always set to 0) so our
* scsi host adapter essentially has 1 bus with 1 target that contains
* up to 256 luns.
*/
#define STORVSC_MAX_LUNS_PER_TARGET 64
#define STORVSC_MAX_TARGETS 1
#define STORVSC_MAX_CHANNELS 1
// Fwd decl
//
//struct VMBUS_CHANNEL;
/* Fwd decl */
/* struct VMBUS_CHANNEL; */
typedef struct _STORVSC_REQUEST* PSTORVSC_REQUEST;
//
// Data types
//
/* Data types */
typedef int (*PFN_ON_IO_REQUEST)(PDEVICE_OBJECT Device, PSTORVSC_REQUEST Request);
typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(PSTORVSC_REQUEST Request);
......@@ -61,7 +63,7 @@ typedef int (*PFN_ON_HOST_RESET)(PDEVICE_OBJECT Device);
typedef void (*PFN_ON_HOST_RESCAN)(PDEVICE_OBJECT Device);
// Matches Windows-end
/* Matches Windows-end */
typedef enum _STORVSC_REQUEST_TYPE{
WRITE_TYPE,
READ_TYPE,
......@@ -87,30 +89,30 @@ typedef struct _STORVSC_REQUEST {
PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
// This points to the memory after DataBuffer
/* This points to the memory after DataBuffer */
void * Extension;
MULTIPAGE_BUFFER DataBuffer;
} STORVSC_REQUEST;
// Represents the block vsc driver
/* Represents the block vsc driver */
typedef struct _STORVSC_DRIVER_OBJECT {
DRIVER_OBJECT Base; // Must be the first field
DRIVER_OBJECT Base; /* Must be the first field */
// Set by caller (in bytes)
/* Set by caller (in bytes) */
u32 RingBufferSize;
// Allocate this much private extension for each I/O request
/* Allocate this much private extension for each I/O request */
u32 RequestExtSize;
// Maximum # of requests in flight per channel/device
/* Maximum # of requests in flight per channel/device */
u32 MaxOutstandingRequestsPerChannel;
// Set by the caller to allow us to re-enumerate the bus on the host
/* Set by the caller to allow us to re-enumerate the bus on the host */
PFN_ON_HOST_RESCAN OnHostRescan;
// Specific to this driver
/* Specific to this driver */
PFN_ON_IO_REQUEST OnIORequest;
PFN_ON_HOST_RESET OnHostReset;
......@@ -122,9 +124,9 @@ typedef struct _STORVSC_DEVICE_INFO {
unsigned char TargetId;
} STORVSC_DEVICE_INFO;
//
// Interface
//
/* Interface */
int
StorVscInitialize(
DRIVER_OBJECT *Driver
......@@ -134,4 +136,4 @@ int
BlkVscInitialize(
DRIVER_OBJECT *Driver
);
#endif // _STORVSC_API_H_
#endif /* _STORVSC_API_H_ */
......@@ -27,57 +27,57 @@
#include "osd.h"
//
// Defines
//
/* Defines */
#define MAX_PAGE_BUFFER_COUNT 16
#define MAX_MULTIPAGE_BUFFER_COUNT 32 // 128K
#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
/* Fwd declarations */
//
// Fwd declarations
//
typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
//
// Data types
//
/* Data types */
#pragma pack(push,1)
// Single-page buffer
/* Single-page buffer */
typedef struct _PAGE_BUFFER {
u32 Length;
u32 Offset;
u64 Pfn;
} PAGE_BUFFER;
// Multiple-page buffer
/* Multiple-page buffer */
typedef struct _MULTIPAGE_BUFFER {
// Length and Offset determines the # of pfns in the array
/* Length and Offset determines the # of pfns in the array */
u32 Length;
u32 Offset;
u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
}MULTIPAGE_BUFFER;
//0x18 includes the proprietary packet header
/* 0x18 includes the proprietary packet header */
#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)
// All drivers
/* All drivers */
typedef int (*PFN_ON_DEVICEADD)(PDEVICE_OBJECT Device, void* AdditionalInfo);
typedef int (*PFN_ON_DEVICEREMOVE)(PDEVICE_OBJECT Device);
typedef char** (*PFN_ON_GETDEVICEIDS)(void);
typedef void (*PFN_ON_CLEANUP)(PDRIVER_OBJECT Driver);
// Vmbus extensions
//typedef int (*PFN_ON_MATCH)(PDEVICE_OBJECT dev, PDRIVER_OBJECT drv);
//typedef int (*PFN_ON_PROBE)(PDEVICE_OBJECT dev);
/* Vmbus extensions */
/* typedef int (*PFN_ON_MATCH)(PDEVICE_OBJECT dev, PDRIVER_OBJECT drv); */
/* typedef int (*PFN_ON_PROBE)(PDEVICE_OBJECT dev); */
typedef int (*PFN_ON_ISR)(PDRIVER_OBJECT drv);
typedef void (*PFN_ON_DPC)(PDRIVER_OBJECT drv);
typedef void (*PFN_GET_CHANNEL_OFFERS)(void);
......@@ -87,7 +87,7 @@ typedef void (*PFN_ON_CHILDDEVICE_DESTROY)(PDEVICE_OBJECT Device);
typedef int (*PFN_ON_CHILDDEVICE_ADD)(PDEVICE_OBJECT RootDevice, PDEVICE_OBJECT ChildDevice);
typedef void (*PFN_ON_CHILDDEVICE_REMOVE)(PDEVICE_OBJECT Device);
// Vmbus channel interface
/* Vmbus channel interface */
typedef void (*VMBUS_CHANNEL_CALLBACK)(void * context);
typedef int (*VMBUS_CHANNEL_OPEN)(
......@@ -148,8 +148,8 @@ typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW)(
typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(
PDEVICE_OBJECT Device,
void * Buffer, // from kmalloc()
u32 BufferLen, // page-size multiple
void * Buffer, /* from kmalloc() */
u32 BufferLen, /* page-size multiple */
u32* GpadlHandle
);
......@@ -203,44 +203,44 @@ typedef struct _VMBUS_CHANNEL_INTERFACE {
typedef void (*VMBUS_GET_CHANNEL_INTERFACE)(VMBUS_CHANNEL_INTERFACE *Interface);
// Base driver object
/* Base driver object */
typedef struct _DRIVER_OBJECT {
const char* name;
GUID deviceType; // the device type supported by this driver
GUID deviceType; /* the device type supported by this driver */
PFN_ON_DEVICEADD OnDeviceAdd;
PFN_ON_DEVICEREMOVE OnDeviceRemove;
PFN_ON_GETDEVICEIDS OnGetDeviceIds; // device ids supported by this driver
PFN_ON_GETDEVICEIDS OnGetDeviceIds; /* device ids supported by this driver */
PFN_ON_CLEANUP OnCleanup;
VMBUS_CHANNEL_INTERFACE VmbusChannelInterface;
} DRIVER_OBJECT;
// Base device object
/* Base device object */
typedef struct _DEVICE_OBJECT {
DRIVER_OBJECT* Driver; // the driver for this device
DRIVER_OBJECT* Driver; /* the driver for this device */
char name[64];
GUID deviceType; // the device type id of this device
GUID deviceInstance; // the device instance id of this device
GUID deviceType; /* the device type id of this device */
GUID deviceInstance; /* the device instance id of this device */
void* context;
void* Extension; // Device extension;
void* Extension; /* Device extension; */
} DEVICE_OBJECT;
// Vmbus driver object
/* Vmbus driver object */
typedef struct _VMBUS_DRIVER_OBJECT {
DRIVER_OBJECT Base; // !! Must be the 1st field !!
DRIVER_OBJECT Base; /* !! Must be the 1st field !! */
// Set by the caller
/* Set by the caller */
PFN_ON_CHILDDEVICE_CREATE OnChildDeviceCreate;
PFN_ON_CHILDDEVICE_DESTROY OnChildDeviceDestroy;
PFN_ON_CHILDDEVICE_ADD OnChildDeviceAdd;
PFN_ON_CHILDDEVICE_REMOVE OnChildDeviceRemove;
// Set by the callee
//PFN_ON_MATCH OnMatch;
//PFN_ON_PROBE OnProbe;
/* Set by the callee */
/* PFN_ON_MATCH OnMatch; */
/* PFN_ON_PROBE OnProbe; */
PFN_ON_ISR OnIsr;
PFN_ON_DPC OnMsgDpc;
PFN_ON_DPC OnEventDpc;
......@@ -251,12 +251,12 @@ typedef struct _VMBUS_DRIVER_OBJECT {
} VMBUS_DRIVER_OBJECT;
//
// Interface
//
/* Interface */
int
VmbusInitialize(
DRIVER_OBJECT* drv
);
#endif // _VMBUS_API_H_
#endif /* _VMBUS_API_H_ */
......@@ -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_ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册