Staging: hv: rename the vmbus to "hyperv"
[firefly-linux-kernel-4.4.55.git] / drivers / staging / hv / vmbus.c
index d449daf819765b789cd5d06ee9fb429e97a05c85..df342f285c0435197703fa5cff3b3dba178f915f 100644 (file)
@@ -27,7 +27,7 @@
 #include "version_info.h"
 #include "vmbus_private.h"
 
-static const char *gDriverName = "vmbus";
+static const char *gDriverName = "hyperv";
 
 /*
  * Windows vmbus does not defined this.
@@ -52,45 +52,12 @@ static const struct hv_guid gVmbusDeviceId = {
 static struct hv_driver *gDriver; /* vmbus driver object */
 static struct hv_device *gDevice; /* vmbus root device */
 
-/*
- * VmbusGetChannelOffers - Retrieve the channel offers from the parent partition
- */
-static void VmbusGetChannelOffers(void)
-{
-       vmbus_request_offers();
-}
-
-/*
- * VmbusCreateChildDevice - Creates the child device on the bus that represents the channel offer
- */
-struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType,
-                                        struct hv_guid *DeviceInstance,
-                                        struct vmbus_channel *channel)
-{
-       struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
-
-       return vmbusDriver->OnChildDeviceCreate(DeviceType, DeviceInstance,
-                                               channel);
-}
-
 /*
  * VmbusChildDeviceAdd - Registers the child device with the vmbus
  */
 int VmbusChildDeviceAdd(struct hv_device *ChildDevice)
 {
-       struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
-
-       return vmbusDriver->OnChildDeviceAdd(gDevice, ChildDevice);
-}
-
-/*
- * VmbusChildDeviceRemove Unregisters the child device from the vmbus
- */
-void VmbusChildDeviceRemove(struct hv_device *ChildDevice)
-{
-       struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
-
-       vmbusDriver->OnChildDeviceRemove(ChildDevice);
+       return vmbus_child_device_register(gDevice, ChildDevice);
 }
 
 /*
@@ -109,7 +76,7 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo)
 
        /* strcpy(dev->name, "vmbus"); */
        /* SynIC setup... */
-       on_each_cpu(HvSynicInit, (void *)irqvector, 1);
+       on_each_cpu(hv_synic_init, (void *)irqvector, 1);
 
        /* Connect to VMBus in the root partition */
        ret = VmbusConnect();
@@ -127,7 +94,7 @@ static int VmbusOnDeviceRemove(struct hv_device *dev)
 
        vmbus_release_unattached_channels();
        VmbusDisconnect();
-       on_each_cpu(HvSynicCleanup, NULL, 1);
+       on_each_cpu(hv_synic_cleanup, NULL, 1);
        return ret;
 }
 
@@ -138,22 +105,22 @@ static void VmbusOnCleanup(struct hv_driver *drv)
 {
        /* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */
 
-       HvCleanup();
+       hv_cleanup();
 }
 
 /*
- * VmbusOnMsgDPC - DPC routine to handle messages from the hypervisior
+ * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
  */
-static void VmbusOnMsgDPC(struct hv_driver *drv)
+void vmbus_on_msg_dpc(struct hv_driver *drv)
 {
        int cpu = smp_processor_id();
-       void *page_addr = gHvContext.synICMessagePage[cpu];
+       void *page_addr = hv_context.synic_message_page[cpu];
        struct hv_message *msg = (struct hv_message *)page_addr +
                                  VMBUS_MESSAGE_SINT;
        struct hv_message *copied;
 
        while (1) {
-               if (msg->Header.MessageType == HvMessageTypeNone) {
+               if (msg->header.message_type == HVMSG_NONE) {
                        /* no msg */
                        break;
                } else {
@@ -166,18 +133,18 @@ static void VmbusOnMsgDPC(struct hv_driver *drv)
                                              (void *)copied);
                }
 
-               msg->Header.MessageType = HvMessageTypeNone;
+               msg->header.message_type = HVMSG_NONE;
 
                /*
                 * Make sure the write to MessageType (ie set to
-                * HvMessageTypeNone) happens before we read the
+                * HVMSG_NONE) happens before we read the
                 * MessagePending and EOMing. Otherwise, the EOMing
                 * will not deliver any more messages since there is
                 * no empty slot
                 */
                mb();
 
-               if (msg->Header.MessageFlags.MessagePending) {
+               if (msg->header.message_flags.msg_pending) {
                        /*
                         * This will cause message queue rescan to
                         * possibly deliver another msg from the
@@ -189,18 +156,18 @@ static void VmbusOnMsgDPC(struct hv_driver *drv)
 }
 
 /*
- * VmbusOnEventDPC - DPC routine to handle events from the hypervisior
+ * vmbus_on_event_dpc - DPC routine to handle events from the hypervisior
  */
-static void VmbusOnEventDPC(struct hv_driver *drv)
+void vmbus_on_event_dpc(struct hv_driver *drv)
 {
        /* TODO: Process any events */
        VmbusOnEvents();
 }
 
 /*
- * VmbusOnISR - ISR routine
+ * vmbus_on_isr - ISR routine
  */
-static int VmbusOnISR(struct hv_driver *drv)
+int vmbus_on_isr(struct hv_driver *drv)
 {
        int ret = 0;
        int cpu = smp_processor_id();
@@ -208,24 +175,24 @@ static int VmbusOnISR(struct hv_driver *drv)
        struct hv_message *msg;
        union hv_synic_event_flags *event;
 
-       page_addr = gHvContext.synICMessagePage[cpu];
+       page_addr = hv_context.synic_message_page[cpu];
        msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
 
        /* Check if there are actual msgs to be process */
-       if (msg->Header.MessageType != HvMessageTypeNone) {
+       if (msg->header.message_type != HVMSG_NONE) {
                DPRINT_DBG(VMBUS, "received msg type %d size %d",
-                               msg->Header.MessageType,
-                               msg->Header.PayloadSize);
+                               msg->header.message_type,
+                               msg->header.payload_size);
                ret |= 0x1;
        }
 
        /* TODO: Check if there are events to be process */
-       page_addr = gHvContext.synICEventPage[cpu];
+       page_addr = hv_context.synic_event_page[cpu];
        event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
 
        /* Since we are a child, we only need to check bit 0 */
-       if (test_and_clear_bit(0, (unsigned long *) &event->Flags32[0])) {
-               DPRINT_DBG(VMBUS, "received event %d", event->Flags32[0]);
+       if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) {
+               DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]);
                ret |= 0x2;
        }
 
@@ -235,9 +202,8 @@ static int VmbusOnISR(struct hv_driver *drv)
 /*
  * VmbusInitialize - Main entry point
  */
-int VmbusInitialize(struct hv_driver *drv)
+int VmbusInitialize(struct hv_driver *driver)
 {
-       struct vmbus_driver *driver = (struct vmbus_driver *)drv;
        int ret;
 
        DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++",
@@ -251,24 +217,20 @@ int VmbusInitialize(struct hv_driver *drv)
                        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));
+       driver->name = gDriverName;
+       memcpy(&driver->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
 
        /* Setup dispatch table */
-       driver->Base.OnDeviceAdd        = VmbusOnDeviceAdd;
-       driver->Base.OnDeviceRemove     = VmbusOnDeviceRemove;
-       driver->Base.OnCleanup          = VmbusOnCleanup;
-       driver->OnIsr                   = VmbusOnISR;
-       driver->OnMsgDpc                = VmbusOnMsgDPC;
-       driver->OnEventDpc              = VmbusOnEventDPC;
-       driver->GetChannelOffers        = VmbusGetChannelOffers;
+       driver->OnDeviceAdd     = VmbusOnDeviceAdd;
+       driver->OnDeviceRemove  = VmbusOnDeviceRemove;
+       driver->OnCleanup       = VmbusOnCleanup;
 
        /* Hypervisor initialization...setup hypercall page..etc */
-       ret = HvInit();
+       ret = hv_init();
        if (ret != 0)
                DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
                                ret);
-       gDriver = drv;
+       gDriver = driver;
 
        return ret;
 }