Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jul 2016 03:25:36 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302610 - head/sys/dev/hyperv/vmbus
Message-ID:  <201607120325.u6C3Pa8u017573@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Tue Jul 12 03:25:36 2016
New Revision: 302610
URL: https://svnweb.freebsd.org/changeset/base/302610

Log:
  hyperv/vmbus: Use post message Hypercall APIs for channel close
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D6906

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/vmbus_reg.h

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Tue Jul 12 03:19:40 2016	(r302609)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Tue Jul 12 03:25:36 2016	(r302610)
@@ -487,10 +487,11 @@ cleanup:
 static void
 hv_vmbus_channel_close_internal(hv_vmbus_channel *channel)
 {
-	int ret = 0;
+	struct vmbus_softc *sc = channel->vmbus_sc;
+	struct vmbus_msghc *mh;
+	struct vmbus_chanmsg_chclose *req;
 	struct taskqueue *rxq = channel->rxq;
-	hv_vmbus_channel_close_channel* msg;
-	hv_vmbus_channel_msg_info* info;
+	int error;
 
 	channel->state = HV_CHANNEL_OPEN_STATE;
 
@@ -504,20 +505,31 @@ hv_vmbus_channel_close_internal(hv_vmbus
 	/**
 	 * Send a closing message
 	 */
-	info = (hv_vmbus_channel_msg_info *)
-		malloc(	sizeof(hv_vmbus_channel_msg_info) +
-			sizeof(hv_vmbus_channel_close_channel),
-				M_DEVBUF, M_NOWAIT);
-	KASSERT(info != NULL, ("VMBUS: malloc failed hv_vmbus_channel_close!"));
-	if(info == NULL)
-	    return;
-
-	msg = (hv_vmbus_channel_close_channel*) info->msg;
-	msg->header.message_type = HV_CHANNEL_MESSAGE_CLOSE_CHANNEL;
-	msg->child_rel_id = channel->offer_msg.child_rel_id;
 
-	ret = hv_vmbus_post_message(
-		msg, sizeof(hv_vmbus_channel_close_channel));
+	mh = vmbus_msghc_get(sc, sizeof(*req));
+	if (mh == NULL) {
+		device_printf(sc->vmbus_dev,
+		    "can not get msg hypercall for chclose(chan%u)\n",
+		    channel->offer_msg.child_rel_id);
+		return;
+	}
+
+	req = vmbus_msghc_dataptr(mh);
+	req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE;
+	req->chm_chanid = channel->offer_msg.child_rel_id;
+
+	error = vmbus_msghc_exec_noresult(mh);
+	vmbus_msghc_put(sc, mh);
+
+	if (error) {
+		device_printf(sc->vmbus_dev,
+		    "chclose(chan%u) msg hypercall exec failed: %d\n",
+		    channel->offer_msg.child_rel_id, error);
+		return;
+	} else if (bootverbose) {
+		device_printf(sc->vmbus_dev, "close chan%u\n",
+		    channel->offer_msg.child_rel_id);
+	}
 
 	/* Tear down the gpadl for the channel's ring buffer */
 	if (channel->ring_buffer_gpadl_handle) {
@@ -533,8 +545,6 @@ hv_vmbus_channel_close_internal(hv_vmbus
 
 	contigfree(channel->ring_buffer_pages, channel->ring_buffer_size,
 	    M_DEVBUF);
-
-	free(info, M_DEVBUF);
 }
 
 /**

Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_reg.h	Tue Jul 12 03:19:40 2016	(r302609)
+++ head/sys/dev/hyperv/vmbus/vmbus_reg.h	Tue Jul 12 03:25:36 2016	(r302610)
@@ -96,6 +96,7 @@ struct vmbus_gpa_range {
 #define VMBUS_CHANMSG_TYPE_CHANNEL_REQ		3	/* REQ */
 #define VMBUS_CHANMSG_TYPE_CHOPEN		5	/* REQ */
 #define VMBUS_CHANMSG_TYPE_CHOPEN_RESP		6	/* RESP */
+#define VMBUS_CHANMSG_TYPE_CHCLOSE		7	/* REQ */
 #define VMBUS_CHANMSG_TYPE_GPADL_CONN		8	/* REQ */
 #define VMBUS_CHANMSG_TYPE_GPADL_SUBCONN	9	/* REQ */
 #define VMBUS_CHANMSG_TYPE_GPADP_CONNRESP	10	/* RESP */
@@ -190,4 +191,10 @@ struct vmbus_chanmsg_gpadl_connresp {
 	uint32_t	chm_status;
 } __packed;
 
+/* VMBUS_CHANMSG_TYPE_CHCLOSE */
+struct vmbus_chanmsg_chclose {
+	struct vmbus_chanmsg_hdr chm_hdr;
+	uint32_t	chm_chanid;
+} __packed;
+
 #endif	/* !_VMBUS_REG_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607120325.u6C3Pa8u017573>