#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
);
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);
}
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);
}
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;
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);
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;
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);
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)
goto Cleanup;
}
- // FIXME: Need to time-out here
+ /* FIXME: Need to time-out here */
WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
--*/
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)
{
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);
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)
(*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;
}
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;
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;
}
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,
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);
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;
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);
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);
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);
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);
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++)
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);
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;
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);
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,
{
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,
*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);
{
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);
*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);
}
-// eof
+/* eof */