svn commit: r303823 - head/sys/dev/hyperv/utilities

Sepherosa Ziehau sephe at FreeBSD.org
Mon Aug 8 06:11:30 UTC 2016


Author: sephe
Date: Mon Aug  8 06:11:28 2016
New Revision: 303823
URL: https://svnweb.freebsd.org/changeset/base/303823

Log:
  hyperv/ic: Expose the receive buffer length for callers to use.
  
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D7423

Modified:
  head/sys/dev/hyperv/utilities/hv_heartbeat.c
  head/sys/dev/hyperv/utilities/hv_kvp.c
  head/sys/dev/hyperv/utilities/hv_shutdown.c
  head/sys/dev/hyperv/utilities/hv_timesync.c
  head/sys/dev/hyperv/utilities/hv_util.c
  head/sys/dev/hyperv/utilities/hv_util.h

Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_heartbeat.c	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_heartbeat.c	Mon Aug  8 06:11:28 2016	(r303823)
@@ -64,7 +64,7 @@ hv_heartbeat_cb(struct vmbus_channel *ch
 	softc = (hv_util_sc*)context;
 	buf = softc->receive_buffer;
 
-	recvlen = PAGE_SIZE;
+	recvlen = softc->ic_buflen;
 	ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid);
 	KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough"));
 	/* XXX check recvlen to make sure that it contains enough data */

Modified: head/sys/dev/hyperv/utilities/hv_kvp.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_kvp.c	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_kvp.c	Mon Aug  8 06:11:28 2016	(r303823)
@@ -629,7 +629,7 @@ hv_kvp_process_request(void *context, in
 	kvp_buf = sc->util_sc.receive_buffer;
 	channel = vmbus_get_channel(sc->dev);
 
-	recvlen = 2 * PAGE_SIZE;
+	recvlen = sc->util_sc.ic_buflen;
 	ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid);
 	KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough"));
 	/* XXX check recvlen to make sure that it contains enough data */
@@ -696,7 +696,7 @@ hv_kvp_process_request(void *context, in
 		/*
 		 * Try reading next buffer
 		 */
-		recvlen = 2 * PAGE_SIZE;
+		recvlen = sc->util_sc.ic_buflen;
 		ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid);
 		KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough"));
 		/* XXX check recvlen to make sure that it contains enough data */

Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_shutdown.c	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_shutdown.c	Mon Aug  8 06:11:28 2016	(r303823)
@@ -68,7 +68,7 @@ hv_shutdown_cb(struct vmbus_channel *cha
 	softc = (hv_util_sc*)context;
 	buf = softc->receive_buffer;
 
-	recv_len = PAGE_SIZE;
+	recv_len = softc->ic_buflen;
 	ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id);
 	KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough"));
 	/* XXX check recv_len to make sure that it contains enough data */

Modified: head/sys/dev/hyperv/utilities/hv_timesync.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_timesync.c	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_timesync.c	Mon Aug  8 06:11:28 2016	(r303823)
@@ -145,7 +145,7 @@ hv_timesync_cb(struct vmbus_channel *cha
 	softc = (hv_timesync_sc*)context;
 	time_buf = softc->util_sc.receive_buffer;
 
-	recvlen = PAGE_SIZE;
+	recvlen = softc->util_sc.ic_buflen;
 	ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId);
 	KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough"));
 	/* XXX check recvlen to make sure that it contains enough data */

Modified: head/sys/dev/hyperv/utilities/hv_util.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_util.c	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_util.c	Mon Aug  8 06:11:28 2016	(r303823)
@@ -44,6 +44,8 @@
 #include <dev/hyperv/utilities/hv_utilreg.h>
 #include "hv_util.h"
 
+#define VMBUS_IC_BRSIZE		(4 * PAGE_SIZE)
+
 void
 hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf)
 {
@@ -75,14 +77,13 @@ hv_negotiate_version(struct hv_vmbus_icm
 int
 hv_util_attach(device_t dev)
 {
-	struct hv_util_sc*	softc;
-	struct vmbus_channel *chan;
-	int			ret;
-
-	softc = device_get_softc(dev);
-	softc->receive_buffer =
-		malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	chan = vmbus_get_channel(dev);
+	struct hv_util_sc *sc = device_get_softc(dev);
+	struct vmbus_channel *chan = vmbus_get_channel(dev);
+	int error;
+
+	sc->ic_buflen = VMBUS_IC_BRSIZE;
+	sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF,
+	    M_WAITOK | M_ZERO);
 
 	/*
 	 * These services are not performance critical and do not need
@@ -93,17 +94,13 @@ hv_util_attach(device_t dev)
 	 */
 	vmbus_chan_set_readbatch(chan, false);
 
-	ret = vmbus_chan_open(chan, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
-	    softc->callback, softc);
-
-	if (ret)
-		goto error0;
-
+	error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0,
+	    sc->callback, sc);
+	if (error) {
+		free(sc->receive_buffer, M_DEVBUF);
+		return (error);
+	}
 	return (0);
-
-error0:
-	free(softc->receive_buffer, M_DEVBUF);
-	return (ret);
 }
 
 int

Modified: head/sys/dev/hyperv/utilities/hv_util.h
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_util.h	Mon Aug  8 05:57:38 2016	(r303822)
+++ head/sys/dev/hyperv/utilities/hv_util.h	Mon Aug  8 06:11:28 2016	(r303823)
@@ -41,6 +41,7 @@ typedef struct hv_util_sc {
 	 */
 	void (*callback)(struct vmbus_channel *, void *);
 	uint8_t			*receive_buffer;
+	int			ic_buflen;
 } hv_util_sc;
 
 void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf);


More information about the svn-src-head mailing list