blob: 0b91edad6e11601e47edb4f0e83de9e4cc4cda47 [file] [log] [blame]
Hank Janssen3e7ee492009-07-13 16:02:34 -07001/*
Hank Janssen3e7ee492009-07-13 16:02:34 -07002 * Copyright (c) 2009, Microsoft Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Authors:
18 * Haiyang Zhang <haiyangz@microsoft.com>
19 * Hank Janssen <hjanssen@microsoft.com>
Hank Janssen3e7ee492009-07-13 16:02:34 -070020 */
Hank Janssen3e7ee492009-07-13 16:02:34 -070021#include <linux/init.h>
22#include <linux/module.h>
23#include <linux/device.h>
24#include <linux/irq.h>
25#include <linux/interrupt.h>
26#include <linux/sysctl.h>
Greg Kroah-Hartman9a775db2010-02-25 16:42:10 -080027#include <linux/pci.h>
Greg Kroah-Hartmanc22090f2010-02-25 16:43:15 -080028#include <linux/dmi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Haiyang Zhang8b5d6d32010-05-28 23:22:44 +000030#include <linux/completion.h>
Greg Kroah-Hartman2d82f6c2010-05-05 22:52:28 -070031#include "version_info.h"
K. Y. Srinivasane3fe0bb2011-02-11 10:00:12 -080032#include "hv_api.h"
Greg Kroah-Hartman645954c2009-08-28 16:22:59 -070033#include "logging.h"
Greg Kroah-Hartman870cde82009-08-19 16:21:28 -070034#include "vmbus.h"
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -070035#include "channel.h"
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -080036#include "vmbus_private.h"
Hank Janssen3e7ee492009-07-13 16:02:34 -070037
Hank Janssen3e7ee492009-07-13 16:02:34 -070038
Bill Pemberton454f18a2009-07-27 16:47:24 -040039/* FIXME! We need to do this dynamically for PIC and APIC system */
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070040#define VMBUS_IRQ 0x5
41#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
Bill Pemberton454f18a2009-07-27 16:47:24 -040042
43/* Main vmbus driver data structure */
Hank Janssen3e7ee492009-07-13 16:02:34 -070044struct vmbus_driver_context {
Hank Janssen3e7ee492009-07-13 16:02:34 -070045
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070046 struct bus_type bus;
47 struct tasklet_struct msg_dpc;
48 struct tasklet_struct event_dpc;
Hank Janssen3e7ee492009-07-13 16:02:34 -070049
Bill Pemberton454f18a2009-07-27 16:47:24 -040050 /* The bus root device */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -080051 struct hv_device device_ctx;
Hank Janssen3e7ee492009-07-13 16:02:34 -070052};
53
Hank Janssen3e7ee492009-07-13 16:02:34 -070054static int vmbus_match(struct device *device, struct device_driver *driver);
55static int vmbus_probe(struct device *device);
56static int vmbus_remove(struct device *device);
57static void vmbus_shutdown(struct device *device);
Hank Janssen3e7ee492009-07-13 16:02:34 -070058static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env);
Hank Janssen3e7ee492009-07-13 16:02:34 -070059
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070060static irqreturn_t vmbus_isr(int irq, void *dev_id);
Hank Janssen3e7ee492009-07-13 16:02:34 -070061
62static void vmbus_device_release(struct device *device);
63static void vmbus_bus_release(struct device *device);
64
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070065static ssize_t vmbus_show_device_attr(struct device *dev,
66 struct device_attribute *dev_attr,
67 char *buf);
Hank Janssen3e7ee492009-07-13 16:02:34 -070068
Hank Janssen3e7ee492009-07-13 16:02:34 -070069
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070070unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
Hank Janssen3e7ee492009-07-13 16:02:34 -070071EXPORT_SYMBOL(vmbus_loglevel);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -070072 /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
73 /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
Hank Janssen3e7ee492009-07-13 16:02:34 -070074
75static int vmbus_irq = VMBUS_IRQ;
76
Bill Pemberton454f18a2009-07-27 16:47:24 -040077/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
Hank Janssen3e7ee492009-07-13 16:02:34 -070078static struct device_attribute vmbus_device_attrs[] = {
79 __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
80 __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
81 __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
82 __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
83 __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
84
85 __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
86 __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
87 __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
88
89 __ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
90 __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
91 __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
92
93 __ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
94 __ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
95 __ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
96 __ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
97 __ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
98
99 __ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
100 __ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
101 __ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
102 __ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
103 __ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
104 __ATTR_NULL
105};
Hank Janssen3e7ee492009-07-13 16:02:34 -0700106
Bill Pemberton454f18a2009-07-27 16:47:24 -0400107/* The one and only one */
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800108static struct vmbus_driver_context vmbus_drv = {
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700109 .bus.name = "vmbus",
110 .bus.match = vmbus_match,
111 .bus.shutdown = vmbus_shutdown,
112 .bus.remove = vmbus_remove,
113 .bus.probe = vmbus_probe,
114 .bus.uevent = vmbus_uevent,
115 .bus.dev_attrs = vmbus_device_attrs,
Hank Janssen3e7ee492009-07-13 16:02:34 -0700116};
117
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800118static const char *driver_name = "hyperv";
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800119
120/*
121 * Windows vmbus does not defined this.
122 * We defined this to be consistent with other devices
123 */
124/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800125static const struct hv_guid device_type = {
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800126 .data = {
127 0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d,
128 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85
129 }
130};
131
132/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800133static const struct hv_guid device_id = {
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800134 .data = {
135 0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40,
136 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5
137 }
138};
139
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800140static struct hv_device *vmbus_device; /* vmbus root device */
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800141
142/*
Haiyang Zhang646f1ea2011-01-26 12:12:10 -0800143 * vmbus_child_dev_add - Registers the child device with the vmbus
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800144 */
Haiyang Zhang646f1ea2011-01-26 12:12:10 -0800145int vmbus_child_dev_add(struct hv_device *child_dev)
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800146{
K. Y. Srinivasan3ca07cb2011-03-10 14:07:21 -0800147 return vmbus_child_device_register(child_dev);
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800148}
149
150/*
Haiyang Zhang646f1ea2011-01-26 12:12:10 -0800151 * vmbus_dev_add - Callback when the root bus device is added
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800152 */
Haiyang Zhang646f1ea2011-01-26 12:12:10 -0800153static int vmbus_dev_add(struct hv_device *dev, void *info)
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800154{
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800155 u32 *irqvector = info;
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800156 int ret;
157
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800158 vmbus_device = dev;
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800159
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800160 memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid));
161 memcpy(&vmbus_device->dev_instance, &device_id,
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800162 sizeof(struct hv_guid));
163
164 /* strcpy(dev->name, "vmbus"); */
165 /* SynIC setup... */
166 on_each_cpu(hv_synic_init, (void *)irqvector, 1);
167
168 /* Connect to VMBus in the root partition */
Haiyang Zhangc6977672011-01-26 12:12:08 -0800169 ret = vmbus_connect();
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800170
171 /* VmbusSendEvent(device->localPortId+1); */
172 return ret;
173}
174
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800175
Timo Teräsbf6506f2010-12-15 20:48:08 +0200176struct onmessage_work_context {
177 struct work_struct work;
178 struct hv_message msg;
179};
180
181static void vmbus_onmessage_work(struct work_struct *work)
182{
183 struct onmessage_work_context *ctx;
184
185 ctx = container_of(work, struct onmessage_work_context,
186 work);
187 vmbus_onmessage(&ctx->msg);
188 kfree(ctx);
189}
190
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800191/*
192 * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
193 */
K. Y. Srinivasan62c10592011-03-10 14:04:53 -0800194static void vmbus_on_msg_dpc(unsigned long data)
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800195{
196 int cpu = smp_processor_id();
197 void *page_addr = hv_context.synic_message_page[cpu];
198 struct hv_message *msg = (struct hv_message *)page_addr +
199 VMBUS_MESSAGE_SINT;
Timo Teräsbf6506f2010-12-15 20:48:08 +0200200 struct onmessage_work_context *ctx;
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800201
202 while (1) {
203 if (msg->header.message_type == HVMSG_NONE) {
204 /* no msg */
205 break;
206 } else {
Timo Teräsbf6506f2010-12-15 20:48:08 +0200207 ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
208 if (ctx == NULL)
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800209 continue;
Timo Teräsbf6506f2010-12-15 20:48:08 +0200210 INIT_WORK(&ctx->work, vmbus_onmessage_work);
211 memcpy(&ctx->msg, msg, sizeof(*msg));
Haiyang Zhangda9fcb72011-01-26 12:12:14 -0800212 queue_work(vmbus_connection.work_queue, &ctx->work);
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800213 }
214
215 msg->header.message_type = HVMSG_NONE;
216
217 /*
218 * Make sure the write to MessageType (ie set to
219 * HVMSG_NONE) happens before we read the
220 * MessagePending and EOMing. Otherwise, the EOMing
221 * will not deliver any more messages since there is
222 * no empty slot
223 */
224 mb();
225
226 if (msg->header.message_flags.msg_pending) {
227 /*
228 * This will cause message queue rescan to
229 * possibly deliver another msg from the
230 * hypervisor
231 */
232 wrmsrl(HV_X64_MSR_EOM, 0);
233 }
234 }
235}
236
237/*
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800238 * vmbus_on_isr - ISR routine
239 */
K. Y. Srinivasan480ae582011-03-10 14:06:06 -0800240static int vmbus_on_isr(void)
Greg Kroah-Hartman36199a92010-12-02 11:59:22 -0800241{
242 int ret = 0;
243 int cpu = smp_processor_id();
244 void *page_addr;
245 struct hv_message *msg;
246 union hv_synic_event_flags *event;
247
248 page_addr = hv_context.synic_message_page[cpu];
249 msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
250
251 /* Check if there are actual msgs to be process */
252 if (msg->header.message_type != HVMSG_NONE) {
253 DPRINT_DBG(VMBUS, "received msg type %d size %d",
254 msg->header.message_type,
255 msg->header.payload_size);
256 ret |= 0x1;
257 }
258
259 /* TODO: Check if there are events to be process */
260 page_addr = hv_context.synic_event_page[cpu];
261 event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
262
263 /* Since we are a child, we only need to check bit 0 */
264 if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) {
265 DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]);
266 ret |= 0x2;
267 }
268
269 return ret;
270}
271
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700272static void get_channel_info(struct hv_device *device,
273 struct hv_device_info *info)
274{
275 struct vmbus_channel_debug_info debug_info;
276
Greg Kroah-Hartmancae5b842010-10-21 09:05:27 -0700277 if (!device->channel)
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700278 return;
279
Greg Kroah-Hartmancae5b842010-10-21 09:05:27 -0700280 vmbus_get_debug_info(device->channel, &debug_info);
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700281
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800282 info->chn_id = debug_info.relid;
283 info->chn_state = debug_info.state;
284 memcpy(&info->chn_type, &debug_info.interfacetype,
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700285 sizeof(struct hv_guid));
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800286 memcpy(&info->chn_instance, &debug_info.interface_instance,
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700287 sizeof(struct hv_guid));
288
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800289 info->monitor_id = debug_info.monitorid;
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700290
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800291 info->server_monitor_pending = debug_info.servermonitor_pending;
292 info->server_monitor_latency = debug_info.servermonitor_latency;
293 info->server_monitor_conn_id = debug_info.servermonitor_connectionid;
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700294
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800295 info->client_monitor_pending = debug_info.clientmonitor_pending;
296 info->client_monitor_latency = debug_info.clientmonitor_latency;
297 info->client_monitor_conn_id = debug_info.clientmonitor_connectionid;
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700298
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800299 info->inbound.int_mask = debug_info.inbound.current_interrupt_mask;
300 info->inbound.read_idx = debug_info.inbound.current_read_index;
301 info->inbound.write_idx = debug_info.inbound.current_write_index;
302 info->inbound.bytes_avail_toread =
303 debug_info.inbound.bytes_avail_toread;
304 info->inbound.bytes_avail_towrite =
Haiyang Zhang82f8bd42010-11-08 14:04:45 -0800305 debug_info.inbound.bytes_avail_towrite;
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700306
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800307 info->outbound.int_mask =
Haiyang Zhang82f8bd42010-11-08 14:04:45 -0800308 debug_info.outbound.current_interrupt_mask;
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800309 info->outbound.read_idx = debug_info.outbound.current_read_index;
310 info->outbound.write_idx = debug_info.outbound.current_write_index;
311 info->outbound.bytes_avail_toread =
Haiyang Zhang82f8bd42010-11-08 14:04:45 -0800312 debug_info.outbound.bytes_avail_toread;
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800313 info->outbound.bytes_avail_towrite =
Haiyang Zhang82f8bd42010-11-08 14:04:45 -0800314 debug_info.outbound.bytes_avail_towrite;
Greg Kroah-Hartman150b19d2010-10-20 16:07:11 -0700315}
316
Hank Janssen3e189512010-03-04 22:11:00 +0000317/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700318 * vmbus_show_device_attr - Show the device attribute in sysfs.
319 *
320 * This is invoked when user does a
321 * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
322 */
323static ssize_t vmbus_show_device_attr(struct device *dev,
324 struct device_attribute *dev_attr,
325 char *buf)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700326{
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800327 struct hv_device *device_ctx = device_to_hv_device(dev);
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -0700328 struct hv_device_info device_info;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700329
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -0700330 memset(&device_info, 0, sizeof(struct hv_device_info));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700331
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800332 get_channel_info(device_ctx, &device_info);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700333
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700334 if (!strcmp(dev_attr->attr.name, "class_id")) {
335 return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
336 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800337 device_info.chn_type.data[3],
338 device_info.chn_type.data[2],
339 device_info.chn_type.data[1],
340 device_info.chn_type.data[0],
341 device_info.chn_type.data[5],
342 device_info.chn_type.data[4],
343 device_info.chn_type.data[7],
344 device_info.chn_type.data[6],
345 device_info.chn_type.data[8],
346 device_info.chn_type.data[9],
347 device_info.chn_type.data[10],
348 device_info.chn_type.data[11],
349 device_info.chn_type.data[12],
350 device_info.chn_type.data[13],
351 device_info.chn_type.data[14],
352 device_info.chn_type.data[15]);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700353 } else if (!strcmp(dev_attr->attr.name, "device_id")) {
354 return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
355 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800356 device_info.chn_instance.data[3],
357 device_info.chn_instance.data[2],
358 device_info.chn_instance.data[1],
359 device_info.chn_instance.data[0],
360 device_info.chn_instance.data[5],
361 device_info.chn_instance.data[4],
362 device_info.chn_instance.data[7],
363 device_info.chn_instance.data[6],
364 device_info.chn_instance.data[8],
365 device_info.chn_instance.data[9],
366 device_info.chn_instance.data[10],
367 device_info.chn_instance.data[11],
368 device_info.chn_instance.data[12],
369 device_info.chn_instance.data[13],
370 device_info.chn_instance.data[14],
371 device_info.chn_instance.data[15]);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700372 } else if (!strcmp(dev_attr->attr.name, "state")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800373 return sprintf(buf, "%d\n", device_info.chn_state);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700374 } else if (!strcmp(dev_attr->attr.name, "id")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800375 return sprintf(buf, "%d\n", device_info.chn_id);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700376 } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800377 return sprintf(buf, "%d\n", device_info.outbound.int_mask);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700378 } else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800379 return sprintf(buf, "%d\n", device_info.outbound.read_idx);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700380 } else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800381 return sprintf(buf, "%d\n", device_info.outbound.write_idx);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700382 } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
383 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800384 device_info.outbound.bytes_avail_toread);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700385 } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
386 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800387 device_info.outbound.bytes_avail_towrite);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700388 } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800389 return sprintf(buf, "%d\n", device_info.inbound.int_mask);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700390 } else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800391 return sprintf(buf, "%d\n", device_info.inbound.read_idx);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700392 } else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800393 return sprintf(buf, "%d\n", device_info.inbound.write_idx);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700394 } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
395 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800396 device_info.inbound.bytes_avail_toread);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700397 } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
398 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800399 device_info.inbound.bytes_avail_towrite);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700400 } else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800401 return sprintf(buf, "%d\n", device_info.monitor_id);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700402 } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800403 return sprintf(buf, "%d\n", device_info.server_monitor_pending);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700404 } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800405 return sprintf(buf, "%d\n", device_info.server_monitor_latency);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700406 } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
407 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800408 device_info.server_monitor_conn_id);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700409 } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800410 return sprintf(buf, "%d\n", device_info.client_monitor_pending);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700411 } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800412 return sprintf(buf, "%d\n", device_info.client_monitor_latency);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700413 } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
414 return sprintf(buf, "%d\n",
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800415 device_info.client_monitor_conn_id);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700416 } else {
Hank Janssen3e7ee492009-07-13 16:02:34 -0700417 return 0;
418 }
419}
420
Hank Janssen3e189512010-03-04 22:11:00 +0000421/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700422 * vmbus_bus_init -Main vmbus driver initialization routine.
423 *
424 * Here, we
Lars Lindley0686e4f2010-03-11 23:51:23 +0100425 * - initialize the vmbus driver context
426 * - setup various driver entry points
427 * - invoke the vmbus hv main init routine
428 * - get the irq resource
429 * - invoke the vmbus to add the vmbus root device
430 * - setup the vmbus root device
431 * - retrieve the channel offers
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700432 */
Greg Kroah-Hartman6c884552010-12-02 12:04:00 -0800433static int vmbus_bus_init(void)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700434{
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800435 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800436 struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700437 int ret;
438 unsigned int vector;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700439
Greg Kroah-Hartman6d26e38fa22010-12-02 12:08:08 -0800440 DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++",
441 HV_DRV_VERSION);
442 DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++",
443 VMBUS_REVISION_NUMBER);
444 DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++",
445 VMBUS_MESSAGE_SINT);
446 DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, "
447 "sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd",
448 sizeof(struct vmbus_channel_packet_page_buffer),
449 sizeof(struct vmbus_channel_packet_multipage_buffer));
450
Greg Kroah-Hartman6d26e38fa22010-12-02 12:08:08 -0800451
452 /* Hypervisor initialization...setup hypercall page..etc */
453 ret = hv_init();
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700454 if (ret != 0) {
Greg Kroah-Hartman6d26e38fa22010-12-02 12:08:08 -0800455 DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
456 ret);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700457 goto cleanup;
458 }
459
Hank Janssen3e7ee492009-07-13 16:02:34 -0700460
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800461 vmbus_drv_ctx->bus.name = driver_name;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700462
Bill Pemberton454f18a2009-07-27 16:47:24 -0400463 /* Initialize the bus context */
K. Y. Srinivasan62c10592011-03-10 14:04:53 -0800464 tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_on_msg_dpc,
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800465 (unsigned long)NULL);
K. Y. Srinivasan6de3d6a2011-03-10 14:05:16 -0800466 tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_on_event,
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800467 (unsigned long)NULL);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700468
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800469 /* Now, register the bus with LDM */
Bill Pembertonc19fbca2009-07-27 16:47:35 -0400470 ret = bus_register(&vmbus_drv_ctx->bus);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700471 if (ret) {
Bill Pembertonc19fbca2009-07-27 16:47:35 -0400472 ret = -1;
473 goto cleanup;
474 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700475
Bill Pemberton454f18a2009-07-27 16:47:24 -0400476 /* Get the interrupt resource */
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700477 ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800478 driver_name, NULL);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700479
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700480 if (ret != 0) {
481 DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
482 vmbus_irq);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700483
484 bus_unregister(&vmbus_drv_ctx->bus);
485
486 ret = -1;
487 goto cleanup;
488 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700489 vector = VMBUS_IRQ_VECTOR;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700490
491 DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
492
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800493 /* Add the root device */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800494 memset(dev_ctx, 0, sizeof(struct hv_device));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700495
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800496 ret = vmbus_dev_add(dev_ctx, &vector);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700497 if (ret != 0) {
498 DPRINT_ERR(VMBUS_DRV,
499 "ERROR - Unable to add vmbus root device");
Hank Janssen3e7ee492009-07-13 16:02:34 -0700500
501 free_irq(vmbus_irq, NULL);
502
503 bus_unregister(&vmbus_drv_ctx->bus);
504
505 ret = -1;
506 goto cleanup;
507 }
Bill Pemberton454f18a2009-07-27 16:47:24 -0400508 /* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */
Greg Kroah-Hartman09d50ff2009-07-13 17:09:34 -0700509 dev_set_name(&dev_ctx->device, "vmbus_0_0");
Hank Janssen3e7ee492009-07-13 16:02:34 -0700510
Bill Pemberton454f18a2009-07-27 16:47:24 -0400511 /* No need to bind a driver to the root device. */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700512 dev_ctx->device.parent = NULL;
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700513 /* NULL; vmbus_remove() does not get invoked */
514 dev_ctx->device.bus = &vmbus_drv_ctx->bus;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700515
Bill Pemberton454f18a2009-07-27 16:47:24 -0400516 /* Setup the device dispatch table */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700517 dev_ctx->device.release = vmbus_bus_release;
518
K. Y. Srinivasana6e4d8e2011-03-10 14:03:51 -0800519 /* register the root device */
Bill Pemberton5d48a1c2009-07-27 16:47:36 -0400520 ret = device_register(&dev_ctx->device);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700521 if (ret) {
522 DPRINT_ERR(VMBUS_DRV,
523 "ERROR - Unable to register vmbus root device");
Bill Pemberton5d48a1c2009-07-27 16:47:36 -0400524
525 free_irq(vmbus_irq, NULL);
526 bus_unregister(&vmbus_drv_ctx->bus);
527
528 ret = -1;
529 goto cleanup;
530 }
531
Greg Kroah-Hartman2d6e8822010-12-02 08:50:58 -0800532 vmbus_request_offers();
Haiyang Zhang8b5d6d32010-05-28 23:22:44 +0000533 wait_for_completion(&hv_channel_ready);
534
Hank Janssen3e7ee492009-07-13 16:02:34 -0700535cleanup:
Hank Janssen3e7ee492009-07-13 16:02:34 -0700536 return ret;
537}
538
Hank Janssen3e189512010-03-04 22:11:00 +0000539/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700540 * vmbus_bus_exit - Terminate the vmbus driver.
541 *
542 * This routine is opposite of vmbus_bus_init()
543 */
Greg Kroah-Hartmanbd1de702009-07-29 09:04:51 -0700544static void vmbus_bus_exit(void)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700545{
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800546 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700547
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800548 struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700549
K. Y. Srinivasanf51b3592011-03-10 14:06:31 -0800550 vmbus_release_unattached_channels();
551 vmbus_disconnect();
552 on_each_cpu(hv_synic_cleanup, NULL, 1);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700553
K. Y. Srinivasanece0e322011-03-10 14:06:55 -0800554 hv_cleanup();
Hank Janssen3e7ee492009-07-13 16:02:34 -0700555
Bill Pemberton454f18a2009-07-27 16:47:24 -0400556 /* Unregister the root bus device */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700557 device_unregister(&dev_ctx->device);
558
559 bus_unregister(&vmbus_drv_ctx->bus);
560
561 free_irq(vmbus_irq, NULL);
562
563 tasklet_kill(&vmbus_drv_ctx->msg_dpc);
564 tasklet_kill(&vmbus_drv_ctx->event_dpc);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700565}
566
Hank Janssen3e189512010-03-04 22:11:00 +0000567
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700568/**
Hank Janssen3e189512010-03-04 22:11:00 +0000569 * vmbus_child_driver_register() - Register a vmbus's child driver
K. Y. Srinivasanc643269d2011-03-07 13:23:43 -0800570 * @drv: Pointer to driver structure you want to register
Hank Janssen3e189512010-03-04 22:11:00 +0000571 *
Hank Janssen3e189512010-03-04 22:11:00 +0000572 *
573 * Registers the given driver with Linux through the 'driver_register()' call
574 * And sets up the hyper-v vmbus handling for this driver.
575 * It will return the state of the 'driver_register()' call.
576 *
577 * Mainly used by Hyper-V drivers.
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700578 */
K. Y. Srinivasanc643269d2011-03-07 13:23:43 -0800579int vmbus_child_driver_register(struct device_driver *drv)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700580{
Bill Pemberton5d48a1c2009-07-27 16:47:36 -0400581 int ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700582
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700583 DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s",
K. Y. Srinivasanc643269d2011-03-07 13:23:43 -0800584 drv, drv->name);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700585
Bill Pemberton454f18a2009-07-27 16:47:24 -0400586 /* The child driver on this vmbus */
K. Y. Srinivasanc643269d2011-03-07 13:23:43 -0800587 drv->bus = &vmbus_drv.bus;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700588
K. Y. Srinivasanc643269d2011-03-07 13:23:43 -0800589 ret = driver_register(drv);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700590
Greg Kroah-Hartman2d6e8822010-12-02 08:50:58 -0800591 vmbus_request_offers();
Hank Janssen3e7ee492009-07-13 16:02:34 -0700592
Bill Pemberton5d48a1c2009-07-27 16:47:36 -0400593 return ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700594}
Hank Janssen3e7ee492009-07-13 16:02:34 -0700595EXPORT_SYMBOL(vmbus_child_driver_register);
596
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700597/**
Hank Janssen3e189512010-03-04 22:11:00 +0000598 * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
K. Y. Srinivasan06de23f2011-03-07 13:24:23 -0800599 * @drv: Pointer to driver structure you want to un-register
Hank Janssen3e189512010-03-04 22:11:00 +0000600 *
Hank Janssen3e189512010-03-04 22:11:00 +0000601 *
602 * Un-register the given driver with Linux through the 'driver_unregister()'
603 * call. And ungegisters the driver from the Hyper-V vmbus handler.
604 *
605 * Mainly used by Hyper-V drivers.
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700606 */
K. Y. Srinivasan06de23f2011-03-07 13:24:23 -0800607void vmbus_child_driver_unregister(struct device_driver *drv)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700608{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700609 DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s",
K. Y. Srinivasan06de23f2011-03-07 13:24:23 -0800610 drv, drv->name);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700611
K. Y. Srinivasan06de23f2011-03-07 13:24:23 -0800612 driver_unregister(drv);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700613
K. Y. Srinivasan06de23f2011-03-07 13:24:23 -0800614 drv->bus = NULL;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700615}
Hank Janssen3e7ee492009-07-13 16:02:34 -0700616EXPORT_SYMBOL(vmbus_child_driver_unregister);
617
Hank Janssen3e189512010-03-04 22:11:00 +0000618/*
Hank Janssen3e189512010-03-04 22:11:00 +0000619 * vmbus_child_device_create - Creates and registers a new child device
620 * on the vmbus.
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700621 */
Greg Kroah-Hartman89733aa2010-12-02 08:22:41 -0800622struct hv_device *vmbus_child_device_create(struct hv_guid *type,
623 struct hv_guid *instance,
624 struct vmbus_channel *channel)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700625{
Nicolas Palix3d3b5512009-07-28 17:32:53 +0200626 struct hv_device *child_device_obj;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700627
Bill Pemberton454f18a2009-07-27 16:47:24 -0400628 /* Allocate the new child device */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800629 child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
630 if (!child_device_obj) {
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700631 DPRINT_ERR(VMBUS_DRV,
632 "unable to allocate device_context for child device");
Hank Janssen3e7ee492009-07-13 16:02:34 -0700633 return NULL;
634 }
635
636 DPRINT_DBG(VMBUS_DRV, "child device (%p) allocated - "
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700637 "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
638 "%02x%02x%02x%02x%02x%02x%02x%02x},"
639 "id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
640 "%02x%02x%02x%02x%02x%02x%02x%02x}",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800641 &child_device_obj->device,
Greg Kroah-Hartmandaaa8cc2009-08-19 16:18:56 -0700642 type->data[3], type->data[2], type->data[1], type->data[0],
643 type->data[5], type->data[4], type->data[7], type->data[6],
644 type->data[8], type->data[9], type->data[10], type->data[11],
645 type->data[12], type->data[13], type->data[14], type->data[15],
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700646 instance->data[3], instance->data[2],
647 instance->data[1], instance->data[0],
648 instance->data[5], instance->data[4],
649 instance->data[7], instance->data[6],
650 instance->data[8], instance->data[9],
651 instance->data[10], instance->data[11],
652 instance->data[12], instance->data[13],
653 instance->data[14], instance->data[15]);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700654
Greg Kroah-Hartmancae5b842010-10-21 09:05:27 -0700655 child_device_obj->channel = channel;
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800656 memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
657 memcpy(&child_device_obj->dev_instance, instance,
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700658 sizeof(struct hv_guid));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700659
Hank Janssen3e7ee492009-07-13 16:02:34 -0700660
Hank Janssen3e7ee492009-07-13 16:02:34 -0700661 return child_device_obj;
662}
663
Hank Janssen3e189512010-03-04 22:11:00 +0000664/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700665 * vmbus_child_device_register - Register the child device on the specified bus
666 */
K. Y. Srinivasan3ca07cb2011-03-10 14:07:21 -0800667int vmbus_child_device_register(struct hv_device *child_device_obj)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700668{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700669 int ret = 0;
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800670
Bill Pembertonf4888412009-07-29 17:00:12 -0400671 static atomic_t device_num = ATOMIC_INIT(0);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700672
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700673 DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800674 child_device_obj);
Bill Pemberton454f18a2009-07-27 16:47:24 -0400675
Haiyang Zhang1bb40a22009-10-23 18:14:24 +0000676 /* Set the device name. Otherwise, device_register() will fail. */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800677 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700678 atomic_inc_return(&device_num));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700679
Bill Pemberton454f18a2009-07-27 16:47:24 -0400680 /* The new device belongs to this bus */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800681 child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
K. Y. Srinivasan3ca07cb2011-03-10 14:07:21 -0800682 child_device_obj->device.parent = &vmbus_device->device;
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800683 child_device_obj->device.release = vmbus_device_release;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700684
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700685 /*
686 * Register with the LDM. This will kick off the driver/device
687 * binding...which will eventually call vmbus_match() and vmbus_probe()
688 */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800689 ret = device_register(&child_device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700690
Bill Pemberton454f18a2009-07-27 16:47:24 -0400691 /* vmbus_probe() error does not get propergate to device_register(). */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800692 ret = child_device_obj->probe_error;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700693
694 if (ret)
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700695 DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800696 &child_device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700697 else
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700698 DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800699 &child_device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700700
Hank Janssen3e7ee492009-07-13 16:02:34 -0700701 return ret;
702}
703
Hank Janssen3e189512010-03-04 22:11:00 +0000704/*
705 * vmbus_child_device_unregister - Remove the specified child device
706 * from the vmbus.
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700707 */
Greg Kroah-Hartman9d8bd712010-12-02 08:34:45 -0800708void vmbus_child_device_unregister(struct hv_device *device_obj)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700709{
Hank Janssen3e7ee492009-07-13 16:02:34 -0700710
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700711 DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800712 &device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700713
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700714 /*
715 * Kick off the process of unregistering the device.
716 * This will call vmbus_remove() and eventually vmbus_device_release()
717 */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800718 device_unregister(&device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700719
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700720 DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800721 &device_obj->device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700722}
723
Hank Janssen3e189512010-03-04 22:11:00 +0000724/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700725 * vmbus_uevent - add uevent for our device
726 *
727 * This routine is invoked when a device is added or removed on the vmbus to
728 * generate a uevent to udev in the userspace. The udev will then look at its
729 * rule and the uevent generated here to load the appropriate driver
730 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700731static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
732{
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800733 struct hv_device *dev = device_to_hv_device(device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700734 int ret;
735
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700736 DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
737 "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
738 "%02x%02x%02x%02x%02x%02x%02x%02x}",
K. Y. Srinivasan65c22792011-03-07 13:35:10 -0800739 dev->dev_type.data[3], dev->dev_type.data[2],
740 dev->dev_type.data[1], dev->dev_type.data[0],
741 dev->dev_type.data[5], dev->dev_type.data[4],
742 dev->dev_type.data[7], dev->dev_type.data[6],
743 dev->dev_type.data[8], dev->dev_type.data[9],
744 dev->dev_type.data[10],
745 dev->dev_type.data[11],
746 dev->dev_type.data[12],
747 dev->dev_type.data[13],
748 dev->dev_type.data[14],
749 dev->dev_type.data[15]);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700750
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700751 ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
752 "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
753 "%02x%02x%02x%02x%02x%02x%02x%02x}",
K. Y. Srinivasan65c22792011-03-07 13:35:10 -0800754 dev->dev_type.data[3],
755 dev->dev_type.data[2],
756 dev->dev_type.data[1],
757 dev->dev_type.data[0],
758 dev->dev_type.data[5],
759 dev->dev_type.data[4],
760 dev->dev_type.data[7],
761 dev->dev_type.data[6],
762 dev->dev_type.data[8],
763 dev->dev_type.data[9],
764 dev->dev_type.data[10],
765 dev->dev_type.data[11],
766 dev->dev_type.data[12],
767 dev->dev_type.data[13],
768 dev->dev_type.data[14],
769 dev->dev_type.data[15]);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700770
771 if (ret)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700772 return ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700773
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700774 ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
775 "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
776 "%02x%02x%02x%02x%02x%02x%02x%02x}",
K. Y. Srinivasand5889772011-03-07 13:35:30 -0800777 dev->dev_instance.data[3],
778 dev->dev_instance.data[2],
779 dev->dev_instance.data[1],
780 dev->dev_instance.data[0],
781 dev->dev_instance.data[5],
782 dev->dev_instance.data[4],
783 dev->dev_instance.data[7],
784 dev->dev_instance.data[6],
785 dev->dev_instance.data[8],
786 dev->dev_instance.data[9],
787 dev->dev_instance.data[10],
788 dev->dev_instance.data[11],
789 dev->dev_instance.data[12],
790 dev->dev_instance.data[13],
791 dev->dev_instance.data[14],
792 dev->dev_instance.data[15]);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700793 if (ret)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700794 return ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700795
Hank Janssen3e7ee492009-07-13 16:02:34 -0700796 return 0;
797}
798
Hank Janssen3e189512010-03-04 22:11:00 +0000799/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700800 * vmbus_match - Attempt to match the specified device to the specified driver
801 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700802static int vmbus_match(struct device *device, struct device_driver *driver)
803{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700804 int match = 0;
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800805 struct hv_driver *drv = drv_to_hv_drv(driver);
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800806 struct hv_device *device_ctx = device_to_hv_device(device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700807
Bill Pemberton454f18a2009-07-27 16:47:24 -0400808 /* We found our driver ? */
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800809 if (memcmp(&device_ctx->dev_type, &drv->dev_type,
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700810 sizeof(struct hv_guid)) == 0) {
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700811
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800812 device_ctx->drv = drv->priv;
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700813 DPRINT_INFO(VMBUS_DRV,
814 "device object (%p) set to driver object (%p)",
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800815 &device_ctx,
816 device_ctx->drv);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700817
818 match = 1;
819 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700820 return match;
821}
822
Hank Janssen3e189512010-03-04 22:11:00 +0000823/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700824 * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe()
825 *
826 * We need a callback because we cannot invoked device_unregister() inside
827 * vmbus_probe() since vmbus_probe() may be invoked inside device_register()
828 * i.e. we cannot call device_unregister() inside device_register()
829 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700830static void vmbus_probe_failed_cb(struct work_struct *context)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700831{
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800832 struct hv_device *device_ctx = (struct hv_device *)context;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700833
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700834 /*
835 * Kick off the process of unregistering the device.
836 * This will call vmbus_remove() and eventually vmbus_device_release()
837 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700838 device_unregister(&device_ctx->device);
839
Bill Pemberton454f18a2009-07-27 16:47:24 -0400840 /* put_device(&device_ctx->device); */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700841}
842
Hank Janssen3e189512010-03-04 22:11:00 +0000843/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700844 * vmbus_probe - Add the new vmbus's child device
845 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700846static int vmbus_probe(struct device *child_device)
847{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700848 int ret = 0;
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800849 struct hv_driver *drv =
850 drv_to_hv_drv(child_device->driver);
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800851 struct hv_device *dev = device_to_hv_device(child_device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700852
Bill Pemberton454f18a2009-07-27 16:47:24 -0400853 /* Let the specific open-source driver handles the probe if it can */
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800854 if (drv->driver.probe) {
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800855 ret = dev->probe_error =
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800856 drv->driver.probe(child_device);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700857 if (ret != 0) {
858 DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
859 "(%p) on driver %s (%d)...",
860 dev_name(child_device), child_device,
861 child_device->driver->name, ret);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700862
K. Y. Srinivasana3c7fe92011-03-07 13:34:27 -0800863 INIT_WORK(&dev->probe_failed_work_item,
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700864 vmbus_probe_failed_cb);
K. Y. Srinivasana3c7fe92011-03-07 13:34:27 -0800865 schedule_work(&dev->probe_failed_work_item);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700866 }
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700867 } else {
868 DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s",
869 child_device->driver->name);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700870 ret = -1;
871 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700872 return ret;
873}
874
Hank Janssen3e189512010-03-04 22:11:00 +0000875/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700876 * vmbus_remove - Remove a vmbus device
877 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700878static int vmbus_remove(struct device *child_device)
879{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700880 int ret;
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800881 struct hv_driver *drv;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700882
Bill Pemberton454f18a2009-07-27 16:47:24 -0400883 /* Special case root bus device */
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700884 if (child_device->parent == NULL) {
885 /*
886 * No-op since it is statically defined and handle in
887 * vmbus_bus_exit()
888 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700889 return 0;
890 }
891
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700892 if (child_device->driver) {
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800893 drv = drv_to_hv_drv(child_device->driver);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700894
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700895 /*
896 * Let the specific open-source driver handles the removal if
897 * it can
898 */
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800899 if (drv->driver.remove) {
900 ret = drv->driver.remove(child_device);
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700901 } else {
902 DPRINT_ERR(VMBUS_DRV,
903 "remove() method not set for driver - %s",
904 child_device->driver->name);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700905 ret = -1;
906 }
907 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700908
Hank Janssen3e7ee492009-07-13 16:02:34 -0700909 return 0;
910}
911
Hank Janssen3e189512010-03-04 22:11:00 +0000912/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700913 * vmbus_shutdown - Shutdown a vmbus device
914 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700915static void vmbus_shutdown(struct device *child_device)
916{
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800917 struct hv_driver *drv;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700918
Bill Pemberton454f18a2009-07-27 16:47:24 -0400919 /* Special case root bus device */
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700920 if (child_device->parent == NULL) {
921 /*
922 * No-op since it is statically defined and handle in
923 * vmbus_bus_exit()
924 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700925 return;
926 }
927
Bill Pemberton454f18a2009-07-27 16:47:24 -0400928 /* The device may not be attached yet */
Greg Kroah-Hartman83c720e2010-07-22 15:14:04 -0700929 if (!child_device->driver)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700930 return;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700931
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800932 drv = drv_to_hv_drv(child_device->driver);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700933
Bill Pemberton454f18a2009-07-27 16:47:24 -0400934 /* Let the specific open-source driver handles the removal if it can */
K. Y. Srinivasan150f9392011-03-07 13:32:31 -0800935 if (drv->driver.shutdown)
936 drv->driver.shutdown(child_device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700937
Hank Janssen3e7ee492009-07-13 16:02:34 -0700938 return;
939}
940
Hank Janssen3e189512010-03-04 22:11:00 +0000941/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700942 * vmbus_bus_release - Final callback release of the vmbus root device
943 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700944static void vmbus_bus_release(struct device *device)
945{
Greg Kroah-Hartman689bf402009-09-01 20:12:58 -0700946 /* FIXME */
947 /* Empty release functions are a bug, or a major sign
948 * of a problem design, this MUST BE FIXED! */
949 dev_err(device, "%s needs to be fixed!\n", __func__);
950 WARN_ON(1);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700951}
952
Hank Janssen3e189512010-03-04 22:11:00 +0000953/*
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700954 * vmbus_device_release - Final callback release of the vmbus child device
955 */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700956static void vmbus_device_release(struct device *device)
957{
K. Y. Srinivasan6bad88d2011-03-07 13:35:48 -0800958 struct hv_device *device_ctx = device_to_hv_device(device);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700959
Hank Janssen3e7ee492009-07-13 16:02:34 -0700960 kfree(device_ctx);
961
Bill Pemberton454f18a2009-07-27 16:47:24 -0400962 /* !!DO NOT REFERENCE device_ctx anymore at this point!! */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700963}
964
Hank Janssen3e7ee492009-07-13 16:02:34 -0700965
Hank Janssen3e7ee492009-07-13 16:02:34 -0700966
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700967static irqreturn_t vmbus_isr(int irq, void *dev_id)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700968{
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700969 int ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700970
K. Y. Srinivasan480ae582011-03-10 14:06:06 -0800971 ret = vmbus_on_isr();
Hank Janssen3e7ee492009-07-13 16:02:34 -0700972
Bill Pemberton454f18a2009-07-27 16:47:24 -0400973 /* Schedules a dpc if necessary */
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700974 if (ret > 0) {
975 if (test_bit(0, (unsigned long *)&ret))
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800976 tasklet_schedule(&vmbus_drv.msg_dpc);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700977
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700978 if (test_bit(1, (unsigned long *)&ret))
Haiyang Zhangadf874c2011-01-26 12:12:09 -0800979 tasklet_schedule(&vmbus_drv.event_dpc);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700980
Hank Janssen3e7ee492009-07-13 16:02:34 -0700981 return IRQ_HANDLED;
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -0700982 } else {
Hank Janssen3e7ee492009-07-13 16:02:34 -0700983 return IRQ_NONE;
984 }
985}
986
Greg Kroah-Hartmanc22090f2010-02-25 16:43:15 -0800987static struct dmi_system_id __initdata microsoft_hv_dmi_table[] = {
988 {
989 .ident = "Hyper-V",
990 .matches = {
991 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
992 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
993 DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
994 },
995 },
996 { },
997};
998MODULE_DEVICE_TABLE(dmi, microsoft_hv_dmi_table);
999
Hank Janssen3e7ee492009-07-13 16:02:34 -07001000static int __init vmbus_init(void)
1001{
Hank Janssen3e7ee492009-07-13 16:02:34 -07001002 DPRINT_INFO(VMBUS_DRV,
1003 "Vmbus initializing.... current log level 0x%x (%x,%x)",
1004 vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel));
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -07001005 /* Todo: it is used for loglevel, to be ported to new kernel. */
Hank Janssen3e7ee492009-07-13 16:02:34 -07001006
Greg Kroah-Hartmanc22090f2010-02-25 16:43:15 -08001007 if (!dmi_check_system(microsoft_hv_dmi_table))
1008 return -ENODEV;
1009
Greg Kroah-Hartman6c884552010-12-02 12:04:00 -08001010 return vmbus_bus_init();
Hank Janssen3e7ee492009-07-13 16:02:34 -07001011}
1012
Hank Janssen3e7ee492009-07-13 16:02:34 -07001013static void __exit vmbus_exit(void)
1014{
Hank Janssen3e7ee492009-07-13 16:02:34 -07001015 vmbus_bus_exit();
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -07001016 /* Todo: it is used for loglevel, to be ported to new kernel. */
Hank Janssen3e7ee492009-07-13 16:02:34 -07001017}
1018
Greg Kroah-Hartman9a775db2010-02-25 16:42:10 -08001019/*
1020 * We use a PCI table to determine if we should autoload this driver This is
1021 * needed by distro tools to determine if the hyperv drivers should be
1022 * installed and/or configured. We don't do anything else with the table, but
1023 * it needs to be present.
Greg Kroah-Hartman9a775db2010-02-25 16:42:10 -08001024 */
Tobias Klauser15f0beb2010-05-20 10:39:38 +02001025static const struct pci_device_id microsoft_hv_pci_table[] = {
Greg Kroah-Hartman9a775db2010-02-25 16:42:10 -08001026 { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
1027 { 0 }
1028};
1029MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
1030
Greg Kroah-Hartman90c99602009-09-02 07:11:14 -07001031MODULE_LICENSE("GPL");
Hank Janssen26c14cc2010-02-11 23:02:42 +00001032MODULE_VERSION(HV_DRV_VERSION);
Hank Janssen3e7ee492009-07-13 16:02:34 -07001033module_param(vmbus_irq, int, S_IRUGO);
1034module_param(vmbus_loglevel, int, S_IRUGO);
Hank Janssen3e7ee492009-07-13 16:02:34 -07001035
1036module_init(vmbus_init);
1037module_exit(vmbus_exit);