Thomas Gleixner | 3b20eb2 | 2019-05-29 16:57:35 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 2 | /* |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 3 | * Copyright (c) 2009, Microsoft Corporation. |
| 4 | * |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 5 | * Authors: |
| 6 | * Haiyang Zhang <haiyangz@microsoft.com> |
| 7 | * Hank Janssen <hjanssen@microsoft.com> |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 8 | */ |
Hank Janssen | 0a46618 | 2011-03-29 13:58:47 -0700 | [diff] [blame] | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 10 | |
Greg Kroah-Hartman | 5654e93 | 2009-07-14 15:08:20 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> |
K. Y. Srinivasan | 0c3b7b2 | 2011-02-11 09:59:43 -0800 | [diff] [blame] | 12 | #include <linux/sched.h> |
| 13 | #include <linux/wait.h> |
Greg Kroah-Hartman | a0086dc | 2009-08-17 17:22:08 -0700 | [diff] [blame] | 14 | #include <linux/mm.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 16 | #include <linux/module.h> |
Greg Kroah-Hartman | 46a9719 | 2011-10-04 12:29:52 -0700 | [diff] [blame] | 17 | #include <linux/hyperv.h> |
K. Y. Srinivasan | 011a7c3 | 2014-02-01 19:02:20 -0800 | [diff] [blame] | 18 | #include <linux/uio.h> |
Dexuan Cui | 63d55b2 | 2015-12-14 16:01:47 -0800 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 20 | #include <asm/page.h> |
K. Y. Srinivasan | 3f335ea | 2011-05-12 19:34:15 -0700 | [diff] [blame] | 21 | |
K. Y. Srinivasan | 0f2a661 | 2011-05-12 19:34:28 -0700 | [diff] [blame] | 22 | #include "hyperv_vmbus.h" |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 23 | |
K. Y. Srinivasan | e3fe0bb | 2011-02-11 10:00:12 -0800 | [diff] [blame] | 24 | #define NUM_PAGES_SPANNED(addr, len) \ |
| 25 | ((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT)) |
| 26 | |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 27 | static unsigned long virt_to_hvpfn(void *addr) |
| 28 | { |
Dexuan Cui | a9fc434 | 2019-05-07 07:46:55 +0000 | [diff] [blame] | 29 | phys_addr_t paddr; |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 30 | |
| 31 | if (is_vmalloc_addr(addr)) |
| 32 | paddr = page_to_phys(vmalloc_to_page(addr)) + |
| 33 | offset_in_page(addr); |
| 34 | else |
| 35 | paddr = __pa(addr); |
| 36 | |
| 37 | return paddr >> PAGE_SHIFT; |
| 38 | } |
| 39 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 40 | /* |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 41 | * vmbus_setevent- Trigger an event notification on the specified |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 42 | * channel. |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 43 | */ |
K. Y. Srinivasan | 1f6ee4e | 2016-11-06 13:14:17 -0800 | [diff] [blame] | 44 | void vmbus_setevent(struct vmbus_channel *channel) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 45 | { |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 46 | struct hv_monitor_page *monitorpage; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 47 | |
Vitaly Kuznetsov | 991f8f1 | 2017-10-29 12:21:16 -0700 | [diff] [blame] | 48 | trace_vmbus_setevent(channel); |
| 49 | |
K. Y. Srinivasan | 3724287 | 2016-07-01 16:26:37 -0700 | [diff] [blame] | 50 | /* |
| 51 | * For channels marked as in "low latency" mode |
| 52 | * bypass the monitor page mechanism. |
| 53 | */ |
Stephen Hemminger | 5c1bec6 | 2017-02-05 17:20:31 -0700 | [diff] [blame] | 54 | if (channel->offermsg.monitor_allocated && !channel->low_latency) { |
| 55 | vmbus_send_interrupt(channel->offermsg.child_relid); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 56 | |
Greg Kroah-Hartman | 8681db4 | 2013-09-13 11:32:55 -0700 | [diff] [blame] | 57 | /* Get the child to parent monitor page */ |
| 58 | monitorpage = vmbus_connection.monitor_pages[1]; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 59 | |
Olaf Hering | 2235658 | 2011-03-21 14:41:37 +0100 | [diff] [blame] | 60 | sync_set_bit(channel->monitor_bit, |
Haiyang Zhang | f6feebe | 2010-11-08 14:04:39 -0800 | [diff] [blame] | 61 | (unsigned long *)&monitorpage->trigger_group |
| 62 | [channel->monitor_grp].pending); |
Bill Pemberton | 7c369f4 | 2009-07-29 17:00:11 -0400 | [diff] [blame] | 63 | |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 64 | } else { |
K. Y. Srinivasan | 21c3bef | 2012-12-01 06:46:43 -0800 | [diff] [blame] | 65 | vmbus_set_event(channel); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 66 | } |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 67 | } |
K. Y. Srinivasan | 1f6ee4e | 2016-11-06 13:14:17 -0800 | [diff] [blame] | 68 | EXPORT_SYMBOL_GPL(vmbus_setevent); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 69 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 70 | /* vmbus_free_ring - drop mapping of ring buffer */ |
| 71 | void vmbus_free_ring(struct vmbus_channel *channel) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 72 | { |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 73 | hv_ringbuffer_cleanup(&channel->outbound); |
| 74 | hv_ringbuffer_cleanup(&channel->inbound); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 75 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 76 | if (channel->ringbuffer_page) { |
| 77 | __free_pages(channel->ringbuffer_page, |
| 78 | get_order(channel->ringbuffer_pagecount |
| 79 | << PAGE_SHIFT)); |
| 80 | channel->ringbuffer_page = NULL; |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 81 | } |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 82 | } |
| 83 | EXPORT_SYMBOL_GPL(vmbus_free_ring); |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 84 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 85 | /* vmbus_alloc_ring - allocate and map pages for ring buffer */ |
| 86 | int vmbus_alloc_ring(struct vmbus_channel *newchannel, |
| 87 | u32 send_size, u32 recv_size) |
| 88 | { |
| 89 | struct page *page; |
| 90 | int order; |
| 91 | |
| 92 | if (send_size % PAGE_SIZE || recv_size % PAGE_SIZE) |
| 93 | return -EINVAL; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 94 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 95 | /* Allocate the ring buffer */ |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 96 | order = get_order(send_size + recv_size); |
K. Y. Srinivasan | 294409d | 2015-05-31 21:27:03 -0700 | [diff] [blame] | 97 | page = alloc_pages_node(cpu_to_node(newchannel->target_cpu), |
Stephen Hemminger | 52a42c2 | 2018-09-14 09:10:16 -0700 | [diff] [blame] | 98 | GFP_KERNEL|__GFP_ZERO, order); |
K. Y. Srinivasan | 294409d | 2015-05-31 21:27:03 -0700 | [diff] [blame] | 99 | |
| 100 | if (!page) |
Stephen Hemminger | 52a42c2 | 2018-09-14 09:10:16 -0700 | [diff] [blame] | 101 | page = alloc_pages(GFP_KERNEL|__GFP_ZERO, order); |
K. Y. Srinivasan | df3493e | 2011-02-11 09:59:00 -0800 | [diff] [blame] | 102 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 103 | if (!page) |
| 104 | return -ENOMEM; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 105 | |
Stephen Hemminger | 52a42c2 | 2018-09-14 09:10:16 -0700 | [diff] [blame] | 106 | newchannel->ringbuffer_page = page; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 107 | newchannel->ringbuffer_pagecount = (send_size + recv_size) >> PAGE_SHIFT; |
| 108 | newchannel->ringbuffer_send_offset = send_size >> PAGE_SHIFT; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 109 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | EXPORT_SYMBOL_GPL(vmbus_alloc_ring); |
K. Y. Srinivasan | 72a95cb | 2011-05-10 07:55:21 -0700 | [diff] [blame] | 113 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 114 | static int __vmbus_open(struct vmbus_channel *newchannel, |
| 115 | void *userdata, u32 userdatalen, |
| 116 | void (*onchannelcallback)(void *context), void *context) |
| 117 | { |
| 118 | struct vmbus_channel_open_channel *open_msg; |
| 119 | struct vmbus_channel_msginfo *open_info = NULL; |
| 120 | struct page *page = newchannel->ringbuffer_page; |
| 121 | u32 send_pages, recv_pages; |
| 122 | unsigned long flags; |
| 123 | int err; |
| 124 | |
| 125 | if (userdatalen > MAX_USER_DEFINED_BYTES) |
| 126 | return -EINVAL; |
| 127 | |
| 128 | send_pages = newchannel->ringbuffer_send_offset; |
| 129 | recv_pages = newchannel->ringbuffer_pagecount - send_pages; |
| 130 | |
| 131 | spin_lock_irqsave(&newchannel->lock, flags); |
| 132 | if (newchannel->state != CHANNEL_OPEN_STATE) { |
| 133 | spin_unlock_irqrestore(&newchannel->lock, flags); |
| 134 | return -EINVAL; |
Bill Pemberton | 3324fb4 | 2010-05-05 15:27:49 -0400 | [diff] [blame] | 135 | } |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 136 | spin_unlock_irqrestore(&newchannel->lock, flags); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 137 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 138 | newchannel->state = CHANNEL_OPENING_STATE; |
| 139 | newchannel->onchannel_callback = onchannelcallback; |
| 140 | newchannel->channel_callback_context = context; |
Bill Pemberton | 3324fb4 | 2010-05-05 15:27:49 -0400 | [diff] [blame] | 141 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 142 | err = hv_ringbuffer_init(&newchannel->outbound, page, send_pages); |
| 143 | if (err) |
| 144 | goto error_clean_ring; |
| 145 | |
| 146 | err = hv_ringbuffer_init(&newchannel->inbound, |
| 147 | &page[send_pages], recv_pages); |
| 148 | if (err) |
| 149 | goto error_clean_ring; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 150 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 151 | /* Establish the gpadl for the ring buffer */ |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 152 | newchannel->ringbuffer_gpadlhandle = 0; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 153 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 154 | err = vmbus_establish_gpadl(newchannel, |
| 155 | page_address(newchannel->ringbuffer_page), |
| 156 | (send_pages + recv_pages) << PAGE_SHIFT, |
Vitaly Kuznetsov | 9988ce6 | 2016-09-02 05:58:20 -0700 | [diff] [blame] | 157 | &newchannel->ringbuffer_gpadlhandle); |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 158 | if (err) |
| 159 | goto error_clean_ring; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 160 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 161 | /* Create and init the channel open message */ |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 162 | open_info = kmalloc(sizeof(*open_info) + |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 163 | sizeof(struct vmbus_channel_open_channel), |
| 164 | GFP_KERNEL); |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 165 | if (!open_info) { |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 166 | err = -ENOMEM; |
Vitaly Kuznetsov | 98f531b | 2016-09-02 05:58:19 -0700 | [diff] [blame] | 167 | goto error_free_gpadl; |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 168 | } |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 169 | |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 170 | init_completion(&open_info->waitevent); |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 171 | open_info->waiting_channel = newchannel; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 172 | |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 173 | open_msg = (struct vmbus_channel_open_channel *)open_info->msg; |
K. Y. Srinivasan | 0987ff6 | 2011-08-25 09:48:55 -0700 | [diff] [blame] | 174 | open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL; |
| 175 | open_msg->openid = newchannel->offermsg.child_relid; |
| 176 | open_msg->child_relid = newchannel->offermsg.child_relid; |
| 177 | open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 178 | open_msg->downstream_ringbuffer_pageoffset = newchannel->ringbuffer_send_offset; |
K. Y. Srinivasan | abbf3b2 | 2012-12-01 06:46:48 -0800 | [diff] [blame] | 179 | open_msg->target_vp = newchannel->target_vp; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 180 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 181 | if (userdatalen) |
K. Y. Srinivasan | 0987ff6 | 2011-08-25 09:48:55 -0700 | [diff] [blame] | 182 | memcpy(open_msg->userdata, userdata, userdatalen); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 183 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 184 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 185 | list_add_tail(&open_info->msglistentry, |
Haiyang Zhang | da9fcb7 | 2011-01-26 12:12:14 -0800 | [diff] [blame] | 186 | &vmbus_connection.chn_msg_list); |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 187 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 188 | |
K. Y. Srinivasan | 6f3d791 | 2017-08-11 10:03:59 -0700 | [diff] [blame] | 189 | if (newchannel->rescind) { |
| 190 | err = -ENODEV; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 191 | goto error_free_info; |
K. Y. Srinivasan | 6f3d791 | 2017-08-11 10:03:59 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 194 | err = vmbus_post_msg(open_msg, |
Vitaly Kuznetsov | c0bb039 | 2016-12-07 01:16:24 -0800 | [diff] [blame] | 195 | sizeof(struct vmbus_channel_open_channel), true); |
Hank Janssen | 98e0870 | 2011-03-29 13:58:44 -0700 | [diff] [blame] | 196 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 197 | trace_vmbus_open(open_msg, err); |
Vitaly Kuznetsov | 9202d77 | 2017-10-29 12:21:09 -0700 | [diff] [blame] | 198 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 199 | if (err != 0) |
Vitaly Kuznetsov | 98f531b | 2016-09-02 05:58:19 -0700 | [diff] [blame] | 200 | goto error_clean_msglist; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 201 | |
Vitaly Kuznetsov | 396e287 | 2016-06-09 17:08:56 -0700 | [diff] [blame] | 202 | wait_for_completion(&open_info->waitevent); |
K. Y. Srinivasan | 0c3b7b2 | 2011-02-11 09:59:43 -0800 | [diff] [blame] | 203 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 204 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 205 | list_del(&open_info->msglistentry); |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 206 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 207 | |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 208 | if (newchannel->rescind) { |
| 209 | err = -ENODEV; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 210 | goto error_free_info; |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Vitaly Kuznetsov | ffc151f | 2015-05-06 17:47:40 -0700 | [diff] [blame] | 213 | if (open_info->response.open_result.status) { |
| 214 | err = -EAGAIN; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 215 | goto error_free_info; |
Vitaly Kuznetsov | ffc151f | 2015-05-06 17:47:40 -0700 | [diff] [blame] | 216 | } |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 217 | |
Vitaly Kuznetsov | ffc151f | 2015-05-06 17:47:40 -0700 | [diff] [blame] | 218 | newchannel->state = CHANNEL_OPENED_STATE; |
K. Y. Srinivasan | 176fb9e | 2011-08-25 09:48:57 -0700 | [diff] [blame] | 219 | kfree(open_info); |
Vitaly Kuznetsov | ffc151f | 2015-05-06 17:47:40 -0700 | [diff] [blame] | 220 | return 0; |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 221 | |
Vitaly Kuznetsov | 98f531b | 2016-09-02 05:58:19 -0700 | [diff] [blame] | 222 | error_clean_msglist: |
K. Y. Srinivasan | 1392550 | 2012-10-12 13:22:42 -0700 | [diff] [blame] | 223 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
| 224 | list_del(&open_info->msglistentry); |
| 225 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 226 | error_free_info: |
| 227 | kfree(open_info); |
Vitaly Kuznetsov | 98f531b | 2016-09-02 05:58:19 -0700 | [diff] [blame] | 228 | error_free_gpadl: |
K. Y. Srinivasan | 40384e4 | 2015-02-27 11:26:04 -0800 | [diff] [blame] | 229 | vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle); |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 230 | newchannel->ringbuffer_gpadlhandle = 0; |
| 231 | error_clean_ring: |
Vitaly Kuznetsov | 9988ce6 | 2016-09-02 05:58:20 -0700 | [diff] [blame] | 232 | hv_ringbuffer_cleanup(&newchannel->outbound); |
| 233 | hv_ringbuffer_cleanup(&newchannel->inbound); |
Dexuan Cui | ac0d12b | 2015-02-27 11:26:00 -0800 | [diff] [blame] | 234 | newchannel->state = CHANNEL_OPEN_STATE; |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 235 | return err; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 236 | } |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 237 | |
| 238 | /* |
| 239 | * vmbus_connect_ring - Open the channel but reuse ring buffer |
| 240 | */ |
| 241 | int vmbus_connect_ring(struct vmbus_channel *newchannel, |
| 242 | void (*onchannelcallback)(void *context), void *context) |
| 243 | { |
| 244 | return __vmbus_open(newchannel, NULL, 0, onchannelcallback, context); |
| 245 | } |
| 246 | EXPORT_SYMBOL_GPL(vmbus_connect_ring); |
| 247 | |
| 248 | /* |
| 249 | * vmbus_open - Open the specified channel. |
| 250 | */ |
| 251 | int vmbus_open(struct vmbus_channel *newchannel, |
| 252 | u32 send_ringbuffer_size, u32 recv_ringbuffer_size, |
| 253 | void *userdata, u32 userdatalen, |
| 254 | void (*onchannelcallback)(void *context), void *context) |
| 255 | { |
| 256 | int err; |
| 257 | |
| 258 | err = vmbus_alloc_ring(newchannel, send_ringbuffer_size, |
| 259 | recv_ringbuffer_size); |
| 260 | if (err) |
| 261 | return err; |
| 262 | |
| 263 | err = __vmbus_open(newchannel, userdata, userdatalen, |
| 264 | onchannelcallback, context); |
| 265 | if (err) |
| 266 | vmbus_free_ring(newchannel); |
| 267 | |
| 268 | return err; |
| 269 | } |
Greg Kroah-Hartman | 36ceadf | 2010-10-21 09:58:21 -0700 | [diff] [blame] | 270 | EXPORT_SYMBOL_GPL(vmbus_open); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 271 | |
Dexuan Cui | 5c23a1a | 2016-01-27 22:29:40 -0800 | [diff] [blame] | 272 | /* Used for Hyper-V Socket: a guest client's connect() to the host */ |
Andy Shevchenko | 593db80 | 2019-01-10 16:25:32 +0200 | [diff] [blame] | 273 | int vmbus_send_tl_connect_request(const guid_t *shv_guest_servie_id, |
| 274 | const guid_t *shv_host_servie_id) |
Dexuan Cui | 5c23a1a | 2016-01-27 22:29:40 -0800 | [diff] [blame] | 275 | { |
| 276 | struct vmbus_channel_tl_connect_request conn_msg; |
Vitaly Kuznetsov | 98f31a0 | 2017-10-29 12:21:15 -0700 | [diff] [blame] | 277 | int ret; |
Dexuan Cui | 5c23a1a | 2016-01-27 22:29:40 -0800 | [diff] [blame] | 278 | |
| 279 | memset(&conn_msg, 0, sizeof(conn_msg)); |
| 280 | conn_msg.header.msgtype = CHANNELMSG_TL_CONNECT_REQUEST; |
| 281 | conn_msg.guest_endpoint_id = *shv_guest_servie_id; |
| 282 | conn_msg.host_service_id = *shv_host_servie_id; |
| 283 | |
Vitaly Kuznetsov | 98f31a0 | 2017-10-29 12:21:15 -0700 | [diff] [blame] | 284 | ret = vmbus_post_msg(&conn_msg, sizeof(conn_msg), true); |
| 285 | |
| 286 | trace_vmbus_send_tl_connect_request(&conn_msg, ret); |
| 287 | |
| 288 | return ret; |
Dexuan Cui | 5c23a1a | 2016-01-27 22:29:40 -0800 | [diff] [blame] | 289 | } |
| 290 | EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request); |
| 291 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 292 | /* |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 293 | * create_gpadl_header - Creates a gpadl for the specified buffer |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 294 | */ |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 295 | static int create_gpadl_header(void *kbuffer, u32 size, |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 296 | struct vmbus_channel_msginfo **msginfo) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 297 | { |
| 298 | int i; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 299 | int pagecount; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 300 | struct vmbus_channel_gpadl_header *gpadl_header; |
| 301 | struct vmbus_channel_gpadl_body *gpadl_body; |
| 302 | struct vmbus_channel_msginfo *msgheader; |
| 303 | struct vmbus_channel_msginfo *msgbody = NULL; |
| 304 | u32 msgsize; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 305 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 306 | int pfnsum, pfncount, pfnleft, pfncurr, pfnsize; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 307 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 308 | pagecount = size >> PAGE_SHIFT; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 309 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 310 | /* do we need a gpadl body msg */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 311 | pfnsize = MAX_SIZE_CHANNEL_MESSAGE - |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 312 | sizeof(struct vmbus_channel_gpadl_header) - |
| 313 | sizeof(struct gpa_range); |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 314 | pfncount = pfnsize / sizeof(u64); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 315 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 316 | if (pagecount > pfncount) { |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 317 | /* we need a gpadl body */ |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 318 | /* fill in the header */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 319 | msgsize = sizeof(struct vmbus_channel_msginfo) + |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 320 | sizeof(struct vmbus_channel_gpadl_header) + |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 321 | sizeof(struct gpa_range) + pfncount * sizeof(u64); |
| 322 | msgheader = kzalloc(msgsize, GFP_KERNEL); |
| 323 | if (!msgheader) |
Bill Pemberton | d1c250b | 2010-05-05 15:27:35 -0400 | [diff] [blame] | 324 | goto nomem; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 325 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 326 | INIT_LIST_HEAD(&msgheader->submsglist); |
| 327 | msgheader->msgsize = msgsize; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 328 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 329 | gpadl_header = (struct vmbus_channel_gpadl_header *) |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 330 | msgheader->msg; |
| 331 | gpadl_header->rangecount = 1; |
| 332 | gpadl_header->range_buflen = sizeof(struct gpa_range) + |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 333 | pagecount * sizeof(u64); |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 334 | gpadl_header->range[0].byte_offset = 0; |
| 335 | gpadl_header->range[0].byte_count = size; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 336 | for (i = 0; i < pfncount; i++) |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 337 | gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn( |
| 338 | kbuffer + PAGE_SIZE * i); |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 339 | *msginfo = msgheader; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 340 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 341 | pfnsum = pfncount; |
| 342 | pfnleft = pagecount - pfncount; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 343 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 344 | /* how many pfns can we fit */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 345 | pfnsize = MAX_SIZE_CHANNEL_MESSAGE - |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 346 | sizeof(struct vmbus_channel_gpadl_body); |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 347 | pfncount = pfnsize / sizeof(u64); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 348 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 349 | /* fill in the body */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 350 | while (pfnleft) { |
| 351 | if (pfnleft > pfncount) |
| 352 | pfncurr = pfncount; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 353 | else |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 354 | pfncurr = pfnleft; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 355 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 356 | msgsize = sizeof(struct vmbus_channel_msginfo) + |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 357 | sizeof(struct vmbus_channel_gpadl_body) + |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 358 | pfncurr * sizeof(u64); |
| 359 | msgbody = kzalloc(msgsize, GFP_KERNEL); |
K. Y. Srinivasan | f38cf9c | 2011-06-06 15:50:06 -0700 | [diff] [blame] | 360 | |
| 361 | if (!msgbody) { |
| 362 | struct vmbus_channel_msginfo *pos = NULL; |
| 363 | struct vmbus_channel_msginfo *tmp = NULL; |
| 364 | /* |
| 365 | * Free up all the allocated messages. |
| 366 | */ |
| 367 | list_for_each_entry_safe(pos, tmp, |
| 368 | &msgheader->submsglist, |
| 369 | msglistentry) { |
| 370 | |
| 371 | list_del(&pos->msglistentry); |
| 372 | kfree(pos); |
| 373 | } |
| 374 | |
Bill Pemberton | d1c250b | 2010-05-05 15:27:35 -0400 | [diff] [blame] | 375 | goto nomem; |
K. Y. Srinivasan | f38cf9c | 2011-06-06 15:50:06 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 378 | msgbody->msgsize = msgsize; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 379 | gpadl_body = |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 380 | (struct vmbus_channel_gpadl_body *)msgbody->msg; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 381 | |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 382 | /* |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 383 | * Gpadl is u32 and we are using a pointer which could |
| 384 | * be 64-bit |
K. Y. Srinivasan | f27df64 | 2011-06-06 15:49:56 -0700 | [diff] [blame] | 385 | * This is governed by the guest/host protocol and |
Stephen Hemminger | bdc1dd4 | 2017-03-04 18:27:14 -0700 | [diff] [blame] | 386 | * so the hypervisor guarantees that this is ok. |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 387 | */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 388 | for (i = 0; i < pfncurr; i++) |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 389 | gpadl_body->pfn[i] = virt_to_hvpfn( |
| 390 | kbuffer + PAGE_SIZE * (pfnsum + i)); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 391 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 392 | /* add to msg header */ |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 393 | list_add_tail(&msgbody->msglistentry, |
| 394 | &msgheader->submsglist); |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 395 | pfnsum += pfncurr; |
| 396 | pfnleft -= pfncurr; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 397 | } |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 398 | } else { |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 399 | /* everything fits in a header */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 400 | msgsize = sizeof(struct vmbus_channel_msginfo) + |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 401 | sizeof(struct vmbus_channel_gpadl_header) + |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 402 | sizeof(struct gpa_range) + pagecount * sizeof(u64); |
| 403 | msgheader = kzalloc(msgsize, GFP_KERNEL); |
| 404 | if (msgheader == NULL) |
Kulikov Vasiliy | e3eb7cd | 2010-07-16 20:13:51 +0400 | [diff] [blame] | 405 | goto nomem; |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 406 | |
| 407 | INIT_LIST_HEAD(&msgheader->submsglist); |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 408 | msgheader->msgsize = msgsize; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 409 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 410 | gpadl_header = (struct vmbus_channel_gpadl_header *) |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 411 | msgheader->msg; |
| 412 | gpadl_header->rangecount = 1; |
| 413 | gpadl_header->range_buflen = sizeof(struct gpa_range) + |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 414 | pagecount * sizeof(u64); |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 415 | gpadl_header->range[0].byte_offset = 0; |
| 416 | gpadl_header->range[0].byte_count = size; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 417 | for (i = 0; i < pagecount; i++) |
Michael Kelley | 6ba3417 | 2018-08-02 03:08:24 +0000 | [diff] [blame] | 418 | gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn( |
| 419 | kbuffer + PAGE_SIZE * i); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 420 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 421 | *msginfo = msgheader; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | return 0; |
Bill Pemberton | d1c250b | 2010-05-05 15:27:35 -0400 | [diff] [blame] | 425 | nomem: |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 426 | kfree(msgheader); |
| 427 | kfree(msgbody); |
Bill Pemberton | d1c250b | 2010-05-05 15:27:35 -0400 | [diff] [blame] | 428 | return -ENOMEM; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 431 | /* |
Stephen Hemminger | bdc1dd4 | 2017-03-04 18:27:14 -0700 | [diff] [blame] | 432 | * vmbus_establish_gpadl - Establish a GPADL for the specified buffer |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 433 | * |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 434 | * @channel: a channel |
Haiyang Zhang | b679ef7 | 2014-01-27 15:03:42 -0800 | [diff] [blame] | 435 | * @kbuffer: from kmalloc or vmalloc |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 436 | * @size: page-size multiple |
| 437 | * @gpadl_handle: some funky thing |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 438 | */ |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 439 | int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 440 | u32 size, u32 *gpadl_handle) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 441 | { |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 442 | struct vmbus_channel_gpadl_header *gpadlmsg; |
| 443 | struct vmbus_channel_gpadl_body *gpadl_body; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 444 | struct vmbus_channel_msginfo *msginfo = NULL; |
Vitaly Kuznetsov | 7cc80c9 | 2016-06-03 17:09:24 -0700 | [diff] [blame] | 445 | struct vmbus_channel_msginfo *submsginfo, *tmp; |
Bill Pemberton | 53af545 | 2009-09-11 21:46:44 -0400 | [diff] [blame] | 446 | struct list_head *curr; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 447 | u32 next_gpadl_handle; |
Greg Kroah-Hartman | dd0813b | 2009-07-15 14:56:45 -0700 | [diff] [blame] | 448 | unsigned long flags; |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 449 | int ret = 0; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 450 | |
K. Y. Srinivasan | 9f52a16 | 2015-01-09 23:54:33 -0800 | [diff] [blame] | 451 | next_gpadl_handle = |
| 452 | (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 453 | |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 454 | ret = create_gpadl_header(kbuffer, size, &msginfo); |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 455 | if (ret) |
| 456 | return ret; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 457 | |
K. Y. Srinivasan | 9568a19 | 2011-05-10 07:55:39 -0700 | [diff] [blame] | 458 | init_completion(&msginfo->waitevent); |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 459 | msginfo->waiting_channel = channel; |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 460 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 461 | gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg; |
| 462 | gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER; |
| 463 | gpadlmsg->child_relid = channel->offermsg.child_relid; |
| 464 | gpadlmsg->gpadl = next_gpadl_handle; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 465 | |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 466 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 467 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 468 | list_add_tail(&msginfo->msglistentry, |
Haiyang Zhang | da9fcb7 | 2011-01-26 12:12:14 -0800 | [diff] [blame] | 469 | &vmbus_connection.chn_msg_list); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 470 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 471 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 472 | |
K. Y. Srinivasan | 6f3d791 | 2017-08-11 10:03:59 -0700 | [diff] [blame] | 473 | if (channel->rescind) { |
| 474 | ret = -ENODEV; |
| 475 | goto cleanup; |
| 476 | } |
| 477 | |
Haiyang Zhang | c697767 | 2011-01-26 12:12:08 -0800 | [diff] [blame] | 478 | ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize - |
Vitaly Kuznetsov | c0bb039 | 2016-12-07 01:16:24 -0800 | [diff] [blame] | 479 | sizeof(*msginfo), true); |
Vitaly Kuznetsov | 69edbd5 | 2017-10-29 12:21:11 -0700 | [diff] [blame] | 480 | |
| 481 | trace_vmbus_establish_gpadl_header(gpadlmsg, ret); |
| 482 | |
Hank Janssen | 98e0870 | 2011-03-29 13:58:44 -0700 | [diff] [blame] | 483 | if (ret != 0) |
K. Y. Srinivasan | 00d760b | 2011-06-06 15:50:12 -0700 | [diff] [blame] | 484 | goto cleanup; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 485 | |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 486 | list_for_each(curr, &msginfo->submsglist) { |
| 487 | submsginfo = (struct vmbus_channel_msginfo *)curr; |
| 488 | gpadl_body = |
| 489 | (struct vmbus_channel_gpadl_body *)submsginfo->msg; |
Bill Pemberton | 53af545 | 2009-09-11 21:46:44 -0400 | [diff] [blame] | 490 | |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 491 | gpadl_body->header.msgtype = |
| 492 | CHANNELMSG_GPADL_BODY; |
| 493 | gpadl_body->gpadl = next_gpadl_handle; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 494 | |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 495 | ret = vmbus_post_msg(gpadl_body, |
Vitaly Kuznetsov | c0bb039 | 2016-12-07 01:16:24 -0800 | [diff] [blame] | 496 | submsginfo->msgsize - sizeof(*submsginfo), |
| 497 | true); |
Vitaly Kuznetsov | 69edbd5 | 2017-10-29 12:21:11 -0700 | [diff] [blame] | 498 | |
| 499 | trace_vmbus_establish_gpadl_body(gpadl_body, ret); |
| 500 | |
Vitaly Kuznetsov | 4d63763 | 2016-06-03 17:09:23 -0700 | [diff] [blame] | 501 | if (ret != 0) |
| 502 | goto cleanup; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 503 | |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 504 | } |
K. Y. Srinivasan | 72c6b71 | 2014-08-27 16:25:34 -0700 | [diff] [blame] | 505 | wait_for_completion(&msginfo->waitevent); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 506 | |
Dexuan Cui | eceb059 | 2018-11-26 02:29:56 +0000 | [diff] [blame] | 507 | if (msginfo->response.gpadl_created.creation_status != 0) { |
| 508 | pr_err("Failed to establish GPADL: err = 0x%x\n", |
| 509 | msginfo->response.gpadl_created.creation_status); |
| 510 | |
| 511 | ret = -EDQUOT; |
| 512 | goto cleanup; |
| 513 | } |
| 514 | |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 515 | if (channel->rescind) { |
| 516 | ret = -ENODEV; |
| 517 | goto cleanup; |
| 518 | } |
| 519 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 520 | /* At this point, we received the gpadl created msg */ |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 521 | *gpadl_handle = gpadlmsg->gpadl; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 522 | |
K. Y. Srinivasan | 00d760b | 2011-06-06 15:50:12 -0700 | [diff] [blame] | 523 | cleanup: |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 524 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 525 | list_del(&msginfo->msglistentry); |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 526 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Vitaly Kuznetsov | 7cc80c9 | 2016-06-03 17:09:24 -0700 | [diff] [blame] | 527 | list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist, |
| 528 | msglistentry) { |
| 529 | kfree(submsginfo); |
| 530 | } |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 531 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 532 | kfree(msginfo); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 533 | return ret; |
| 534 | } |
Greg Kroah-Hartman | 9887372 | 2010-10-21 08:47:43 -0700 | [diff] [blame] | 535 | EXPORT_SYMBOL_GPL(vmbus_establish_gpadl); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 536 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 537 | /* |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 538 | * vmbus_teardown_gpadl -Teardown the specified GPADL handle |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 539 | */ |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 540 | int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 541 | { |
Greg Kroah-Hartman | 8225021 | 2009-08-26 15:16:04 -0700 | [diff] [blame] | 542 | struct vmbus_channel_gpadl_teardown *msg; |
Greg Kroah-Hartman | aded716 | 2009-08-18 15:21:19 -0700 | [diff] [blame] | 543 | struct vmbus_channel_msginfo *info; |
Greg Kroah-Hartman | dd0813b | 2009-07-15 14:56:45 -0700 | [diff] [blame] | 544 | unsigned long flags; |
K. Y. Srinivasan | 66be653 | 2014-08-27 16:25:32 -0700 | [diff] [blame] | 545 | int ret; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 546 | |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 547 | info = kmalloc(sizeof(*info) + |
| 548 | sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL); |
Bill Pemberton | c3bf2e2 | 2010-05-05 15:27:34 -0400 | [diff] [blame] | 549 | if (!info) |
| 550 | return -ENOMEM; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 551 | |
K. Y. Srinivasan | 9568a19 | 2011-05-10 07:55:39 -0700 | [diff] [blame] | 552 | init_completion(&info->waitevent); |
K. Y. Srinivasan | ccb61f8 | 2016-12-22 16:54:00 -0800 | [diff] [blame] | 553 | info->waiting_channel = channel; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 554 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 555 | msg = (struct vmbus_channel_gpadl_teardown *)info->msg; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 556 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 557 | msg->header.msgtype = CHANNELMSG_GPADL_TEARDOWN; |
| 558 | msg->child_relid = channel->offermsg.child_relid; |
| 559 | msg->gpadl = gpadl_handle; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 560 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 561 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 562 | list_add_tail(&info->msglistentry, |
Haiyang Zhang | da9fcb7 | 2011-01-26 12:12:14 -0800 | [diff] [blame] | 563 | &vmbus_connection.chn_msg_list); |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 564 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
K. Y. Srinivasan | 6f3d791 | 2017-08-11 10:03:59 -0700 | [diff] [blame] | 565 | |
| 566 | if (channel->rescind) |
| 567 | goto post_msg_err; |
| 568 | |
Vitaly Kuznetsov | c0bb039 | 2016-12-07 01:16:24 -0800 | [diff] [blame] | 569 | ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown), |
| 570 | true); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 571 | |
Vitaly Kuznetsov | 09cdf8f | 2017-10-29 12:21:12 -0700 | [diff] [blame] | 572 | trace_vmbus_teardown_gpadl(msg, ret); |
| 573 | |
K. Y. Srinivasan | 66be653 | 2014-08-27 16:25:32 -0700 | [diff] [blame] | 574 | if (ret) |
| 575 | goto post_msg_err; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 576 | |
K. Y. Srinivasan | 66be653 | 2014-08-27 16:25:32 -0700 | [diff] [blame] | 577 | wait_for_completion(&info->waitevent); |
| 578 | |
| 579 | post_msg_err: |
K. Y. Srinivasan | 5e030d5 | 2017-03-12 20:00:30 -0700 | [diff] [blame] | 580 | /* |
| 581 | * If the channel has been rescinded; |
| 582 | * we will be awakened by the rescind |
| 583 | * handler; set the error code to zero so we don't leak memory. |
| 584 | */ |
| 585 | if (channel->rescind) |
| 586 | ret = 0; |
| 587 | |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 588 | spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 589 | list_del(&info->msglistentry); |
Haiyang Zhang | 15b2f64 | 2011-01-26 12:12:07 -0800 | [diff] [blame] | 590 | spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 591 | |
Greg Kroah-Hartman | 8c69f52 | 2009-07-15 12:48:29 -0700 | [diff] [blame] | 592 | kfree(info); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 593 | return ret; |
| 594 | } |
Greg Kroah-Hartman | 18726d7 | 2010-10-21 08:39:59 -0700 | [diff] [blame] | 595 | EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 596 | |
K. Y. Srinivasan | d3ba720 | 2014-04-08 18:45:53 -0700 | [diff] [blame] | 597 | static void reset_channel_cb(void *arg) |
| 598 | { |
| 599 | struct vmbus_channel *channel = arg; |
| 600 | |
| 601 | channel->onchannel_callback = NULL; |
| 602 | } |
| 603 | |
Dexuan Cui | d3b26dd | 2018-08-02 03:08:23 +0000 | [diff] [blame] | 604 | void vmbus_reset_channel_cb(struct vmbus_channel *channel) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 605 | { |
Dexuan Cui | 63d55b2 | 2015-12-14 16:01:47 -0800 | [diff] [blame] | 606 | /* |
Dexuan Cui | dad72a1 | 2017-03-04 18:13:58 -0700 | [diff] [blame] | 607 | * vmbus_on_event(), running in the per-channel tasklet, can race |
Dexuan Cui | 63d55b2 | 2015-12-14 16:01:47 -0800 | [diff] [blame] | 608 | * with vmbus_close_internal() in the case of SMP guest, e.g., when |
| 609 | * the former is accessing channel->inbound.ring_buffer, the latter |
Dexuan Cui | dad72a1 | 2017-03-04 18:13:58 -0700 | [diff] [blame] | 610 | * could be freeing the ring_buffer pages, so here we must stop it |
| 611 | * first. |
Dexuan Cui | 63d55b2 | 2015-12-14 16:01:47 -0800 | [diff] [blame] | 612 | */ |
Dexuan Cui | dad72a1 | 2017-03-04 18:13:58 -0700 | [diff] [blame] | 613 | tasklet_disable(&channel->callback_event); |
Dexuan Cui | 63d55b2 | 2015-12-14 16:01:47 -0800 | [diff] [blame] | 614 | |
Dexuan Cui | d3b26dd | 2018-08-02 03:08:23 +0000 | [diff] [blame] | 615 | channel->sc_creation_callback = NULL; |
| 616 | |
| 617 | /* Stop the callback asap */ |
| 618 | if (channel->target_cpu != get_cpu()) { |
| 619 | put_cpu(); |
| 620 | smp_call_function_single(channel->target_cpu, reset_channel_cb, |
| 621 | channel, true); |
| 622 | } else { |
| 623 | reset_channel_cb(channel); |
| 624 | put_cpu(); |
| 625 | } |
| 626 | |
| 627 | /* Re-enable tasklet for use on re-open */ |
| 628 | tasklet_enable(&channel->callback_event); |
| 629 | } |
| 630 | |
| 631 | static int vmbus_close_internal(struct vmbus_channel *channel) |
| 632 | { |
| 633 | struct vmbus_channel_close_channel *msg; |
| 634 | int ret; |
| 635 | |
| 636 | vmbus_reset_channel_cb(channel); |
| 637 | |
Dexuan Cui | 64b7faf | 2015-12-14 16:01:48 -0800 | [diff] [blame] | 638 | /* |
| 639 | * In case a device driver's probe() fails (e.g., |
| 640 | * util_probe() -> vmbus_open() returns -ENOMEM) and the device is |
Masahiro Yamada | 8a1115f | 2017-03-09 16:16:31 -0800 | [diff] [blame] | 641 | * rescinded later (e.g., we dynamically disable an Integrated Service |
Dexuan Cui | 64b7faf | 2015-12-14 16:01:48 -0800 | [diff] [blame] | 642 | * in Hyper-V Manager), the driver's remove() invokes vmbus_close(): |
| 643 | * here we should skip most of the below cleanup work. |
| 644 | */ |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 645 | if (channel->state != CHANNEL_OPENED_STATE) |
| 646 | return -EINVAL; |
Dexuan Cui | 64b7faf | 2015-12-14 16:01:48 -0800 | [diff] [blame] | 647 | |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 648 | channel->state = CHANNEL_OPEN_STATE; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 649 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 650 | /* Send a closing message */ |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 651 | |
K. Y. Srinivasan | e9a27a9 | 2011-06-06 15:49:59 -0700 | [diff] [blame] | 652 | msg = &channel->close_msg.msg; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 653 | |
Haiyang Zhang | c50f7fb | 2010-11-08 14:04:38 -0800 | [diff] [blame] | 654 | msg->header.msgtype = CHANNELMSG_CLOSECHANNEL; |
| 655 | msg->child_relid = channel->offermsg.child_relid; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 656 | |
Vitaly Kuznetsov | c0bb039 | 2016-12-07 01:16:24 -0800 | [diff] [blame] | 657 | ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel), |
| 658 | true); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 659 | |
Vitaly Kuznetsov | 633b005 | 2017-10-29 12:21:10 -0700 | [diff] [blame] | 660 | trace_vmbus_close_internal(msg, ret); |
| 661 | |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 662 | if (ret) { |
| 663 | pr_err("Close failed: close post msg return is %d\n", ret); |
| 664 | /* |
| 665 | * If we failed to post the close msg, |
| 666 | * it is perhaps better to leak memory. |
| 667 | */ |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 668 | } |
| 669 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 670 | /* Tear down the gpadl for the channel's ring buffer */ |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 671 | else if (channel->ringbuffer_gpadlhandle) { |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 672 | ret = vmbus_teardown_gpadl(channel, |
| 673 | channel->ringbuffer_gpadlhandle); |
| 674 | if (ret) { |
| 675 | pr_err("Close failed: teardown gpadl return %d\n", ret); |
| 676 | /* |
| 677 | * If we failed to teardown gpadl, |
| 678 | * it is perhaps better to leak memory. |
| 679 | */ |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 680 | } |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 681 | |
| 682 | channel->ringbuffer_gpadlhandle = 0; |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 683 | } |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 684 | |
K. Y. Srinivasan | 98d731b | 2014-08-27 16:25:33 -0700 | [diff] [blame] | 685 | return ret; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 686 | } |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 687 | |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 688 | /* disconnect ring - close all channels */ |
| 689 | int vmbus_disconnect_ring(struct vmbus_channel *channel) |
| 690 | { |
| 691 | struct vmbus_channel *cur_channel, *tmp; |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 692 | int ret; |
| 693 | |
| 694 | if (channel->primary_channel != NULL) |
| 695 | return -EINVAL; |
| 696 | |
Dexuan Cui | b5679ce | 2019-01-09 20:56:06 +0000 | [diff] [blame] | 697 | list_for_each_entry_safe(cur_channel, tmp, &channel->sc_list, sc_list) { |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 698 | if (cur_channel->rescind) |
| 699 | wait_for_completion(&cur_channel->rescind_event); |
| 700 | |
| 701 | mutex_lock(&vmbus_connection.channel_mutex); |
| 702 | if (vmbus_close_internal(cur_channel) == 0) { |
| 703 | vmbus_free_ring(cur_channel); |
| 704 | |
| 705 | if (cur_channel->rescind) |
| 706 | hv_process_channel_removal(cur_channel); |
| 707 | } |
| 708 | mutex_unlock(&vmbus_connection.channel_mutex); |
| 709 | } |
| 710 | |
| 711 | /* |
| 712 | * Now close the primary. |
| 713 | */ |
| 714 | mutex_lock(&vmbus_connection.channel_mutex); |
| 715 | ret = vmbus_close_internal(channel); |
| 716 | mutex_unlock(&vmbus_connection.channel_mutex); |
| 717 | |
| 718 | return ret; |
| 719 | } |
| 720 | EXPORT_SYMBOL_GPL(vmbus_disconnect_ring); |
| 721 | |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 722 | /* |
| 723 | * vmbus_close - Close the specified channel |
| 724 | */ |
| 725 | void vmbus_close(struct vmbus_channel *channel) |
| 726 | { |
Stephen Hemminger | ae6935e | 2018-09-14 09:10:17 -0700 | [diff] [blame] | 727 | if (vmbus_disconnect_ring(channel) == 0) |
| 728 | vmbus_free_ring(channel); |
K. Y. Srinivasan | e68d297 | 2013-05-23 12:02:32 -0700 | [diff] [blame] | 729 | } |
Greg Kroah-Hartman | 70bfa30 | 2010-10-21 09:52:22 -0700 | [diff] [blame] | 730 | EXPORT_SYMBOL_GPL(vmbus_close); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 731 | |
stephen hemminger | 5dd0fb9 | 2017-08-16 08:56:26 -0700 | [diff] [blame] | 732 | /** |
| 733 | * vmbus_sendpacket() - Send the specified buffer on the given channel |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 734 | * @channel: Pointer to vmbus_channel structure |
| 735 | * @buffer: Pointer to the buffer you want to send the data from. |
| 736 | * @bufferlen: Maximum size of what the buffer holds. |
stephen hemminger | 5dd0fb9 | 2017-08-16 08:56:26 -0700 | [diff] [blame] | 737 | * @requestid: Identifier of the request |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 738 | * @type: Type of packet that is being sent e.g. negotiate, time |
| 739 | * packet etc. |
| 740 | * @flags: 0 or VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED |
stephen hemminger | 5dd0fb9 | 2017-08-16 08:56:26 -0700 | [diff] [blame] | 741 | * |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 742 | * Sends data in @buffer directly to Hyper-V via the vmbus. |
| 743 | * This will send the data unparsed to Hyper-V. |
stephen hemminger | 5dd0fb9 | 2017-08-16 08:56:26 -0700 | [diff] [blame] | 744 | * |
| 745 | * Mainly used by Hyper-V drivers. |
| 746 | */ |
| 747 | int vmbus_sendpacket(struct vmbus_channel *channel, void *buffer, |
| 748 | u32 bufferlen, u64 requestid, |
| 749 | enum vmbus_packet_type type, u32 flags) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 750 | { |
Greg Kroah-Hartman | 8dc0a06 | 2009-08-27 16:02:36 -0700 | [diff] [blame] | 751 | struct vmpacket_descriptor desc; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 752 | u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen; |
Uwe Kleine-König | 7350968 | 2011-01-20 09:32:01 +0100 | [diff] [blame] | 753 | u32 packetlen_aligned = ALIGN(packetlen, sizeof(u64)); |
K. Y. Srinivasan | 011a7c3 | 2014-02-01 19:02:20 -0800 | [diff] [blame] | 754 | struct kvec bufferlist[3]; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 755 | u64 aligned_data = 0; |
K. Y. Srinivasan | b81658c | 2015-08-01 16:08:14 -0700 | [diff] [blame] | 756 | int num_vecs = ((bufferlen != 0) ? 3 : 1); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 757 | |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 758 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 759 | /* Setup the descriptor */ |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 760 | desc.type = type; /* VmbusPacketTypeDataInBand; */ |
| 761 | desc.flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */ |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 762 | /* in 8-bytes granularity */ |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 763 | desc.offset8 = sizeof(struct vmpacket_descriptor) >> 3; |
| 764 | desc.len8 = (u16)(packetlen_aligned >> 3); |
| 765 | desc.trans_id = requestid; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 766 | |
K. Y. Srinivasan | 011a7c3 | 2014-02-01 19:02:20 -0800 | [diff] [blame] | 767 | bufferlist[0].iov_base = &desc; |
| 768 | bufferlist[0].iov_len = sizeof(struct vmpacket_descriptor); |
| 769 | bufferlist[1].iov_base = buffer; |
| 770 | bufferlist[1].iov_len = bufferlen; |
| 771 | bufferlist[2].iov_base = &aligned_data; |
| 772 | bufferlist[2].iov_len = (packetlen_aligned - packetlen); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 773 | |
Stephen Hemminger | 5529eaf | 2017-02-11 23:02:22 -0700 | [diff] [blame] | 774 | return hv_ringbuffer_write(channel, bufferlist, num_vecs); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 775 | } |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 776 | EXPORT_SYMBOL(vmbus_sendpacket); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 777 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 778 | /* |
stephen hemminger | 5a668d8 | 2017-08-16 08:56:25 -0700 | [diff] [blame] | 779 | * vmbus_sendpacket_pagebuffer - Send a range of single-page buffer |
K. Y. Srinivasan | 87e93d6 | 2015-02-28 11:39:03 -0800 | [diff] [blame] | 780 | * packets using a GPADL Direct packet type. This interface allows you |
| 781 | * to control notifying the host. This will be useful for sending |
| 782 | * batched data. Also the sender can control the send flags |
| 783 | * explicitly. |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 784 | */ |
stephen hemminger | 5a668d8 | 2017-08-16 08:56:25 -0700 | [diff] [blame] | 785 | int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, |
| 786 | struct hv_page_buffer pagebuffers[], |
| 787 | u32 pagecount, void *buffer, u32 bufferlen, |
| 788 | u64 requestid) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 789 | { |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 790 | int i; |
Haiyang Zhang | 430a8e9 | 2010-09-20 21:07:51 +0000 | [diff] [blame] | 791 | struct vmbus_channel_packet_page_buffer desc; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 792 | u32 descsize; |
| 793 | u32 packetlen; |
| 794 | u32 packetlen_aligned; |
K. Y. Srinivasan | 011a7c3 | 2014-02-01 19:02:20 -0800 | [diff] [blame] | 795 | struct kvec bufferlist[3]; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 796 | u64 aligned_data = 0; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 797 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 798 | if (pagecount > MAX_PAGE_BUFFER_COUNT) |
Bill Pemberton | 002b53e | 2010-05-05 15:27:39 -0400 | [diff] [blame] | 799 | return -EINVAL; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 800 | |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 801 | /* |
Haiyang Zhang | 430a8e9 | 2010-09-20 21:07:51 +0000 | [diff] [blame] | 802 | * Adjust the size down since vmbus_channel_packet_page_buffer is the |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 803 | * largest size we support |
| 804 | */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 805 | descsize = sizeof(struct vmbus_channel_packet_page_buffer) - |
| 806 | ((MAX_PAGE_BUFFER_COUNT - pagecount) * |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 807 | sizeof(struct hv_page_buffer)); |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 808 | packetlen = descsize + bufferlen; |
Uwe Kleine-König | 7350968 | 2011-01-20 09:32:01 +0100 | [diff] [blame] | 809 | packetlen_aligned = ALIGN(packetlen, sizeof(u64)); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 810 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 811 | /* Setup the descriptor */ |
Haiyang Zhang | 415f228 | 2011-01-26 12:12:13 -0800 | [diff] [blame] | 812 | desc.type = VM_PKT_DATA_USING_GPA_DIRECT; |
stephen hemminger | 5a668d8 | 2017-08-16 08:56:25 -0700 | [diff] [blame] | 813 | desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; |
Stephen Hemminger | bdc1dd4 | 2017-03-04 18:27:14 -0700 | [diff] [blame] | 814 | desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */ |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 815 | desc.length8 = (u16)(packetlen_aligned >> 3); |
| 816 | desc.transactionid = requestid; |
Stephen Hemminger | 33d426a | 2017-10-05 17:35:05 -0700 | [diff] [blame] | 817 | desc.reserved = 0; |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 818 | desc.rangecount = pagecount; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 819 | |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 820 | for (i = 0; i < pagecount; i++) { |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 821 | desc.range[i].len = pagebuffers[i].len; |
| 822 | desc.range[i].offset = pagebuffers[i].offset; |
| 823 | desc.range[i].pfn = pagebuffers[i].pfn; |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 824 | } |
| 825 | |
K. Y. Srinivasan | 011a7c3 | 2014-02-01 19:02:20 -0800 | [diff] [blame] | 826 | bufferlist[0].iov_base = &desc; |
| 827 | bufferlist[0].iov_len = descsize; |
| 828 | bufferlist[1].iov_base = buffer; |
| 829 | bufferlist[1].iov_len = bufferlen; |
| 830 | bufferlist[2].iov_base = &aligned_data; |
| 831 | bufferlist[2].iov_len = (packetlen_aligned - packetlen); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 832 | |
Stephen Hemminger | 5529eaf | 2017-02-11 23:02:22 -0700 | [diff] [blame] | 833 | return hv_ringbuffer_write(channel, bufferlist, 3); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 834 | } |
Greg Kroah-Hartman | 713efeb | 2010-10-21 09:29:54 -0700 | [diff] [blame] | 835 | EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 836 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 837 | /* |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 838 | * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 839 | * using a GPADL Direct packet type. |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 840 | * The buffer includes the vmbus descriptor. |
| 841 | */ |
| 842 | int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel, |
| 843 | struct vmbus_packet_mpb_array *desc, |
| 844 | u32 desc_size, |
| 845 | void *buffer, u32 bufferlen, u64 requestid) |
| 846 | { |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 847 | u32 packetlen; |
| 848 | u32 packetlen_aligned; |
| 849 | struct kvec bufferlist[3]; |
| 850 | u64 aligned_data = 0; |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 851 | |
| 852 | packetlen = desc_size + bufferlen; |
| 853 | packetlen_aligned = ALIGN(packetlen, sizeof(u64)); |
| 854 | |
| 855 | /* Setup the descriptor */ |
| 856 | desc->type = VM_PKT_DATA_USING_GPA_DIRECT; |
| 857 | desc->flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; |
Stephen Hemminger | bdc1dd4 | 2017-03-04 18:27:14 -0700 | [diff] [blame] | 858 | desc->dataoffset8 = desc_size >> 3; /* in 8-bytes granularity */ |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 859 | desc->length8 = (u16)(packetlen_aligned >> 3); |
| 860 | desc->transactionid = requestid; |
Stephen Hemminger | 33d426a | 2017-10-05 17:35:05 -0700 | [diff] [blame] | 861 | desc->reserved = 0; |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 862 | desc->rangecount = 1; |
| 863 | |
| 864 | bufferlist[0].iov_base = desc; |
| 865 | bufferlist[0].iov_len = desc_size; |
| 866 | bufferlist[1].iov_base = buffer; |
| 867 | bufferlist[1].iov_len = bufferlen; |
| 868 | bufferlist[2].iov_base = &aligned_data; |
| 869 | bufferlist[2].iov_len = (packetlen_aligned - packetlen); |
| 870 | |
Stephen Hemminger | 5529eaf | 2017-02-11 23:02:22 -0700 | [diff] [blame] | 871 | return hv_ringbuffer_write(channel, bufferlist, 3); |
K. Y. Srinivasan | d61031e | 2015-01-09 23:54:34 -0800 | [diff] [blame] | 872 | } |
| 873 | EXPORT_SYMBOL_GPL(vmbus_sendpacket_mpb_desc); |
| 874 | |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 875 | /** |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 876 | * __vmbus_recvpacket() - Retrieve the user packet on the specified channel |
| 877 | * @channel: Pointer to vmbus_channel structure |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 878 | * @buffer: Pointer to the buffer you want to receive the data into. |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 879 | * @bufferlen: Maximum size of what the buffer can hold. |
| 880 | * @buffer_actual_len: The actual size of the data after it was received. |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 881 | * @requestid: Identifier of the request |
Dexuan Cui | fe857bb | 2018-09-23 21:10:41 +0000 | [diff] [blame] | 882 | * @raw: true means keep the vmpacket_descriptor header in the received data. |
Hank Janssen | c88c4e4 | 2010-05-04 15:55:05 -0700 | [diff] [blame] | 883 | * |
| 884 | * Receives directly from the hyper-v vmbus and puts the data it received |
| 885 | * into Buffer. This will receive the data unparsed from hyper-v. |
| 886 | * |
| 887 | * Mainly used by Hyper-V drivers. |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 888 | */ |
Vitaly Kuznetsov | 667d374 | 2015-12-14 19:02:00 -0800 | [diff] [blame] | 889 | static inline int |
| 890 | __vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, |
| 891 | u32 bufferlen, u32 *buffer_actual_len, u64 *requestid, |
| 892 | bool raw) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 893 | { |
K. Y. Srinivasan | 3372592 | 2016-11-06 13:14:18 -0800 | [diff] [blame] | 894 | return hv_ringbuffer_read(channel, buffer, bufferlen, |
| 895 | buffer_actual_len, requestid, raw); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 896 | |
Vitaly Kuznetsov | 667d374 | 2015-12-14 19:02:00 -0800 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, |
| 900 | u32 bufferlen, u32 *buffer_actual_len, |
| 901 | u64 *requestid) |
| 902 | { |
| 903 | return __vmbus_recvpacket(channel, buffer, bufferlen, |
| 904 | buffer_actual_len, requestid, false); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 905 | } |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 906 | EXPORT_SYMBOL(vmbus_recvpacket); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 907 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 908 | /* |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 909 | * vmbus_recvpacket_raw - Retrieve the raw packet on the specified channel |
Greg Kroah-Hartman | f4266e3 | 2009-09-01 17:24:57 -0700 | [diff] [blame] | 910 | */ |
Haiyang Zhang | fff41b2 | 2010-10-07 11:40:08 -0700 | [diff] [blame] | 911 | int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, |
Haiyang Zhang | 39d70a4 | 2010-09-30 10:52:13 -0700 | [diff] [blame] | 912 | u32 bufferlen, u32 *buffer_actual_len, |
| 913 | u64 *requestid) |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 914 | { |
Vitaly Kuznetsov | 667d374 | 2015-12-14 19:02:00 -0800 | [diff] [blame] | 915 | return __vmbus_recvpacket(channel, buffer, bufferlen, |
| 916 | buffer_actual_len, requestid, true); |
Hank Janssen | 3e7ee49 | 2009-07-13 16:02:34 -0700 | [diff] [blame] | 917 | } |
Greg Kroah-Hartman | adaee6b | 2010-10-21 09:09:23 -0700 | [diff] [blame] | 918 | EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); |