From owner-svn-src-head@freebsd.org Mon Aug 8 06:11:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4589BB11B0; Mon, 8 Aug 2016 06:11:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 663C919BE; Mon, 8 Aug 2016 06:11:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u786BTCl016308; Mon, 8 Aug 2016 06:11:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u786BTRl016302; Mon, 8 Aug 2016 06:11:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201608080611.u786BTRl016302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 8 Aug 2016 06:11:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303823 - head/sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2016 06:11:30 -0000 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 #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);