blob: e57cc40cb768b7d3b85c761700e3729c2a2deebc [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 Janssen0a466182011-03-29 13:58:47 -070021#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
Greg Kroah-Hartman5654e932009-07-14 15:08:20 -070023#include <linux/kernel.h>
K. Y. Srinivasan0c3b7b22011-02-11 09:59:43 -080024#include <linux/sched.h>
25#include <linux/wait.h>
Greg Kroah-Hartmana0086dc2009-08-17 17:22:08 -070026#include <linux/mm.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090027#include <linux/slab.h>
Hank Janssenc88c4e42010-05-04 15:55:05 -070028#include <linux/module.h>
Greg Kroah-Hartman46a97192011-10-04 12:29:52 -070029#include <linux/hyperv.h>
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -080030#include <linux/uio.h>
Dexuan Cui63d55b22015-12-14 16:01:47 -080031#include <linux/interrupt.h>
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -070032
K. Y. Srinivasan0f2a6612011-05-12 19:34:28 -070033#include "hyperv_vmbus.h"
Hank Janssen3e7ee492009-07-13 16:02:34 -070034
K. Y. Srinivasane3fe0bb2011-02-11 10:00:12 -080035#define NUM_PAGES_SPANNED(addr, len) \
36((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT))
37
Hank Janssen3e189512010-03-04 22:11:00 +000038/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -070039 * vmbus_setevent- Trigger an event notification on the specified
Hank Janssen3e189512010-03-04 22:11:00 +000040 * channel.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -070041 */
K. Y. Srinivasan1f6ee4e2016-11-06 13:14:17 -080042void vmbus_setevent(struct vmbus_channel *channel)
Hank Janssen3e7ee492009-07-13 16:02:34 -070043{
Haiyang Zhang39d70a42010-09-30 10:52:13 -070044 struct hv_monitor_page *monitorpage;
Hank Janssen3e7ee492009-07-13 16:02:34 -070045
K. Y. Srinivasan37242872016-07-01 16:26:37 -070046 /*
47 * For channels marked as in "low latency" mode
48 * bypass the monitor page mechanism.
49 */
Stephen Hemminger5c1bec62017-02-05 17:20:31 -070050 if (channel->offermsg.monitor_allocated && !channel->low_latency) {
51 vmbus_send_interrupt(channel->offermsg.child_relid);
Hank Janssen3e7ee492009-07-13 16:02:34 -070052
Greg Kroah-Hartman8681db42013-09-13 11:32:55 -070053 /* Get the child to parent monitor page */
54 monitorpage = vmbus_connection.monitor_pages[1];
Hank Janssen3e7ee492009-07-13 16:02:34 -070055
Olaf Hering22356582011-03-21 14:41:37 +010056 sync_set_bit(channel->monitor_bit,
Haiyang Zhangf6feebe2010-11-08 14:04:39 -080057 (unsigned long *)&monitorpage->trigger_group
58 [channel->monitor_grp].pending);
Bill Pemberton7c369f42009-07-29 17:00:11 -040059
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -070060 } else {
K. Y. Srinivasan21c3bef2012-12-01 06:46:43 -080061 vmbus_set_event(channel);
Hank Janssen3e7ee492009-07-13 16:02:34 -070062 }
Hank Janssen3e7ee492009-07-13 16:02:34 -070063}
K. Y. Srinivasan1f6ee4e2016-11-06 13:14:17 -080064EXPORT_SYMBOL_GPL(vmbus_setevent);
Hank Janssen3e7ee492009-07-13 16:02:34 -070065
Hank Janssen3e189512010-03-04 22:11:00 +000066/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -070067 * vmbus_open - Open the specified channel.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -070068 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -070069int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
Haiyang Zhang39d70a42010-09-30 10:52:13 -070070 u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
71 void (*onchannelcallback)(void *context), void *context)
Hank Janssen3e7ee492009-07-13 16:02:34 -070072{
K. Y. Srinivasan0987ff62011-08-25 09:48:55 -070073 struct vmbus_channel_open_channel *open_msg;
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -070074 struct vmbus_channel_msginfo *open_info = NULL;
Greg Kroah-Hartmandd0813b2009-07-15 14:56:45 -070075 unsigned long flags;
Nicholas Mc Guire08a95132015-02-27 11:26:01 -080076 int ret, err = 0;
K. Y. Srinivasan294409d2015-05-31 21:27:03 -070077 struct page *page;
Hank Janssen3e7ee492009-07-13 16:02:34 -070078
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -070079 if (send_ringbuffer_size % PAGE_SIZE ||
80 recv_ringbuffer_size % PAGE_SIZE)
81 return -EINVAL;
82
Vitaly Kuznetsov67fae052015-01-20 16:45:05 +010083 spin_lock_irqsave(&newchannel->lock, flags);
K. Y. Srinivasane68d2972013-05-23 12:02:32 -070084 if (newchannel->state == CHANNEL_OPEN_STATE) {
85 newchannel->state = CHANNEL_OPENING_STATE;
86 } else {
Vitaly Kuznetsov67fae052015-01-20 16:45:05 +010087 spin_unlock_irqrestore(&newchannel->lock, flags);
K. Y. Srinivasane68d2972013-05-23 12:02:32 -070088 return -EINVAL;
89 }
Vitaly Kuznetsov67fae052015-01-20 16:45:05 +010090 spin_unlock_irqrestore(&newchannel->lock, flags);
K. Y. Srinivasane68d2972013-05-23 12:02:32 -070091
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -080092 newchannel->onchannel_callback = onchannelcallback;
93 newchannel->channel_callback_context = context;
Hank Janssen3e7ee492009-07-13 16:02:34 -070094
Bill Pemberton454f18a2009-07-27 16:47:24 -040095 /* Allocate the ring buffer */
K. Y. Srinivasan294409d2015-05-31 21:27:03 -070096 page = alloc_pages_node(cpu_to_node(newchannel->target_cpu),
97 GFP_KERNEL|__GFP_ZERO,
98 get_order(send_ringbuffer_size +
99 recv_ringbuffer_size));
100
101 if (!page)
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700102 page = alloc_pages(GFP_KERNEL|__GFP_ZERO,
103 get_order(send_ringbuffer_size +
104 recv_ringbuffer_size));
K. Y. Srinivasandf3493e2011-02-11 09:59:00 -0800105
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700106 if (!page) {
Dexuan Cuiac0d12b2015-02-27 11:26:00 -0800107 err = -ENOMEM;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700108 goto error_set_chnstate;
Dexuan Cuiac0d12b2015-02-27 11:26:00 -0800109 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700110
Vitaly Kuznetsov9988ce62016-09-02 05:58:20 -0700111 newchannel->ringbuffer_pages = page_address(page);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800112 newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700113 recv_ringbuffer_size) >> PAGE_SHIFT;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700114
Vitaly Kuznetsov9988ce62016-09-02 05:58:20 -0700115 ret = hv_ringbuffer_init(&newchannel->outbound, page,
116 send_ringbuffer_size >> PAGE_SHIFT);
K. Y. Srinivasan72a95cb2011-05-10 07:55:21 -0700117
Haiyang Zhangfd4dc882010-05-13 15:56:30 +0000118 if (ret != 0) {
Bill Pemberton3324fb42010-05-05 15:27:49 -0400119 err = ret;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700120 goto error_free_pages;
Bill Pemberton3324fb42010-05-05 15:27:49 -0400121 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700122
Vitaly Kuznetsov9988ce62016-09-02 05:58:20 -0700123 ret = hv_ringbuffer_init(&newchannel->inbound,
124 &page[send_ringbuffer_size >> PAGE_SHIFT],
125 recv_ringbuffer_size >> PAGE_SHIFT);
Haiyang Zhangfd4dc882010-05-13 15:56:30 +0000126 if (ret != 0) {
Bill Pemberton3324fb42010-05-05 15:27:49 -0400127 err = ret;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700128 goto error_free_pages;
Bill Pemberton3324fb42010-05-05 15:27:49 -0400129 }
130
Hank Janssen3e7ee492009-07-13 16:02:34 -0700131
Bill Pemberton454f18a2009-07-27 16:47:24 -0400132 /* Establish the gpadl for the ring buffer */
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800133 newchannel->ringbuffer_gpadlhandle = 0;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700134
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700135 ret = vmbus_establish_gpadl(newchannel,
Vitaly Kuznetsov9988ce62016-09-02 05:58:20 -0700136 page_address(page),
137 send_ringbuffer_size +
138 recv_ringbuffer_size,
139 &newchannel->ringbuffer_gpadlhandle);
Bill Pembertonb94ef342010-05-05 15:27:37 -0400140
Haiyang Zhangfd4dc882010-05-13 15:56:30 +0000141 if (ret != 0) {
Bill Pembertonb94ef342010-05-05 15:27:37 -0400142 err = ret;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700143 goto error_free_pages;
Bill Pembertonb94ef342010-05-05 15:27:37 -0400144 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700145
Bill Pemberton454f18a2009-07-27 16:47:24 -0400146 /* Create and init the channel open message */
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700147 open_info = kmalloc(sizeof(*open_info) +
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700148 sizeof(struct vmbus_channel_open_channel),
149 GFP_KERNEL);
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700150 if (!open_info) {
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400151 err = -ENOMEM;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700152 goto error_free_gpadl;
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400153 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700154
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700155 init_completion(&open_info->waitevent);
K. Y. Srinivasanccb61f82016-12-22 16:54:00 -0800156 open_info->waiting_channel = newchannel;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700157
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700158 open_msg = (struct vmbus_channel_open_channel *)open_info->msg;
K. Y. Srinivasan0987ff62011-08-25 09:48:55 -0700159 open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
160 open_msg->openid = newchannel->offermsg.child_relid;
161 open_msg->child_relid = newchannel->offermsg.child_relid;
162 open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
163 open_msg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700164 PAGE_SHIFT;
K. Y. Srinivasanabbf3b22012-12-01 06:46:48 -0800165 open_msg->target_vp = newchannel->target_vp;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700166
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700167 if (userdatalen > MAX_USER_DEFINED_BYTES) {
Bill Pembertonc827f942010-05-05 15:27:38 -0400168 err = -EINVAL;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700169 goto error_free_gpadl;
Bill Pembertonc827f942010-05-05 15:27:38 -0400170 }
171
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700172 if (userdatalen)
K. Y. Srinivasan0987ff62011-08-25 09:48:55 -0700173 memcpy(open_msg->userdata, userdata, userdatalen);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700174
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800175 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700176 list_add_tail(&open_info->msglistentry,
Haiyang Zhangda9fcb72011-01-26 12:12:14 -0800177 &vmbus_connection.chn_msg_list);
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800178 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700179
K. Y. Srinivasan0987ff62011-08-25 09:48:55 -0700180 ret = vmbus_post_msg(open_msg,
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800181 sizeof(struct vmbus_channel_open_channel), true);
Hank Janssen98e08702011-03-29 13:58:44 -0700182
K. Y. Srinivasan45d727c2014-08-27 16:25:35 -0700183 if (ret != 0) {
184 err = ret;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700185 goto error_clean_msglist;
K. Y. Srinivasan45d727c2014-08-27 16:25:35 -0700186 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700187
Vitaly Kuznetsov396e2872016-06-09 17:08:56 -0700188 wait_for_completion(&open_info->waitevent);
K. Y. Srinivasan0c3b7b22011-02-11 09:59:43 -0800189
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800190 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700191 list_del(&open_info->msglistentry);
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800192 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700193
K. Y. Srinivasanccb61f82016-12-22 16:54:00 -0800194 if (newchannel->rescind) {
195 err = -ENODEV;
196 goto error_free_gpadl;
197 }
198
Vitaly Kuznetsovffc151f2015-05-06 17:47:40 -0700199 if (open_info->response.open_result.status) {
200 err = -EAGAIN;
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700201 goto error_free_gpadl;
Vitaly Kuznetsovffc151f2015-05-06 17:47:40 -0700202 }
K. Y. Srinivasane68d2972013-05-23 12:02:32 -0700203
Vitaly Kuznetsovffc151f2015-05-06 17:47:40 -0700204 newchannel->state = CHANNEL_OPENED_STATE;
K. Y. Srinivasan176fb9e2011-08-25 09:48:57 -0700205 kfree(open_info);
Vitaly Kuznetsovffc151f2015-05-06 17:47:40 -0700206 return 0;
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400207
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700208error_clean_msglist:
K. Y. Srinivasan13925502012-10-12 13:22:42 -0700209 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
210 list_del(&open_info->msglistentry);
211 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
212
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700213error_free_gpadl:
K. Y. Srinivasan40384e42015-02-27 11:26:04 -0800214 vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle);
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700215 kfree(open_info);
216error_free_pages:
Vitaly Kuznetsov9988ce62016-09-02 05:58:20 -0700217 hv_ringbuffer_cleanup(&newchannel->outbound);
218 hv_ringbuffer_cleanup(&newchannel->inbound);
219 __free_pages(page,
220 get_order(send_ringbuffer_size + recv_ringbuffer_size));
Vitaly Kuznetsov98f531b2016-09-02 05:58:19 -0700221error_set_chnstate:
Dexuan Cuiac0d12b2015-02-27 11:26:00 -0800222 newchannel->state = CHANNEL_OPEN_STATE;
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400223 return err;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700224}
Greg Kroah-Hartman36ceadf2010-10-21 09:58:21 -0700225EXPORT_SYMBOL_GPL(vmbus_open);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700226
Dexuan Cui5c23a1a2016-01-27 22:29:40 -0800227/* Used for Hyper-V Socket: a guest client's connect() to the host */
228int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
229 const uuid_le *shv_host_servie_id)
230{
231 struct vmbus_channel_tl_connect_request conn_msg;
232
233 memset(&conn_msg, 0, sizeof(conn_msg));
234 conn_msg.header.msgtype = CHANNELMSG_TL_CONNECT_REQUEST;
235 conn_msg.guest_endpoint_id = *shv_guest_servie_id;
236 conn_msg.host_service_id = *shv_host_servie_id;
237
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800238 return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
Dexuan Cui5c23a1a2016-01-27 22:29:40 -0800239}
240EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
241
Hank Janssen3e189512010-03-04 22:11:00 +0000242/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700243 * create_gpadl_header - Creates a gpadl for the specified buffer
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700244 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700245static int create_gpadl_header(void *kbuffer, u32 size,
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700246 struct vmbus_channel_msginfo **msginfo)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700247{
248 int i;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700249 int pagecount;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700250 struct vmbus_channel_gpadl_header *gpadl_header;
251 struct vmbus_channel_gpadl_body *gpadl_body;
252 struct vmbus_channel_msginfo *msgheader;
253 struct vmbus_channel_msginfo *msgbody = NULL;
254 u32 msgsize;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700255
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700256 int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700257
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700258 pagecount = size >> PAGE_SHIFT;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700259
Bill Pemberton454f18a2009-07-27 16:47:24 -0400260 /* do we need a gpadl body msg */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700261 pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700262 sizeof(struct vmbus_channel_gpadl_header) -
263 sizeof(struct gpa_range);
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700264 pfncount = pfnsize / sizeof(u64);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700265
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700266 if (pagecount > pfncount) {
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700267 /* we need a gpadl body */
Bill Pemberton454f18a2009-07-27 16:47:24 -0400268 /* fill in the header */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700269 msgsize = sizeof(struct vmbus_channel_msginfo) +
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700270 sizeof(struct vmbus_channel_gpadl_header) +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700271 sizeof(struct gpa_range) + pfncount * sizeof(u64);
272 msgheader = kzalloc(msgsize, GFP_KERNEL);
273 if (!msgheader)
Bill Pembertond1c250b2010-05-05 15:27:35 -0400274 goto nomem;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700275
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800276 INIT_LIST_HEAD(&msgheader->submsglist);
277 msgheader->msgsize = msgsize;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700278
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700279 gpadl_header = (struct vmbus_channel_gpadl_header *)
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800280 msgheader->msg;
281 gpadl_header->rangecount = 1;
282 gpadl_header->range_buflen = sizeof(struct gpa_range) +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700283 pagecount * sizeof(u64);
Haiyang Zhang415f2282011-01-26 12:12:13 -0800284 gpadl_header->range[0].byte_offset = 0;
285 gpadl_header->range[0].byte_count = size;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700286 for (i = 0; i < pfncount; i++)
Haiyang Zhangb679ef72014-01-27 15:03:42 -0800287 gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys(
288 kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700289 *msginfo = msgheader;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700290
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700291 pfnsum = pfncount;
292 pfnleft = pagecount - pfncount;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700293
Bill Pemberton454f18a2009-07-27 16:47:24 -0400294 /* how many pfns can we fit */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700295 pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700296 sizeof(struct vmbus_channel_gpadl_body);
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700297 pfncount = pfnsize / sizeof(u64);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700298
Bill Pemberton454f18a2009-07-27 16:47:24 -0400299 /* fill in the body */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700300 while (pfnleft) {
301 if (pfnleft > pfncount)
302 pfncurr = pfncount;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700303 else
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700304 pfncurr = pfnleft;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700305
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700306 msgsize = sizeof(struct vmbus_channel_msginfo) +
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700307 sizeof(struct vmbus_channel_gpadl_body) +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700308 pfncurr * sizeof(u64);
309 msgbody = kzalloc(msgsize, GFP_KERNEL);
K. Y. Srinivasanf38cf9c2011-06-06 15:50:06 -0700310
311 if (!msgbody) {
312 struct vmbus_channel_msginfo *pos = NULL;
313 struct vmbus_channel_msginfo *tmp = NULL;
314 /*
315 * Free up all the allocated messages.
316 */
317 list_for_each_entry_safe(pos, tmp,
318 &msgheader->submsglist,
319 msglistentry) {
320
321 list_del(&pos->msglistentry);
322 kfree(pos);
323 }
324
Bill Pembertond1c250b2010-05-05 15:27:35 -0400325 goto nomem;
K. Y. Srinivasanf38cf9c2011-06-06 15:50:06 -0700326 }
327
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800328 msgbody->msgsize = msgsize;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700329 gpadl_body =
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800330 (struct vmbus_channel_gpadl_body *)msgbody->msg;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700331
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700332 /*
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700333 * Gpadl is u32 and we are using a pointer which could
334 * be 64-bit
K. Y. Srinivasanf27df642011-06-06 15:49:56 -0700335 * This is governed by the guest/host protocol and
Stephen Hemmingerbdc1dd42017-03-04 18:27:14 -0700336 * so the hypervisor guarantees that this is ok.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700337 */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700338 for (i = 0; i < pfncurr; i++)
Haiyang Zhangb679ef72014-01-27 15:03:42 -0800339 gpadl_body->pfn[i] = slow_virt_to_phys(
340 kbuffer + PAGE_SIZE * (pfnsum + i)) >>
341 PAGE_SHIFT;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700342
Bill Pemberton454f18a2009-07-27 16:47:24 -0400343 /* add to msg header */
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800344 list_add_tail(&msgbody->msglistentry,
345 &msgheader->submsglist);
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700346 pfnsum += pfncurr;
347 pfnleft -= pfncurr;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700348 }
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700349 } else {
Bill Pemberton454f18a2009-07-27 16:47:24 -0400350 /* everything fits in a header */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700351 msgsize = sizeof(struct vmbus_channel_msginfo) +
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700352 sizeof(struct vmbus_channel_gpadl_header) +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700353 sizeof(struct gpa_range) + pagecount * sizeof(u64);
354 msgheader = kzalloc(msgsize, GFP_KERNEL);
355 if (msgheader == NULL)
Kulikov Vasiliye3eb7cd2010-07-16 20:13:51 +0400356 goto nomem;
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700357
358 INIT_LIST_HEAD(&msgheader->submsglist);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800359 msgheader->msgsize = msgsize;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700360
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700361 gpadl_header = (struct vmbus_channel_gpadl_header *)
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800362 msgheader->msg;
363 gpadl_header->rangecount = 1;
364 gpadl_header->range_buflen = sizeof(struct gpa_range) +
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700365 pagecount * sizeof(u64);
Haiyang Zhang415f2282011-01-26 12:12:13 -0800366 gpadl_header->range[0].byte_offset = 0;
367 gpadl_header->range[0].byte_count = size;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700368 for (i = 0; i < pagecount; i++)
Haiyang Zhangb679ef72014-01-27 15:03:42 -0800369 gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys(
370 kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700371
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700372 *msginfo = msgheader;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700373 }
374
375 return 0;
Bill Pembertond1c250b2010-05-05 15:27:35 -0400376nomem:
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700377 kfree(msgheader);
378 kfree(msgbody);
Bill Pembertond1c250b2010-05-05 15:27:35 -0400379 return -ENOMEM;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700380}
381
Hank Janssen3e189512010-03-04 22:11:00 +0000382/*
Stephen Hemmingerbdc1dd42017-03-04 18:27:14 -0700383 * vmbus_establish_gpadl - Establish a GPADL for the specified buffer
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700384 *
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700385 * @channel: a channel
Haiyang Zhangb679ef72014-01-27 15:03:42 -0800386 * @kbuffer: from kmalloc or vmalloc
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700387 * @size: page-size multiple
388 * @gpadl_handle: some funky thing
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700389 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700390int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700391 u32 size, u32 *gpadl_handle)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700392{
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700393 struct vmbus_channel_gpadl_header *gpadlmsg;
394 struct vmbus_channel_gpadl_body *gpadl_body;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700395 struct vmbus_channel_msginfo *msginfo = NULL;
Vitaly Kuznetsov7cc80c92016-06-03 17:09:24 -0700396 struct vmbus_channel_msginfo *submsginfo, *tmp;
Bill Pemberton53af5452009-09-11 21:46:44 -0400397 struct list_head *curr;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700398 u32 next_gpadl_handle;
Greg Kroah-Hartmandd0813b2009-07-15 14:56:45 -0700399 unsigned long flags;
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400400 int ret = 0;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700401
K. Y. Srinivasan9f52a162015-01-09 23:54:33 -0800402 next_gpadl_handle =
403 (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700404
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700405 ret = create_gpadl_header(kbuffer, size, &msginfo);
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400406 if (ret)
407 return ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700408
K. Y. Srinivasan9568a192011-05-10 07:55:39 -0700409 init_completion(&msginfo->waitevent);
K. Y. Srinivasanccb61f82016-12-22 16:54:00 -0800410 msginfo->waiting_channel = channel;
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400411
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800412 gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
413 gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
414 gpadlmsg->child_relid = channel->offermsg.child_relid;
415 gpadlmsg->gpadl = next_gpadl_handle;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700416
Hank Janssen3e7ee492009-07-13 16:02:34 -0700417
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800418 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800419 list_add_tail(&msginfo->msglistentry,
Haiyang Zhangda9fcb72011-01-26 12:12:14 -0800420 &vmbus_connection.chn_msg_list);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700421
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800422 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700423
Haiyang Zhangc6977672011-01-26 12:12:08 -0800424 ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800425 sizeof(*msginfo), true);
Hank Janssen98e08702011-03-29 13:58:44 -0700426 if (ret != 0)
K. Y. Srinivasan00d760b2011-06-06 15:50:12 -0700427 goto cleanup;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700428
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700429 list_for_each(curr, &msginfo->submsglist) {
430 submsginfo = (struct vmbus_channel_msginfo *)curr;
431 gpadl_body =
432 (struct vmbus_channel_gpadl_body *)submsginfo->msg;
Bill Pemberton53af5452009-09-11 21:46:44 -0400433
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700434 gpadl_body->header.msgtype =
435 CHANNELMSG_GPADL_BODY;
436 gpadl_body->gpadl = next_gpadl_handle;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700437
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700438 ret = vmbus_post_msg(gpadl_body,
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800439 submsginfo->msgsize - sizeof(*submsginfo),
440 true);
Vitaly Kuznetsov4d637632016-06-03 17:09:23 -0700441 if (ret != 0)
442 goto cleanup;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700443
Hank Janssen3e7ee492009-07-13 16:02:34 -0700444 }
K. Y. Srinivasan72c6b712014-08-27 16:25:34 -0700445 wait_for_completion(&msginfo->waitevent);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700446
K. Y. Srinivasanccb61f82016-12-22 16:54:00 -0800447 if (channel->rescind) {
448 ret = -ENODEV;
449 goto cleanup;
450 }
451
Bill Pemberton454f18a2009-07-27 16:47:24 -0400452 /* At this point, we received the gpadl created msg */
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800453 *gpadl_handle = gpadlmsg->gpadl;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700454
K. Y. Srinivasan00d760b2011-06-06 15:50:12 -0700455cleanup:
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800456 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800457 list_del(&msginfo->msglistentry);
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800458 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Vitaly Kuznetsov7cc80c92016-06-03 17:09:24 -0700459 list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist,
460 msglistentry) {
461 kfree(submsginfo);
462 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700463
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700464 kfree(msginfo);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700465 return ret;
466}
Greg Kroah-Hartman98873722010-10-21 08:47:43 -0700467EXPORT_SYMBOL_GPL(vmbus_establish_gpadl);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700468
Hank Janssen3e189512010-03-04 22:11:00 +0000469/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700470 * vmbus_teardown_gpadl -Teardown the specified GPADL handle
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700471 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700472int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700473{
Greg Kroah-Hartman82250212009-08-26 15:16:04 -0700474 struct vmbus_channel_gpadl_teardown *msg;
Greg Kroah-Hartmanaded7162009-08-18 15:21:19 -0700475 struct vmbus_channel_msginfo *info;
Greg Kroah-Hartmandd0813b2009-07-15 14:56:45 -0700476 unsigned long flags;
K. Y. Srinivasan66be6532014-08-27 16:25:32 -0700477 int ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700478
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700479 info = kmalloc(sizeof(*info) +
480 sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
Bill Pembertonc3bf2e22010-05-05 15:27:34 -0400481 if (!info)
482 return -ENOMEM;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700483
K. Y. Srinivasan9568a192011-05-10 07:55:39 -0700484 init_completion(&info->waitevent);
K. Y. Srinivasanccb61f82016-12-22 16:54:00 -0800485 info->waiting_channel = channel;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700486
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800487 msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700488
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800489 msg->header.msgtype = CHANNELMSG_GPADL_TEARDOWN;
490 msg->child_relid = channel->offermsg.child_relid;
491 msg->gpadl = gpadl_handle;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700492
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800493 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800494 list_add_tail(&info->msglistentry,
Haiyang Zhangda9fcb72011-01-26 12:12:14 -0800495 &vmbus_connection.chn_msg_list);
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800496 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800497 ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
498 true);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700499
K. Y. Srinivasan66be6532014-08-27 16:25:32 -0700500 if (ret)
501 goto post_msg_err;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700502
K. Y. Srinivasan66be6532014-08-27 16:25:32 -0700503 wait_for_completion(&info->waitevent);
504
505post_msg_err:
K. Y. Srinivasan5e030d52017-03-12 20:00:30 -0700506 /*
507 * If the channel has been rescinded;
508 * we will be awakened by the rescind
509 * handler; set the error code to zero so we don't leak memory.
510 */
511 if (channel->rescind)
512 ret = 0;
513
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800514 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800515 list_del(&info->msglistentry);
Haiyang Zhang15b2f642011-01-26 12:12:07 -0800516 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700517
Greg Kroah-Hartman8c69f522009-07-15 12:48:29 -0700518 kfree(info);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700519 return ret;
520}
Greg Kroah-Hartman18726d72010-10-21 08:39:59 -0700521EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700522
K. Y. Srinivasand3ba7202014-04-08 18:45:53 -0700523static void reset_channel_cb(void *arg)
524{
525 struct vmbus_channel *channel = arg;
526
527 channel->onchannel_callback = NULL;
528}
529
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700530static int vmbus_close_internal(struct vmbus_channel *channel)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700531{
Greg Kroah-Hartman82250212009-08-26 15:16:04 -0700532 struct vmbus_channel_close_channel *msg;
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700533 int ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700534
Dexuan Cui63d55b22015-12-14 16:01:47 -0800535 /*
Dexuan Cuidad72a12017-03-04 18:13:58 -0700536 * vmbus_on_event(), running in the per-channel tasklet, can race
Dexuan Cui63d55b22015-12-14 16:01:47 -0800537 * with vmbus_close_internal() in the case of SMP guest, e.g., when
538 * the former is accessing channel->inbound.ring_buffer, the latter
Dexuan Cuidad72a12017-03-04 18:13:58 -0700539 * could be freeing the ring_buffer pages, so here we must stop it
540 * first.
Dexuan Cui63d55b22015-12-14 16:01:47 -0800541 */
Dexuan Cuidad72a12017-03-04 18:13:58 -0700542 tasklet_disable(&channel->callback_event);
Dexuan Cui63d55b22015-12-14 16:01:47 -0800543
Dexuan Cui64b7faf2015-12-14 16:01:48 -0800544 /*
545 * In case a device driver's probe() fails (e.g.,
546 * util_probe() -> vmbus_open() returns -ENOMEM) and the device is
Masahiro Yamada8a1115f2017-03-09 16:16:31 -0800547 * rescinded later (e.g., we dynamically disable an Integrated Service
Dexuan Cui64b7faf2015-12-14 16:01:48 -0800548 * in Hyper-V Manager), the driver's remove() invokes vmbus_close():
549 * here we should skip most of the below cleanup work.
550 */
551 if (channel->state != CHANNEL_OPENED_STATE) {
552 ret = -EINVAL;
553 goto out;
554 }
555
K. Y. Srinivasane68d2972013-05-23 12:02:32 -0700556 channel->state = CHANNEL_OPEN_STATE;
557 channel->sc_creation_callback = NULL;
Bill Pemberton454f18a2009-07-27 16:47:24 -0400558 /* Stop callback and cancel the timer asap */
K. Y. Srinivasan2115b562014-08-28 18:29:53 -0700559 if (channel->target_cpu != get_cpu()) {
560 put_cpu();
K. Y. Srinivasand3ba7202014-04-08 18:45:53 -0700561 smp_call_function_single(channel->target_cpu, reset_channel_cb,
562 channel, true);
K. Y. Srinivasan2115b562014-08-28 18:29:53 -0700563 } else {
K. Y. Srinivasand3ba7202014-04-08 18:45:53 -0700564 reset_channel_cb(channel);
K. Y. Srinivasan2115b562014-08-28 18:29:53 -0700565 put_cpu();
566 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700567
Bill Pemberton454f18a2009-07-27 16:47:24 -0400568 /* Send a closing message */
Hank Janssen3e7ee492009-07-13 16:02:34 -0700569
K. Y. Srinivasane9a27a92011-06-06 15:49:59 -0700570 msg = &channel->close_msg.msg;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700571
Haiyang Zhangc50f7fb2010-11-08 14:04:38 -0800572 msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
573 msg->child_relid = channel->offermsg.child_relid;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700574
Vitaly Kuznetsovc0bb0392016-12-07 01:16:24 -0800575 ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel),
576 true);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700577
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700578 if (ret) {
579 pr_err("Close failed: close post msg return is %d\n", ret);
580 /*
581 * If we failed to post the close msg,
582 * it is perhaps better to leak memory.
583 */
Dexuan Cui63d55b22015-12-14 16:01:47 -0800584 goto out;
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700585 }
586
Bill Pemberton454f18a2009-07-27 16:47:24 -0400587 /* Tear down the gpadl for the channel's ring buffer */
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700588 if (channel->ringbuffer_gpadlhandle) {
589 ret = vmbus_teardown_gpadl(channel,
590 channel->ringbuffer_gpadlhandle);
591 if (ret) {
592 pr_err("Close failed: teardown gpadl return %d\n", ret);
593 /*
594 * If we failed to teardown gpadl,
595 * it is perhaps better to leak memory.
596 */
Dexuan Cui63d55b22015-12-14 16:01:47 -0800597 goto out;
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700598 }
599 }
Hank Janssen3e7ee492009-07-13 16:02:34 -0700600
Bill Pemberton454f18a2009-07-27 16:47:24 -0400601 /* Cleanup the ring buffers for this channel */
K. Y. Srinivasan2dba6882011-05-10 07:55:22 -0700602 hv_ringbuffer_cleanup(&channel->outbound);
603 hv_ringbuffer_cleanup(&channel->inbound);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700604
K. Y. Srinivasandf3493e2011-02-11 09:59:00 -0800605 free_pages((unsigned long)channel->ringbuffer_pages,
606 get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700607
Dexuan Cui63d55b22015-12-14 16:01:47 -0800608out:
Stephen Hemminger6463a452017-06-25 12:47:46 -0700609 /* re-enable tasklet for use on re-open */
610 tasklet_enable(&channel->callback_event);
K. Y. Srinivasan98d731b2014-08-27 16:25:33 -0700611 return ret;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700612}
K. Y. Srinivasane68d2972013-05-23 12:02:32 -0700613
614/*
615 * vmbus_close - Close the specified channel
616 */
617void vmbus_close(struct vmbus_channel *channel)
618{
619 struct list_head *cur, *tmp;
620 struct vmbus_channel *cur_channel;
621
622 if (channel->primary_channel != NULL) {
623 /*
624 * We will only close sub-channels when
625 * the primary is closed.
626 */
627 return;
628 }
629 /*
630 * Close all the sub-channels first and then close the
631 * primary channel.
632 */
633 list_for_each_safe(cur, tmp, &channel->sc_list) {
634 cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
K. Y. Srinivasane68d2972013-05-23 12:02:32 -0700635 vmbus_close_internal(cur_channel);
K. Y. Srinivasan54a66262017-04-30 16:21:18 -0700636 if (cur_channel->rescind) {
637 mutex_lock(&vmbus_connection.channel_mutex);
638 hv_process_channel_removal(cur_channel,
639 cur_channel->offermsg.child_relid);
640 mutex_unlock(&vmbus_connection.channel_mutex);
641 }
K. Y. Srinivasane68d2972013-05-23 12:02:32 -0700642 }
643 /*
644 * Now close the primary.
645 */
646 vmbus_close_internal(channel);
647}
Greg Kroah-Hartman70bfa302010-10-21 09:52:22 -0700648EXPORT_SYMBOL_GPL(vmbus_close);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700649
K. Y. Srinivasane9395e32015-02-28 11:39:04 -0800650int vmbus_sendpacket_ctl(struct vmbus_channel *channel, void *buffer,
Stephen Hemminger34543232017-02-05 17:20:34 -0700651 u32 bufferlen, u64 requestid,
652 enum vmbus_packet_type type, u32 flags)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700653{
Greg Kroah-Hartman8dc0a062009-08-27 16:02:36 -0700654 struct vmpacket_descriptor desc;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700655 u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
Uwe Kleine-König73509682011-01-20 09:32:01 +0100656 u32 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800657 struct kvec bufferlist[3];
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700658 u64 aligned_data = 0;
K. Y. Srinivasanb81658c2015-08-01 16:08:14 -0700659 int num_vecs = ((bufferlen != 0) ? 3 : 1);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700660
Hank Janssen3e7ee492009-07-13 16:02:34 -0700661
Bill Pemberton454f18a2009-07-27 16:47:24 -0400662 /* Setup the descriptor */
Haiyang Zhang415f2282011-01-26 12:12:13 -0800663 desc.type = type; /* VmbusPacketTypeDataInBand; */
664 desc.flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700665 /* in 8-bytes granularity */
Haiyang Zhang415f2282011-01-26 12:12:13 -0800666 desc.offset8 = sizeof(struct vmpacket_descriptor) >> 3;
667 desc.len8 = (u16)(packetlen_aligned >> 3);
668 desc.trans_id = requestid;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700669
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800670 bufferlist[0].iov_base = &desc;
671 bufferlist[0].iov_len = sizeof(struct vmpacket_descriptor);
672 bufferlist[1].iov_base = buffer;
673 bufferlist[1].iov_len = bufferlen;
674 bufferlist[2].iov_base = &aligned_data;
675 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700676
Stephen Hemminger5529eaf2017-02-11 23:02:22 -0700677 return hv_ringbuffer_write(channel, bufferlist, num_vecs);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700678}
K. Y. Srinivasane9395e32015-02-28 11:39:04 -0800679EXPORT_SYMBOL(vmbus_sendpacket_ctl);
680
681/**
682 * vmbus_sendpacket() - Send the specified buffer on the given channel
683 * @channel: Pointer to vmbus_channel structure.
684 * @buffer: Pointer to the buffer you want to receive the data into.
685 * @bufferlen: Maximum size of what the the buffer will hold
686 * @requestid: Identifier of the request
687 * @type: Type of packet that is being send e.g. negotiate, time
688 * packet etc.
689 *
690 * Sends data in @buffer directly to hyper-v via the vmbus
691 * This will send the data unparsed to hyper-v.
692 *
693 * Mainly used by Hyper-V drivers.
694 */
695int vmbus_sendpacket(struct vmbus_channel *channel, void *buffer,
696 u32 bufferlen, u64 requestid,
697 enum vmbus_packet_type type, u32 flags)
698{
699 return vmbus_sendpacket_ctl(channel, buffer, bufferlen, requestid,
Stephen Hemminger34543232017-02-05 17:20:34 -0700700 type, flags);
K. Y. Srinivasane9395e32015-02-28 11:39:04 -0800701}
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700702EXPORT_SYMBOL(vmbus_sendpacket);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700703
Hank Janssen3e189512010-03-04 22:11:00 +0000704/*
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800705 * vmbus_sendpacket_pagebuffer_ctl - Send a range of single-page buffer
706 * packets using a GPADL Direct packet type. This interface allows you
707 * to control notifying the host. This will be useful for sending
708 * batched data. Also the sender can control the send flags
709 * explicitly.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700710 */
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800711int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel *channel,
Stephen Hemminger34543232017-02-05 17:20:34 -0700712 struct hv_page_buffer pagebuffers[],
713 u32 pagecount, void *buffer, u32 bufferlen,
714 u64 requestid, u32 flags)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700715{
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700716 int i;
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000717 struct vmbus_channel_packet_page_buffer desc;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700718 u32 descsize;
719 u32 packetlen;
720 u32 packetlen_aligned;
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800721 struct kvec bufferlist[3];
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700722 u64 aligned_data = 0;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700723
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700724 if (pagecount > MAX_PAGE_BUFFER_COUNT)
Bill Pemberton002b53e2010-05-05 15:27:39 -0400725 return -EINVAL;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700726
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700727 /*
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000728 * Adjust the size down since vmbus_channel_packet_page_buffer is the
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700729 * largest size we support
730 */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700731 descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
732 ((MAX_PAGE_BUFFER_COUNT - pagecount) *
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700733 sizeof(struct hv_page_buffer));
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700734 packetlen = descsize + bufferlen;
Uwe Kleine-König73509682011-01-20 09:32:01 +0100735 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700736
Bill Pemberton454f18a2009-07-27 16:47:24 -0400737 /* Setup the descriptor */
Haiyang Zhang415f2282011-01-26 12:12:13 -0800738 desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800739 desc.flags = flags;
Stephen Hemmingerbdc1dd42017-03-04 18:27:14 -0700740 desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700741 desc.length8 = (u16)(packetlen_aligned >> 3);
742 desc.transactionid = requestid;
743 desc.rangecount = pagecount;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700744
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700745 for (i = 0; i < pagecount; i++) {
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800746 desc.range[i].len = pagebuffers[i].len;
747 desc.range[i].offset = pagebuffers[i].offset;
748 desc.range[i].pfn = pagebuffers[i].pfn;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700749 }
750
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800751 bufferlist[0].iov_base = &desc;
752 bufferlist[0].iov_len = descsize;
753 bufferlist[1].iov_base = buffer;
754 bufferlist[1].iov_len = bufferlen;
755 bufferlist[2].iov_base = &aligned_data;
756 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700757
Stephen Hemminger5529eaf2017-02-11 23:02:22 -0700758 return hv_ringbuffer_write(channel, bufferlist, 3);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700759}
K. Y. Srinivasanb3a19b32015-03-18 12:29:29 -0700760EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer_ctl);
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800761
762/*
763 * vmbus_sendpacket_pagebuffer - Send a range of single-page buffer
764 * packets using a GPADL Direct packet type.
765 */
766int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
767 struct hv_page_buffer pagebuffers[],
768 u32 pagecount, void *buffer, u32 bufferlen,
769 u64 requestid)
770{
771 u32 flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
Stephen Hemminger34543232017-02-05 17:20:34 -0700772
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800773 return vmbus_sendpacket_pagebuffer_ctl(channel, pagebuffers, pagecount,
Stephen Hemminger34543232017-02-05 17:20:34 -0700774 buffer, bufferlen,
775 requestid, flags);
K. Y. Srinivasan87e93d62015-02-28 11:39:03 -0800776
777}
Greg Kroah-Hartman713efeb2010-10-21 09:29:54 -0700778EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700779
Hank Janssen3e189512010-03-04 22:11:00 +0000780/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700781 * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet
Hank Janssen3e189512010-03-04 22:11:00 +0000782 * using a GPADL Direct packet type.
K. Y. Srinivasand61031e2015-01-09 23:54:34 -0800783 * The buffer includes the vmbus descriptor.
784 */
785int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
786 struct vmbus_packet_mpb_array *desc,
787 u32 desc_size,
788 void *buffer, u32 bufferlen, u64 requestid)
789{
K. Y. Srinivasand61031e2015-01-09 23:54:34 -0800790 u32 packetlen;
791 u32 packetlen_aligned;
792 struct kvec bufferlist[3];
793 u64 aligned_data = 0;
K. Y. Srinivasand61031e2015-01-09 23:54:34 -0800794
795 packetlen = desc_size + bufferlen;
796 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
797
798 /* Setup the descriptor */
799 desc->type = VM_PKT_DATA_USING_GPA_DIRECT;
800 desc->flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
Stephen Hemmingerbdc1dd42017-03-04 18:27:14 -0700801 desc->dataoffset8 = desc_size >> 3; /* in 8-bytes granularity */
K. Y. Srinivasand61031e2015-01-09 23:54:34 -0800802 desc->length8 = (u16)(packetlen_aligned >> 3);
803 desc->transactionid = requestid;
804 desc->rangecount = 1;
805
806 bufferlist[0].iov_base = desc;
807 bufferlist[0].iov_len = desc_size;
808 bufferlist[1].iov_base = buffer;
809 bufferlist[1].iov_len = bufferlen;
810 bufferlist[2].iov_base = &aligned_data;
811 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
812
Stephen Hemminger5529eaf2017-02-11 23:02:22 -0700813 return hv_ringbuffer_write(channel, bufferlist, 3);
K. Y. Srinivasand61031e2015-01-09 23:54:34 -0800814}
815EXPORT_SYMBOL_GPL(vmbus_sendpacket_mpb_desc);
816
817/*
818 * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet
819 * using a GPADL Direct packet type.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700820 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700821int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700822 struct hv_multipage_buffer *multi_pagebuffer,
823 void *buffer, u32 bufferlen, u64 requestid)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700824{
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000825 struct vmbus_channel_packet_multipage_buffer desc;
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700826 u32 descsize;
827 u32 packetlen;
828 u32 packetlen_aligned;
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800829 struct kvec bufferlist[3];
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700830 u64 aligned_data = 0;
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800831 u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->offset,
832 multi_pagebuffer->len);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700833
Tobias Klauser24b8a402014-04-25 17:03:50 +0200834 if (pfncount > MAX_MULTIPAGE_BUFFER_COUNT)
Bill Pemberton002b53e2010-05-05 15:27:39 -0400835 return -EINVAL;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700836
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700837 /*
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000838 * Adjust the size down since vmbus_channel_packet_multipage_buffer is
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700839 * the largest size we support
840 */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700841 descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
842 ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700843 sizeof(u64));
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700844 packetlen = descsize + bufferlen;
Uwe Kleine-König73509682011-01-20 09:32:01 +0100845 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700846
Hank Janssen3e7ee492009-07-13 16:02:34 -0700847
Bill Pemberton454f18a2009-07-27 16:47:24 -0400848 /* Setup the descriptor */
Haiyang Zhang415f2282011-01-26 12:12:13 -0800849 desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000850 desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
Stephen Hemmingerbdc1dd42017-03-04 18:27:14 -0700851 desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700852 desc.length8 = (u16)(packetlen_aligned >> 3);
853 desc.transactionid = requestid;
Haiyang Zhang430a8e92010-09-20 21:07:51 +0000854 desc.rangecount = 1;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700855
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800856 desc.range.len = multi_pagebuffer->len;
857 desc.range.offset = multi_pagebuffer->offset;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700858
Haiyang Zhangca623ad2011-01-26 12:12:11 -0800859 memcpy(desc.range.pfn_array, multi_pagebuffer->pfn_array,
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700860 pfncount * sizeof(u64));
Hank Janssen3e7ee492009-07-13 16:02:34 -0700861
K. Y. Srinivasan011a7c32014-02-01 19:02:20 -0800862 bufferlist[0].iov_base = &desc;
863 bufferlist[0].iov_len = descsize;
864 bufferlist[1].iov_base = buffer;
865 bufferlist[1].iov_len = bufferlen;
866 bufferlist[2].iov_base = &aligned_data;
867 bufferlist[2].iov_len = (packetlen_aligned - packetlen);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700868
Stephen Hemminger5529eaf2017-02-11 23:02:22 -0700869 return hv_ringbuffer_write(channel, bufferlist, 3);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700870}
Greg Kroah-Hartman4cb106f2010-10-21 09:23:59 -0700871EXPORT_SYMBOL_GPL(vmbus_sendpacket_multipagebuffer);
Hank Janssenc88c4e42010-05-04 15:55:05 -0700872
873/**
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700874 * vmbus_recvpacket() - Retrieve the user packet on the specified channel
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700875 * @channel: Pointer to vmbus_channel structure.
876 * @buffer: Pointer to the buffer you want to receive the data into.
877 * @bufferlen: Maximum size of what the the buffer will hold
878 * @buffer_actual_len: The actual size of the data after it was received
879 * @requestid: Identifier of the request
Hank Janssenc88c4e42010-05-04 15:55:05 -0700880 *
881 * Receives directly from the hyper-v vmbus and puts the data it received
882 * into Buffer. This will receive the data unparsed from hyper-v.
883 *
884 * Mainly used by Hyper-V drivers.
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700885 */
Vitaly Kuznetsov667d3742015-12-14 19:02:00 -0800886static inline int
887__vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
888 u32 bufferlen, u32 *buffer_actual_len, u64 *requestid,
889 bool raw)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700890{
K. Y. Srinivasan33725922016-11-06 13:14:18 -0800891 return hv_ringbuffer_read(channel, buffer, bufferlen,
892 buffer_actual_len, requestid, raw);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700893
Vitaly Kuznetsov667d3742015-12-14 19:02:00 -0800894}
895
896int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
897 u32 bufferlen, u32 *buffer_actual_len,
898 u64 *requestid)
899{
900 return __vmbus_recvpacket(channel, buffer, bufferlen,
901 buffer_actual_len, requestid, false);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700902}
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700903EXPORT_SYMBOL(vmbus_recvpacket);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700904
Hank Janssen3e189512010-03-04 22:11:00 +0000905/*
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700906 * vmbus_recvpacket_raw - Retrieve the raw packet on the specified channel
Greg Kroah-Hartmanf4266e32009-09-01 17:24:57 -0700907 */
Haiyang Zhangfff41b22010-10-07 11:40:08 -0700908int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
Haiyang Zhang39d70a42010-09-30 10:52:13 -0700909 u32 bufferlen, u32 *buffer_actual_len,
910 u64 *requestid)
Hank Janssen3e7ee492009-07-13 16:02:34 -0700911{
Vitaly Kuznetsov667d3742015-12-14 19:02:00 -0800912 return __vmbus_recvpacket(channel, buffer, bufferlen,
913 buffer_actual_len, requestid, true);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700914}
Greg Kroah-Hartmanadaee6b2010-10-21 09:09:23 -0700915EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);