Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2016 05:40:34 +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: r302871 - in head/sys/dev/hyperv: include vmbus
Message-ID:  <201607150540.u6F5eYSh079626@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Jul 15 05:40:34 2016
New Revision: 302871
URL: https://svnweb.freebsd.org/changeset/base/302871

Log:
  hyperv/vmbus: Add vmbus_chan_gpadl_connect, which takes GPA physaddr
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D7139

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

Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h	Fri Jul 15 05:29:04 2016	(r302870)
+++ head/sys/dev/hyperv/include/hyperv.h	Fri Jul 15 05:40:34 2016	(r302871)
@@ -409,6 +409,9 @@ int		hv_vmbus_channel_teardown_gpdal(
 				hv_vmbus_channel*	channel,
 				uint32_t		gpadl_handle);
 
+int		vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
+		    bus_addr_t paddr, int size, uint32_t *gpadl);
+
 struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary);
 
 void		vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu);

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 05:29:04 2016	(r302870)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 05:40:34 2016	(r302871)
@@ -330,26 +330,33 @@ failed:
  */
 int
 hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel,
-    void *contig_buffer, uint32_t size, uint32_t *gpadl0)
+    void *contig_buffer, uint32_t size, uint32_t *gpadl)
 {
-	struct vmbus_softc *sc = channel->vmbus_sc;
+	return vmbus_chan_gpadl_connect(channel,
+	    hv_get_phys_addr(contig_buffer), size, gpadl);
+}
+
+int
+vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr,
+    int size, uint32_t *gpadl0)
+{
+	struct vmbus_softc *sc = chan->vmbus_sc;
 	struct vmbus_msghc *mh;
 	struct vmbus_chanmsg_gpadl_conn *req;
 	const struct vmbus_message *msg;
 	size_t reqsz;
 	uint32_t gpadl, status;
 	int page_count, range_len, i, cnt, error;
-	uint64_t page_id, paddr;
+	uint64_t page_id;
 
 	/*
 	 * Preliminary checks.
 	 */
 
 	KASSERT((size & PAGE_MASK) == 0,
-	    ("invalid GPA size %u, not multiple page size", size));
+	    ("invalid GPA size %d, not multiple page size", size));
 	page_count = size >> PAGE_SHIFT;
 
-	paddr = hv_get_phys_addr(contig_buffer);
 	KASSERT((paddr & PAGE_MASK) == 0,
 	    ("GPA is not page aligned %jx", (uintmax_t)paddr));
 	page_id = paddr >> PAGE_SHIFT;
@@ -390,13 +397,13 @@ hv_vmbus_channel_establish_gpadl(struct 
 	if (mh == NULL) {
 		device_printf(sc->vmbus_dev,
 		    "can not get msg hypercall for gpadl->chan%u\n",
-		    channel->ch_id);
+		    chan->ch_id);
 		return EIO;
 	}
 
 	req = vmbus_msghc_dataptr(mh);
 	req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN;
-	req->chm_chanid = channel->ch_id;
+	req->chm_chanid = chan->ch_id;
 	req->chm_gpadl = gpadl;
 	req->chm_range_len = range_len;
 	req->chm_range_cnt = 1;
@@ -409,7 +416,7 @@ hv_vmbus_channel_establish_gpadl(struct 
 	if (error) {
 		device_printf(sc->vmbus_dev,
 		    "gpadl->chan%u msg hypercall exec failed: %d\n",
-		    channel->ch_id, error);
+		    chan->ch_id, error);
 		vmbus_msghc_put(sc, mh);
 		return error;
 	}
@@ -445,12 +452,12 @@ hv_vmbus_channel_establish_gpadl(struct 
 
 	if (status != 0) {
 		device_printf(sc->vmbus_dev, "gpadl->chan%u failed: "
-		    "status %u\n", channel->ch_id, status);
+		    "status %u\n", chan->ch_id, status);
 		return EIO;
 	} else {
 		if (bootverbose) {
 			device_printf(sc->vmbus_dev, "gpadl->chan%u "
-			    "succeeded\n", channel->ch_id);
+			    "succeeded\n", chan->ch_id);
 		}
 	}
 	return 0;



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