Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010, 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> |
| 20 | */ |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 22 | |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 23 | #include <linux/kernel.h> |
| 24 | #include <linux/init.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/slab.h> |
| 27 | #include <linux/sysctl.h> |
Greg Kroah-Hartman | 9e62907 | 2010-05-04 08:26:23 -0700 | [diff] [blame] | 28 | #include <linux/reboot.h> |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 29 | |
K. Y. Srinivasan | 3f335ea | 2011-05-12 19:34:15 -0700 | [diff] [blame] | 30 | #include "hyperv.h" |
Ky Srinivasan | 245ba56 | 2010-12-16 18:54:16 -0700 | [diff] [blame] | 31 | #include "hv_kvp.h" |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 32 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 33 | static u8 *shut_txf_buf; |
| 34 | static u8 *time_txf_buf; |
| 35 | static u8 *hbeat_txf_buf; |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 36 | |
Greg Kroah-Hartman | 6610944 | 2010-05-04 14:31:18 -0700 | [diff] [blame] | 37 | static void shutdown_onchannelcallback(void *context) |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 38 | { |
| 39 | struct vmbus_channel *channel = context; |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 40 | u32 recvlen; |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 41 | u64 requestid; |
| 42 | u8 execute_shutdown = false; |
| 43 | |
| 44 | struct shutdown_msg_data *shutdown_msg; |
| 45 | |
| 46 | struct icmsg_hdr *icmsghdrp; |
| 47 | struct icmsg_negotiate *negop = NULL; |
| 48 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 49 | vmbus_recvpacket(channel, shut_txf_buf, |
| 50 | PAGE_SIZE, &recvlen, &requestid); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 51 | |
| 52 | if (recvlen > 0) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 53 | icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[ |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 54 | sizeof(struct vmbuspipe_hdr)]; |
| 55 | |
| 56 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 57 | prep_negotiate_resp(icmsghdrp, negop, shut_txf_buf); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 58 | } else { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 59 | shutdown_msg = |
| 60 | (struct shutdown_msg_data *)&shut_txf_buf[ |
| 61 | sizeof(struct vmbuspipe_hdr) + |
| 62 | sizeof(struct icmsg_hdr)]; |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 63 | |
| 64 | switch (shutdown_msg->flags) { |
| 65 | case 0: |
| 66 | case 1: |
| 67 | icmsghdrp->status = HV_S_OK; |
| 68 | execute_shutdown = true; |
| 69 | |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 70 | pr_info("Shutdown request received -" |
Greg Kroah-Hartman | 32235b0 | 2011-04-13 12:14:05 -0700 | [diff] [blame] | 71 | " graceful shutdown initiated\n"); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 72 | break; |
| 73 | default: |
| 74 | icmsghdrp->status = HV_E_FAIL; |
| 75 | execute_shutdown = false; |
| 76 | |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 77 | pr_info("Shutdown request received -" |
| 78 | " Invalid request\n"); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 79 | break; |
Joe Perches | 95cd17c | 2011-04-10 14:31:35 -0700 | [diff] [blame] | 80 | } |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION |
| 84 | | ICMSGHDRFLAG_RESPONSE; |
| 85 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 86 | vmbus_sendpacket(channel, shut_txf_buf, |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 87 | recvlen, requestid, |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 88 | VM_PKT_DATA_INBAND, 0); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 91 | if (execute_shutdown == true) |
K. Y. Srinivasan | ae2a0b4 | 2011-08-27 11:31:30 -0700 | [diff] [blame^] | 92 | orderly_poweroff(true); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 95 | /* |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 96 | * Set guest time to host UTC time. |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 97 | */ |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 98 | static inline void do_adj_guesttime(u64 hosttime) |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 99 | { |
| 100 | s64 host_tns; |
| 101 | struct timespec host_ts; |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 102 | |
| 103 | host_tns = (hosttime - WLTIMEDELTA) * 100; |
| 104 | host_ts = ns_to_timespec(host_tns); |
| 105 | |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 106 | do_settimeofday(&host_ts); |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | * Synchronize time with host after reboot, restore, etc. |
| 111 | * |
| 112 | * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. |
| 113 | * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time |
| 114 | * message after the timesync channel is opened. Since the hv_utils module is |
| 115 | * loaded after hv_vmbus, the first message is usually missed. The other |
| 116 | * thing is, systime is automatically set to emulated hardware clock which may |
| 117 | * not be UTC time or in the same time zone. So, to override these effects, we |
| 118 | * use the first 50 time samples for initial system time setting. |
| 119 | */ |
| 120 | static inline void adj_guesttime(u64 hosttime, u8 flags) |
| 121 | { |
| 122 | static s32 scnt = 50; |
| 123 | |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 124 | if ((flags & ICTIMESYNCFLAG_SYNC) != 0) { |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 125 | do_adj_guesttime(hosttime); |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 126 | return; |
| 127 | } |
| 128 | |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 129 | if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) { |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 130 | scnt--; |
Haiyang Zhang | e9ec360 | 2010-05-11 15:11:24 +0000 | [diff] [blame] | 131 | do_adj_guesttime(hosttime); |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 132 | } |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /* |
| 136 | * Time Sync Channel message handler. |
| 137 | */ |
| 138 | static void timesync_onchannelcallback(void *context) |
| 139 | { |
| 140 | struct vmbus_channel *channel = context; |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 141 | u32 recvlen; |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 142 | u64 requestid; |
| 143 | struct icmsg_hdr *icmsghdrp; |
| 144 | struct ictimesync_data *timedatap; |
| 145 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 146 | vmbus_recvpacket(channel, time_txf_buf, |
| 147 | PAGE_SIZE, &recvlen, &requestid); |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 148 | |
| 149 | if (recvlen > 0) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 150 | icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[ |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 151 | sizeof(struct vmbuspipe_hdr)]; |
| 152 | |
| 153 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 154 | prep_negotiate_resp(icmsghdrp, NULL, time_txf_buf); |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 155 | } else { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 156 | timedatap = (struct ictimesync_data *)&time_txf_buf[ |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 157 | sizeof(struct vmbuspipe_hdr) + |
| 158 | sizeof(struct icmsg_hdr)]; |
| 159 | adj_guesttime(timedatap->parenttime, timedatap->flags); |
| 160 | } |
| 161 | |
| 162 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION |
| 163 | | ICMSGHDRFLAG_RESPONSE; |
| 164 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 165 | vmbus_sendpacket(channel, time_txf_buf, |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 166 | recvlen, requestid, |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 167 | VM_PKT_DATA_INBAND, 0); |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 168 | } |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 171 | /* |
| 172 | * Heartbeat functionality. |
| 173 | * Every two seconds, Hyper-V send us a heartbeat request message. |
| 174 | * we respond to this message, and Hyper-V knows we are alive. |
| 175 | */ |
| 176 | static void heartbeat_onchannelcallback(void *context) |
| 177 | { |
| 178 | struct vmbus_channel *channel = context; |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 179 | u32 recvlen; |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 180 | u64 requestid; |
| 181 | struct icmsg_hdr *icmsghdrp; |
| 182 | struct heartbeat_msg_data *heartbeat_msg; |
| 183 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 184 | vmbus_recvpacket(channel, hbeat_txf_buf, |
| 185 | PAGE_SIZE, &recvlen, &requestid); |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 186 | |
| 187 | if (recvlen > 0) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 188 | icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[ |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 189 | sizeof(struct vmbuspipe_hdr)]; |
| 190 | |
| 191 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 192 | prep_negotiate_resp(icmsghdrp, NULL, hbeat_txf_buf); |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 193 | } else { |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 194 | heartbeat_msg = |
| 195 | (struct heartbeat_msg_data *)&hbeat_txf_buf[ |
| 196 | sizeof(struct vmbuspipe_hdr) + |
| 197 | sizeof(struct icmsg_hdr)]; |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 198 | |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 199 | heartbeat_msg->seq_num += 1; |
| 200 | } |
| 201 | |
| 202 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION |
| 203 | | ICMSGHDRFLAG_RESPONSE; |
| 204 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 205 | vmbus_sendpacket(channel, hbeat_txf_buf, |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 206 | recvlen, requestid, |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 207 | VM_PKT_DATA_INBAND, 0); |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 208 | } |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 209 | } |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 210 | |
K. Y. Srinivasan | 283f212 | 2011-08-25 09:48:36 -0700 | [diff] [blame] | 211 | /* |
| 212 | * The devices managed by the util driver don't need any additional |
| 213 | * setup. |
| 214 | */ |
| 215 | static int util_probe(struct hv_device *dev) |
| 216 | { |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | static int util_remove(struct hv_device *dev) |
| 221 | { |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | static const struct hv_vmbus_device_id id_table[] = { |
Greg Kroah-Hartman | c45cf2d | 2011-08-25 11:41:33 -0700 | [diff] [blame] | 226 | /* Shutdown guid */ |
| 227 | { VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, |
| 228 | 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) }, |
| 229 | /* Time synch guid */ |
| 230 | { VMBUS_DEVICE(0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, |
| 231 | 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) }, |
| 232 | /* Heartbeat guid */ |
| 233 | { VMBUS_DEVICE(0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, |
| 234 | 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) }, |
| 235 | /* KVP guid */ |
| 236 | { VMBUS_DEVICE(0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, |
| 237 | 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6) }, |
| 238 | { }, |
K. Y. Srinivasan | 283f212 | 2011-08-25 09:48:36 -0700 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | MODULE_DEVICE_TABLE(vmbus, id_table); |
| 242 | |
| 243 | /* The one and only one */ |
| 244 | static struct hv_driver util_drv = { |
Greg Kroah-Hartman | 768fa21 | 2011-08-25 15:07:32 -0700 | [diff] [blame] | 245 | .name = "hv_util", |
K. Y. Srinivasan | 283f212 | 2011-08-25 09:48:36 -0700 | [diff] [blame] | 246 | .id_table = id_table, |
| 247 | .probe = util_probe, |
| 248 | .remove = util_remove, |
| 249 | }; |
| 250 | |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 251 | static int __init init_hyperv_utils(void) |
| 252 | { |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 253 | pr_info("Registering HyperV Utility Driver\n"); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 254 | |
Ky Srinivasan | 245ba56 | 2010-12-16 18:54:16 -0700 | [diff] [blame] | 255 | if (hv_kvp_init()) |
| 256 | return -ENODEV; |
| 257 | |
| 258 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 259 | shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 260 | time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 261 | hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 262 | |
| 263 | if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) { |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 264 | pr_info("Unable to allocate memory for receive buffer\n"); |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 265 | kfree(shut_txf_buf); |
| 266 | kfree(time_txf_buf); |
| 267 | kfree(hbeat_txf_buf); |
| 268 | return -ENOMEM; |
| 269 | } |
| 270 | |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 271 | hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; |
| 272 | |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 273 | hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; |
| 274 | |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 275 | hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback; |
| 276 | |
K. Y. Srinivasan | b9d8e35 | 2011-05-16 06:44:36 -0700 | [diff] [blame] | 277 | hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; |
Ky Srinivasan | 245ba56 | 2010-12-16 18:54:16 -0700 | [diff] [blame] | 278 | |
Greg Kroah-Hartman | 768fa21 | 2011-08-25 15:07:32 -0700 | [diff] [blame] | 279 | return vmbus_driver_register(&util_drv); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | static void exit_hyperv_utils(void) |
| 283 | { |
Hank Janssen | af7a5b6 | 2011-03-29 13:58:49 -0700 | [diff] [blame] | 284 | pr_info("De-Registered HyperV Utility Driver\n"); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 285 | |
K. Y. Srinivasan | b9d8e35 | 2011-05-16 06:44:36 -0700 | [diff] [blame] | 286 | if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL) |
| 287 | hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback = |
| 288 | &chn_cb_negotiate; |
| 289 | hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL; |
Haiyang Zhang | 39c4e9c | 2010-05-05 19:23:46 +0000 | [diff] [blame] | 290 | |
K. Y. Srinivasan | b9d8e35 | 2011-05-16 06:44:36 -0700 | [diff] [blame] | 291 | if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL) |
| 292 | hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback = |
| 293 | &chn_cb_negotiate; |
| 294 | hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL; |
Hank Janssen | 9153f7b | 2010-05-15 14:39:58 -0700 | [diff] [blame] | 295 | |
K. Y. Srinivasan | b9d8e35 | 2011-05-16 06:44:36 -0700 | [diff] [blame] | 296 | if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL) |
| 297 | hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback = |
| 298 | &chn_cb_negotiate; |
| 299 | hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL; |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 300 | |
K. Y. Srinivasan | b9d8e35 | 2011-05-16 06:44:36 -0700 | [diff] [blame] | 301 | if (hv_cb_utils[HV_KVP_MSG].channel != NULL) |
| 302 | hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback = |
| 303 | &chn_cb_negotiate; |
| 304 | hv_cb_utils[HV_KVP_MSG].callback = NULL; |
| 305 | |
Ky Srinivasan | 245ba56 | 2010-12-16 18:54:16 -0700 | [diff] [blame] | 306 | hv_kvp_deinit(); |
| 307 | |
Hank Janssen | 45241e5 | 2010-12-13 16:23:36 -0800 | [diff] [blame] | 308 | kfree(shut_txf_buf); |
| 309 | kfree(time_txf_buf); |
| 310 | kfree(hbeat_txf_buf); |
Greg Kroah-Hartman | 768fa21 | 2011-08-25 15:07:32 -0700 | [diff] [blame] | 311 | vmbus_driver_unregister(&util_drv); |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | module_init(init_hyperv_utils); |
| 315 | module_exit(exit_hyperv_utils); |
| 316 | |
| 317 | MODULE_DESCRIPTION("Hyper-V Utilities"); |
| 318 | MODULE_VERSION(HV_DRV_VERSION); |
| 319 | MODULE_LICENSE("GPL"); |