diff options
Diffstat (limited to 'drivers/staging/hv')
29 files changed, 1040 insertions, 1781 deletions
diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig index 97480f5c6599..7455c804962a 100644 --- a/drivers/staging/hv/Kconfig +++ b/drivers/staging/hv/Kconfig @@ -17,7 +17,7 @@ config HYPERV_STORAGE config HYPERV_BLOCK tristate "Microsoft Hyper-V virtual block driver" - depends on BLOCK && SCSI && LBDAF + depends on BLOCK && SCSI && (LBDAF || 64BIT) default HYPERV help Select this option to enable the Hyper-V virtual block driver. diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile index 1866f80a45d3..b46349bb43bf 100644 --- a/drivers/staging/hv/Makefile +++ b/drivers/staging/hv/Makefile @@ -1,12 +1,12 @@ -obj-$(CONFIG_HYPERV) += hv_vmbus.o +obj-$(CONFIG_HYPERV) += hv_vmbus.o hv_timesource.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o -hv_vmbus-objs := vmbus_drv.o osd.o \ +hv_vmbus-y := vmbus_drv.o osd.o \ vmbus.o hv.o connection.o channel.o \ - channel_mgmt.o channel_interface.o ring_buffer.o -hv_storvsc-objs := storvsc_drv.o storvsc.o -hv_blkvsc-objs := blkvsc_drv.o blkvsc.o -hv_netvsc-objs := netvsc_drv.o netvsc.o rndis_filter.o + channel_mgmt.o ring_buffer.o +hv_storvsc-y := storvsc_drv.o storvsc.o +hv_blkvsc-y := blkvsc_drv.o blkvsc.o +hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO index 66a89c809dd3..582fd4ab3f1e 100644 --- a/drivers/staging/hv/TODO +++ b/drivers/staging/hv/TODO @@ -2,8 +2,6 @@ TODO: - fix remaining checkpatch warnings and errors - audit the vmbus to verify it is working properly with the driver model - - convert vmbus driver interface function pointer tables - to constant, a.k.a vmbus_ops - see if the vmbus can be merged with the other virtual busses in the kernel - audit the network driver diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c index 0daebc472e63..d5b0abd771ab 100644 --- a/drivers/staging/hv/blkvsc.c +++ b/drivers/staging/hv/blkvsc.c @@ -40,15 +40,11 @@ static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) struct storvsc_device_info *deviceInfo; int ret = 0; - DPRINT_ENTER(BLKVSC); - deviceInfo = (struct storvsc_device_info *)AdditionalInfo; ret = StorVscOnDeviceAdd(Device, AdditionalInfo); - if (ret != 0) { - DPRINT_EXIT(BLKVSC); + if (ret != 0) return ret; - } /* * We need to use the device instance guid to set the path and target @@ -63,8 +59,6 @@ static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) deviceInfo->TargetId = Device->deviceInstance.data[5] << 8 | Device->deviceInstance.data[4]; - DPRINT_EXIT(BLKVSC); - return ret; } @@ -73,8 +67,6 @@ int BlkVscInitialize(struct hv_driver *Driver) struct storvsc_driver_object *storDriver; int ret = 0; - DPRINT_ENTER(BLKVSC); - storDriver = (struct storvsc_driver_object *)Driver; /* Make sure we are at least 2 pages since 1 page is used for control */ @@ -89,7 +81,7 @@ int BlkVscInitialize(struct hv_driver *Driver) * 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 + struct vstor_packet + u64) + * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64) */ storDriver->MaxOutstandingRequestsPerChannel = ((storDriver->RingBufferSize - PAGE_SIZE) / @@ -106,7 +98,5 @@ int BlkVscInitialize(struct hv_driver *Driver) storDriver->Base.OnCleanup = StorVscOnCleanup; storDriver->OnIORequest = StorVscOnIORequest; - DPRINT_EXIT(BLKVSC); - return ret; } diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 61bd0be5fb18..3f81ca591064 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -25,6 +25,7 @@ #include <linux/major.h> #include <linux/delay.h> #include <linux/hdreg.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -123,6 +124,7 @@ struct blkvsc_driver_context { }; /* Static decl */ +static DEFINE_MUTEX(blkvsc_mutex); static int blkvsc_probe(struct device *dev); static int blkvsc_remove(struct device *device); static void blkvsc_shutdown(struct device *device); @@ -175,10 +177,6 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx; int ret; - DPRINT_ENTER(BLKVSC_DRV); - - vmbus_get_interface(&storvsc_drv_obj->Base.VmbusChannelInterface); - storvsc_drv_obj->RingBufferSize = blkvsc_ringbuffer_size; /* Callback to client driver to complete the initialization */ @@ -195,8 +193,6 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) /* The driver belongs to vmbus */ ret = vmbus_child_driver_register(drv_ctx); - DPRINT_EXIT(BLKVSC_DRV); - return ret; } @@ -214,8 +210,6 @@ static void blkvsc_drv_exit(void) struct device *current_dev; int ret; - DPRINT_ENTER(BLKVSC_DRV); - while (1) { current_dev = NULL; @@ -241,8 +235,6 @@ static void blkvsc_drv_exit(void) vmbus_child_driver_unregister(drv_ctx); - DPRINT_EXIT(BLKVSC_DRV); - return; } @@ -268,8 +260,6 @@ static int blkvsc_probe(struct device *device) static int ide0_registered; static int ide1_registered; - DPRINT_ENTER(BLKVSC_DRV); - DPRINT_DBG(BLKVSC_DRV, "blkvsc_probe - enter"); if (!storvsc_drv_obj->Base.OnDeviceAdd) { @@ -413,8 +403,6 @@ Cleanup: blkdev = NULL; } - DPRINT_EXIT(BLKVSC_DRV); - return ret; } @@ -751,14 +739,10 @@ static int blkvsc_remove(struct device *device) unsigned long flags; int ret; - DPRINT_ENTER(BLKVSC_DRV); - DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n"); - if (!storvsc_drv_obj->Base.OnDeviceRemove) { - DPRINT_EXIT(BLKVSC_DRV); + if (!storvsc_drv_obj->Base.OnDeviceRemove) return -1; - } /* * Call to the vsc driver to let it know that the device is being @@ -802,8 +786,6 @@ static int blkvsc_remove(struct device *device) kfree(blkdev); - DPRINT_EXIT(BLKVSC_DRV); - return ret; } @@ -823,7 +805,8 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req) blkvsc_req->cmnd[0] = READ_16; } - blkvsc_req->cmnd[1] |= blk_fua_rq(blkvsc_req->req) ? 0x8 : 0; + blkvsc_req->cmnd[1] |= + (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; *(unsigned long long *)&blkvsc_req->cmnd[2] = cpu_to_be64(blkvsc_req->sector_start); @@ -839,7 +822,8 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req) blkvsc_req->cmnd[0] = READ_10; } - blkvsc_req->cmnd[1] |= blk_fua_rq(blkvsc_req->req) ? 0x8 : 0; + blkvsc_req->cmnd[1] |= + (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; *(unsigned int *)&blkvsc_req->cmnd[2] = cpu_to_be32(blkvsc_req->sector_start); @@ -1286,7 +1270,7 @@ static void blkvsc_request(struct request_queue *queue) DPRINT_DBG(BLKVSC_DRV, "- req %p\n", req); blkdev = req->rq_disk->private_data; - if (blkdev->shutting_down || !blk_fs_request(req) || + if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS || blkdev->media_not_present) { __blk_end_request_cur(req, 0); continue; @@ -1324,6 +1308,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode) DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, blkdev->gd->disk_name); + mutex_lock(&blkvsc_mutex); spin_lock(&blkdev->lock); if (!blkdev->users && blkdev->device_type == DVD_TYPE) { @@ -1335,6 +1320,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode) blkdev->users++; spin_unlock(&blkdev->lock); + mutex_unlock(&blkvsc_mutex); return 0; } @@ -1345,6 +1331,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, blkdev->gd->disk_name); + mutex_lock(&blkvsc_mutex); spin_lock(&blkdev->lock); if (blkdev->users == 1) { spin_unlock(&blkdev->lock); @@ -1355,6 +1342,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) blkdev->users--; spin_unlock(&blkdev->lock); + mutex_unlock(&blkvsc_mutex); return 0; } @@ -1492,22 +1480,16 @@ static int __init blkvsc_init(void) BUILD_BUG_ON(sizeof(sector_t) != 8); - DPRINT_ENTER(BLKVSC_DRV); - DPRINT_INFO(BLKVSC_DRV, "Blkvsc initializing...."); ret = blkvsc_drv_init(BlkVscInitialize); - DPRINT_EXIT(BLKVSC_DRV); - return ret; } static void __exit blkvsc_exit(void) { - DPRINT_ENTER(BLKVSC_DRV); blkvsc_drv_exit(); - DPRINT_ENTER(BLKVSC_DRV); } MODULE_LICENSE("GPL"); diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index f047c5a7f64c..26ebc77f22b7 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -27,13 +27,13 @@ #include "vmbus_private.h" /* Internal routines */ -static int VmbusChannelCreateGpadlHeader( - void *Kbuffer, /* must be phys and virt contiguous */ - u32 Size, /* page-size multiple */ - struct vmbus_channel_msginfo **msgInfo, - u32 *MessageCount); -static void DumpVmbusChannel(struct vmbus_channel *channel); -static void VmbusChannelSetEvent(struct vmbus_channel *channel); +static int create_gpadl_header( + void *kbuffer, /* must be phys and virt contiguous */ + u32 size, /* page-size multiple */ + struct vmbus_channel_msginfo **msginfo, + u32 *messagecount); +static void dump_vmbus_channel(struct vmbus_channel *channel); +static void vmbus_setevent(struct vmbus_channel *channel); #if 0 @@ -67,33 +67,29 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage) #endif /* - * VmbusChannelSetEvent - Trigger an event notification on the specified + * vmbus_setevent- Trigger an event notification on the specified * channel. */ -static void VmbusChannelSetEvent(struct vmbus_channel *Channel) +static void vmbus_setevent(struct vmbus_channel *channel) { - struct hv_monitor_page *monitorPage; - - DPRINT_ENTER(VMBUS); + struct hv_monitor_page *monitorpage; - if (Channel->OfferMsg.MonitorAllocated) { + if (channel->OfferMsg.MonitorAllocated) { /* Each u32 represents 32 channels */ - set_bit(Channel->OfferMsg.ChildRelId & 31, + set_bit(channel->OfferMsg.ChildRelId & 31, (unsigned long *) gVmbusConnection.SendInterruptPage + - (Channel->OfferMsg.ChildRelId >> 5)); + (channel->OfferMsg.ChildRelId >> 5)); - monitorPage = gVmbusConnection.MonitorPages; - monitorPage++; /* Get the child to parent monitor page */ + monitorpage = gVmbusConnection.MonitorPages; + monitorpage++; /* Get the child to parent monitor page */ - set_bit(Channel->MonitorBit, - (unsigned long *)&monitorPage->TriggerGroup - [Channel->MonitorGroup].Pending); + set_bit(channel->MonitorBit, + (unsigned long *)&monitorpage->TriggerGroup + [channel->MonitorGroup].Pending); } else { - VmbusSetEvent(Channel->OfferMsg.ChildRelId); + VmbusSetEvent(channel->OfferMsg.ChildRelId); } - - DPRINT_EXIT(VMBUS); } #if 0 @@ -101,8 +97,6 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel) { struct hv_monitor_page *monitorPage; - DPRINT_ENTER(VMBUS); - if (Channel->OfferMsg.MonitorAllocated) { /* Each u32 represents 32 channels */ clear_bit(Channel->OfferMsg.ChildRelId & 31, @@ -117,62 +111,60 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel) (unsigned long *)&monitorPage->TriggerGroup [Channel->MonitorGroup].Pending); } - - DPRINT_EXIT(VMBUS); } #endif /* - * VmbusChannelGetDebugInfo -Retrieve various channel debug info + * vmbus_get_debug_info -Retrieve various channel debug info */ -void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel, - struct vmbus_channel_debug_info *DebugInfo) +void vmbus_get_debug_info(struct vmbus_channel *channel, + struct vmbus_channel_debug_info *debuginfo) { - struct hv_monitor_page *monitorPage; - u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32; - u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32; + struct hv_monitor_page *monitorpage; + u8 monitor_group = (u8)channel->OfferMsg.MonitorId / 32; + u8 monitor_offset = (u8)channel->OfferMsg.MonitorId % 32; /* u32 monitorBit = 1 << monitorOffset; */ - DebugInfo->RelId = Channel->OfferMsg.ChildRelId; - DebugInfo->State = Channel->State; - memcpy(&DebugInfo->InterfaceType, - &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid)); - memcpy(&DebugInfo->InterfaceInstance, - &Channel->OfferMsg.Offer.InterfaceInstance, + debuginfo->RelId = channel->OfferMsg.ChildRelId; + debuginfo->State = channel->State; + memcpy(&debuginfo->InterfaceType, + &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid)); + memcpy(&debuginfo->InterfaceInstance, + &channel->OfferMsg.Offer.InterfaceInstance, sizeof(struct hv_guid)); - monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages; + monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages; - DebugInfo->MonitorId = Channel->OfferMsg.MonitorId; + debuginfo->MonitorId = channel->OfferMsg.MonitorId; - DebugInfo->ServerMonitorPending = - monitorPage->TriggerGroup[monitorGroup].Pending; - DebugInfo->ServerMonitorLatency = - monitorPage->Latency[monitorGroup][monitorOffset]; - DebugInfo->ServerMonitorConnectionId = - monitorPage->Parameter[monitorGroup] - [monitorOffset].ConnectionId.u.Id; + debuginfo->ServerMonitorPending = + monitorpage->TriggerGroup[monitor_group].Pending; + debuginfo->ServerMonitorLatency = + monitorpage->Latency[monitor_group][monitor_offset]; + debuginfo->ServerMonitorConnectionId = + monitorpage->Parameter[monitor_group] + [monitor_offset].ConnectionId.u.Id; - monitorPage++; + monitorpage++; - DebugInfo->ClientMonitorPending = - monitorPage->TriggerGroup[monitorGroup].Pending; - DebugInfo->ClientMonitorLatency = - monitorPage->Latency[monitorGroup][monitorOffset]; - DebugInfo->ClientMonitorConnectionId = - monitorPage->Parameter[monitorGroup] - [monitorOffset].ConnectionId.u.Id; + debuginfo->ClientMonitorPending = + monitorpage->TriggerGroup[monitor_group].Pending; + debuginfo->ClientMonitorLatency = + monitorpage->Latency[monitor_group][monitor_offset]; + debuginfo->ClientMonitorConnectionId = + monitorpage->Parameter[monitor_group] + [monitor_offset].ConnectionId.u.Id; - RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound); - RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound); + RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound); + RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound); } /* - * VmbusChannelOpen - Open the specified channel. + * vmbus_open - Open the specified channel. */ -int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, - u32 RecvRingBufferSize, void *UserData, u32 UserDataLen, - void (*OnChannelCallback)(void *context), void *Context) +int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, + u32 recv_ringbuffer_size, void *userdata, u32 userdatalen, + void (*onchannelcallback)(void *context), void *context) { struct vmbus_channel_open_channel *openMsg; struct vmbus_channel_msginfo *openInfo = NULL; @@ -180,36 +172,34 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, unsigned long flags; int ret, err = 0; - DPRINT_ENTER(VMBUS); - /* Aligned to page size */ /* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */ /* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */ - NewChannel->OnChannelCallback = OnChannelCallback; - NewChannel->ChannelCallbackContext = Context; + newchannel->OnChannelCallback = onchannelcallback; + newchannel->ChannelCallbackContext = context; /* Allocate the ring buffer */ - out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize) + out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size) >> PAGE_SHIFT); if (!out) return -ENOMEM; /* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */ - in = (void *)((unsigned long)out + SendRingBufferSize); + in = (void *)((unsigned long)out + send_ringbuffer_size); - NewChannel->RingBufferPages = out; - NewChannel->RingBufferPageCount = (SendRingBufferSize + - RecvRingBufferSize) >> PAGE_SHIFT; + newchannel->RingBufferPages = out; + newchannel->RingBufferPageCount = (send_ringbuffer_size + + recv_ringbuffer_size) >> PAGE_SHIFT; - ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize); + ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size); if (ret != 0) { err = ret; goto errorout; } - ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize); + ret = RingBufferInit(&newchannel->Inbound, in, recv_ringbuffer_size); if (ret != 0) { err = ret; goto errorout; @@ -218,15 +208,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, /* Establish the gpadl for the ring buffer */ DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...", - NewChannel); + newchannel); - NewChannel->RingBufferGpadlHandle = 0; + newchannel->RingBufferGpadlHandle = 0; - ret = VmbusChannelEstablishGpadl(NewChannel, - NewChannel->Outbound.RingBuffer, - SendRingBufferSize + - RecvRingBufferSize, - &NewChannel->RingBufferGpadlHandle); + ret = vmbus_establish_gpadl(newchannel, + newchannel->Outbound.RingBuffer, + send_ringbuffer_size + + recv_ringbuffer_size, + &newchannel->RingBufferGpadlHandle); if (ret != 0) { err = ret; @@ -235,13 +225,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p " "size %d recv ring %p size %d, downstreamoffset %d>", - NewChannel, NewChannel->OfferMsg.ChildRelId, - NewChannel->RingBufferGpadlHandle, - NewChannel->Outbound.RingBuffer, - NewChannel->Outbound.RingSize, - NewChannel->Inbound.RingBuffer, - NewChannel->Inbound.RingSize, - SendRingBufferSize); + newchannel, newchannel->OfferMsg.ChildRelId, + newchannel->RingBufferGpadlHandle, + newchannel->Outbound.RingBuffer, + newchannel->Outbound.RingSize, + newchannel->Inbound.RingBuffer, + newchannel->Inbound.RingSize, + send_ringbuffer_size); /* Create and init the channel open message */ openInfo = kmalloc(sizeof(*openInfo) + @@ -260,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg; openMsg->Header.MessageType = ChannelMessageOpenChannel; - openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */ - openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId; - openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle; - openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >> + openMsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */ + openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId; + openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle; + openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >> PAGE_SHIFT; openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */ - if (UserDataLen > MAX_USER_DEFINED_BYTES) { + if (userdatalen > MAX_USER_DEFINED_BYTES) { err = -EINVAL; goto errorout; } - if (UserDataLen) - memcpy(openMsg->UserData, UserData, UserDataLen); + if (userdatalen) + memcpy(openMsg->UserData, userdata, userdatalen); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); list_add_tail(&openInfo->MsgListEntry, @@ -293,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, osd_WaitEventWait(openInfo->WaitEvent); if (openInfo->Response.OpenResult.Status == 0) - DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel); + DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel); else DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!", - NewChannel, openInfo->Response.OpenResult.Status); + newchannel, openInfo->Response.OpenResult.Status); Cleanup: spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); @@ -305,312 +295,309 @@ Cleanup: kfree(openInfo->WaitEvent); kfree(openInfo); - - DPRINT_EXIT(VMBUS); - return 0; errorout: - RingBufferCleanup(&NewChannel->Outbound); - RingBufferCleanup(&NewChannel->Inbound); - osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize) + RingBufferCleanup(&newchannel->Outbound); + RingBufferCleanup(&newchannel->Inbound); + osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size) >> PAGE_SHIFT); kfree(openInfo); return err; } +EXPORT_SYMBOL_GPL(vmbus_open); /* - * DumpGpadlBody - Dump the gpadl body message to the console for + * dump_gpadl_body - Dump the gpadl body message to the console for * debugging purposes. */ -static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len) +static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len) { int i; - int pfnCount; + int pfncount; - pfnCount = (Len - sizeof(struct vmbus_channel_gpadl_body)) / + pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) / sizeof(u64); - DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", Len, pfnCount); + DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount); - for (i = 0; i < pfnCount; i++) + for (i = 0; i < pfncount; i++) DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu", - i, Gpadl->Pfn[i]); + i, gpadl->Pfn[i]); } /* - * DumpGpadlHeader - Dump the gpadl header message to the console for + * dump_gpadl_header - Dump the gpadl header message to the console for * debugging purposes. */ -static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl) +static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl) { int i, j; - int pageCount; + int pagecount; DPRINT_DBG(VMBUS, "gpadl header - relid %d, range count %d, range buflen %d", - Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen); - for (i = 0; i < Gpadl->RangeCount; i++) { - pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT; - pageCount = (pageCount > 26) ? 26 : pageCount; + gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen); + for (i = 0; i < gpadl->RangeCount; i++) { + pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT; + pagecount = (pagecount > 26) ? 26 : pagecount; DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d " - "page count %d", i, Gpadl->Range[i].ByteCount, - Gpadl->Range[i].ByteOffset, pageCount); + "page count %d", i, gpadl->Range[i].ByteCount, + gpadl->Range[i].ByteOffset, pagecount); - for (j = 0; j < pageCount; j++) + for (j = 0; j < pagecount; j++) DPRINT_DBG(VMBUS, "%d) pfn %llu", j, - Gpadl->Range[i].PfnArray[j]); + gpadl->Range[i].PfnArray[j]); } } /* - * VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer + * create_gpadl_header - Creates a gpadl for the specified buffer */ -static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, - struct vmbus_channel_msginfo **MsgInfo, - u32 *MessageCount) +static int create_gpadl_header(void *kbuffer, u32 size, + struct vmbus_channel_msginfo **msginfo, + u32 *messagecount) { int i; - int pageCount; + int pagecount; unsigned long long pfn; - struct vmbus_channel_gpadl_header *gpaHeader; - struct vmbus_channel_gpadl_body *gpadlBody; - struct vmbus_channel_msginfo *msgHeader; - struct vmbus_channel_msginfo *msgBody = NULL; - u32 msgSize; + struct vmbus_channel_gpadl_header *gpadl_header; + struct vmbus_channel_gpadl_body *gpadl_body; + struct vmbus_channel_msginfo *msgheader; + struct vmbus_channel_msginfo *msgbody = NULL; + u32 msgsize; - int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize; + int pfnsum, pfncount, pfnleft, pfncurr, pfnsize; /* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */ /* ASSERT((Size & (PAGE_SIZE-1)) == 0); */ - pageCount = Size >> PAGE_SHIFT; - pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT; + pagecount = size >> PAGE_SHIFT; + pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT; /* do we need a gpadl body msg */ - pfnSize = MAX_SIZE_CHANNEL_MESSAGE - + pfnsize = MAX_SIZE_CHANNEL_MESSAGE - sizeof(struct vmbus_channel_gpadl_header) - sizeof(struct gpa_range); - pfnCount = pfnSize / sizeof(u64); + pfncount = pfnsize / sizeof(u64); - if (pageCount > pfnCount) { + if (pagecount > pfncount) { /* we need a gpadl body */ /* fill in the header */ - msgSize = sizeof(struct vmbus_channel_msginfo) + + msgsize = sizeof(struct vmbus_channel_msginfo) + sizeof(struct vmbus_channel_gpadl_header) + - sizeof(struct gpa_range) + pfnCount * sizeof(u64); - msgHeader = kzalloc(msgSize, GFP_KERNEL); - if (!msgHeader) + sizeof(struct gpa_range) + pfncount * sizeof(u64); + msgheader = kzalloc(msgsize, GFP_KERNEL); + if (!msgheader) goto nomem; - INIT_LIST_HEAD(&msgHeader->SubMsgList); - msgHeader->MessageSize = msgSize; + INIT_LIST_HEAD(&msgheader->SubMsgList); + msgheader->MessageSize = msgsize; - gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg; - gpaHeader->RangeCount = 1; - gpaHeader->RangeBufLen = sizeof(struct gpa_range) + - pageCount * sizeof(u64); - gpaHeader->Range[0].ByteOffset = 0; - gpaHeader->Range[0].ByteCount = Size; - for (i = 0; i < pfnCount; i++) - gpaHeader->Range[0].PfnArray[i] = pfn+i; - *MsgInfo = msgHeader; - *MessageCount = 1; + gpadl_header = (struct vmbus_channel_gpadl_header *) + msgheader->Msg; + gpadl_header->RangeCount = 1; + gpadl_header->RangeBufLen = sizeof(struct gpa_range) + + pagecount * sizeof(u64); + gpadl_header->Range[0].ByteOffset = 0; + gpadl_header->Range[0].ByteCount = size; + for (i = 0; i < pfncount; i++) + gpadl_header->Range[0].PfnArray[i] = pfn+i; + *msginfo = msgheader; + *messagecount = 1; - pfnSum = pfnCount; - pfnLeft = pageCount - pfnCount; + pfnsum = pfncount; + pfnleft = pagecount - pfncount; /* how many pfns can we fit */ - pfnSize = MAX_SIZE_CHANNEL_MESSAGE - + pfnsize = MAX_SIZE_CHANNEL_MESSAGE - sizeof(struct vmbus_channel_gpadl_body); - pfnCount = pfnSize / sizeof(u64); + pfncount = pfnsize / sizeof(u64); /* fill in the body */ - while (pfnLeft) { - if (pfnLeft > pfnCount) - pfnCurr = pfnCount; + while (pfnleft) { + if (pfnleft > pfncount) + pfncurr = pfncount; else - pfnCurr = pfnLeft; + pfncurr = pfnleft; - msgSize = sizeof(struct vmbus_channel_msginfo) + + msgsize = sizeof(struct vmbus_channel_msginfo) + sizeof(struct vmbus_channel_gpadl_body) + - pfnCurr * sizeof(u64); - msgBody = kzalloc(msgSize, GFP_KERNEL); + pfncurr * sizeof(u64); + msgbody = kzalloc(msgsize, GFP_KERNEL); /* FIXME: we probably need to more if this fails */ - if (!msgBody) + if (!msgbody) goto nomem; - msgBody->MessageSize = msgSize; - (*MessageCount)++; - gpadlBody = - (struct vmbus_channel_gpadl_body *)msgBody->Msg; + msgbody->MessageSize = msgsize; + (*messagecount)++; + gpadl_body = + (struct vmbus_channel_gpadl_body *)msgbody->Msg; /* * 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; + /* gpadl_body->Gpadl = kbuffer; */ + for (i = 0; i < pfncurr; i++) + gpadl_body->Pfn[i] = pfn + pfnsum + i; /* add to msg header */ - list_add_tail(&msgBody->MsgListEntry, - &msgHeader->SubMsgList); - pfnSum += pfnCurr; - pfnLeft -= pfnCurr; + list_add_tail(&msgbody->MsgListEntry, + &msgheader->SubMsgList); + pfnsum += pfncurr; + pfnleft -= pfncurr; } } else { /* everything fits in a header */ - msgSize = sizeof(struct vmbus_channel_msginfo) + + msgsize = sizeof(struct vmbus_channel_msginfo) + sizeof(struct vmbus_channel_gpadl_header) + - sizeof(struct gpa_range) + pageCount * sizeof(u64); - msgHeader = kzalloc(msgSize, GFP_KERNEL); - msgHeader->MessageSize = msgSize; - - gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg; - gpaHeader->RangeCount = 1; - gpaHeader->RangeBufLen = sizeof(struct gpa_range) + - pageCount * sizeof(u64); - gpaHeader->Range[0].ByteOffset = 0; - gpaHeader->Range[0].ByteCount = Size; - for (i = 0; i < pageCount; i++) - gpaHeader->Range[0].PfnArray[i] = pfn+i; - - *MsgInfo = msgHeader; - *MessageCount = 1; + sizeof(struct gpa_range) + pagecount * sizeof(u64); + msgheader = kzalloc(msgsize, GFP_KERNEL); + if (msgheader == NULL) + goto nomem; + msgheader->MessageSize = msgsize; + + gpadl_header = (struct vmbus_channel_gpadl_header *) + msgheader->Msg; + gpadl_header->RangeCount = 1; + gpadl_header->RangeBufLen = sizeof(struct gpa_range) + + pagecount * sizeof(u64); + gpadl_header->Range[0].ByteOffset = 0; + gpadl_header->Range[0].ByteCount = size; + for (i = 0; i < pagecount; i++) + gpadl_header->Range[0].PfnArray[i] = pfn+i; + + *msginfo = msgheader; + *messagecount = 1; } return 0; nomem: - kfree(msgHeader); - kfree(msgBody); + kfree(msgheader); + kfree(msgbody); return -ENOMEM; } /* - * VmbusChannelEstablishGpadl - Estabish a GPADL for the specified buffer + * vmbus_establish_gpadl - Estabish a GPADL for the specified buffer * - * @Channel: a channel - * @Kbuffer: from kmalloc - * @Size: page-size multiple - * @GpadlHandle: some funky thing + * @channel: a channel + * @kbuffer: from kmalloc + * @size: page-size multiple + * @gpadl_handle: some funky thing */ -int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer, - u32 Size, u32 *GpadlHandle) +int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, + u32 size, u32 *gpadl_handle) { - struct vmbus_channel_gpadl_header *gpadlMsg; - struct vmbus_channel_gpadl_body *gpadlBody; + struct vmbus_channel_gpadl_header *gpadlmsg; + struct vmbus_channel_gpadl_body *gpadl_body; /* struct vmbus_channel_gpadl_created *gpadlCreated; */ - struct vmbus_channel_msginfo *msgInfo = NULL; - struct vmbus_channel_msginfo *subMsgInfo; - u32 msgCount; + struct vmbus_channel_msginfo *msginfo = NULL; + struct vmbus_channel_msginfo *submsginfo; + u32 msgcount; struct list_head *curr; - u32 nextGpadlHandle; + u32 next_gpadl_handle; unsigned long flags; int ret = 0; - DPRINT_ENTER(VMBUS); - - nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle); + next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle); atomic_inc(&gVmbusConnection.NextGpadlHandle); - ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount); + ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount); if (ret) return ret; - msgInfo->WaitEvent = osd_WaitEventCreate(); - if (!msgInfo->WaitEvent) { + msginfo->WaitEvent = osd_WaitEventCreate(); + if (!msginfo->WaitEvent) { ret = -ENOMEM; goto Cleanup; } - gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg; - gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader; - gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId; - gpadlMsg->Gpadl = nextGpadlHandle; + gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg; + gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader; + gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId; + gpadlmsg->Gpadl = next_gpadl_handle; - DumpGpadlHeader(gpadlMsg); + dump_gpadl_header(gpadlmsg); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); - list_add_tail(&msgInfo->MsgListEntry, + list_add_tail(&msginfo->MsgListEntry, &gVmbusConnection.ChannelMsgList); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d", - Kbuffer, Size, msgCount); + kbuffer, size, msgcount); DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd", - msgInfo->MessageSize - sizeof(*msgInfo)); + msginfo->MessageSize - sizeof(*msginfo)); - ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize - - sizeof(*msgInfo)); + ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize - + sizeof(*msginfo)); if (ret != 0) { DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret); goto Cleanup; } - if (msgCount > 1) { - list_for_each(curr, &msgInfo->SubMsgList) { + if (msgcount > 1) { + list_for_each(curr, &msginfo->SubMsgList) { /* FIXME: should this use list_entry() instead ? */ - subMsgInfo = (struct vmbus_channel_msginfo *)curr; - gpadlBody = - (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg; + submsginfo = (struct vmbus_channel_msginfo *)curr; + gpadl_body = + (struct vmbus_channel_gpadl_body *)submsginfo->Msg; - gpadlBody->Header.MessageType = ChannelMessageGpadlBody; - gpadlBody->Gpadl = nextGpadlHandle; + gpadl_body->Header.MessageType = + ChannelMessageGpadlBody; + gpadl_body->Gpadl = next_gpadl_handle; DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd", - subMsgInfo->MessageSize - - sizeof(*subMsgInfo)); - - DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize - - sizeof(*subMsgInfo)); - ret = VmbusPostMessage(gpadlBody, - subMsgInfo->MessageSize - - sizeof(*subMsgInfo)); + submsginfo->MessageSize - + sizeof(*submsginfo)); + + dump_gpadl_body(gpadl_body, submsginfo->MessageSize - + sizeof(*submsginfo)); + ret = VmbusPostMessage(gpadl_body, + submsginfo->MessageSize - + sizeof(*submsginfo)); if (ret != 0) goto Cleanup; } } - osd_WaitEventWait(msgInfo->WaitEvent); + osd_WaitEventWait(msginfo->WaitEvent); /* 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, - gpadlMsg->Gpadl); + channel->OfferMsg.ChildRelId, + msginfo->Response.GpadlCreated.CreationStatus, + gpadlmsg->Gpadl); - *GpadlHandle = gpadlMsg->Gpadl; + *gpadl_handle = gpadlmsg->Gpadl; Cleanup: spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); - list_del(&msgInfo->MsgListEntry); + list_del(&msginfo->MsgListEntry); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); - kfree(msgInfo->WaitEvent); - kfree(msgInfo); - - DPRINT_EXIT(VMBUS); - + kfree(msginfo->WaitEvent); + kfree(msginfo); return ret; } +EXPORT_SYMBOL_GPL(vmbus_establish_gpadl); /* - * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle + * vmbus_teardown_gpadl -Teardown the specified GPADL handle */ -int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle) +int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) { struct vmbus_channel_gpadl_teardown *msg; struct vmbus_channel_msginfo *info; unsigned long flags; int ret; - DPRINT_ENTER(VMBUS); - - /* ASSERT(GpadlHandle != 0); */ + /* ASSERT(gpadl_handle != 0); */ info = kmalloc(sizeof(*info) + sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL); @@ -626,8 +613,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle) msg = (struct vmbus_channel_gpadl_teardown *)info->Msg; msg->Header.MessageType = ChannelMessageGpadlTeardown; - msg->ChildRelId = Channel->OfferMsg.ChildRelId; - msg->Gpadl = GpadlHandle; + msg->ChildRelId = channel->OfferMsg.ChildRelId; + msg->Gpadl = gpadl_handle; spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); list_add_tail(&info->MsgListEntry, @@ -650,27 +637,23 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle) kfree(info->WaitEvent); kfree(info); - - DPRINT_EXIT(VMBUS); - return ret; } +EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl); /* - * VmbusChannelClose - Close the specified channel + * vmbus_close - Close the specified channel */ -void VmbusChannelClose(struct vmbus_channel *Channel) +void vmbus_close(struct vmbus_channel *channel) { struct vmbus_channel_close_channel *msg; struct vmbus_channel_msginfo *info; unsigned long flags; int ret; - DPRINT_ENTER(VMBUS); - /* Stop callback and cancel the timer asap */ - Channel->OnChannelCallback = NULL; - del_timer_sync(&Channel->poll_timer); + channel->OnChannelCallback = NULL; + del_timer_sync(&channel->poll_timer); /* Send a closing message */ info = kmalloc(sizeof(*info) + @@ -684,7 +667,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel) msg = (struct vmbus_channel_close_channel *)info->Msg; msg->Header.MessageType = ChannelMessageCloseChannel; - msg->ChildRelId = Channel->OfferMsg.ChildRelId; + msg->ChildRelId = channel->OfferMsg.ChildRelId; ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel)); if (ret != 0) { @@ -693,17 +676,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel) } /* Tear down the gpadl for the channel's ring buffer */ - if (Channel->RingBufferGpadlHandle) - VmbusChannelTeardownGpadl(Channel, - Channel->RingBufferGpadlHandle); + if (channel->RingBufferGpadlHandle) + vmbus_teardown_gpadl(channel, + channel->RingBufferGpadlHandle); /* TODO: Send a msg to release the childRelId */ /* Cleanup the ring buffers for this channel */ - RingBufferCleanup(&Channel->Outbound); - RingBufferCleanup(&Channel->Inbound); + RingBufferCleanup(&channel->Outbound); + RingBufferCleanup(&channel->Inbound); - osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount); + osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount); kfree(info); @@ -713,369 +696,349 @@ void VmbusChannelClose(struct vmbus_channel *Channel) * caller will free the channel */ - if (Channel->State == CHANNEL_OPEN_STATE) { + if (channel->State == CHANNEL_OPEN_STATE) { spin_lock_irqsave(&gVmbusConnection.channel_lock, flags); - list_del(&Channel->ListEntry); + list_del(&channel->ListEntry); spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags); - FreeVmbusChannel(Channel); + free_channel(channel); } - - DPRINT_EXIT(VMBUS); } +EXPORT_SYMBOL_GPL(vmbus_close); /** - * VmbusChannelSendPacket() - Send the specified buffer on the given channel - * @Channel: Pointer to vmbus_channel structure. - * @Buffer: Pointer to the buffer you want to receive the data into. - * @BufferLen: Maximum size of what the the buffer will hold - * @RequestId: Identifier of the request - * @vmbus_packet_type: Type of packet that is being send e.g. negotiate, time + * vmbus_sendpacket() - Send the specified buffer on the given channel + * @channel: Pointer to vmbus_channel structure. + * @buffer: Pointer to the buffer you want to receive the data into. + * @bufferlen: Maximum size of what the the buffer will hold + * @requestid: Identifier of the request + * @type: Type of packet that is being send e.g. negotiate, time * packet etc. * - * Sends data in @Buffer directly to hyper-v via the vmbus + * Sends data in @buffer directly to hyper-v via the vmbus * This will send the data unparsed to hyper-v. * * Mainly used by Hyper-V drivers. */ -int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer, - u32 BufferLen, u64 RequestId, - enum vmbus_packet_type Type, u32 Flags) +int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer, + u32 bufferlen, u64 requestid, + enum vmbus_packet_type type, u32 flags) { struct vmpacket_descriptor desc; - u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen; - u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64)); - struct scatterlist bufferList[3]; - u64 alignedData = 0; + u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen; + u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64)); + struct scatterlist bufferlist[3]; + u64 aligned_data = 0; int ret; - DPRINT_ENTER(VMBUS); DPRINT_DBG(VMBUS, "channel %p buffer %p len %d", - Channel, Buffer, BufferLen); + channel, buffer, bufferlen); - DumpVmbusChannel(Channel); + dump_vmbus_channel(channel); /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */ /* Setup the descriptor */ - desc.Type = Type; /* VmbusPacketTypeDataInBand; */ - desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */ + desc.Type = type; /* VmbusPacketTypeDataInBand; */ + desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */ /* in 8-bytes granularity */ desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3; - desc.Length8 = (u16)(packetLenAligned >> 3); - desc.TransactionId = RequestId; + desc.Length8 = (u16)(packetlen_aligned >> 3); + desc.TransactionId = requestid; - sg_init_table(bufferList, 3); - sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor)); - sg_set_buf(&bufferList[1], Buffer, BufferLen); - sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen); + sg_init_table(bufferlist, 3); + sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor)); + sg_set_buf(&bufferlist[1], buffer, bufferlen); + sg_set_buf(&bufferlist[2], &aligned_data, + packetlen_aligned - packetlen); - ret = RingBufferWrite(&Channel->Outbound, bufferList, 3); + ret = RingBufferWrite(&channel->Outbound, bufferlist, 3); /* TODO: We should determine if this is optional */ - if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound)) - VmbusChannelSetEvent(Channel); - - DPRINT_EXIT(VMBUS); + if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound)) + vmbus_setevent(channel); return ret; } -EXPORT_SYMBOL(VmbusChannelSendPacket); +EXPORT_SYMBOL(vmbus_sendpacket); /* - * VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer + * vmbus_sendpacket_pagebuffer - Send a range of single-page buffer * packets using a GPADL Direct packet type. */ -int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel, - struct hv_page_buffer PageBuffers[], - u32 PageCount, void *Buffer, u32 BufferLen, - u64 RequestId) +int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, + struct hv_page_buffer pagebuffers[], + u32 pagecount, void *buffer, u32 bufferlen, + u64 requestid) { int ret; int i; - struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER desc; - u32 descSize; - u32 packetLen; - u32 packetLenAligned; - struct scatterlist bufferList[3]; - u64 alignedData = 0; - - DPRINT_ENTER(VMBUS); - - if (PageCount > MAX_PAGE_BUFFER_COUNT) + struct vmbus_channel_packet_page_buffer desc; + u32 descsize; + u32 packetlen; + u32 packetlen_aligned; + struct scatterlist bufferlist[3]; + u64 aligned_data = 0; + + if (pagecount > MAX_PAGE_BUFFER_COUNT) return -EINVAL; - DumpVmbusChannel(Channel); + dump_vmbus_channel(channel); /* - * Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the + * Adjust the size down since vmbus_channel_packet_page_buffer is the * largest size we support */ - descSize = sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER) - - ((MAX_PAGE_BUFFER_COUNT - PageCount) * + descsize = sizeof(struct vmbus_channel_packet_page_buffer) - + ((MAX_PAGE_BUFFER_COUNT - pagecount) * sizeof(struct hv_page_buffer)); - packetLen = descSize + BufferLen; - packetLenAligned = ALIGN_UP(packetLen, sizeof(u64)); + packetlen = descsize + bufferlen; + packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64)); /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */ /* 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.RangeCount = PageCount; - - for (i = 0; i < PageCount; i++) { - desc.Range[i].Length = PageBuffers[i].Length; - desc.Range[i].Offset = PageBuffers[i].Offset; - desc.Range[i].Pfn = PageBuffers[i].Pfn; + desc.type = VmbusPacketTypeDataUsingGpaDirect; + desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; + desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */ + desc.length8 = (u16)(packetlen_aligned >> 3); + desc.transactionid = requestid; + desc.rangecount = pagecount; + + for (i = 0; i < pagecount; i++) { + desc.range[i].Length = pagebuffers[i].Length; + desc.range[i].Offset = pagebuffers[i].Offset; + desc.range[i].Pfn = pagebuffers[i].Pfn; } - sg_init_table(bufferList, 3); - sg_set_buf(&bufferList[0], &desc, descSize); - sg_set_buf(&bufferList[1], Buffer, BufferLen); - sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen); + sg_init_table(bufferlist, 3); + sg_set_buf(&bufferlist[0], &desc, descsize); + sg_set_buf(&bufferlist[1], buffer, bufferlen); + sg_set_buf(&bufferlist[2], &aligned_data, + packetlen_aligned - packetlen); - ret = RingBufferWrite(&Channel->Outbound, bufferList, 3); + ret = RingBufferWrite(&channel->Outbound, bufferlist, 3); /* TODO: We should determine if this is optional */ - if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound)) - VmbusChannelSetEvent(Channel); - - DPRINT_EXIT(VMBUS); + if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound)) + vmbus_setevent(channel); return ret; } +EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer); /* - * VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet + * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet * using a GPADL Direct packet type. */ -int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel, - struct hv_multipage_buffer *MultiPageBuffer, - void *Buffer, u32 BufferLen, u64 RequestId) +int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel, + struct hv_multipage_buffer *multi_pagebuffer, + void *buffer, u32 bufferlen, u64 requestid) { int ret; - struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER desc; - u32 descSize; - u32 packetLen; - u32 packetLenAligned; - struct scatterlist bufferList[3]; - u64 alignedData = 0; - u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, - MultiPageBuffer->Length); - - DPRINT_ENTER(VMBUS); + struct vmbus_channel_packet_multipage_buffer desc; + u32 descsize; + u32 packetlen; + u32 packetlen_aligned; + struct scatterlist bufferlist[3]; + u64 aligned_data = 0; + u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset, + multi_pagebuffer->Length); - DumpVmbusChannel(Channel); + dump_vmbus_channel(channel); DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u", - MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount); + multi_pagebuffer->Offset, + multi_pagebuffer->Length, pfncount); - if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT)) + if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT)) return -EINVAL; /* - * Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is + * Adjust the size down since vmbus_channel_packet_multipage_buffer is * the largest size we support */ - descSize = sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER) - - ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) * + descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) - + ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) * sizeof(u64)); - packetLen = descSize + BufferLen; - packetLenAligned = ALIGN_UP(packetLen, sizeof(u64)); + packetlen = descsize + bufferlen; + packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64)); /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */ /* 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.RangeCount = 1; + desc.type = VmbusPacketTypeDataUsingGpaDirect; + desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; + desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */ + desc.length8 = (u16)(packetlen_aligned >> 3); + desc.transactionid = requestid; + desc.rangecount = 1; - desc.Range.Length = MultiPageBuffer->Length; - desc.Range.Offset = MultiPageBuffer->Offset; + desc.range.Length = multi_pagebuffer->Length; + desc.range.Offset = multi_pagebuffer->Offset; - memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, - PfnCount * sizeof(u64)); + memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray, + pfncount * sizeof(u64)); - sg_init_table(bufferList, 3); - sg_set_buf(&bufferList[0], &desc, descSize); - sg_set_buf(&bufferList[1], Buffer, BufferLen); - sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen); + sg_init_table(bufferlist, 3); + sg_set_buf(&bufferlist[0], &desc, descsize); + sg_set_buf(&bufferlist[1], buffer, bufferlen); + sg_set_buf(&bufferlist[2], &aligned_data, + packetlen_aligned - packetlen); - ret = RingBufferWrite(&Channel->Outbound, bufferList, 3); + ret = RingBufferWrite(&channel->Outbound, bufferlist, 3); /* TODO: We should determine if this is optional */ - if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound)) - VmbusChannelSetEvent(Channel); - - DPRINT_EXIT(VMBUS); + if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound)) + vmbus_setevent(channel); return ret; } - +EXPORT_SYMBOL_GPL(vmbus_sendpacket_multipagebuffer); /** - * VmbusChannelRecvPacket() - Retrieve the user packet on the specified channel - * @Channel: Pointer to vmbus_channel structure. - * @Buffer: Pointer to the buffer you want to receive the data into. - * @BufferLen: Maximum size of what the the buffer will hold - * @BufferActualLen: The actual size of the data after it was received - * @RequestId: Identifier of the request + * vmbus_recvpacket() - Retrieve the user packet on the specified channel + * @channel: Pointer to vmbus_channel structure. + * @buffer: Pointer to the buffer you want to receive the data into. + * @bufferlen: Maximum size of what the the buffer will hold + * @buffer_actual_len: The actual size of the data after it was received + * @requestid: Identifier of the request * * Receives directly from the hyper-v vmbus and puts the data it received * into Buffer. This will receive the data unparsed from hyper-v. * * Mainly used by Hyper-V drivers. */ -int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer, - u32 BufferLen, u32 *BufferActualLen, u64 *RequestId) +int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, + u32 bufferlen, u32 *buffer_actual_len, u64 *requestid) { struct vmpacket_descriptor desc; - u32 packetLen; - u32 userLen; + u32 packetlen; + u32 userlen; int ret; unsigned long flags; - DPRINT_ENTER(VMBUS); + *buffer_actual_len = 0; + *requestid = 0; - *BufferActualLen = 0; - *RequestId = 0; + spin_lock_irqsave(&channel->inbound_lock, flags); - spin_lock_irqsave(&Channel->inbound_lock, flags); - - ret = RingBufferPeek(&Channel->Inbound, &desc, + ret = RingBufferPeek(&channel->Inbound, &desc, sizeof(struct vmpacket_descriptor)); if (ret != 0) { - spin_unlock_irqrestore(&Channel->inbound_lock, flags); + spin_unlock_irqrestore(&channel->inbound_lock, flags); /* DPRINT_DBG(VMBUS, "nothing to read!!"); */ - DPRINT_EXIT(VMBUS); return 0; } /* VmbusChannelClearEvent(Channel); */ - packetLen = desc.Length8 << 3; - userLen = packetLen - (desc.DataOffset8 << 3); + packetlen = desc.Length8 << 3; + userlen = packetlen - (desc.DataOffset8 << 3); /* ASSERT(userLen > 0); */ DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d " "flag %d tid %llx pktlen %d datalen %d> ", - Channel, Channel->OfferMsg.ChildRelId, desc.Type, - desc.Flags, desc.TransactionId, packetLen, userLen); + channel, channel->OfferMsg.ChildRelId, desc.Type, + desc.Flags, desc.TransactionId, packetlen, userlen); - *BufferActualLen = userLen; + *buffer_actual_len = userlen; - if (userLen > BufferLen) { - spin_unlock_irqrestore(&Channel->inbound_lock, flags); + if (userlen > bufferlen) { + spin_unlock_irqrestore(&channel->inbound_lock, flags); DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d", - BufferLen, userLen); - DPRINT_EXIT(VMBUS); - + bufferlen, userlen); return -1; } - *RequestId = desc.TransactionId; + *requestid = desc.TransactionId; /* Copy over the packet to the user buffer */ - ret = RingBufferRead(&Channel->Inbound, Buffer, userLen, + ret = RingBufferRead(&channel->Inbound, buffer, userlen, (desc.DataOffset8 << 3)); - spin_unlock_irqrestore(&Channel->inbound_lock, flags); - - DPRINT_EXIT(VMBUS); + spin_unlock_irqrestore(&channel->inbound_lock, flags); return 0; } -EXPORT_SYMBOL(VmbusChannelRecvPacket); +EXPORT_SYMBOL(vmbus_recvpacket); /* - * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel + * vmbus_recvpacket_raw - Retrieve the raw packet on the specified channel */ -int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer, - u32 BufferLen, u32 *BufferActualLen, - u64 *RequestId) +int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, + u32 bufferlen, u32 *buffer_actual_len, + u64 *requestid) { struct vmpacket_descriptor desc; - u32 packetLen; - u32 userLen; + u32 packetlen; + u32 userlen; int ret; unsigned long flags; - DPRINT_ENTER(VMBUS); - - *BufferActualLen = 0; - *RequestId = 0; + *buffer_actual_len = 0; + *requestid = 0; - spin_lock_irqsave(&Channel->inbound_lock, flags); + spin_lock_irqsave(&channel->inbound_lock, flags); - ret = RingBufferPeek(&Channel->Inbound, &desc, + ret = RingBufferPeek(&channel->Inbound, &desc, sizeof(struct vmpacket_descriptor)); if (ret != 0) { - spin_unlock_irqrestore(&Channel->inbound_lock, flags); + spin_unlock_irqrestore(&channel->inbound_lock, flags); /* DPRINT_DBG(VMBUS, "nothing to read!!"); */ - DPRINT_EXIT(VMBUS); return 0; } /* VmbusChannelClearEvent(Channel); */ - packetLen = desc.Length8 << 3; - userLen = packetLen - (desc.DataOffset8 << 3); + packetlen = desc.Length8 << 3; + userlen = packetlen - (desc.DataOffset8 << 3); DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d " "flag %d tid %llx pktlen %d datalen %d> ", - Channel, Channel->OfferMsg.ChildRelId, desc.Type, - desc.Flags, desc.TransactionId, packetLen, userLen); + channel, channel->OfferMsg.ChildRelId, desc.Type, + desc.Flags, desc.TransactionId, packetlen, userlen); - *BufferActualLen = packetLen; + *buffer_actual_len = packetlen; - if (packetLen > BufferLen) { - spin_unlock_irqrestore(&Channel->inbound_lock, flags); + if (packetlen > bufferlen) { + spin_unlock_irqrestore(&channel->inbound_lock, flags); DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but " - "got space for only %d bytes", packetLen, BufferLen); - DPRINT_EXIT(VMBUS); + "got space for only %d bytes", packetlen, bufferlen); return -2; } - *RequestId = desc.TransactionId; + *requestid = desc.TransactionId; /* Copy over the entire packet to the user buffer */ - ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0); - - spin_unlock_irqrestore(&Channel->inbound_lock, flags); - - DPRINT_EXIT(VMBUS); + ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0); + spin_unlock_irqrestore(&channel->inbound_lock, flags); return 0; } +EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); /* - * VmbusChannelOnChannelEvent - Channel event callback + * vmbus_onchannel_event - Channel event callback */ -void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel) +void vmbus_onchannel_event(struct vmbus_channel *channel) { - DumpVmbusChannel(Channel); + dump_vmbus_channel(channel); /* ASSERT(Channel->OnChannelCallback); */ - Channel->OnChannelCallback(Channel->ChannelCallbackContext); + channel->OnChannelCallback(channel->ChannelCallbackContext); - mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100)); + mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100)); } /* - * VmbusChannelOnTimer - Timer event callback + * vmbus_ontimer - Timer event callback */ -void VmbusChannelOnTimer(unsigned long data) +void vmbus_ontimer(unsigned long data) { struct vmbus_channel *channel = (struct vmbus_channel *)data; @@ -1084,11 +1047,11 @@ void VmbusChannelOnTimer(unsigned long data) } /* - * DumpVmbusChannel - Dump vmbus channel info to the console + * dump_vmbus_channel- Dump vmbus channel info to the console */ -static void DumpVmbusChannel(struct vmbus_channel *Channel) +static void dump_vmbus_channel(struct vmbus_channel *channel) { - DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId); - DumpRingInfo(&Channel->Outbound, "Outbound "); - DumpRingInfo(&Channel->Inbound, "Inbound "); + DPRINT_DBG(VMBUS, "Channel (%d)", channel->OfferMsg.ChildRelId); + DumpRingInfo(&channel->Outbound, "Outbound "); + DumpRingInfo(&channel->Inbound, "Inbound "); } diff --git a/drivers/staging/hv/channel.h b/drivers/staging/hv/channel.h index acb2c556369b..7997056734d7 100644 --- a/drivers/staging/hv/channel.h +++ b/drivers/staging/hv/channel.h @@ -28,85 +28,85 @@ #include "channel_mgmt.h" /* The format must be the same as struct vmdata_gpa_direct */ -struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER { - u16 Type; - u16 DataOffset8; - u16 Length8; - u16 Flags; - u64 TransactionId; - u32 Reserved; - u32 RangeCount; - struct hv_page_buffer Range[MAX_PAGE_BUFFER_COUNT]; +struct vmbus_channel_packet_page_buffer { + u16 type; + u16 dataoffset8; + u16 length8; + u16 flags; + u64 transactionid; + u32 reserved; + u32 rangecount; + struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT]; } __attribute__((packed)); /* The format must be the same as struct vmdata_gpa_direct */ -struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER { - u16 Type; - u16 DataOffset8; - u16 Length8; - u16 Flags; - u64 TransactionId; - u32 Reserved; - u32 RangeCount; /* Always 1 in this case */ - struct hv_multipage_buffer Range; +struct vmbus_channel_packet_multipage_buffer { + u16 type; + u16 dataoffset8; + u16 length8; + u16 flags; + u64 transactionid; + u32 reserved; + u32 rangecount; /* Always 1 in this case */ + struct hv_multipage_buffer range; } __attribute__((packed)); -extern int VmbusChannelOpen(struct vmbus_channel *channel, - u32 SendRingBufferSize, - u32 RecvRingBufferSize, - void *UserData, - u32 UserDataLen, - void(*OnChannelCallback)(void *context), - void *Context); +extern int vmbus_open(struct vmbus_channel *channel, + u32 send_ringbuffersize, + u32 recv_ringbuffersize, + void *userdata, + u32 userdatalen, + void(*onchannel_callback)(void *context), + void *context); -extern void VmbusChannelClose(struct vmbus_channel *channel); +extern void vmbus_close(struct vmbus_channel *channel); -extern int VmbusChannelSendPacket(struct vmbus_channel *channel, - const void *Buffer, - u32 BufferLen, - u64 RequestId, - enum vmbus_packet_type Type, - u32 Flags); +extern int vmbus_sendpacket(struct vmbus_channel *channel, + const void *buffer, + u32 bufferLen, + u64 requestid, + enum vmbus_packet_type type, + u32 flags); -extern int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel, - struct hv_page_buffer PageBuffers[], - u32 PageCount, - void *Buffer, - u32 BufferLen, - u64 RequestId); +extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, + struct hv_page_buffer pagebuffers[], + u32 pagecount, + void *buffer, + u32 bufferlen, + u64 requestid); -extern int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel, +extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel, struct hv_multipage_buffer *mpb, - void *Buffer, - u32 BufferLen, - u64 RequestId); + void *buffer, + u32 bufferlen, + u64 requestid); -extern int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, - void *Kbuffer, - u32 Size, - u32 *GpadlHandle); +extern int vmbus_establish_gpadl(struct vmbus_channel *channel, + void *kbuffer, + u32 size, + u32 *gpadl_handle); -extern int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, - u32 GpadlHandle); +extern int vmbus_teardown_gpadl(struct vmbus_channel *channel, + u32 gpadl_handle); -extern int VmbusChannelRecvPacket(struct vmbus_channel *channel, - void *Buffer, - u32 BufferLen, - u32 *BufferActualLen, - u64 *RequestId); +extern int vmbus_recvpacket(struct vmbus_channel *channel, + void *buffer, + u32 bufferlen, + u32 *buffer_actual_len, + u64 *requestid); -extern int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel, - void *Buffer, - u32 BufferLen, - u32 *BufferActualLen, - u64 *RequestId); +extern int vmbus_recvpacket_raw(struct vmbus_channel *channel, + void *buffer, + u32 bufferlen, + u32 *buffer_actual_len, + u64 *requestid); -extern void VmbusChannelOnChannelEvent(struct vmbus_channel *channel); +extern void vmbus_onchannel_event(struct vmbus_channel *channel); -extern void VmbusChannelGetDebugInfo(struct vmbus_channel *channel, +extern void vmbus_get_debug_info(struct vmbus_channel *channel, struct vmbus_channel_debug_info *debug); -extern void VmbusChannelOnTimer(unsigned long data); +extern void vmbus_ontimer(unsigned long data); #endif /* _CHANNEL_H_ */ diff --git a/drivers/staging/hv/channel_interface.c b/drivers/staging/hv/channel_interface.c deleted file mode 100644 index d9f51ac75eaa..000000000000 --- a/drivers/staging/hv/channel_interface.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * - * Copyright (c) 2009, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang <haiyangz@microsoft.com> - * Hank Janssen <hjanssen@microsoft.com> - * - */ -#include <linux/kernel.h> -#include <linux/mm.h> -#include "osd.h" -#include "vmbus_private.h" - -static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize, - u32 RecvRingBufferSize, void *UserData, - u32 UserDataLen, - void (*ChannelCallback)(void *context), - void *Context) -{ - return VmbusChannelOpen(device->context, SendBufferSize, - RecvRingBufferSize, UserData, UserDataLen, - ChannelCallback, Context); -} - -static void IVmbusChannelClose(struct hv_device *device) -{ - VmbusChannelClose(device->context); -} - -static int IVmbusChannelSendPacket(struct hv_device *device, const void *Buffer, - u32 BufferLen, u64 RequestId, u32 Type, - u32 Flags) -{ - return VmbusChannelSendPacket(device->context, Buffer, BufferLen, - RequestId, Type, Flags); -} - -static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device, - struct hv_page_buffer PageBuffers[], - u32 PageCount, void *Buffer, - u32 BufferLen, u64 RequestId) -{ - return VmbusChannelSendPacketPageBuffer(device->context, PageBuffers, - PageCount, Buffer, BufferLen, - RequestId); -} - -static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device, - struct hv_multipage_buffer *MultiPageBuffer, - void *Buffer, u32 BufferLen, u64 RequestId) -{ - return VmbusChannelSendPacketMultiPageBuffer(device->context, - MultiPageBuffer, Buffer, - BufferLen, RequestId); -} - -static int IVmbusChannelRecvPacket(struct hv_device *device, void *Buffer, - u32 BufferLen, u32 *BufferActualLen, - u64 *RequestId) -{ - return VmbusChannelRecvPacket(device->context, Buffer, BufferLen, - BufferActualLen, RequestId); -} - -static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *Buffer, - u32 BufferLen, u32 *BufferActualLen, - u64 *RequestId) -{ - return VmbusChannelRecvPacketRaw(device->context, Buffer, BufferLen, - BufferActualLen, RequestId); -} - -static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *Buffer, - u32 BufferLen, u32 *GpadlHandle) -{ - return VmbusChannelEstablishGpadl(device->context, Buffer, BufferLen, - GpadlHandle); -} - -static int IVmbusChannelTeardownGpadl(struct hv_device *device, u32 GpadlHandle) -{ - return VmbusChannelTeardownGpadl(device->context, GpadlHandle); - -} - -void GetChannelInterface(struct vmbus_channel_interface *iface) -{ - iface->Open = IVmbusChannelOpen; - iface->Close = IVmbusChannelClose; - iface->SendPacket = IVmbusChannelSendPacket; - iface->SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer; - iface->SendPacketMultiPageBuffer = - IVmbusChannelSendPacketMultiPageBuffer; - iface->RecvPacket = IVmbusChannelRecvPacket; - iface->RecvPacketRaw = IVmbusChannelRecvPacketRaw; - iface->EstablishGpadl = IVmbusChannelEstablishGpadl; - iface->TeardownGpadl = IVmbusChannelTeardownGpadl; - iface->GetInfo = GetChannelInfo; -} - -void GetChannelInfo(struct hv_device *device, struct hv_device_info *info) -{ - struct vmbus_channel_debug_info debugInfo; - - if (!device->context) - return; - - VmbusChannelGetDebugInfo(device->context, &debugInfo); - - info->ChannelId = debugInfo.RelId; - info->ChannelState = debugInfo.State; - memcpy(&info->ChannelType, &debugInfo.InterfaceType, - sizeof(struct hv_guid)); - memcpy(&info->ChannelInstance, &debugInfo.InterfaceInstance, - sizeof(struct hv_guid)); - - info->MonitorId = debugInfo.MonitorId; - - info->ServerMonitorPending = debugInfo.ServerMonitorPending; - info->ServerMonitorLatency = debugInfo.ServerMonitorLatency; - info->ServerMonitorConnectionId = debugInfo.ServerMonitorConnectionId; - - info->ClientMonitorPending = debugInfo.ClientMonitorPending; - info->ClientMonitorLatency = debugInfo.ClientMonitorLatency; - info->ClientMonitorConnectionId = debugInfo.ClientMonitorConnectionId; - - info->Inbound.InterruptMask = debugInfo.Inbound.CurrentInterruptMask; - info->Inbound.ReadIndex = debugInfo.Inbound.CurrentReadIndex; - info->Inbound.WriteIndex = debugInfo.Inbound.CurrentWriteIndex; - info->Inbound.BytesAvailToRead = debugInfo.Inbound.BytesAvailToRead; - info->Inbound.BytesAvailToWrite = debugInfo.Inbound.BytesAvailToWrite; - - info->Outbound.InterruptMask = debugInfo.Outbound.CurrentInterruptMask; - info->Outbound.ReadIndex = debugInfo.Outbound.CurrentReadIndex; - info->Outbound.WriteIndex = debugInfo.Outbound.CurrentWriteIndex; - info->Outbound.BytesAvailToRead = debugInfo.Outbound.BytesAvailToRead; - info->Outbound.BytesAvailToWrite = debugInfo.Outbound.BytesAvailToWrite; -} diff --git a/drivers/staging/hv/channel_interface.h b/drivers/staging/hv/channel_interface.h deleted file mode 100644 index 6acaf6ce2c48..000000000000 --- a/drivers/staging/hv/channel_interface.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Copyright (c) 2009, Microsoft Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - * - * Authors: - * Haiyang Zhang <haiyangz@microsoft.com> - * Hank Janssen <hjanssen@microsoft.com> - * - */ - - -#ifndef _CHANNEL_INTERFACE_H_ -#define _CHANNEL_INTERFACE_H_ - -#include "vmbus_api.h" - -void GetChannelInterface(struct vmbus_channel_interface *ChannelInterface); - -void GetChannelInfo(struct hv_device *Device, - struct hv_device_info *DeviceInfo); - -#endif /* _CHANNEL_INTERFACE_H_ */ diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 12db555a3a5d..45dbe305afed 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -172,7 +172,7 @@ void chn_cb_negotiate(void *context) buflen = PAGE_SIZE; buf = kmalloc(buflen, GFP_ATOMIC); - VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid); + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid); if (recvlen > 0) { icmsghdrp = (struct icmsg_hdr *)&buf[ @@ -183,7 +183,7 @@ void chn_cb_negotiate(void *context) icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; - VmbusChannelSendPacket(channel, buf, + vmbus_sendpacket(channel, buf, recvlen, requestid, VmbusPacketTypeDataInBand, 0); } @@ -235,9 +235,9 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { EXPORT_SYMBOL(hv_cb_utils); /* - * AllocVmbusChannel - Allocate and initialize a vmbus channel object + * alloc_channel - Allocate and initialize a vmbus channel object */ -struct vmbus_channel *AllocVmbusChannel(void) +static struct vmbus_channel *alloc_channel(void) { struct vmbus_channel *channel; @@ -249,7 +249,7 @@ struct vmbus_channel *AllocVmbusChannel(void) init_timer(&channel->poll_timer); channel->poll_timer.data = (unsigned long)channel; - channel->poll_timer.function = VmbusChannelOnTimer; + channel->poll_timer.function = vmbus_ontimer; channel->ControlWQ = create_workqueue("hv_vmbus_ctl"); if (!channel->ControlWQ) { @@ -261,37 +261,33 @@ struct vmbus_channel *AllocVmbusChannel(void) } /* - * ReleaseVmbusChannel - Release the vmbus channel object itself + * release_hannel - Release the vmbus channel object itself */ -static inline void ReleaseVmbusChannel(void *context) +static inline void release_channel(void *context) { struct vmbus_channel *channel = context; - DPRINT_ENTER(VMBUS); - DPRINT_DBG(VMBUS, "releasing channel (%p)", channel); destroy_workqueue(channel->ControlWQ); DPRINT_DBG(VMBUS, "channel released (%p)", channel); kfree(channel); - - DPRINT_EXIT(VMBUS); } /* - * FreeVmbusChannel - Release the resources used by the vmbus channel object + * free_channel - Release the resources used by the vmbus channel object */ -void FreeVmbusChannel(struct vmbus_channel *Channel) +void free_channel(struct vmbus_channel *channel) { - del_timer_sync(&Channel->poll_timer); + del_timer_sync(&channel->poll_timer); /* * We have to release the channel's workqueue/thread in the vmbus's * workqueue/thread context * ie we can't destroy ourselves. */ - osd_schedule_callback(gVmbusConnection.WorkQueue, ReleaseVmbusChannel, - Channel); + osd_schedule_callback(gVmbusConnection.WorkQueue, release_channel, + channel); } @@ -314,46 +310,43 @@ static void count_hv_channel(void) /* - * VmbusChannelProcessOffer - Process the offer by creating a channel/device + * vmbus_process_offer - Process the offer by creating a channel/device * associated with this offer */ -static void VmbusChannelProcessOffer(void *context) +static void vmbus_process_offer(void *context) { - struct vmbus_channel *newChannel = context; + struct vmbus_channel *newchannel = context; struct vmbus_channel *channel; - bool fNew = true; + bool fnew = true; int ret; int cnt; unsigned long flags; - DPRINT_ENTER(VMBUS); - /* Make sure this is a new offer */ spin_lock_irqsave(&gVmbusConnection.channel_lock, flags); list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) { if (!memcmp(&channel->OfferMsg.Offer.InterfaceType, - &newChannel->OfferMsg.Offer.InterfaceType, + &newchannel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid)) && !memcmp(&channel->OfferMsg.Offer.InterfaceInstance, - &newChannel->OfferMsg.Offer.InterfaceInstance, + &newchannel->OfferMsg.Offer.InterfaceInstance, sizeof(struct hv_guid))) { - fNew = false; + fnew = false; break; } } - if (fNew) - list_add_tail(&newChannel->ListEntry, + if (fnew) + list_add_tail(&newchannel->ListEntry, &gVmbusConnection.ChannelList); spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags); - if (!fNew) { + if (!fnew) { DPRINT_DBG(VMBUS, "Ignoring duplicate offer for relid (%d)", - newChannel->OfferMsg.ChildRelId); - FreeVmbusChannel(newChannel); - DPRINT_EXIT(VMBUS); + newchannel->OfferMsg.ChildRelId); + free_channel(newchannel); return; } @@ -362,105 +355,100 @@ static void VmbusChannelProcessOffer(void *context) * We need to set the DeviceObject field before calling * VmbusChildDeviceAdd() */ - newChannel->DeviceObject = VmbusChildDeviceCreate( - &newChannel->OfferMsg.Offer.InterfaceType, - &newChannel->OfferMsg.Offer.InterfaceInstance, - newChannel); + newchannel->DeviceObject = VmbusChildDeviceCreate( + &newchannel->OfferMsg.Offer.InterfaceType, + &newchannel->OfferMsg.Offer.InterfaceInstance, + newchannel); DPRINT_DBG(VMBUS, "child device object allocated - %p", - newChannel->DeviceObject); + 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. */ - ret = VmbusChildDeviceAdd(newChannel->DeviceObject); + ret = VmbusChildDeviceAdd(newchannel->DeviceObject); if (ret != 0) { DPRINT_ERR(VMBUS, "unable to add child device object (relid %d)", - newChannel->OfferMsg.ChildRelId); + newchannel->OfferMsg.ChildRelId); spin_lock_irqsave(&gVmbusConnection.channel_lock, flags); - list_del(&newChannel->ListEntry); + list_del(&newchannel->ListEntry); spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags); - FreeVmbusChannel(newChannel); + free_channel(newchannel); } else { /* * 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; + newchannel->State = CHANNEL_OPEN_STATE; /* Open IC channels */ for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) { - if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType, + if (memcmp(&newchannel->OfferMsg.Offer.InterfaceType, &hv_cb_utils[cnt].data, sizeof(struct hv_guid)) == 0 && - VmbusChannelOpen(newChannel, 2 * PAGE_SIZE, + vmbus_open(newchannel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0, hv_cb_utils[cnt].callback, - newChannel) == 0) { - hv_cb_utils[cnt].channel = newChannel; + newchannel) == 0) { + hv_cb_utils[cnt].channel = newchannel; DPRINT_INFO(VMBUS, "%s", hv_cb_utils[cnt].log_msg); count_hv_channel(); } } } - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelProcessRescindOffer - Rescind the offer by initiating a device removal + * vmbus_process_rescind_offer - + * Rescind the offer by initiating a device removal */ -static void VmbusChannelProcessRescindOffer(void *context) +static void vmbus_process_rescind_offer(void *context) { struct vmbus_channel *channel = context; - DPRINT_ENTER(VMBUS); VmbusChildDeviceRemove(channel->DeviceObject); - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnOffer - Handler for channel offers from vmbus in parent partition. + * vmbus_onoffer - Handler for channel offers from vmbus in parent partition. * * We ignore all offers except network and storage offers. For each network and * storage offers, we create a channel object and queue a work item to the * channel object to process the offer synchronously */ -static void VmbusChannelOnOffer(struct vmbus_channel_message_header *hdr) +static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) { struct vmbus_channel_offer_channel *offer; - struct vmbus_channel *newChannel; - struct hv_guid *guidType; - struct hv_guid *guidInstance; + struct vmbus_channel *newchannel; + struct hv_guid *guidtype; + struct hv_guid *guidinstance; int i; - int fSupported = 0; - - DPRINT_ENTER(VMBUS); + int fsupported = 0; offer = (struct vmbus_channel_offer_channel *)hdr; for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) { if (memcmp(&offer->Offer.InterfaceType, &gSupportedDeviceClasses[i], sizeof(struct hv_guid)) == 0) { - fSupported = 1; + fsupported = 1; break; } } - if (!fSupported) { + if (!fsupported) { DPRINT_DBG(VMBUS, "Ignoring channel offer notification for " "child relid %d", offer->ChildRelId); - DPRINT_EXIT(VMBUS); return; } - guidType = &offer->Offer.InterfaceType; - guidInstance = &offer->Offer.InterfaceInstance; + guidtype = &offer->Offer.InterfaceType; + guidinstance = &offer->Offer.InterfaceInstance; DPRINT_INFO(VMBUS, "Channel offer notification - " "child relid %d monitor id %d allocated %d, " @@ -470,56 +458,52 @@ static void VmbusChannelOnOffer(struct vmbus_channel_message_header *hdr) "%02x%02x%02x%02x%02x%02x%02x%02x}", offer->ChildRelId, offer->MonitorId, offer->MonitorAllocated, - 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]); + 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. */ - newChannel = AllocVmbusChannel(); - if (!newChannel) { + newchannel = alloc_channel(); + if (!newchannel) { DPRINT_ERR(VMBUS, "unable to allocate channel object"); return; } - DPRINT_DBG(VMBUS, "channel object allocated - %p", newChannel); + DPRINT_DBG(VMBUS, "channel object allocated - %p", newchannel); - memcpy(&newChannel->OfferMsg, offer, + memcpy(&newchannel->OfferMsg, offer, sizeof(struct vmbus_channel_offer_channel)); - newChannel->MonitorGroup = (u8)offer->MonitorId / 32; - newChannel->MonitorBit = (u8)offer->MonitorId % 32; + newchannel->MonitorGroup = (u8)offer->MonitorId / 32; + newchannel->MonitorBit = (u8)offer->MonitorId % 32; /* TODO: Make sure the offer comes from our parent partition */ - osd_schedule_callback(newChannel->ControlWQ, VmbusChannelProcessOffer, - newChannel); - - DPRINT_EXIT(VMBUS); + osd_schedule_callback(newchannel->ControlWQ, vmbus_process_offer, + newchannel); } /* - * VmbusChannelOnOfferRescind - Rescind offer handler. + * vmbus_onoffer_rescind - Rescind offer handler. * * We queue a work item to process this offer synchronously */ -static void VmbusChannelOnOfferRescind(struct vmbus_channel_message_header *hdr) +static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) { struct vmbus_channel_rescind_offer *rescind; struct vmbus_channel *channel; - DPRINT_ENTER(VMBUS); - rescind = (struct vmbus_channel_rescind_offer *)hdr; channel = GetChannelFromRelId(rescind->ChildRelId); if (channel == NULL) { @@ -529,42 +513,37 @@ static void VmbusChannelOnOfferRescind(struct vmbus_channel_message_header *hdr) } osd_schedule_callback(channel->ControlWQ, - VmbusChannelProcessRescindOffer, + vmbus_process_rescind_offer, channel); - - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnOffersDelivered - This is invoked when all offers have been delivered. + * vmbus_onoffers_delivered - + * This is invoked when all offers have been delivered. * * Nothing to do here. */ -static void VmbusChannelOnOffersDelivered( +static void vmbus_onoffers_delivered( struct vmbus_channel_message_header *hdr) { - DPRINT_ENTER(VMBUS); - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnOpenResult - Open result handler. + * vmbus_onopen_result - Open result handler. * * This is invoked when we received a response to our channel open request. * Find the matching request, copy the response and signal the requesting * thread. */ -static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr) +static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr) { struct vmbus_channel_open_result *result; struct list_head *curr; - struct vmbus_channel_msginfo *msgInfo; - struct vmbus_channel_message_header *requestHeader; - struct vmbus_channel_open_channel *openMsg; + struct vmbus_channel_msginfo *msginfo; + struct vmbus_channel_message_header *requestheader; + struct vmbus_channel_open_channel *openmsg; unsigned long flags; - DPRINT_ENTER(VMBUS); - result = (struct vmbus_channel_open_result *)hdr; DPRINT_DBG(VMBUS, "vmbus open result - %d", result->Status); @@ -575,47 +554,45 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr) list_for_each(curr, &gVmbusConnection.ChannelMsgList) { /* FIXME: this should probably use list_entry() instead */ - msgInfo = (struct vmbus_channel_msginfo *)curr; - requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg; - - if (requestHeader->MessageType == ChannelMessageOpenChannel) { - openMsg = (struct vmbus_channel_open_channel *)msgInfo->Msg; - if (openMsg->ChildRelId == result->ChildRelId && - openMsg->OpenId == result->OpenId) { - memcpy(&msgInfo->Response.OpenResult, + msginfo = (struct vmbus_channel_msginfo *)curr; + requestheader = + (struct vmbus_channel_message_header *)msginfo->Msg; + + if (requestheader->MessageType == ChannelMessageOpenChannel) { + openmsg = + (struct vmbus_channel_open_channel *)msginfo->Msg; + if (openmsg->ChildRelId == result->ChildRelId && + openmsg->OpenId == result->OpenId) { + memcpy(&msginfo->Response.OpenResult, result, sizeof(struct vmbus_channel_open_result)); - osd_WaitEventSet(msgInfo->WaitEvent); + osd_WaitEventSet(msginfo->WaitEvent); break; } } } spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); - - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnGpadlCreated - GPADL created handler. + * vmbus_ongpadl_created - GPADL created handler. * * This is invoked when we received a response to our gpadl create request. * Find the matching request, copy the response and signal the requesting * thread. */ -static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr) +static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr) { - struct vmbus_channel_gpadl_created *gpadlCreated; + struct vmbus_channel_gpadl_created *gpadlcreated; struct list_head *curr; - struct vmbus_channel_msginfo *msgInfo; - struct vmbus_channel_message_header *requestHeader; - struct vmbus_channel_gpadl_header *gpadlHeader; + struct vmbus_channel_msginfo *msginfo; + struct vmbus_channel_message_header *requestheader; + struct vmbus_channel_gpadl_header *gpadlheader; unsigned long flags; - DPRINT_ENTER(VMBUS); - - gpadlCreated = (struct vmbus_channel_gpadl_created *)hdr; + gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr; DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d", - gpadlCreated->CreationStatus); + gpadlcreated->CreationStatus); /* * Find the establish msg, copy the result and signal/unblock the wait @@ -625,48 +602,46 @@ static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr) list_for_each(curr, &gVmbusConnection.ChannelMsgList) { /* FIXME: this should probably use list_entry() instead */ - msgInfo = (struct vmbus_channel_msginfo *)curr; - requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg; - - if (requestHeader->MessageType == ChannelMessageGpadlHeader) { - gpadlHeader = (struct vmbus_channel_gpadl_header *)requestHeader; - - if ((gpadlCreated->ChildRelId == - gpadlHeader->ChildRelId) && - (gpadlCreated->Gpadl == gpadlHeader->Gpadl)) { - memcpy(&msgInfo->Response.GpadlCreated, - gpadlCreated, + msginfo = (struct vmbus_channel_msginfo *)curr; + requestheader = + (struct vmbus_channel_message_header *)msginfo->Msg; + + if (requestheader->MessageType == ChannelMessageGpadlHeader) { + gpadlheader = + (struct vmbus_channel_gpadl_header *)requestheader; + + if ((gpadlcreated->ChildRelId == + gpadlheader->ChildRelId) && + (gpadlcreated->Gpadl == gpadlheader->Gpadl)) { + memcpy(&msginfo->Response.GpadlCreated, + gpadlcreated, sizeof(struct vmbus_channel_gpadl_created)); - osd_WaitEventSet(msgInfo->WaitEvent); + osd_WaitEventSet(msginfo->WaitEvent); break; } } } spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); - - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnGpadlTorndown - GPADL torndown handler. + * vmbus_ongpadl_torndown - GPADL torndown handler. * * This is invoked when we received a response to our gpadl teardown request. * Find the matching request, copy the response and signal the requesting * thread. */ -static void VmbusChannelOnGpadlTorndown( +static void vmbus_ongpadl_torndown( struct vmbus_channel_message_header *hdr) { - struct vmbus_channel_gpadl_torndown *gpadlTorndown; + struct vmbus_channel_gpadl_torndown *gpadl_torndown; struct list_head *curr; - struct vmbus_channel_msginfo *msgInfo; - struct vmbus_channel_message_header *requestHeader; - struct vmbus_channel_gpadl_teardown *gpadlTeardown; + struct vmbus_channel_msginfo *msginfo; + struct vmbus_channel_message_header *requestheader; + struct vmbus_channel_gpadl_teardown *gpadl_teardown; unsigned long flags; - DPRINT_ENTER(VMBUS); - - gpadlTorndown = (struct vmbus_channel_gpadl_torndown *)hdr; + gpadl_torndown = (struct vmbus_channel_gpadl_torndown *)hdr; /* * Find the open msg, copy the result and signal/unblock the wait event @@ -675,102 +650,98 @@ static void VmbusChannelOnGpadlTorndown( list_for_each(curr, &gVmbusConnection.ChannelMsgList) { /* FIXME: this should probably use list_entry() instead */ - msgInfo = (struct vmbus_channel_msginfo *)curr; - requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg; + msginfo = (struct vmbus_channel_msginfo *)curr; + requestheader = + (struct vmbus_channel_message_header *)msginfo->Msg; - if (requestHeader->MessageType == ChannelMessageGpadlTeardown) { - gpadlTeardown = (struct vmbus_channel_gpadl_teardown *)requestHeader; + if (requestheader->MessageType == ChannelMessageGpadlTeardown) { + gpadl_teardown = + (struct vmbus_channel_gpadl_teardown *)requestheader; - if (gpadlTorndown->Gpadl == gpadlTeardown->Gpadl) { - memcpy(&msgInfo->Response.GpadlTorndown, - gpadlTorndown, + if (gpadl_torndown->Gpadl == gpadl_teardown->Gpadl) { + memcpy(&msginfo->Response.GpadlTorndown, + gpadl_torndown, sizeof(struct vmbus_channel_gpadl_torndown)); - osd_WaitEventSet(msgInfo->WaitEvent); + osd_WaitEventSet(msginfo->WaitEvent); break; } } } spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); - - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelOnVersionResponse - Version response handler + * vmbus_onversion_response - Version response handler * * This is invoked when we received a response to our initiate contact request. * Find the matching request, copy the response and signal the requesting * thread. */ -static void VmbusChannelOnVersionResponse( +static void vmbus_onversion_response( struct vmbus_channel_message_header *hdr) { struct list_head *curr; - struct vmbus_channel_msginfo *msgInfo; - struct vmbus_channel_message_header *requestHeader; + struct vmbus_channel_msginfo *msginfo; + struct vmbus_channel_message_header *requestheader; struct vmbus_channel_initiate_contact *initiate; - struct vmbus_channel_version_response *versionResponse; + struct vmbus_channel_version_response *version_response; unsigned long flags; - DPRINT_ENTER(VMBUS); - - versionResponse = (struct vmbus_channel_version_response *)hdr; + version_response = (struct vmbus_channel_version_response *)hdr; spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags); list_for_each(curr, &gVmbusConnection.ChannelMsgList) { /* FIXME: this should probably use list_entry() instead */ - msgInfo = (struct vmbus_channel_msginfo *)curr; - requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg; + msginfo = (struct vmbus_channel_msginfo *)curr; + requestheader = + (struct vmbus_channel_message_header *)msginfo->Msg; - if (requestHeader->MessageType == + if (requestheader->MessageType == ChannelMessageInitiateContact) { - initiate = (struct vmbus_channel_initiate_contact *)requestHeader; - memcpy(&msgInfo->Response.VersionResponse, - versionResponse, + initiate = + (struct vmbus_channel_initiate_contact *)requestheader; + memcpy(&msginfo->Response.VersionResponse, + version_response, sizeof(struct vmbus_channel_version_response)); - osd_WaitEventSet(msgInfo->WaitEvent); + osd_WaitEventSet(msginfo->WaitEvent); } } spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags); - - DPRINT_EXIT(VMBUS); } /* Channel message dispatch table */ static struct vmbus_channel_message_table_entry gChannelMessageTable[ChannelMessageCount] = { {ChannelMessageInvalid, NULL}, - {ChannelMessageOfferChannel, VmbusChannelOnOffer}, - {ChannelMessageRescindChannelOffer, VmbusChannelOnOfferRescind}, + {ChannelMessageOfferChannel, vmbus_onoffer}, + {ChannelMessageRescindChannelOffer, vmbus_onoffer_rescind}, {ChannelMessageRequestOffers, NULL}, - {ChannelMessageAllOffersDelivered, VmbusChannelOnOffersDelivered}, + {ChannelMessageAllOffersDelivered, vmbus_onoffers_delivered}, {ChannelMessageOpenChannel, NULL}, - {ChannelMessageOpenChannelResult, VmbusChannelOnOpenResult}, + {ChannelMessageOpenChannelResult, vmbus_onopen_result}, {ChannelMessageCloseChannel, NULL}, {ChannelMessageGpadlHeader, NULL}, {ChannelMessageGpadlBody, NULL}, - {ChannelMessageGpadlCreated, VmbusChannelOnGpadlCreated}, + {ChannelMessageGpadlCreated, vmbus_ongpadl_created}, {ChannelMessageGpadlTeardown, NULL}, - {ChannelMessageGpadlTorndown, VmbusChannelOnGpadlTorndown}, + {ChannelMessageGpadlTorndown, vmbus_ongpadl_torndown}, {ChannelMessageRelIdReleased, NULL}, {ChannelMessageInitiateContact, NULL}, - {ChannelMessageVersionResponse, VmbusChannelOnVersionResponse}, + {ChannelMessageVersionResponse, vmbus_onversion_response}, {ChannelMessageUnload, NULL}, }; /* - * VmbusOnChannelMessage - Handler for channel protocol messages. + * vmbus_onmessage - Handler for channel protocol messages. * * This is invoked in the vmbus worker thread context. */ -void VmbusOnChannelMessage(void *Context) +void vmbus_onmessage(void *context) { - struct hv_message *msg = Context; + struct hv_message *msg = context; struct vmbus_channel_message_header *hdr; int size; - DPRINT_ENTER(VMBUS); - hdr = (struct vmbus_channel_message_header *)msg->u.Payload; size = msg->Header.PayloadSize; @@ -794,33 +765,30 @@ void VmbusOnChannelMessage(void *Context) /* Free the msg that was allocated in VmbusOnMsgDPC() */ kfree(msg); - DPRINT_EXIT(VMBUS); } /* - * VmbusChannelRequestOffers - Send a request to get all our pending offers. + * vmbus_request_offers - Send a request to get all our pending offers. */ -int VmbusChannelRequestOffers(void) +int vmbus_request_offers(void) { struct vmbus_channel_message_header *msg; - struct vmbus_channel_msginfo *msgInfo; + struct vmbus_channel_msginfo *msginfo; int ret; - DPRINT_ENTER(VMBUS); - - msgInfo = kmalloc(sizeof(*msgInfo) + + msginfo = kmalloc(sizeof(*msginfo) + sizeof(struct vmbus_channel_message_header), GFP_KERNEL); - if (!msgInfo) + if (!msginfo) return -ENOMEM; - msgInfo->WaitEvent = osd_WaitEventCreate(); - if (!msgInfo->WaitEvent) { - kfree(msgInfo); + msginfo->WaitEvent = osd_WaitEventCreate(); + if (!msginfo->WaitEvent) { + kfree(msginfo); return -ENOMEM; } - msg = (struct vmbus_channel_message_header *)msgInfo->Msg; + msg = (struct vmbus_channel_message_header *)msginfo->Msg; msg->MessageType = ChannelMessageRequestOffers; @@ -848,20 +816,19 @@ int VmbusChannelRequestOffers(void) Cleanup: - if (msgInfo) { - kfree(msgInfo->WaitEvent); - kfree(msgInfo); + if (msginfo) { + kfree(msginfo->WaitEvent); + kfree(msginfo); } - DPRINT_EXIT(VMBUS); return ret; } /* - * VmbusChannelReleaseUnattachedChannels - Release channels that are + * vmbus_release_unattached_channels - Release channels that are * unattached/unconnected ie (no drivers associated) */ -void VmbusChannelReleaseUnattachedChannels(void) +void vmbus_release_unattached_channels(void) { struct vmbus_channel *channel, *pos; struct vmbus_channel *start = NULL; @@ -881,7 +848,7 @@ void VmbusChannelReleaseUnattachedChannels(void) channel->DeviceObject); VmbusChildDeviceRemove(channel->DeviceObject); - FreeVmbusChannel(channel); + free_channel(channel); } else { if (!start) start = channel; diff --git a/drivers/staging/hv/channel_mgmt.h b/drivers/staging/hv/channel_mgmt.h index 5908b81d3e9c..d16cc0811169 100644 --- a/drivers/staging/hv/channel_mgmt.h +++ b/drivers/staging/hv/channel_mgmt.h @@ -247,8 +247,8 @@ struct vmbus_channel { /* Allocated memory for ring buffer */ void *RingBufferPages; u32 RingBufferPageCount; - RING_BUFFER_INFO Outbound; /* send to parent */ - RING_BUFFER_INFO Inbound; /* receive from parent */ + struct hv_ring_buffer_info Outbound; /* send to parent */ + struct hv_ring_buffer_info Inbound; /* receive from parent */ spinlock_t inbound_lock; struct workqueue_struct *ControlWQ; @@ -272,8 +272,8 @@ struct vmbus_channel_debug_info { u32 ClientMonitorLatency; u32 ClientMonitorConnectionId; - RING_BUFFER_DEBUG_INFO Inbound; - RING_BUFFER_DEBUG_INFO Outbound; + struct hv_ring_buffer_debug_info Inbound; + struct hv_ring_buffer_debug_info Outbound; }; /* @@ -307,14 +307,12 @@ struct vmbus_channel_msginfo { }; -struct vmbus_channel *AllocVmbusChannel(void); +void free_channel(struct vmbus_channel *channel); -void FreeVmbusChannel(struct vmbus_channel *Channel); +void vmbus_onmessage(void *context); -void VmbusOnChannelMessage(void *Context); +int vmbus_request_offers(void); -int VmbusChannelRequestOffers(void); - -void VmbusChannelReleaseUnattachedChannels(void); +void vmbus_release_unattached_channels(void); #endif /* _CHANNEL_MGMT_H_ */ diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index e8824dadffc3..f8477072ace4 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -44,8 +44,6 @@ int VmbusConnect(void) struct vmbus_channel_initiate_contact *msg; unsigned long flags; - DPRINT_ENTER(VMBUS); - /* Make sure we are not connecting or connected */ if (gVmbusConnection.ConnectState != Disconnected) return -1; @@ -155,8 +153,6 @@ int VmbusConnect(void) kfree(msgInfo->WaitEvent); kfree(msgInfo); - DPRINT_EXIT(VMBUS); - return 0; Cleanup: @@ -180,8 +176,6 @@ Cleanup: kfree(msgInfo); } - DPRINT_EXIT(VMBUS); - return ret; } @@ -193,8 +187,6 @@ int VmbusDisconnect(void) int ret = 0; struct vmbus_channel_message_header *msg; - DPRINT_ENTER(VMBUS); - /* Make sure we are connected */ if (gVmbusConnection.ConnectState != Connected) return -1; @@ -221,7 +213,6 @@ int VmbusDisconnect(void) Cleanup: kfree(msg); - DPRINT_EXIT(VMBUS); return ret; } @@ -263,10 +254,10 @@ static void VmbusProcessChannelEvent(void *context) channel = GetChannelFromRelId(relId); if (channel) { - VmbusChannelOnChannelEvent(channel); + vmbus_onchannel_event(channel); /* * WorkQueueQueueWorkItem(channel->dataWorkQueue, - * VmbusChannelOnChannelEvent, + * vmbus_onchannel_event, * (void*)channel); */ } else { @@ -285,8 +276,6 @@ void VmbusOnEvents(void) int relid; u32 *recvInterruptPage = gVmbusConnection.RecvInterruptPage; - DPRINT_ENTER(VMBUS); - /* Check events */ if (recvInterruptPage) { for (dword = 0; dword < maxdword; dword++) { @@ -310,8 +299,6 @@ void VmbusOnEvents(void) } } } - DPRINT_EXIT(VMBUS); - return; } @@ -332,18 +319,10 @@ int VmbusPostMessage(void *buffer, size_t bufferLen) */ int VmbusSetEvent(u32 childRelId) { - int ret = 0; - - DPRINT_ENTER(VMBUS); - /* Each u32 represents 32 channels */ set_bit(childRelId & 31, (unsigned long *)gVmbusConnection.SendInterruptPage + (childRelId >> 5)); - ret = HvSignalEvent(); - - DPRINT_EXIT(VMBUS); - - return ret; + return HvSignalEvent(); } diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index 6c77e64027f0..86b1ddd90404 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -192,8 +192,6 @@ int HvInit(void) union hv_x64_msr_hypercall_contents hypercallMsr; void *virtAddr = NULL; - DPRINT_ENTER(VMBUS); - memset(gHvContext.synICEventPage, 0, sizeof(void *) * MAX_NUM_CPUS); memset(gHvContext.synICMessagePage, 0, sizeof(void *) * MAX_NUM_CPUS); @@ -275,8 +273,6 @@ int HvInit(void) gHvContext.SignalEventParam->FlagNumber = 0; gHvContext.SignalEventParam->RsvdZ = 0; - DPRINT_EXIT(VMBUS); - return ret; Cleanup: @@ -289,8 +285,6 @@ Cleanup: vfree(virtAddr); } ret = -1; - DPRINT_EXIT(VMBUS); - return ret; } @@ -303,8 +297,6 @@ void HvCleanup(void) { union hv_x64_msr_hypercall_contents hypercallMsr; - DPRINT_ENTER(VMBUS); - kfree(gHvContext.SignalEventBuffer); gHvContext.SignalEventBuffer = NULL; gHvContext.SignalEventParam = NULL; @@ -315,8 +307,6 @@ void HvCleanup(void) vfree(gHvContext.HypercallPage); gHvContext.HypercallPage = NULL; } - - DPRINT_EXIT(VMBUS); } /* @@ -392,12 +382,8 @@ void HvSynicInit(void *irqarg) u32 irqVector = *((u32 *)(irqarg)); int cpu = smp_processor_id(); - DPRINT_ENTER(VMBUS); - - if (!gHvContext.HypercallPage) { - DPRINT_EXIT(VMBUS); + if (!gHvContext.HypercallPage) return; - } /* Check the version */ rdmsrl(HV_X64_MSR_SVERSION, version); @@ -464,9 +450,6 @@ void HvSynicInit(void *irqarg) wrmsrl(HV_X64_MSR_SCONTROL, sctrl.AsUINT64); gHvContext.SynICInitialized = true; - - DPRINT_EXIT(VMBUS); - return; Cleanup: @@ -475,8 +458,6 @@ Cleanup: if (gHvContext.synICMessagePage[cpu]) osd_PageFree(gHvContext.synICMessagePage[cpu], 1); - - DPRINT_EXIT(VMBUS); return; } @@ -490,12 +471,8 @@ void HvSynicCleanup(void *arg) union hv_synic_siefp siefp; int cpu = smp_processor_id(); - DPRINT_ENTER(VMBUS); - - if (!gHvContext.SynICInitialized) { - DPRINT_EXIT(VMBUS); + if (!gHvContext.SynICInitialized) return; - } rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64); @@ -519,6 +496,4 @@ void HvSynicCleanup(void *arg) osd_PageFree(gHvContext.synICMessagePage[cpu], 1); osd_PageFree(gHvContext.synICEventPage[cpu], 1); - - DPRINT_EXIT(VMBUS); } diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c new file mode 100644 index 000000000000..a7ee533303b4 --- /dev/null +++ b/drivers/staging/hv/hv_timesource.c @@ -0,0 +1,101 @@ +/* + * A clocksource for Linux running on HyperV. + * + * + * Copyright (C) 2010, Novell, Inc. + * Author : K. Y. Srinivasan <ksrinivasan@novell.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <linux/version.h> +#include <linux/clocksource.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/dmi.h> +#include <asm/hyperv.h> +#include <asm/mshyperv.h> +#include <asm/hypervisor.h> + +#define HV_CLOCK_SHIFT 22 + +static cycle_t read_hv_clock(struct clocksource *arg) +{ + cycle_t current_tick; + /* + * Read the partition counter to get the current tick count. This count + * is set to 0 when the partition is created and is incremented in + * 100 nanosecond units. + */ + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick); + return current_tick; +} + +static struct clocksource hyperv_cs = { + .name = "hyperv_clocksource", + .rating = 400, /* use this when running on Hyperv*/ + .read = read_hv_clock, + .mask = CLOCKSOURCE_MASK(64), + /* + * The time ref counter in HyperV is in 100ns units. + * The definition of mult is: + * mult/2^shift = ns/cyc = 100 + * mult = (100 << shift) + */ + .mult = (100 << HV_CLOCK_SHIFT), + .shift = HV_CLOCK_SHIFT, +}; + +static const struct dmi_system_id __initconst +hv_timesource_dmi_table[] __maybe_unused = { + { + .ident = "Hyper-V", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), + DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), + }, + }, + { }, +}; +MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table); + +static const struct pci_device_id __initconst +hv_timesource_pci_table[] __maybe_unused = { + { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ + { 0 } +}; +MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table); + + +static int __init init_hv_clocksource(void) +{ + if ((x86_hyper != &x86_hyper_ms_hyperv) || + !(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)) + return -ENODEV; + + if (!dmi_check_system(hv_timesource_dmi_table)) + return -ENODEV; + + printk(KERN_INFO "Registering HyperV clock source\n"); + return clocksource_register(&hyperv_cs); +} + +module_init(init_hv_clocksource); +MODULE_DESCRIPTION("HyperV based clocksource"); +MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c index 2adc9b48ca9c..702a478d5542 100644 --- a/drivers/staging/hv/hv_utils.c +++ b/drivers/staging/hv/hv_utils.c @@ -52,12 +52,10 @@ static void shutdown_onchannelcallback(void *context) struct icmsg_hdr *icmsghdrp; struct icmsg_negotiate *negop = NULL; - DPRINT_ENTER(VMBUS); - buflen = PAGE_SIZE; buf = kmalloc(buflen, GFP_ATOMIC); - VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid); + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid); if (recvlen > 0) { DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld", @@ -95,15 +93,13 @@ static void shutdown_onchannelcallback(void *context) icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; - VmbusChannelSendPacket(channel, buf, + vmbus_sendpacket(channel, buf, recvlen, requestid, VmbusPacketTypeDataInBand, 0); } kfree(buf); - DPRINT_EXIT(VMBUS); - if (execute_shutdown == true) orderly_poweroff(false); } @@ -160,12 +156,10 @@ static void timesync_onchannelcallback(void *context) struct icmsg_hdr *icmsghdrp; struct ictimesync_data *timedatap; - DPRINT_ENTER(VMBUS); - buflen = PAGE_SIZE; buf = kmalloc(buflen, GFP_ATOMIC); - VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid); + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid); if (recvlen > 0) { DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld", @@ -186,14 +180,12 @@ static void timesync_onchannelcallback(void *context) icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; - VmbusChannelSendPacket(channel, buf, + vmbus_sendpacket(channel, buf, recvlen, requestid, VmbusPacketTypeDataInBand, 0); } kfree(buf); - - DPRINT_EXIT(VMBUS); } /* @@ -210,12 +202,10 @@ static void heartbeat_onchannelcallback(void *context) struct icmsg_hdr *icmsghdrp; struct heartbeat_msg_data *heartbeat_msg; - DPRINT_ENTER(VMBUS); - buflen = PAGE_SIZE; buf = kmalloc(buflen, GFP_ATOMIC); - VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid); + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid); if (recvlen > 0) { DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld", @@ -243,14 +233,12 @@ static void heartbeat_onchannelcallback(void *context) icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; - VmbusChannelSendPacket(channel, buf, + vmbus_sendpacket(channel, buf, recvlen, requestid, VmbusPacketTypeDataInBand, 0); } kfree(buf); - - DPRINT_EXIT(VMBUS); } static const struct pci_device_id __initconst diff --git a/drivers/staging/hv/logging.h b/drivers/staging/hv/logging.h index ad4cfcfb7b11..20d4d12023de 100644 --- a/drivers/staging/hv/logging.h +++ b/drivers/staging/hv/logging.h @@ -92,21 +92,4 @@ extern unsigned int vmbus_loglevel; __func__, ## args);\ } while (0) -#ifdef DEBUG -#define DPRINT_ENTER(mod) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \ - printk(KERN_DEBUG "["#mod"]: %s() enter\n", __func__);\ - } while (0) - -#define DPRINT_EXIT(mod) do {\ - if ((mod & (HIWORD(vmbus_loglevel))) && \ - (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \ - printk(KERN_DEBUG "["#mod"]: %s() exit\n", __func__);\ - } while (0) -#else -#define DPRINT_ENTER(mod) -#define DPRINT_EXIT(mod) -#endif - #endif /* _LOGGING_H_ */ diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index ba15059c45b2..4c2632cb19e9 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -27,6 +27,7 @@ #include "logging.h" #include "netvsc.h" #include "rndis_filter.h" +#include "channel.h" /* Globals */ @@ -174,8 +175,6 @@ int NetVscInitialize(struct hv_driver *drv) { struct netvsc_driver *driver = (struct netvsc_driver *)drv; - DPRINT_ENTER(NETVSC); - DPRINT_DBG(NETVSC, "sizeof(struct hv_netvsc_packet)=%zd, " "sizeof(struct nvsp_message)=%zd, " "sizeof(struct vmtransfer_page_packet_header)=%zd", @@ -202,9 +201,6 @@ int NetVscInitialize(struct hv_driver *drv) driver->OnSend = NetVscOnSend; RndisFilterInit(driver); - - DPRINT_EXIT(NETVSC); - return 0; } @@ -214,13 +210,10 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) struct netvsc_device *netDevice; struct nvsp_message *initPacket; - DPRINT_ENTER(NETVSC); - netDevice = GetOutboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return -1; } /* ASSERT(netDevice->ReceiveBufferSize > 0); */ @@ -247,10 +240,9 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) * channel. Note: This call uses the vmbus connection rather * than the channel to establish the gpadl handle. */ - ret = Device->Driver->VmbusChannelInterface.EstablishGpadl(Device, - netDevice->ReceiveBuffer, - netDevice->ReceiveBufferSize, - &netDevice->ReceiveBufferGpadlHandle); + ret = vmbus_establish_gpadl(Device->channel, netDevice->ReceiveBuffer, + netDevice->ReceiveBufferSize, + &netDevice->ReceiveBufferGpadlHandle); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to establish receive buffer's gpadl"); @@ -271,12 +263,11 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; /* Send the gpadl notification request */ - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - initPacket, - sizeof(struct nvsp_message), - (unsigned long)initPacket, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, initPacket, + sizeof(struct nvsp_message), + (unsigned long)initPacket, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send receive buffer's gpadl to netvsp"); @@ -335,7 +326,6 @@ Cleanup: Exit: PutNetDevice(Device); - DPRINT_EXIT(NETVSC); return ret; } @@ -345,13 +335,10 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) struct netvsc_device *netDevice; struct nvsp_message *initPacket; - DPRINT_ENTER(NETVSC); - netDevice = GetOutboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return -1; } if (netDevice->SendBufferSize <= 0) { @@ -380,10 +367,9 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) * channel. Note: This call uses the vmbus connection rather * than the channel to establish the gpadl handle. */ - ret = Device->Driver->VmbusChannelInterface.EstablishGpadl(Device, - netDevice->SendBuffer, - netDevice->SendBufferSize, - &netDevice->SendBufferGpadlHandle); + ret = vmbus_establish_gpadl(Device->channel, netDevice->SendBuffer, + netDevice->SendBufferSize, + &netDevice->SendBufferGpadlHandle); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl"); goto Cleanup; @@ -403,11 +389,11 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_SEND_BUFFER_ID; /* Send the gpadl notification request */ - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - initPacket, sizeof(struct nvsp_message), - (unsigned long)initPacket, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, initPacket, + sizeof(struct nvsp_message), + (unsigned long)initPacket, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send receive buffer's gpadl to netvsp"); @@ -434,7 +420,6 @@ Cleanup: Exit: PutNetDevice(Device); - DPRINT_EXIT(NETVSC); return ret; } @@ -443,8 +428,6 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) struct nvsp_message *revokePacket; int ret = 0; - DPRINT_ENTER(NETVSC); - /* * If we got a section count, it means we received a * SendReceiveBufferComplete msg (ie sent @@ -462,12 +445,10 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) revokePacket->Header.MessageType = NvspMessage1TypeRevokeReceiveBuffer; revokePacket->Messages.Version1Messages.RevokeReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; - ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket( - NetDevice->Device, - revokePacket, - sizeof(struct nvsp_message), - (unsigned long)revokePacket, - VmbusPacketTypeDataInBand, 0); + ret = vmbus_sendpacket(NetDevice->Device->channel, revokePacket, + sizeof(struct nvsp_message), + (unsigned long)revokePacket, + VmbusPacketTypeDataInBand, 0); /* * If we failed here, we might as well return and * have a leak rather than continue and a bugchk @@ -475,7 +456,6 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send revoke receive " "buffer to netvsp"); - DPRINT_EXIT(NETVSC); return -1; } } @@ -484,15 +464,13 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) if (NetDevice->ReceiveBufferGpadlHandle) { DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL..."); - ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl( - NetDevice->Device, - NetDevice->ReceiveBufferGpadlHandle); + ret = vmbus_teardown_gpadl(NetDevice->Device->channel, + NetDevice->ReceiveBufferGpadlHandle); /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */ if (ret != 0) { DPRINT_ERR(NETVSC, "unable to teardown receive buffer's gpadl"); - DPRINT_EXIT(NETVSC); return -1; } NetDevice->ReceiveBufferGpadlHandle = 0; @@ -513,8 +491,6 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) NetDevice->ReceiveSections = NULL; } - DPRINT_EXIT(NETVSC); - return ret; } @@ -523,8 +499,6 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) struct nvsp_message *revokePacket; int ret = 0; - DPRINT_ENTER(NETVSC); - /* * If we got a section count, it means we received a * SendReceiveBufferComplete msg (ie sent @@ -542,11 +516,10 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) revokePacket->Header.MessageType = NvspMessage1TypeRevokeSendBuffer; revokePacket->Messages.Version1Messages.RevokeSendBuffer.Id = NETVSC_SEND_BUFFER_ID; - ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket(NetDevice->Device, - revokePacket, - sizeof(struct nvsp_message), - (unsigned long)revokePacket, - VmbusPacketTypeDataInBand, 0); + ret = vmbus_sendpacket(NetDevice->Device->channel, revokePacket, + sizeof(struct nvsp_message), + (unsigned long)revokePacket, + VmbusPacketTypeDataInBand, 0); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -554,7 +527,6 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send revoke send buffer " "to netvsp"); - DPRINT_EXIT(NETVSC); return -1; } } @@ -562,8 +534,8 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) /* Teardown the gpadl on the vsp end */ if (NetDevice->SendBufferGpadlHandle) { DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL..."); - - ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl(NetDevice->Device, NetDevice->SendBufferGpadlHandle); + ret = vmbus_teardown_gpadl(NetDevice->Device->channel, + NetDevice->SendBufferGpadlHandle); /* * If we failed here, we might as well return and have a leak @@ -572,7 +544,6 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) if (ret != 0) { DPRINT_ERR(NETVSC, "unable to teardown send buffer's " "gpadl"); - DPRINT_EXIT(NETVSC); return -1; } NetDevice->SendBufferGpadlHandle = 0; @@ -587,8 +558,6 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) NetDevice->SendBuffer = NULL; } - DPRINT_EXIT(NETVSC); - return ret; } @@ -600,13 +569,10 @@ static int NetVscConnectToVsp(struct hv_device *Device) struct nvsp_message *initPacket; int ndisVersion; - DPRINT_ENTER(NETVSC); - netDevice = GetOutboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return -1; } @@ -620,12 +586,11 @@ static int NetVscConnectToVsp(struct hv_device *Device) DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit..."); /* Send the init request */ - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - initPacket, - sizeof(struct nvsp_message), - (unsigned long)initPacket, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, initPacket, + sizeof(struct nvsp_message), + (unsigned long)initPacket, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send NvspMessageTypeInit"); @@ -670,11 +635,10 @@ static int NetVscConnectToVsp(struct hv_device *Device) ndisVersion & 0xFFFF; /* Send the init request */ - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - initPacket, - sizeof(struct nvsp_message), - (unsigned long)initPacket, - VmbusPacketTypeDataInBand, 0); + ret = vmbus_sendpacket(Device->channel, initPacket, + sizeof(struct nvsp_message), + (unsigned long)initPacket, + VmbusPacketTypeDataInBand, 0); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send NvspMessage1TypeSendNdisVersion"); @@ -696,18 +660,13 @@ static int NetVscConnectToVsp(struct hv_device *Device) Cleanup: PutNetDevice(Device); - DPRINT_EXIT(NETVSC); return ret; } static void NetVscDisconnectFromVsp(struct netvsc_device *NetDevice) { - DPRINT_ENTER(NETVSC); - NetVscDestroyReceiveBuffer(NetDevice); NetVscDestroySendBuffer(NetDevice); - - DPRINT_EXIT(NETVSC); } /* @@ -722,8 +681,6 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) struct netvsc_driver *netDriver = (struct netvsc_driver *)Device->Driver; - DPRINT_ENTER(NETVSC); - netDevice = AllocNetDevice(Device); if (!netDevice) { ret = -1; @@ -760,12 +717,9 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) } /* Open the channel */ - ret = Device->Driver->VmbusChannelInterface.Open(Device, - netDriver->RingBufferSize, - netDriver->RingBufferSize, - NULL, 0, - NetVscOnChannelCallback, - Device); + ret = vmbus_open(Device->channel, netDriver->RingBufferSize, + netDriver->RingBufferSize, NULL, 0, + NetVscOnChannelCallback, Device); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to open channel: %d", ret); @@ -781,18 +735,17 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) if (ret != 0) { DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret); ret = -1; - goto Close; + goto close; } DPRINT_INFO(NETVSC, "*** NetVSC channel handshake result - %d ***", ret); - DPRINT_EXIT(NETVSC); return ret; -Close: +close: /* Now, we can close the channel safely */ - Device->Driver->VmbusChannelInterface.Close(Device); + vmbus_close(Device->channel); Cleanup: @@ -812,7 +765,6 @@ Cleanup: FreeNetDevice(netDevice); } - DPRINT_EXIT(NETVSC); return ret; } @@ -824,8 +776,6 @@ static int NetVscOnDeviceRemove(struct hv_device *Device) struct netvsc_device *netDevice; struct hv_netvsc_packet *netvscPacket, *pos; - DPRINT_ENTER(NETVSC); - DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...", Device->Extension); @@ -857,7 +807,7 @@ static int NetVscOnDeviceRemove(struct hv_device *Device) DPRINT_INFO(NETVSC, "net device (%p) safe to remove", netDevice); /* Now, we can close the channel safely */ - Device->Driver->VmbusChannelInterface.Close(Device); + vmbus_close(Device->channel); /* Release all resources */ list_for_each_entry_safe(netvscPacket, pos, @@ -868,8 +818,6 @@ static int NetVscOnDeviceRemove(struct hv_device *Device) kfree(netDevice->ChannelInitEvent); FreeNetDevice(netDevice); - - DPRINT_EXIT(NETVSC); return 0; } @@ -878,8 +826,6 @@ static int NetVscOnDeviceRemove(struct hv_device *Device) */ static void NetVscOnCleanup(struct hv_driver *drv) { - DPRINT_ENTER(NETVSC); - DPRINT_EXIT(NETVSC); } static void NetVscOnSendCompletion(struct hv_device *Device, @@ -889,13 +835,10 @@ static void NetVscOnSendCompletion(struct hv_device *Device, struct nvsp_message *nvspPacket; struct hv_netvsc_packet *nvscPacket; - DPRINT_ENTER(NETVSC); - netDevice = GetInboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return; } @@ -929,7 +872,6 @@ static void NetVscOnSendCompletion(struct hv_device *Device, } PutNetDevice(Device); - DPRINT_EXIT(NETVSC); } static int NetVscOnSend(struct hv_device *Device, @@ -940,13 +882,10 @@ static int NetVscOnSend(struct hv_device *Device, struct nvsp_message sendMessage; - DPRINT_ENTER(NETVSC); - netDevice = GetOutboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "net device (%p) shutting down..." "ignoring outbound packets", netDevice); - DPRINT_EXIT(NETVSC); return -2; } @@ -964,19 +903,18 @@ static int NetVscOnSend(struct hv_device *Device, sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize = 0; if (Packet->PageBufferCount) { - ret = Device->Driver->VmbusChannelInterface.SendPacketPageBuffer( - Device, Packet->PageBuffers, - Packet->PageBufferCount, - &sendMessage, - sizeof(struct nvsp_message), - (unsigned long)Packet); + ret = vmbus_sendpacket_pagebuffer(Device->channel, + Packet->PageBuffers, + Packet->PageBufferCount, + &sendMessage, + sizeof(struct nvsp_message), + (unsigned long)Packet); } else { - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - &sendMessage, - sizeof(struct nvsp_message), - (unsigned long)Packet, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, &sendMessage, + sizeof(struct nvsp_message), + (unsigned long)Packet, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); } @@ -986,8 +924,6 @@ static int NetVscOnSend(struct hv_device *Device, atomic_inc(&netDevice->NumOutstandingSends); PutNetDevice(Device); - - DPRINT_EXIT(NETVSC); return ret; } @@ -1007,13 +943,10 @@ static void NetVscOnReceive(struct hv_device *Device, unsigned long flags; LIST_HEAD(listHead); - DPRINT_ENTER(NETVSC); - netDevice = GetInboundNetDevice(Device); if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return; } @@ -1189,7 +1122,6 @@ static void NetVscOnReceive(struct hv_device *Device, /* ASSERT(list_empty(&listHead)); */ PutNetDevice(Device); - DPRINT_EXIT(NETVSC); } static void NetVscSendReceiveCompletion(struct hv_device *Device, @@ -1210,11 +1142,9 @@ static void NetVscSendReceiveCompletion(struct hv_device *Device, retry_send_cmplt: /* Send the completion */ - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - &recvcompMessage, - sizeof(struct nvsp_message), - TransactionId, - VmbusPacketTypeCompletion, 0); + ret = vmbus_sendpacket(Device->channel, &recvcompMessage, + sizeof(struct nvsp_message), TransactionId, + VmbusPacketTypeCompletion, 0); if (ret == 0) { /* success */ /* no-op */ @@ -1248,8 +1178,6 @@ static void NetVscOnReceiveCompletion(void *Context) bool fSendReceiveComp = false; unsigned long flags; - DPRINT_ENTER(NETVSC); - /* ASSERT(packet->XferPagePacket); */ /* @@ -1261,7 +1189,6 @@ static void NetVscOnReceiveCompletion(void *Context) if (!netDevice) { DPRINT_ERR(NETVSC, "unable to get net device..." "device being destroyed?"); - DPRINT_EXIT(NETVSC); return; } @@ -1292,7 +1219,6 @@ static void NetVscOnReceiveCompletion(void *Context) NetVscSendReceiveCompletion(device, transactionId); PutNetDevice(device); - DPRINT_EXIT(NETVSC); } static void NetVscOnChannelCallback(void *Context) @@ -1307,9 +1233,6 @@ static void NetVscOnChannelCallback(void *Context) unsigned char *buffer; int bufferlen = NETVSC_PACKET_SIZE; - - DPRINT_ENTER(NETVSC); - /* ASSERT(device); */ packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), @@ -1322,14 +1245,12 @@ static void NetVscOnChannelCallback(void *Context) if (!netDevice) { DPRINT_ERR(NETVSC, "net device (%p) shutting down..." "ignoring inbound packets", netDevice); - DPRINT_EXIT(NETVSC); goto out; } do { - ret = device->Driver->VmbusChannelInterface.RecvPacketRaw( - device, buffer, bufferlen, - &bytesRecvd, &requestId); + ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, + &bytesRecvd, &requestId); if (ret == 0) { if (bytesRecvd > 0) { DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx", @@ -1386,7 +1307,6 @@ static void NetVscOnChannelCallback(void *Context) } while (1); PutNetDevice(device); - DPRINT_EXIT(NETVSC); out: kfree(buffer); return; diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 55b993298ff4..141535295a41 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -59,7 +59,7 @@ struct netvsc_driver_context { /* Need this many pages to handle worst case fragmented packet */ #define PACKET_PAGES_HIWATER (MAX_SKB_FRAGS + 2) -static int ring_size = roundup_pow_of_two(2*MAX_SKB_FRAGS+1); +static int ring_size = 128; module_param(ring_size, int, S_IRUGO); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); @@ -76,8 +76,6 @@ static int netvsc_open(struct net_device *net) struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj; int ret = 0; - DPRINT_ENTER(NETVSC_DRV); - if (netif_carrier_ok(net)) { /* Open up the device */ ret = RndisFilterOnOpen(device_obj); @@ -92,7 +90,6 @@ static int netvsc_open(struct net_device *net) DPRINT_ERR(NETVSC_DRV, "unable to open device...link is down."); } - DPRINT_EXIT(NETVSC_DRV); return ret; } @@ -102,16 +99,12 @@ static int netvsc_close(struct net_device *net) struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj; int ret; - DPRINT_ENTER(NETVSC_DRV); - netif_stop_queue(net); ret = RndisFilterOnClose(device_obj); if (ret != 0) DPRINT_ERR(NETVSC_DRV, "unable to close device (ret %d).", ret); - DPRINT_EXIT(NETVSC_DRV); - return ret; } @@ -121,8 +114,6 @@ static void netvsc_xmit_completion(void *context) struct sk_buff *skb = (struct sk_buff *) (unsigned long)packet->Completion.Send.SendCompletionTid; - DPRINT_ENTER(NETVSC_DRV); - kfree(packet); if (skb) { @@ -135,8 +126,6 @@ static void netvsc_xmit_completion(void *context) if ((net_device_ctx->avail += num_pages) >= PACKET_PAGES_HIWATER) netif_wake_queue(net); } - - DPRINT_EXIT(NETVSC_DRV); } static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) @@ -151,8 +140,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) int ret; unsigned int i, num_pages; - DPRINT_ENTER(NETVSC_DRV); - DPRINT_DBG(NETVSC_DRV, "xmit packet - len %d data_len %d", skb->len, skb->data_len); @@ -225,7 +212,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) netvsc_xmit_completion(packet); } - DPRINT_EXIT(NETVSC_DRV); return NETDEV_TX_OK; } @@ -238,8 +224,6 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, struct vm_device *device_ctx = to_vm_device(device_obj); struct net_device *net = dev_get_drvdata(&device_ctx->device); - DPRINT_ENTER(NETVSC_DRV); - if (!net) { DPRINT_ERR(NETVSC_DRV, "got link status but net device " "not initialized yet"); @@ -253,7 +237,6 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, netif_carrier_off(net); netif_stop_queue(net); } - DPRINT_EXIT(NETVSC_DRV); } /* @@ -270,8 +253,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj, int i; unsigned long flags; - DPRINT_ENTER(NETVSC_DRV); - if (!net) { DPRINT_ERR(NETVSC_DRV, "got receive callback but net device " "not initialized yet"); @@ -323,8 +304,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj, DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu", net->stats.rx_packets, net->stats.rx_bytes); - DPRINT_EXIT(NETVSC_DRV); - return 0; } @@ -348,6 +327,9 @@ static const struct net_device_ops device_ops = { .ndo_stop = netvsc_close, .ndo_start_xmit = netvsc_start_xmit, .ndo_set_multicast_list = netvsc_set_multicast_list, + .ndo_change_mtu = eth_change_mtu, + .ndo_validate_addr = eth_validate_addr, + .ndo_set_mac_address = eth_mac_addr, }; static int netvsc_probe(struct device *device) @@ -364,8 +346,6 @@ static int netvsc_probe(struct device *device) struct netvsc_device_info device_info; int ret; - DPRINT_ENTER(NETVSC_DRV); - if (!net_drv_obj->Base.OnDeviceAdd) return -1; @@ -422,7 +402,6 @@ static int netvsc_probe(struct device *device) free_netdev(net); } - DPRINT_EXIT(NETVSC_DRV); return ret; } @@ -438,18 +417,13 @@ static int netvsc_remove(struct device *device) struct hv_device *device_obj = &device_ctx->device_obj; int ret; - DPRINT_ENTER(NETVSC_DRV); - if (net == NULL) { DPRINT_INFO(NETVSC, "no net device to remove"); - DPRINT_EXIT(NETVSC_DRV); return 0; } - if (!net_drv_obj->Base.OnDeviceRemove) { - DPRINT_EXIT(NETVSC_DRV); + if (!net_drv_obj->Base.OnDeviceRemove) return -1; - } /* Stop outbound asap */ netif_stop_queue(net); @@ -468,7 +442,6 @@ static int netvsc_remove(struct device *device) } free_netdev(net); - DPRINT_EXIT(NETVSC_DRV); return ret; } @@ -488,8 +461,6 @@ static void netvsc_drv_exit(void) struct device *current_dev; int ret; - DPRINT_ENTER(NETVSC_DRV); - while (1) { current_dev = NULL; @@ -515,8 +486,6 @@ static void netvsc_drv_exit(void) vmbus_child_driver_unregister(drv_ctx); - DPRINT_EXIT(NETVSC_DRV); - return; } @@ -526,10 +495,6 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx; int ret; - DPRINT_ENTER(NETVSC_DRV); - - vmbus_get_interface(&net_drv_obj->Base.VmbusChannelInterface); - net_drv_obj->RingBufferSize = ring_size * PAGE_SIZE; net_drv_obj->OnReceiveCallback = netvsc_recv_callback; net_drv_obj->OnLinkStatusChanged = netvsc_linkstatus_callback; @@ -547,8 +512,6 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) /* The driver belongs to vmbus */ ret = vmbus_child_driver_register(drv_ctx); - DPRINT_EXIT(NETVSC_DRV); - return ret; } @@ -568,26 +531,17 @@ MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table); static int __init netvsc_init(void) { - int ret; - - DPRINT_ENTER(NETVSC_DRV); DPRINT_INFO(NETVSC_DRV, "Netvsc initializing...."); if (!dmi_check_system(hv_netvsc_dmi_table)) return -ENODEV; - ret = netvsc_drv_init(NetVscInitialize); - - DPRINT_EXIT(NETVSC_DRV); - - return ret; + return netvsc_drv_init(NetVscInitialize); } static void __exit netvsc_exit(void) { - DPRINT_ENTER(NETVSC_DRV); netvsc_drv_exit(); - DPRINT_EXIT(NETVSC_DRV); } static const struct pci_device_id __initconst diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index ae2a10e24d92..d78c569ac94a 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -46,7 +46,7 @@ Description: --*/ static inline void -GetRingBufferAvailBytes(RING_BUFFER_INFO *rbi, u32 *read, u32 *write) +GetRingBufferAvailBytes(struct hv_ring_buffer_info *rbi, u32 *read, u32 *write) { u32 read_loc, write_loc; @@ -68,7 +68,7 @@ Description: --*/ static inline u32 -GetNextWriteLocation(RING_BUFFER_INFO *RingInfo) +GetNextWriteLocation(struct hv_ring_buffer_info *RingInfo) { u32 next = RingInfo->RingBuffer->WriteIndex; @@ -87,7 +87,8 @@ Description: --*/ static inline void -SetNextWriteLocation(RING_BUFFER_INFO *RingInfo, u32 NextWriteLocation) +SetNextWriteLocation(struct hv_ring_buffer_info *RingInfo, + u32 NextWriteLocation) { RingInfo->RingBuffer->WriteIndex = NextWriteLocation; } @@ -102,7 +103,7 @@ Description: --*/ static inline u32 -GetNextReadLocation(RING_BUFFER_INFO *RingInfo) +GetNextReadLocation(struct hv_ring_buffer_info *RingInfo) { u32 next = RingInfo->RingBuffer->ReadIndex; @@ -122,7 +123,7 @@ Description: --*/ static inline u32 -GetNextReadLocationWithOffset(RING_BUFFER_INFO *RingInfo, u32 Offset) +GetNextReadLocationWithOffset(struct hv_ring_buffer_info *RingInfo, u32 Offset) { u32 next = RingInfo->RingBuffer->ReadIndex; @@ -143,7 +144,7 @@ Description: --*/ static inline void -SetNextReadLocation(RING_BUFFER_INFO *RingInfo, u32 NextReadLocation) +SetNextReadLocation(struct hv_ring_buffer_info *RingInfo, u32 NextReadLocation) { RingInfo->RingBuffer->ReadIndex = NextReadLocation; } @@ -159,7 +160,7 @@ Description: --*/ static inline void * -GetRingBuffer(RING_BUFFER_INFO *RingInfo) +GetRingBuffer(struct hv_ring_buffer_info *RingInfo) { return (void *)RingInfo->RingBuffer->Buffer; } @@ -175,7 +176,7 @@ Description: --*/ static inline u32 -GetRingBufferSize(RING_BUFFER_INFO *RingInfo) +GetRingBufferSize(struct hv_ring_buffer_info *RingInfo) { return RingInfo->RingDataSize; } @@ -190,10 +191,9 @@ Description: --*/ static inline u64 -GetRingBufferIndices(RING_BUFFER_INFO *RingInfo) +GetRingBufferIndices(struct hv_ring_buffer_info *RingInfo) { - return ((u64)RingInfo->RingBuffer->WriteIndex << 32) - || RingInfo->RingBuffer->ReadIndex; + return (u64)RingInfo->RingBuffer->WriteIndex << 32; } @@ -206,7 +206,7 @@ Description: Dump out to console the ring buffer info --*/ -void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix) +void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix) { u32 bytesAvailToWrite; u32 bytesAvailToRead; @@ -233,14 +233,14 @@ void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix) static u32 CopyToRingBuffer( - RING_BUFFER_INFO *RingInfo, + struct hv_ring_buffer_info *RingInfo, u32 StartWriteOffset, void *Src, u32 SrcLen); static u32 CopyFromRingBuffer( - RING_BUFFER_INFO *RingInfo, + struct hv_ring_buffer_info *RingInfo, void *Dest, u32 DestLen, u32 StartReadOffset); @@ -256,8 +256,8 @@ Description: Get various debug metrics for the specified ring buffer --*/ -void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo, - RING_BUFFER_DEBUG_INFO *DebugInfo) +void RingBufferGetDebugInfo(struct hv_ring_buffer_info *RingInfo, + struct hv_ring_buffer_debug_info *debug_info) { u32 bytesAvailToWrite; u32 bytesAvailToRead; @@ -267,11 +267,11 @@ void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo, &bytesAvailToRead, &bytesAvailToWrite); - DebugInfo->BytesAvailToRead = bytesAvailToRead; - DebugInfo->BytesAvailToWrite = bytesAvailToWrite; - DebugInfo->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex; - DebugInfo->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex; - DebugInfo->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask; + debug_info->BytesAvailToRead = bytesAvailToRead; + debug_info->BytesAvailToWrite = bytesAvailToWrite; + debug_info->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex; + debug_info->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex; + debug_info->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask; } } @@ -285,7 +285,7 @@ Description: Get the interrupt mask for the specified ring buffer --*/ -u32 GetRingBufferInterruptMask(RING_BUFFER_INFO *rbi) +u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *rbi) { return rbi->RingBuffer->InterruptMask; } @@ -299,18 +299,18 @@ Description: Initialize the ring buffer --*/ -int RingBufferInit(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen) +int RingBufferInit(struct hv_ring_buffer_info *RingInfo, void *Buffer, u32 BufferLen) { - if (sizeof(RING_BUFFER) != PAGE_SIZE) + if (sizeof(struct hv_ring_buffer) != PAGE_SIZE) return -EINVAL; - memset(RingInfo, 0, sizeof(RING_BUFFER_INFO)); + memset(RingInfo, 0, sizeof(struct hv_ring_buffer_info)); - RingInfo->RingBuffer = (RING_BUFFER *)Buffer; + RingInfo->RingBuffer = (struct hv_ring_buffer *)Buffer; RingInfo->RingBuffer->ReadIndex = RingInfo->RingBuffer->WriteIndex = 0; RingInfo->RingSize = BufferLen; - RingInfo->RingDataSize = BufferLen - sizeof(RING_BUFFER); + RingInfo->RingDataSize = BufferLen - sizeof(struct hv_ring_buffer); spin_lock_init(&RingInfo->ring_lock); @@ -326,7 +326,7 @@ Description: Cleanup the ring buffer --*/ -void RingBufferCleanup(RING_BUFFER_INFO *RingInfo) +void RingBufferCleanup(struct hv_ring_buffer_info *RingInfo) { } @@ -339,7 +339,7 @@ Description: Write to the ring buffer --*/ -int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, +int RingBufferWrite(struct hv_ring_buffer_info *OutRingInfo, struct scatterlist *sglist, u32 sgcount) { int i = 0; @@ -352,8 +352,6 @@ int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, u64 prevIndices = 0; unsigned long flags; - DPRINT_ENTER(VMBUS); - for_each_sg(sglist, sg, sgcount, i) { totalBytesToWrite += sg->length; @@ -382,9 +380,6 @@ int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, byteAvailToWrite); spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); - - DPRINT_EXIT(VMBUS); - return -1; } @@ -416,9 +411,6 @@ int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, /* DumpRingInfo(OutRingInfo, "AFTER "); */ spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); - - DPRINT_EXIT(VMBUS); - return 0; } @@ -432,7 +424,7 @@ Description: Read without advancing the read index --*/ -int RingBufferPeek(RING_BUFFER_INFO *InRingInfo, void *Buffer, u32 BufferLen) +int RingBufferPeek(struct hv_ring_buffer_info *InRingInfo, void *Buffer, u32 BufferLen) { u32 bytesAvailToWrite; u32 bytesAvailToRead; @@ -481,7 +473,7 @@ Description: Read and advance the read index --*/ -int RingBufferRead(RING_BUFFER_INFO *InRingInfo, void *Buffer, +int RingBufferRead(struct hv_ring_buffer_info *InRingInfo, void *Buffer, u32 BufferLen, u32 Offset) { u32 bytesAvailToWrite; @@ -556,7 +548,7 @@ Description: --*/ static u32 CopyToRingBuffer( - RING_BUFFER_INFO *RingInfo, + struct hv_ring_buffer_info *RingInfo, u32 StartWriteOffset, void *Src, u32 SrcLen) @@ -594,7 +586,7 @@ Description: --*/ static u32 CopyFromRingBuffer( - RING_BUFFER_INFO *RingInfo, + struct hv_ring_buffer_info *RingInfo, void *Dest, u32 DestLen, u32 StartReadOffset) diff --git a/drivers/staging/hv/ring_buffer.h b/drivers/staging/hv/ring_buffer.h index 6202157e145d..a7f1717c6a56 100644 --- a/drivers/staging/hv/ring_buffer.h +++ b/drivers/staging/hv/ring_buffer.h @@ -27,7 +27,7 @@ #include <linux/scatterlist.h> -typedef struct _RING_BUFFER { +struct hv_ring_buffer { /* Offset in bytes from the start of ring data below */ volatile u32 WriteIndex; @@ -51,51 +51,52 @@ typedef struct _RING_BUFFER { * !!! DO NOT place any fields below this !!! */ u8 Buffer[0]; -} __attribute__((packed)) RING_BUFFER; +} __attribute__((packed)); -typedef struct _RING_BUFFER_INFO { - RING_BUFFER *RingBuffer; +struct hv_ring_buffer_info { + struct hv_ring_buffer *RingBuffer; u32 RingSize; /* Include the shared header */ spinlock_t ring_lock; u32 RingDataSize; /* < ringSize */ u32 RingDataStartOffset; +}; -} RING_BUFFER_INFO; - -typedef struct _RING_BUFFER_DEBUG_INFO { +struct hv_ring_buffer_debug_info { u32 CurrentInterruptMask; u32 CurrentReadIndex; u32 CurrentWriteIndex; u32 BytesAvailToRead; u32 BytesAvailToWrite; -} RING_BUFFER_DEBUG_INFO; +}; /* Interface */ -int RingBufferInit(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen); +int RingBufferInit(struct hv_ring_buffer_info *RingInfo, void *Buffer, + u32 BufferLen); -void RingBufferCleanup(RING_BUFFER_INFO *RingInfo); +void RingBufferCleanup(struct hv_ring_buffer_info *RingInfo); -int RingBufferWrite(RING_BUFFER_INFO *RingInfo, +int RingBufferWrite(struct hv_ring_buffer_info *RingInfo, struct scatterlist *sglist, u32 sgcount); -int RingBufferPeek(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen); +int RingBufferPeek(struct hv_ring_buffer_info *RingInfo, void *Buffer, + u32 BufferLen); -int RingBufferRead(RING_BUFFER_INFO *RingInfo, +int RingBufferRead(struct hv_ring_buffer_info *RingInfo, void *Buffer, u32 BufferLen, u32 Offset); -u32 GetRingBufferInterruptMask(RING_BUFFER_INFO *RingInfo); +u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *RingInfo); -void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix); +void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix); -void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo, - RING_BUFFER_DEBUG_INFO *DebugInfo); +void RingBufferGetDebugInfo(struct hv_ring_buffer_info *RingInfo, + struct hv_ring_buffer_debug_info *debug_info); #endif /* _RING_BUFFER_H_ */ diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c index 5edf0853c6af..fa2141f454f0 100644 --- a/drivers/staging/hv/rndis_filter.c +++ b/drivers/staging/hv/rndis_filter.c @@ -244,8 +244,6 @@ static int RndisFilterSendRequest(struct rndis_device *Device, int ret; struct hv_netvsc_packet *packet; - DPRINT_ENTER(NETVSC); - /* Setup the packet to send it */ packet = &Request->Packet; @@ -265,7 +263,6 @@ static int RndisFilterSendRequest(struct rndis_device *Device, packet->Completion.Send.SendCompletionTid = (unsigned long)Device; ret = gRndisFilter.InnerDriver.OnSend(Device->NetDevice->Device, packet); - DPRINT_EXIT(NETVSC); return ret; } @@ -276,8 +273,6 @@ static void RndisFilterReceiveResponse(struct rndis_device *Device, bool found = false; unsigned long flags; - DPRINT_ENTER(NETVSC); - spin_lock_irqsave(&Device->request_lock, flags); list_for_each_entry(request, &Device->RequestList, ListEntry) { /* @@ -325,8 +320,6 @@ static void RndisFilterReceiveResponse(struct rndis_device *Device, Response->Message.InitializeComplete.RequestId, Response->NdisMessageType); } - - DPRINT_EXIT(NETVSC); } static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device, @@ -353,8 +346,6 @@ static void RndisFilterReceiveData(struct rndis_device *Device, struct rndis_packet *rndisPacket; u32 dataOffset; - DPRINT_ENTER(NETVSC); - /* empty ethernet frame ?? */ /* ASSERT(Packet->PageBuffers[0].Length > */ /* RNDIS_MESSAGE_SIZE(struct rndis_packet)); */ @@ -377,8 +368,6 @@ static void RndisFilterReceiveData(struct rndis_device *Device, gRndisFilter.InnerDriver.OnReceiveCallback(Device->NetDevice->Device, Packet); - - DPRINT_EXIT(NETVSC); } static int RndisFilterOnReceive(struct hv_device *Device, @@ -389,8 +378,6 @@ static int RndisFilterOnReceive(struct hv_device *Device, struct rndis_message rndisMessage; struct rndis_message *rndisHeader; - DPRINT_ENTER(NETVSC); - if (!netDevice) return -EINVAL; @@ -398,7 +385,6 @@ static int RndisFilterOnReceive(struct hv_device *Device, if (!netDevice->Extension) { DPRINT_ERR(NETVSC, "got rndis message but no rndis device..." "dropping this message!"); - DPRINT_EXIT(NETVSC); return -1; } @@ -406,7 +392,6 @@ static int RndisFilterOnReceive(struct hv_device *Device, if (rndisDevice->State == RNDIS_DEV_UNINITIALIZED) { DPRINT_ERR(NETVSC, "got rndis message but rndis device " "uninitialized...dropping this message!"); - DPRINT_EXIT(NETVSC); return -1; } @@ -431,7 +416,6 @@ static int RndisFilterOnReceive(struct hv_device *Device, "bytes got %u)...dropping this message!", rndisHeader->MessageLength, Packet->TotalDataBufferLength); - DPRINT_EXIT(NETVSC); return -1; } #endif @@ -479,7 +463,6 @@ static int RndisFilterOnReceive(struct hv_device *Device, break; } - DPRINT_EXIT(NETVSC); return 0; } @@ -492,8 +475,6 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid, struct rndis_query_complete *queryComplete; int ret = 0; - DPRINT_ENTER(NETVSC); - if (!Result) return -EINVAL; @@ -536,7 +517,6 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid, Cleanup: if (request) PutRndisRequest(Device, request); - DPRINT_EXIT(NETVSC); return ret; } @@ -568,8 +548,6 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device, u32 status; int ret; - DPRINT_ENTER(NETVSC); - /* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */ /* sizeof(struct rndis_message)); */ @@ -614,15 +592,11 @@ Cleanup: if (request) PutRndisRequest(Device, request); Exit: - DPRINT_EXIT(NETVSC); - return ret; } int RndisFilterInit(struct netvsc_driver *Driver) { - DPRINT_ENTER(NETVSC); - DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd", sizeof(struct rndis_filter_packet)); @@ -658,8 +632,6 @@ int RndisFilterInit(struct netvsc_driver *Driver) /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */ Driver->OnReceiveCallback = RndisFilterOnReceive; - DPRINT_EXIT(NETVSC); - return 0; } @@ -671,8 +643,6 @@ static int RndisFilterInitDevice(struct rndis_device *Device) u32 status; int ret; - DPRINT_ENTER(NETVSC); - request = GetRndisRequest(Device, REMOTE_NDIS_INITIALIZE_MSG, RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); if (!request) { @@ -710,7 +680,6 @@ static int RndisFilterInitDevice(struct rndis_device *Device) Cleanup: if (request) PutRndisRequest(Device, request); - DPRINT_EXIT(NETVSC); return ret; } @@ -720,8 +689,6 @@ static void RndisFilterHaltDevice(struct rndis_device *Device) struct rndis_request *request; struct rndis_halt_request *halt; - DPRINT_ENTER(NETVSC); - /* Attempt to do a rndis device halt */ request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG, RNDIS_MESSAGE_SIZE(struct rndis_halt_request)); @@ -740,7 +707,6 @@ static void RndisFilterHaltDevice(struct rndis_device *Device) Cleanup: if (request) PutRndisRequest(Device, request); - DPRINT_EXIT(NETVSC); return; } @@ -748,8 +714,6 @@ static int RndisFilterOpenDevice(struct rndis_device *Device) { int ret; - DPRINT_ENTER(NETVSC); - if (Device->State != RNDIS_DEV_INITIALIZED) return 0; @@ -760,7 +724,6 @@ static int RndisFilterOpenDevice(struct rndis_device *Device) if (ret == 0) Device->State = RNDIS_DEV_DATAINITIALIZED; - DPRINT_EXIT(NETVSC); return ret; } @@ -768,8 +731,6 @@ static int RndisFilterCloseDevice(struct rndis_device *Device) { int ret; - DPRINT_ENTER(NETVSC); - if (Device->State != RNDIS_DEV_DATAINITIALIZED) return 0; @@ -777,8 +738,6 @@ static int RndisFilterCloseDevice(struct rndis_device *Device) if (ret == 0) Device->State = RNDIS_DEV_INITIALIZED; - DPRINT_EXIT(NETVSC); - return ret; } @@ -790,13 +749,9 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, struct rndis_device *rndisDevice; struct netvsc_device_info *deviceInfo = AdditionalInfo; - DPRINT_ENTER(NETVSC); - rndisDevice = GetRndisDevice(); - if (!rndisDevice) { - DPRINT_EXIT(NETVSC); + if (!rndisDevice) return -1; - } DPRINT_DBG(NETVSC, "rndis device object allocated - %p", rndisDevice); @@ -808,7 +763,6 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, ret = gRndisFilter.InnerDriver.Base.OnDeviceAdd(Device, AdditionalInfo); if (ret != 0) { kfree(rndisDevice); - DPRINT_EXIT(NETVSC); return ret; } @@ -849,8 +803,6 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice, ((deviceInfo->LinkState) ? ("down") : ("up"))); - DPRINT_EXIT(NETVSC); - return ret; } @@ -859,8 +811,6 @@ static int RndisFilterOnDeviceRemove(struct hv_device *Device) struct netvsc_device *netDevice = Device->Extension; struct rndis_device *rndisDevice = netDevice->Extension; - DPRINT_ENTER(NETVSC); - /* Halt and release the rndis device */ RndisFilterHaltDevice(rndisDevice); @@ -870,50 +820,31 @@ static int RndisFilterOnDeviceRemove(struct hv_device *Device) /* Pass control to inner driver to remove the device */ gRndisFilter.InnerDriver.Base.OnDeviceRemove(Device); - DPRINT_EXIT(NETVSC); - return 0; } static void RndisFilterOnCleanup(struct hv_driver *Driver) { - DPRINT_ENTER(NETVSC); - - DPRINT_EXIT(NETVSC); } int RndisFilterOnOpen(struct hv_device *Device) { - int ret; struct netvsc_device *netDevice = Device->Extension; - DPRINT_ENTER(NETVSC); - if (!netDevice) return -EINVAL; - ret = RndisFilterOpenDevice(netDevice->Extension); - - DPRINT_EXIT(NETVSC); - - return ret; + return RndisFilterOpenDevice(netDevice->Extension); } int RndisFilterOnClose(struct hv_device *Device) { - int ret; struct netvsc_device *netDevice = Device->Extension; - DPRINT_ENTER(NETVSC); - if (!netDevice) return -EINVAL; - ret = RndisFilterCloseDevice(netDevice->Extension); - - DPRINT_EXIT(NETVSC); - - return ret; + return RndisFilterCloseDevice(netDevice->Extension); } static int RndisFilterOnSend(struct hv_device *Device, @@ -925,8 +856,6 @@ static int RndisFilterOnSend(struct hv_device *Device, struct rndis_packet *rndisPacket; u32 rndisMessageSize; - DPRINT_ENTER(NETVSC); - /* Add the rndis header */ filterPacket = (struct rndis_filter_packet *)Packet->Extension; /* ASSERT(filterPacket); */ @@ -971,8 +900,6 @@ static int RndisFilterOnSend(struct hv_device *Device, filterPacket->CompletionContext; } - DPRINT_EXIT(NETVSC); - return ret; } @@ -980,19 +907,12 @@ static void RndisFilterOnSendCompletion(void *Context) { struct rndis_filter_packet *filterPacket = Context; - DPRINT_ENTER(NETVSC); - /* Pass it back to the original handler */ filterPacket->OnCompletion(filterPacket->CompletionContext); - - DPRINT_EXIT(NETVSC); } static void RndisFilterOnSendRequestCompletion(void *Context) { - DPRINT_ENTER(NETVSC); - /* Noop */ - DPRINT_EXIT(NETVSC); } diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 27a276e08ee9..19e87f689fa0 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -28,6 +28,7 @@ #include "storvsc_api.h" #include "vmbus_packet_format.h" #include "vstorage.h" +#include "channel.h" struct storvsc_request_extension { @@ -186,7 +187,6 @@ static int StorVscChannelInit(struct hv_device *Device) if (!storDevice) { DPRINT_ERR(STORVSC, "unable to get stor device..." "device being destroyed?"); - DPRINT_EXIT(STORVSC); return -1; } @@ -213,12 +213,11 @@ static int StorVscChannelInit(struct hv_device *Device) DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION..."); - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)request, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)request, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(STORVSC, "unable to send BEGIN_INITIALIZATION_OPERATION"); @@ -245,12 +244,11 @@ static int StorVscChannelInit(struct hv_device *Device) vstorPacket->Version.MajorMinor = VMSTOR_PROTOCOL_VERSION_CURRENT; FILL_VMSTOR_REVISION(vstorPacket->Version.Revision); - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)request, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)request, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(STORVSC, "unable to send BEGIN_INITIALIZATION_OPERATION"); @@ -277,12 +275,11 @@ static int StorVscChannelInit(struct hv_device *Device) vstorPacket->StorageChannelProperties.PortNumber = storDevice->PortNumber; - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)request, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)request, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(STORVSC, @@ -314,12 +311,11 @@ static int StorVscChannelInit(struct hv_device *Device) vstorPacket->Operation = VStorOperationEndInitialization; vstorPacket->Flags = REQUEST_COMPLETION_FLAG; - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)request, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)request, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(STORVSC, @@ -344,8 +340,6 @@ Cleanup: request->WaitEvent = NULL; nomem: PutStorDevice(Device); - - DPRINT_EXIT(STORVSC); return ret; } @@ -356,13 +350,10 @@ static void StorVscOnIOCompletion(struct hv_device *Device, struct hv_storvsc_request *request; struct storvsc_device *storDevice; - DPRINT_ENTER(STORVSC); - storDevice = MustGetStorDevice(Device); if (!storDevice) { DPRINT_ERR(STORVSC, "unable to get stor device..." "device being destroyed?"); - DPRINT_EXIT(STORVSC); return; } @@ -414,8 +405,6 @@ static void StorVscOnIOCompletion(struct hv_device *Device, atomic_dec(&storDevice->NumOutstandingRequests); PutStorDevice(Device); - - DPRINT_EXIT(STORVSC); } static void StorVscOnReceive(struct hv_device *Device, @@ -449,23 +438,19 @@ static void StorVscOnChannelCallback(void *context) struct storvsc_request_extension *request; int ret; - DPRINT_ENTER(STORVSC); - /* ASSERT(device); */ storDevice = MustGetStorDevice(device); if (!storDevice) { DPRINT_ERR(STORVSC, "unable to get stor device..." "device being destroyed?"); - DPRINT_EXIT(STORVSC); return; } do { - ret = device->Driver->VmbusChannelInterface.RecvPacket(device, - packet, - ALIGN_UP(sizeof(struct vstor_packet), 8), - &bytesRecvd, &requestId); + ret = vmbus_recvpacket(device->channel, packet, + ALIGN_UP(sizeof(struct vstor_packet), 8), + &bytesRecvd, &requestId); if (ret == 0 && bytesRecvd > 0) { DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx", bytesRecvd, requestId); @@ -501,8 +486,6 @@ static void StorVscOnChannelCallback(void *context) } while (1); PutStorDevice(device); - - DPRINT_EXIT(STORVSC); return; } @@ -516,13 +499,11 @@ static int StorVscConnectToVsp(struct hv_device *Device) memset(&props, 0, sizeof(struct vmstorage_channel_properties)); /* Open the channel */ - ret = Device->Driver->VmbusChannelInterface.Open(Device, - storDriver->RingBufferSize, - storDriver->RingBufferSize, - (void *)&props, - sizeof(struct vmstorage_channel_properties), - StorVscOnChannelCallback, - Device); + ret = vmbus_open(Device->channel, + storDriver->RingBufferSize, storDriver->RingBufferSize, + (void *)&props, + sizeof(struct vmstorage_channel_properties), + StorVscOnChannelCallback, Device); DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d", props.PathId, props.TargetId, props.MaxTransferBytes); @@ -547,8 +528,6 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) struct storvsc_device_info *deviceInfo; int ret = 0; - DPRINT_ENTER(STORVSC); - deviceInfo = (struct storvsc_device_info *)AdditionalInfo; storDevice = AllocStorDevice(Device); if (!storDevice) { @@ -584,8 +563,6 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) storDevice->TargetId); Cleanup: - DPRINT_EXIT(STORVSC); - return ret; } @@ -596,8 +573,6 @@ static int StorVscOnDeviceRemove(struct hv_device *Device) { struct storvsc_device *storDevice; - DPRINT_ENTER(STORVSC); - DPRINT_INFO(STORVSC, "disabling storage device (%p)...", Device->Extension); @@ -622,11 +597,9 @@ static int StorVscOnDeviceRemove(struct hv_device *Device) DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice); /* Close the channel */ - Device->Driver->VmbusChannelInterface.Close(Device); + vmbus_close(Device->channel); FreeStorDevice(storDevice); - - DPRINT_EXIT(STORVSC); return 0; } @@ -637,15 +610,12 @@ int StorVscOnHostReset(struct hv_device *Device) struct vstor_packet *vstorPacket; int ret; - DPRINT_ENTER(STORVSC); - DPRINT_INFO(STORVSC, "resetting host adapter..."); storDevice = GetStorDevice(Device); if (!storDevice) { DPRINT_ERR(STORVSC, "unable to get stor device..." "device being destroyed?"); - DPRINT_EXIT(STORVSC); return -1; } @@ -662,12 +632,11 @@ int StorVscOnHostReset(struct hv_device *Device) vstorPacket->Flags = REQUEST_COMPLETION_FLAG; vstorPacket->VmSrb.PathId = storDevice->PathId; - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)&storDevice->ResetRequest, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)&storDevice->ResetRequest, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (ret != 0) { DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d", vstorPacket, ret); @@ -687,7 +656,6 @@ int StorVscOnHostReset(struct hv_device *Device) Cleanup: PutStorDevice(Device); - DPRINT_EXIT(STORVSC); return ret; } @@ -702,8 +670,6 @@ static int StorVscOnIORequest(struct hv_device *Device, struct vstor_packet *vstorPacket; int ret = 0; - DPRINT_ENTER(STORVSC); - requestExtension = (struct storvsc_request_extension *)Request->Extension; vstorPacket = &requestExtension->VStorPacket; @@ -720,7 +686,6 @@ static int StorVscOnIORequest(struct hv_device *Device, if (!storDevice) { DPRINT_ERR(STORVSC, "unable to get stor device..." "device being destroyed?"); - DPRINT_EXIT(STORVSC); return -2; } @@ -763,19 +728,17 @@ static int StorVscOnIORequest(struct hv_device *Device, vstorPacket->VmSrb.CdbLength); if (requestExtension->Request->DataBuffer.Length) { - ret = Device->Driver->VmbusChannelInterface. - SendPacketMultiPageBuffer(Device, + ret = vmbus_sendpacket_multipagebuffer(Device->channel, &requestExtension->Request->DataBuffer, vstorPacket, sizeof(struct vstor_packet), (unsigned long)requestExtension); } else { - ret = Device->Driver->VmbusChannelInterface.SendPacket(Device, - vstorPacket, - sizeof(struct vstor_packet), - (unsigned long)requestExtension, - VmbusPacketTypeDataInBand, - VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + ret = vmbus_sendpacket(Device->channel, vstorPacket, + sizeof(struct vstor_packet), + (unsigned long)requestExtension, + VmbusPacketTypeDataInBand, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); } if (ret != 0) { @@ -786,8 +749,6 @@ static int StorVscOnIORequest(struct hv_device *Device, atomic_inc(&storDevice->NumOutstandingRequests); PutStorDevice(Device); - - DPRINT_EXIT(STORVSC); return ret; } @@ -796,8 +757,6 @@ static int StorVscOnIORequest(struct hv_device *Device, */ static void StorVscOnCleanup(struct hv_driver *Driver) { - DPRINT_ENTER(STORVSC); - DPRINT_EXIT(STORVSC); } /* @@ -807,8 +766,6 @@ int StorVscInitialize(struct hv_driver *Driver) { struct storvsc_driver_object *storDriver; - DPRINT_ENTER(STORVSC); - storDriver = (struct storvsc_driver_object *)Driver; DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd " @@ -833,7 +790,7 @@ int StorVscInitialize(struct hv_driver *Driver) * 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 + struct vstor_packet + u64) + * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64) */ storDriver->MaxOutstandingRequestsPerChannel = ((storDriver->RingBufferSize - PAGE_SIZE) / @@ -852,7 +809,5 @@ int StorVscInitialize(struct hv_driver *Driver) storDriver->OnIORequest = StorVscOnIORequest; - DPRINT_EXIT(STORVSC); - return 0; } diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 0063bde9a4b2..8505a1c5f9ee 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -28,10 +28,10 @@ #include "vmbus_api.h" /* Defines */ -#define STORVSC_RING_BUFFER_SIZE (10*PAGE_SIZE) +#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) #define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) -#define STORVSC_MAX_IO_REQUESTS 64 +#define STORVSC_MAX_IO_REQUESTS 128 /* * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index d22e35f598ba..41d9acf4cd61 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -141,10 +141,6 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj; struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx; - DPRINT_ENTER(STORVSC_DRV); - - vmbus_get_interface(&storvsc_drv_obj->Base.VmbusChannelInterface); - storvsc_drv_obj->RingBufferSize = storvsc_ringbuffer_size; /* Callback to client driver to complete the initialization */ @@ -175,8 +171,6 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) /* The driver belongs to vmbus */ ret = vmbus_child_driver_register(drv_ctx); - DPRINT_EXIT(STORVSC_DRV); - return ret; } @@ -194,8 +188,6 @@ static void storvsc_drv_exit(void) struct device *current_dev = NULL; int ret; - DPRINT_ENTER(STORVSC_DRV); - while (1) { current_dev = NULL; @@ -219,9 +211,6 @@ static void storvsc_drv_exit(void) storvsc_drv_obj->Base.OnCleanup(&storvsc_drv_obj->Base); vmbus_child_driver_unregister(drv_ctx); - - DPRINT_EXIT(STORVSC_DRV); - return; } @@ -243,8 +232,6 @@ static int storvsc_probe(struct device *device) struct host_device_context *host_device_ctx; struct storvsc_device_info device_info; - DPRINT_ENTER(STORVSC_DRV); - if (!storvsc_drv_obj->Base.OnDeviceAdd) return -1; @@ -271,8 +258,6 @@ static int storvsc_probe(struct device *device) if (!host_device_ctx->request_pool) { scsi_host_put(host); - DPRINT_EXIT(STORVSC_DRV); - return -ENOMEM; } @@ -284,8 +269,6 @@ static int storvsc_probe(struct device *device) DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device"); kmem_cache_destroy(host_device_ctx->request_pool); scsi_host_put(host); - DPRINT_EXIT(STORVSC_DRV); - return -1; } @@ -309,15 +292,10 @@ static int storvsc_probe(struct device *device) kmem_cache_destroy(host_device_ctx->request_pool); scsi_host_put(host); - DPRINT_EXIT(STORVSC_DRV); - return -1; } scsi_scan_host(host); - - DPRINT_EXIT(STORVSC_DRV); - return ret; } @@ -340,12 +318,8 @@ static int storvsc_remove(struct device *device) (struct host_device_context *)host->hostdata; - DPRINT_ENTER(STORVSC_DRV); - - if (!storvsc_drv_obj->Base.OnDeviceRemove) { - DPRINT_EXIT(STORVSC_DRV); + if (!storvsc_drv_obj->Base.OnDeviceRemove) return -1; - } /* * Call to the vsc driver to let it know that the device is being @@ -368,9 +342,6 @@ static int storvsc_remove(struct device *device) DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host); scsi_host_put(host); - - DPRINT_EXIT(STORVSC_DRV); - return ret; } @@ -393,8 +364,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) /* (unsigned long)cmd_request); */ /* ASSERT(scmnd->scsi_done); */ - DPRINT_ENTER(STORVSC_DRV); - if (cmd_request->bounce_sgl_count) { /* using bounce buffer */ /* printk("copy_from_bounce_buffer\n"); */ @@ -427,8 +396,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) scsi_done_fn(scmnd); kmem_cache_free(host_device_ctx->request_pool, cmd_request); - - DPRINT_EXIT(STORVSC_DRV); } static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count) @@ -526,7 +493,7 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */ - if (j == 0) + if (bounce_addr == 0) bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0); while (srclen) { @@ -587,7 +554,7 @@ static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl, destlen = orig_sgl[i].length; /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */ - if (j == 0) + if (bounce_addr == 0) bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0); while (destlen) { @@ -646,8 +613,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, unsigned int request_size = 0; int i; struct scatterlist *sgl; - - DPRINT_ENTER(STORVSC_DRV); + unsigned int sg_count = 0; DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d " "queue depth %d tagged %d", scmnd, scmnd->sc_data_direction, @@ -730,6 +696,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, request->DataBuffer.Length = scsi_bufflen(scmnd); if (scsi_sg_count(scmnd)) { sgl = (struct scatterlist *)scsi_sglist(scmnd); + sg_count = scsi_sg_count(scmnd); /* check if we need to bounce the sgl */ if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) { @@ -764,15 +731,16 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, scsi_sg_count(scmnd)); sgl = cmd_request->bounce_sgl; + sg_count = cmd_request->bounce_sgl_count; } request->DataBuffer.Offset = sgl[0].offset; - for (i = 0; i < scsi_sg_count(scmnd); i++) { + for (i = 0; i < sg_count; i++) { DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n", i, sgl[i].length, sgl[i].offset); request->DataBuffer.PfnArray[i] = - page_to_pfn(sg_page((&sgl[i]))); + page_to_pfn(sg_page((&sgl[i]))); } } else if (scsi_sglist(scmnd)) { /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */ @@ -812,8 +780,6 @@ retry_request: ret = SCSI_MLQUEUE_DEVICE_BUSY; } - DPRINT_EXIT(STORVSC_DRV); - return ret; } @@ -873,23 +839,17 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) (struct host_device_context *)scmnd->device->host->hostdata; struct vm_device *device_ctx = host_device_ctx->device_ctx; - DPRINT_ENTER(STORVSC_DRV); - DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...", scmnd->device, &device_ctx->device_obj); /* Invokes the vsc to reset the host/bus */ ret = StorVscOnHostReset(&device_ctx->device_obj); - if (ret != 0) { - DPRINT_EXIT(STORVSC_DRV); + if (ret != 0) return ret; - } DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted", scmnd->device, &device_ctx->device_obj); - DPRINT_EXIT(STORVSC_DRV); - return ret; } @@ -977,18 +937,14 @@ static int __init storvsc_init(void) { int ret; - DPRINT_ENTER(STORVSC_DRV); DPRINT_INFO(STORVSC_DRV, "Storvsc initializing...."); ret = storvsc_drv_init(StorVscInitialize); - DPRINT_EXIT(STORVSC_DRV); return ret; } static void __exit storvsc_exit(void) { - DPRINT_ENTER(STORVSC_DRV); storvsc_drv_exit(); - DPRINT_ENTER(STORVSC_DRV); } MODULE_LICENSE("GPL"); diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c index 007543bdb410..d449daf81976 100644 --- a/drivers/staging/hv/vmbus.c +++ b/drivers/staging/hv/vmbus.c @@ -57,26 +57,7 @@ static struct hv_device *gDevice; /* vmbus root device */ */ static void VmbusGetChannelOffers(void) { - DPRINT_ENTER(VMBUS); - VmbusChannelRequestOffers(); - DPRINT_EXIT(VMBUS); -} - -/* - * VmbusGetChannelInterface - Get the channel interface - */ -static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface) -{ - GetChannelInterface(Interface); -} - -/* - * VmbusGetChannelInfo - Get the device info for the specified device object - */ -static void VmbusGetChannelInfo(struct hv_device *DeviceObject, - struct hv_device_info *DeviceInfo) -{ - GetChannelInfo(DeviceObject, DeviceInfo); + vmbus_request_offers(); } /* @@ -84,12 +65,12 @@ static void VmbusGetChannelInfo(struct hv_device *DeviceObject, */ struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType, struct hv_guid *DeviceInstance, - void *Context) + struct vmbus_channel *channel) { struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver; return vmbusDriver->OnChildDeviceCreate(DeviceType, DeviceInstance, - Context); + channel); } /* @@ -120,8 +101,6 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) u32 *irqvector = AdditionalInfo; int ret; - DPRINT_ENTER(VMBUS); - gDevice = dev; memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); @@ -136,8 +115,6 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) ret = VmbusConnect(); /* VmbusSendEvent(device->localPortId+1); */ - DPRINT_EXIT(VMBUS); - return ret; } @@ -148,12 +125,9 @@ static int VmbusOnDeviceRemove(struct hv_device *dev) { int ret = 0; - DPRINT_ENTER(VMBUS); - VmbusChannelReleaseUnattachedChannels(); + vmbus_release_unattached_channels(); VmbusDisconnect(); on_each_cpu(HvSynicCleanup, NULL, 1); - DPRINT_EXIT(VMBUS); - return ret; } @@ -164,9 +138,7 @@ static void VmbusOnCleanup(struct hv_driver *drv) { /* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */ - DPRINT_ENTER(VMBUS); HvCleanup(); - DPRINT_EXIT(VMBUS); } /* @@ -190,7 +162,7 @@ static void VmbusOnMsgDPC(struct hv_driver *drv) continue; osd_schedule_callback(gVmbusConnection.WorkQueue, - VmbusOnChannelMessage, + vmbus_onmessage, (void *)copied); } @@ -239,8 +211,6 @@ static int VmbusOnISR(struct hv_driver *drv) page_addr = gHvContext.synICMessagePage[cpu]; msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; - DPRINT_ENTER(VMBUS); - /* Check if there are actual msgs to be process */ if (msg->Header.MessageType != HvMessageTypeNone) { DPRINT_DBG(VMBUS, "received msg type %d size %d", @@ -259,7 +229,6 @@ static int VmbusOnISR(struct hv_driver *drv) ret |= 0x2; } - DPRINT_EXIT(VMBUS); return ret; } @@ -271,18 +240,16 @@ int VmbusInitialize(struct hv_driver *drv) struct vmbus_driver *driver = (struct vmbus_driver *)drv; int ret; - DPRINT_ENTER(VMBUS); - DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++", HV_DRV_VERSION); DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++", VMBUS_REVISION_NUMBER); DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++", VMBUS_MESSAGE_SINT); - DPRINT_DBG(VMBUS, "sizeof(VMBUS_CHANNEL_PACKET_PAGE_BUFFER)=%zd, " + DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, " "sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd", - sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER), - sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)); + sizeof(struct vmbus_channel_packet_page_buffer), + sizeof(struct vmbus_channel_packet_multipage_buffer)); drv->name = gDriverName; memcpy(&drv->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); @@ -295,8 +262,6 @@ int VmbusInitialize(struct hv_driver *drv) driver->OnMsgDpc = VmbusOnMsgDPC; driver->OnEventDpc = VmbusOnEventDPC; driver->GetChannelOffers = VmbusGetChannelOffers; - driver->GetChannelInterface = VmbusGetChannelInterface; - driver->GetChannelInfo = VmbusGetChannelInfo; /* Hypervisor initialization...setup hypercall page..etc */ ret = HvInit(); @@ -305,7 +270,5 @@ int VmbusInitialize(struct hv_driver *drv) ret); gDriver = drv; - DPRINT_EXIT(VMBUS); - return ret; } diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h index 3c14b2926e00..42f2adb99547 100644 --- a/drivers/staging/hv/vmbus.h +++ b/drivers/staging/hv/vmbus.h @@ -69,10 +69,8 @@ static inline struct driver_context *driver_to_driver_context(struct device_driv /* Vmbus interface */ - int vmbus_child_driver_register(struct driver_context *driver_ctx); void vmbus_child_driver_unregister(struct driver_context *driver_ctx); -void vmbus_get_interface(struct vmbus_channel_interface *interface); extern struct completion hv_channel_ready; diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h index 4275be3292ce..2af42e550076 100644 --- a/drivers/staging/hv/vmbus_api.h +++ b/drivers/staging/hv/vmbus_api.h @@ -84,51 +84,6 @@ struct hv_device_info { struct hv_dev_port_info Outbound; }; -/** - * struct vmbus_channel_interface - Contains member functions for vmbus channel - * @Open: Open the channel - * @Close: Close the channel - * @SendPacket: Send a packet over the channel - * @SendPacketPageBuffer: Send a single page buffer over the channel - * @SendPacketMultiPageBuffer: Send a multiple page buffers - * @RecvPacket: Receive packet - * @RecvPacketRaw: Receive Raw packet - * @EstablishGpadl: Set up GPADL for ringbuffer - * @TeardownGpadl: Teardown GPADL for ringbuffer - * @GetInfo: Get info about the channel - * - * This structure contains function pointer to control vmbus channel - * behavior. None of these functions is externally callable, but they - * are used for normal vmbus channel internal behavior. - * Only used by Hyper-V drivers. - */ -struct vmbus_channel_interface { - int (*Open)(struct hv_device *Device, u32 SendBufferSize, - u32 RecvRingBufferSize, void *UserData, u32 UserDataLen, - void (*ChannelCallback)(void *context), - void *Context); - void (*Close)(struct hv_device *device); - int (*SendPacket)(struct hv_device *Device, const void *Buffer, - u32 BufferLen, u64 RequestId, u32 Type, u32 Flags); - int (*SendPacketPageBuffer)(struct hv_device *dev, - struct hv_page_buffer PageBuffers[], - u32 PageCount, void *Buffer, u32 BufferLen, - u64 RequestId); - int (*SendPacketMultiPageBuffer)(struct hv_device *device, - struct hv_multipage_buffer *mpb, - void *Buffer, - u32 BufferLen, - u64 RequestId); - int (*RecvPacket)(struct hv_device *dev, void *buf, u32 buflen, - u32 *BufferActualLen, u64 *RequestId); - int (*RecvPacketRaw)(struct hv_device *dev, void *buf, u32 buflen, - u32 *BufferActualLen, u64 *RequestId); - int (*EstablishGpadl)(struct hv_device *dev, void *buf, u32 buflen, - u32 *GpadlHandle); - int (*TeardownGpadl)(struct hv_device *device, u32 GpadlHandle); - void (*GetInfo)(struct hv_device *dev, struct hv_device_info *devinfo); -}; - /* Base driver object */ struct hv_driver { const char *name; @@ -139,8 +94,6 @@ struct hv_driver { int (*OnDeviceAdd)(struct hv_device *device, void *data); int (*OnDeviceRemove)(struct hv_device *device); void (*OnCleanup)(struct hv_driver *driver); - - struct vmbus_channel_interface VmbusChannelInterface; }; /* Base device object */ @@ -156,7 +109,7 @@ struct hv_device { /* the device instance id of this device */ struct hv_guid deviceInstance; - void *context; + struct vmbus_channel *channel; /* Device extension; */ void *Extension; @@ -171,7 +124,7 @@ struct vmbus_driver { /* Set by the caller */ struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType, struct hv_guid *DeviceInstance, - void *Context); + struct vmbus_channel *channel); void (*OnChildDeviceDestroy)(struct hv_device *device); int (*OnChildDeviceAdd)(struct hv_device *RootDevice, struct hv_device *ChildDevice); @@ -182,10 +135,6 @@ struct vmbus_driver { void (*OnMsgDpc)(struct hv_driver *driver); void (*OnEventDpc)(struct hv_driver *driver); void (*GetChannelOffers)(void); - - void (*GetChannelInterface)(struct vmbus_channel_interface *i); - void (*GetChannelInfo)(struct hv_device *dev, - struct hv_device_info *devinfo); }; int VmbusInitialize(struct hv_driver *drv); diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 22c80ece6388..0d9f3a411e72 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -32,6 +32,7 @@ #include "osd.h" #include "logging.h" #include "vmbus.h" +#include "channel.h" /* FIXME! We need to do this dynamically for PIC and APIC system */ @@ -70,13 +71,11 @@ static void vmbus_bus_release(struct device *device); static struct hv_device *vmbus_child_device_create(struct hv_guid *type, struct hv_guid *instance, - void *context); + struct vmbus_channel *channel); static void vmbus_child_device_destroy(struct hv_device *device_obj); static int vmbus_child_device_register(struct hv_device *root_device_obj, struct hv_device *child_device_obj); static void vmbus_child_device_unregister(struct hv_device *child_device_obj); -static void vmbus_child_device_get_info(struct hv_device *device_obj, - struct hv_device_info *device_info); static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf); @@ -130,6 +129,47 @@ static struct vmbus_driver_context g_vmbus_drv = { .bus.dev_attrs = vmbus_device_attrs, }; +static void get_channel_info(struct hv_device *device, + struct hv_device_info *info) +{ + struct vmbus_channel_debug_info debug_info; + + if (!device->channel) + return; + + vmbus_get_debug_info(device->channel, &debug_info); + + info->ChannelId = debug_info.RelId; + info->ChannelState = debug_info.State; + memcpy(&info->ChannelType, &debug_info.InterfaceType, + sizeof(struct hv_guid)); + memcpy(&info->ChannelInstance, &debug_info.InterfaceInstance, + sizeof(struct hv_guid)); + + info->MonitorId = debug_info.MonitorId; + + info->ServerMonitorPending = debug_info.ServerMonitorPending; + info->ServerMonitorLatency = debug_info.ServerMonitorLatency; + info->ServerMonitorConnectionId = debug_info.ServerMonitorConnectionId; + + info->ClientMonitorPending = debug_info.ClientMonitorPending; + info->ClientMonitorLatency = debug_info.ClientMonitorLatency; + info->ClientMonitorConnectionId = debug_info.ClientMonitorConnectionId; + + info->Inbound.InterruptMask = debug_info.Inbound.CurrentInterruptMask; + info->Inbound.ReadIndex = debug_info.Inbound.CurrentReadIndex; + info->Inbound.WriteIndex = debug_info.Inbound.CurrentWriteIndex; + info->Inbound.BytesAvailToRead = debug_info.Inbound.BytesAvailToRead; + info->Inbound.BytesAvailToWrite = debug_info.Inbound.BytesAvailToWrite; + + info->Outbound.InterruptMask = debug_info.Outbound.CurrentInterruptMask; + info->Outbound.ReadIndex = debug_info.Outbound.CurrentReadIndex; + info->Outbound.WriteIndex = debug_info.Outbound.CurrentWriteIndex; + info->Outbound.BytesAvailToRead = debug_info.Outbound.BytesAvailToRead; + info->Outbound.BytesAvailToWrite = + debug_info.Outbound.BytesAvailToWrite; +} + /* * vmbus_show_device_attr - Show the device attribute in sysfs. * @@ -145,7 +185,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev, memset(&device_info, 0, sizeof(struct hv_device_info)); - vmbus_child_device_get_info(&device_ctx->device_obj, &device_info); + get_channel_info(&device_ctx->device_obj, &device_info); if (!strcmp(dev_attr->attr.name, "class_id")) { return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" @@ -254,8 +294,6 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) int ret; unsigned int vector; - DPRINT_ENTER(VMBUS_DRV); - /* * Set this up to allow lower layer to callback to add/remove child * devices on the bus @@ -360,8 +398,6 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) wait_for_completion(&hv_channel_ready); cleanup: - DPRINT_EXIT(VMBUS_DRV); - return ret; } @@ -377,8 +413,6 @@ static void vmbus_bus_exit(void) struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx; - DPRINT_ENTER(VMBUS_DRV); - /* Remove the root device */ if (vmbus_drv_obj->Base.OnDeviceRemove) vmbus_drv_obj->Base.OnDeviceRemove(&dev_ctx->device_obj); @@ -395,10 +429,6 @@ static void vmbus_bus_exit(void) tasklet_kill(&vmbus_drv_ctx->msg_dpc); tasklet_kill(&vmbus_drv_ctx->event_dpc); - - DPRINT_EXIT(VMBUS_DRV); - - return; } @@ -419,8 +449,6 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx) struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; int ret; - DPRINT_ENTER(VMBUS_DRV); - DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s", driver_ctx, driver_ctx->driver.name); @@ -431,8 +459,6 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx) vmbus_drv_obj->GetChannelOffers(); - DPRINT_EXIT(VMBUS_DRV); - return ret; } EXPORT_SYMBOL(vmbus_child_driver_register); @@ -450,71 +476,31 @@ EXPORT_SYMBOL(vmbus_child_driver_register); */ void vmbus_child_driver_unregister(struct driver_context *driver_ctx) { - DPRINT_ENTER(VMBUS_DRV); - DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s", driver_ctx, driver_ctx->driver.name); driver_unregister(&driver_ctx->driver); driver_ctx->driver.bus = NULL; - - DPRINT_EXIT(VMBUS_DRV); } EXPORT_SYMBOL(vmbus_child_driver_unregister); -/** - * vmbus_get_interface() - Get the vmbus channel interface. - * @interface: Pointer to channel interface structure - * - * Get the Hyper-V channel used for the driver. - * - * @interface is of type &struct vmbus_channel_interface - * This is invoked by child/client driver that sits above vmbus. - * - * Mainly used by Hyper-V drivers. - */ -void vmbus_get_interface(struct vmbus_channel_interface *interface) -{ - struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; - - vmbus_drv_obj->GetChannelInterface(interface); -} -EXPORT_SYMBOL(vmbus_get_interface); - -/* - * vmbus_child_device_get_info - Get the vmbus child device info. - * - * This is invoked to display various device attributes in sysfs. - */ -static void vmbus_child_device_get_info(struct hv_device *device_obj, - struct hv_device_info *device_info) -{ - struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; - - vmbus_drv_obj->GetChannelInfo(device_obj, device_info); -} - /* * vmbus_child_device_create - Creates and registers a new child device * on the vmbus. */ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, struct hv_guid *instance, - void *context) + struct vmbus_channel *channel) { struct vm_device *child_device_ctx; struct hv_device *child_device_obj; - DPRINT_ENTER(VMBUS_DRV); - /* Allocate the new child device */ child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL); if (!child_device_ctx) { DPRINT_ERR(VMBUS_DRV, "unable to allocate device_context for child device"); - DPRINT_EXIT(VMBUS_DRV); - return NULL; } @@ -538,7 +524,7 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, instance->data[14], instance->data[15]); child_device_obj = &child_device_ctx->device_obj; - child_device_obj->context = context; + child_device_obj->channel = channel; memcpy(&child_device_obj->deviceType, type, sizeof(struct hv_guid)); memcpy(&child_device_obj->deviceInstance, instance, sizeof(struct hv_guid)); @@ -546,8 +532,6 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, memcpy(&child_device_ctx->class_id, type, sizeof(struct hv_guid)); memcpy(&child_device_ctx->device_id, instance, sizeof(struct hv_guid)); - DPRINT_EXIT(VMBUS_DRV); - return child_device_obj; } @@ -564,8 +548,6 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, to_vm_device(child_device_obj); static atomic_t device_num = ATOMIC_INIT(0); - DPRINT_ENTER(VMBUS_DRV); - DPRINT_DBG(VMBUS_DRV, "child device (%p) registering", child_device_ctx); @@ -594,8 +576,6 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, DPRINT_INFO(VMBUS_DRV, "child device (%p) registered", &child_device_ctx->device); - DPRINT_EXIT(VMBUS_DRV); - return ret; } @@ -607,8 +587,6 @@ static void vmbus_child_device_unregister(struct hv_device *device_obj) { struct vm_device *device_ctx = to_vm_device(device_obj); - DPRINT_ENTER(VMBUS_DRV); - DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)", &device_ctx->device); @@ -620,8 +598,6 @@ static void vmbus_child_device_unregister(struct hv_device *device_obj) DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered", &device_ctx->device); - - DPRINT_EXIT(VMBUS_DRV); } /* @@ -629,9 +605,6 @@ static void vmbus_child_device_unregister(struct hv_device *device_obj) */ static void vmbus_child_device_destroy(struct hv_device *device_obj) { - DPRINT_ENTER(VMBUS_DRV); - - DPRINT_EXIT(VMBUS_DRV); } /* @@ -646,8 +619,6 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) struct vm_device *device_ctx = device_to_vm_device(device); int ret; - DPRINT_ENTER(VMBUS_DRV); - DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" "%02x%02x%02x%02x-%02x%02x-%02x%02x-" "%02x%02x%02x%02x%02x%02x%02x%02x}", @@ -708,8 +679,6 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) if (ret) return ret; - DPRINT_EXIT(VMBUS_DRV); - return 0; } @@ -722,8 +691,6 @@ static int vmbus_match(struct device *device, struct device_driver *driver) struct driver_context *driver_ctx = driver_to_driver_context(driver); struct vm_device *device_ctx = device_to_vm_device(device); - DPRINT_ENTER(VMBUS_DRV); - /* We found our driver ? */ if (memcmp(&device_ctx->class_id, &driver_ctx->class_id, sizeof(struct hv_guid)) == 0) { @@ -742,9 +709,6 @@ static int vmbus_match(struct device *device, struct device_driver *driver) match = 1; } - - DPRINT_EXIT(VMBUS_DRV); - return match; } @@ -759,8 +723,6 @@ static void vmbus_probe_failed_cb(struct work_struct *context) { struct vm_device *device_ctx = (struct vm_device *)context; - DPRINT_ENTER(VMBUS_DRV); - /* * Kick off the process of unregistering the device. * This will call vmbus_remove() and eventually vmbus_device_release() @@ -768,7 +730,6 @@ static void vmbus_probe_failed_cb(struct work_struct *context) device_unregister(&device_ctx->device); /* put_device(&device_ctx->device); */ - DPRINT_EXIT(VMBUS_DRV); } /* @@ -782,8 +743,6 @@ static int vmbus_probe(struct device *child_device) struct vm_device *device_ctx = device_to_vm_device(child_device); - DPRINT_ENTER(VMBUS_DRV); - /* Let the specific open-source driver handles the probe if it can */ if (driver_ctx->probe) { ret = device_ctx->probe_error = driver_ctx->probe(child_device); @@ -802,8 +761,6 @@ static int vmbus_probe(struct device *child_device) child_device->driver->name); ret = -1; } - - DPRINT_EXIT(VMBUS_DRV); return ret; } @@ -815,15 +772,12 @@ static int vmbus_remove(struct device *child_device) int ret; struct driver_context *driver_ctx; - DPRINT_ENTER(VMBUS_DRV); - /* Special case root bus device */ if (child_device->parent == NULL) { /* * No-op since it is statically defined and handle in * vmbus_bus_exit() */ - DPRINT_EXIT(VMBUS_DRV); return 0; } @@ -844,8 +798,6 @@ static int vmbus_remove(struct device *child_device) } } - DPRINT_EXIT(VMBUS_DRV); - return 0; } @@ -856,23 +808,18 @@ static void vmbus_shutdown(struct device *child_device) { struct driver_context *driver_ctx; - DPRINT_ENTER(VMBUS_DRV); - /* Special case root bus device */ if (child_device->parent == NULL) { /* * No-op since it is statically defined and handle in * vmbus_bus_exit() */ - DPRINT_EXIT(VMBUS_DRV); return; } /* The device may not be attached yet */ - if (!child_device->driver) { - DPRINT_EXIT(VMBUS_DRV); + if (!child_device->driver) return; - } driver_ctx = driver_to_driver_context(child_device->driver); @@ -880,8 +827,6 @@ static void vmbus_shutdown(struct device *child_device) if (driver_ctx->shutdown) driver_ctx->shutdown(child_device); - DPRINT_EXIT(VMBUS_DRV); - return; } @@ -890,13 +835,11 @@ static void vmbus_shutdown(struct device *child_device) */ static void vmbus_bus_release(struct device *device) { - DPRINT_ENTER(VMBUS_DRV); /* FIXME */ /* Empty release functions are a bug, or a major sign * of a problem design, this MUST BE FIXED! */ dev_err(device, "%s needs to be fixed!\n", __func__); WARN_ON(1); - DPRINT_EXIT(VMBUS_DRV); } /* @@ -906,15 +849,10 @@ static void vmbus_device_release(struct device *device) { struct vm_device *device_ctx = device_to_vm_device(device); - DPRINT_ENTER(VMBUS_DRV); - /* vmbus_child_device_destroy(&device_ctx->device_obj); */ kfree(device_ctx); /* !!DO NOT REFERENCE device_ctx anymore at this point!! */ - DPRINT_EXIT(VMBUS_DRV); - - return; } /* @@ -924,14 +862,10 @@ static void vmbus_msg_dpc(unsigned long data) { struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data; - DPRINT_ENTER(VMBUS_DRV); - /* ASSERT(vmbus_drv_obj->OnMsgDpc != NULL); */ /* Call to bus driver to handle interrupt */ vmbus_drv_obj->OnMsgDpc(&vmbus_drv_obj->Base); - - DPRINT_EXIT(VMBUS_DRV); } /* @@ -941,14 +875,10 @@ static void vmbus_event_dpc(unsigned long data) { struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data; - DPRINT_ENTER(VMBUS_DRV); - /* ASSERT(vmbus_drv_obj->OnEventDpc != NULL); */ /* Call to bus driver to handle interrupt */ vmbus_drv_obj->OnEventDpc(&vmbus_drv_obj->Base); - - DPRINT_EXIT(VMBUS_DRV); } static irqreturn_t vmbus_isr(int irq, void *dev_id) @@ -956,8 +886,6 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) struct vmbus_driver *vmbus_driver_obj = &g_vmbus_drv.drv_obj; int ret; - DPRINT_ENTER(VMBUS_DRV); - /* ASSERT(vmbus_driver_obj->OnIsr != NULL); */ /* Call to bus driver to handle interrupt */ @@ -971,10 +899,8 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) if (test_bit(1, (unsigned long *)&ret)) tasklet_schedule(&g_vmbus_drv.event_dpc); - DPRINT_EXIT(VMBUS_DRV); return IRQ_HANDLED; } else { - DPRINT_EXIT(VMBUS_DRV); return IRQ_NONE; } } @@ -994,10 +920,6 @@ MODULE_DEVICE_TABLE(dmi, microsoft_hv_dmi_table); static int __init vmbus_init(void) { - int ret = 0; - - DPRINT_ENTER(VMBUS_DRV); - DPRINT_INFO(VMBUS_DRV, "Vmbus initializing.... current log level 0x%x (%x,%x)", vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel)); @@ -1006,20 +928,13 @@ static int __init vmbus_init(void) if (!dmi_check_system(microsoft_hv_dmi_table)) return -ENODEV; - ret = vmbus_bus_init(VmbusInitialize); - - DPRINT_EXIT(VMBUS_DRV); - return ret; + return vmbus_bus_init(VmbusInitialize); } static void __exit vmbus_exit(void) { - DPRINT_ENTER(VMBUS_DRV); - vmbus_bus_exit(); /* Todo: it is used for loglevel, to be ported to new kernel. */ - DPRINT_EXIT(VMBUS_DRV); - return; } /* @@ -1028,7 +943,7 @@ static void __exit vmbus_exit(void) * installed and/or configured. We don't do anything else with the table, but * it needs to be present. */ -const static struct pci_device_id microsoft_hv_pci_table[] = { +static const struct pci_device_id microsoft_hv_pci_table[] = { { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ { 0 } }; diff --git a/drivers/staging/hv/vmbus_private.h b/drivers/staging/hv/vmbus_private.h index 588c667a7f6b..09eaec964b30 100644 --- a/drivers/staging/hv/vmbus_private.h +++ b/drivers/staging/hv/vmbus_private.h @@ -29,7 +29,6 @@ #include "vmbus_api.h" #include "channel.h" #include "channel_mgmt.h" -#include "channel_interface.h" #include "ring_buffer.h" #include <linux/list.h> @@ -105,7 +104,7 @@ extern struct VMBUS_CONNECTION gVmbusConnection; struct hv_device *VmbusChildDeviceCreate(struct hv_guid *deviceType, struct hv_guid *deviceInstance, - void *context); + struct vmbus_channel *channel); int VmbusChildDeviceAdd(struct hv_device *Device); |