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
This commit is contained in:
parent
f5207880ba
commit
9b6306f287
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user