aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hyperv
diff options
context:
space:
mode:
authorSepherosa Ziehau <sephe@FreeBSD.org>2016-08-08 06:11:28 +0000
committerSepherosa Ziehau <sephe@FreeBSD.org>2016-08-08 06:11:28 +0000
commit9b6306f2874df3bc83408bb88895713d1853a972 (patch)
tree471a6e06ef48b812f2bd478f4a6b54f8fc1667bd /sys/dev/hyperv
parentf5207880ba701d9f4541ba3d9bd4a0c5d813c822 (diff)
Notes
Diffstat (limited to 'sys/dev/hyperv')
-rw-r--r--sys/dev/hyperv/utilities/hv_heartbeat.c2
-rw-r--r--sys/dev/hyperv/utilities/hv_kvp.c4
-rw-r--r--sys/dev/hyperv/utilities/hv_shutdown.c2
-rw-r--r--sys/dev/hyperv/utilities/hv_timesync.c2
-rw-r--r--sys/dev/hyperv/utilities/hv_util.c31
-rw-r--r--sys/dev/hyperv/utilities/hv_util.h1
6 files changed, 20 insertions, 22 deletions
diff --git a/sys/dev/hyperv/utilities/hv_heartbeat.c b/sys/dev/hyperv/utilities/hv_heartbeat.c
index cf279a11c4b4..cbb3206e9b73 100644
--- a/sys/dev/hyperv/utilities/hv_heartbeat.c
+++ b/sys/dev/hyperv/utilities/hv_heartbeat.c
@@ -64,7 +64,7 @@ hv_heartbeat_cb(struct vmbus_channel *channel, void *context)
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 */
diff --git a/sys/dev/hyperv/utilities/hv_kvp.c b/sys/dev/hyperv/utilities/hv_kvp.c
index 6c5d0b179b71..a23eb27f880b 100644
--- a/sys/dev/hyperv/utilities/hv_kvp.c
+++ b/sys/dev/hyperv/utilities/hv_kvp.c
@@ -629,7 +629,7 @@ hv_kvp_process_request(void *context, int pending)
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, int pending)
/*
* 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 */
diff --git a/sys/dev/hyperv/utilities/hv_shutdown.c b/sys/dev/hyperv/utilities/hv_shutdown.c
index 1c4df234f912..9828fd61b63d 100644
--- a/sys/dev/hyperv/utilities/hv_shutdown.c
+++ b/sys/dev/hyperv/utilities/hv_shutdown.c
@@ -68,7 +68,7 @@ hv_shutdown_cb(struct vmbus_channel *channel, void *context)
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 */
diff --git a/sys/dev/hyperv/utilities/hv_timesync.c b/sys/dev/hyperv/utilities/hv_timesync.c
index 2eb6b3e8b775..33ed8da32302 100644
--- a/sys/dev/hyperv/utilities/hv_timesync.c
+++ b/sys/dev/hyperv/utilities/hv_timesync.c
@@ -145,7 +145,7 @@ hv_timesync_cb(struct vmbus_channel *channel, void *context)
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 */
diff --git a/sys/dev/hyperv/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c
index 9ecae82f7aa9..3c90ce658993 100644
--- a/sys/dev/hyperv/utilities/hv_util.c
+++ b/sys/dev/hyperv/utilities/hv_util.c
@@ -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_icmsg_hdr *icmsghdrp, uint8_t *buf)
int
hv_util_attach(device_t dev)
{
- struct hv_util_sc* softc;
- struct vmbus_channel *chan;
- int ret;
+ struct hv_util_sc *sc = device_get_softc(dev);
+ struct vmbus_channel *chan = vmbus_get_channel(dev);
+ int error;
- softc = device_get_softc(dev);
- softc->receive_buffer =
- malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
- chan = vmbus_get_channel(dev);
+ 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
diff --git a/sys/dev/hyperv/utilities/hv_util.h b/sys/dev/hyperv/utilities/hv_util.h
index 0a9f4dc4eee7..fc2ba43f000a 100644
--- a/sys/dev/hyperv/utilities/hv_util.h
+++ b/sys/dev/hyperv/utilities/hv_util.h
@@ -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);