Index: head/sys/dev/hyperv/utilities/hv_heartbeat.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c @@ -61,7 +61,7 @@ static void vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; int dlen, error; uint64_t xactid; @@ -70,7 +70,7 @@ /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -126,18 +126,22 @@ hv_heartbeat_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_heartbeat_cb)); + return (vmbus_ic_attach(dev, vmbus_heartbeat_cb)); } static device_method_t heartbeat_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_heartbeat_probe), DEVMETHOD(device_attach, hv_heartbeat_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t heartbeat_driver = { "hvheartbeat", heartbeat_methods, sizeof(hv_util_sc)}; +static driver_t heartbeat_driver = { + "hvheartbeat", + heartbeat_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t heartbeat_devclass; Index: head/sys/dev/hyperv/utilities/hv_kvp.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.c +++ head/sys/dev/hyperv/utilities/hv_kvp.c @@ -128,7 +128,7 @@ * KVP transaction requests from the host. */ typedef struct hv_kvp_sc { - struct hv_util_sc util_sc; + struct vmbus_ic_softc util_sc; device_t dev; /* Unless specified the pending mutex should be @@ -590,7 +590,7 @@ hv_kvp_log_info("%s: entering hv_kvp_process_request\n", __func__); sc = (hv_kvp_sc*)context; - kvp_buf = sc->util_sc.receive_buffer; + kvp_buf = sc->util_sc.ic_buf; channel = vmbus_get_channel(sc->dev); recvlen = sc->util_sc.ic_buflen; @@ -885,7 +885,7 @@ return (error); sc->hv_kvp_dev->si_drv1 = sc; - return hv_util_attach(dev, hv_kvp_callback); + return (vmbus_ic_attach(dev, hv_kvp_callback)); } static int @@ -900,7 +900,7 @@ } destroy_dev(sc->hv_kvp_dev); - return hv_util_detach(dev); + return (vmbus_ic_detach(dev)); } static device_method_t kvp_methods[] = { Index: head/sys/dev/hyperv/utilities/hv_shutdown.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c +++ head/sys/dev/hyperv/utilities/hv_shutdown.c @@ -62,7 +62,7 @@ static void vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; struct vmbus_icmsg_shutdown *msg; int dlen, error, do_shutdown = 0; @@ -72,7 +72,7 @@ /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -141,18 +141,22 @@ hv_shutdown_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_shutdown_cb)); + return (vmbus_ic_attach(dev, vmbus_shutdown_cb)); } static device_method_t shutdown_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_shutdown_probe), DEVMETHOD(device_attach, hv_shutdown_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t shutdown_driver = { "hvshutdown", shutdown_methods, sizeof(hv_util_sc)}; +static driver_t shutdown_driver = { + "hvshutdown", + shutdown_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t shutdown_devclass; Index: head/sys/dev/hyperv/utilities/hv_snapshot.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_snapshot.c +++ head/sys/dev/hyperv/utilities/hv_snapshot.c @@ -204,7 +204,7 @@ * https://clovertrail.github.io/assets/vssdot.png */ typedef struct hv_vss_sc { - struct hv_util_sc util_sc; + struct vmbus_ic_softc util_sc; device_t dev; struct task task; @@ -808,7 +808,7 @@ hv_vss_log_info("%s: entering hv_vss_process_request\n", __func__); sc = (hv_vss_sc*)context; - vss_buf = sc->util_sc.receive_buffer; + vss_buf = sc->util_sc.ic_buf; channel = vmbus_get_channel(sc->dev); recvlen = sc->util_sc.ic_buflen; @@ -1020,7 +1020,7 @@ sc->hv_appvss_dev->si_drv1 = &sc->app_sc; sc->app_sc.sc = sc; - return hv_util_attach(dev, hv_vss_callback); + return (vmbus_ic_attach(dev, hv_vss_callback)); } static int @@ -1041,7 +1041,7 @@ hv_vss_destroy_send_receive_queue(dev); destroy_dev(sc->hv_vss_dev); destroy_dev(sc->hv_appvss_dev); - return hv_util_detach(dev); + return (vmbus_ic_detach(dev)); } static device_method_t vss_methods[] = { Index: head/sys/dev/hyperv/utilities/hv_timesync.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c +++ head/sys/dev/hyperv/utilities/hv_timesync.c @@ -85,7 +85,7 @@ &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); static void -vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint64_t sent_tc, +vmbus_timesync(struct vmbus_ic_softc *sc, uint64_t hvtime, uint64_t sent_tc, uint8_t tsflags) { struct timespec vm_ts; @@ -150,7 +150,7 @@ static void vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { - struct hv_util_sc *sc = xsc; + struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; const struct vmbus_icmsg_timesync *msg; int dlen, error; @@ -160,7 +160,7 @@ /* * Receive request. */ - data = sc->receive_buffer; + data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); @@ -219,18 +219,22 @@ hv_timesync_attach(device_t dev) { - return (hv_util_attach(dev, vmbus_timesync_cb)); + return (vmbus_ic_attach(dev, vmbus_timesync_cb)); } static device_method_t timesync_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_timesync_probe), DEVMETHOD(device_attach, hv_timesync_attach), - DEVMETHOD(device_detach, hv_util_detach), + DEVMETHOD(device_detach, vmbus_ic_detach), { 0, 0 } }; -static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_util_sc)}; +static driver_t timesync_driver = { + "hvtimesync", + timesync_methods, + sizeof(struct vmbus_ic_softc) +}; static devclass_t timesync_devclass; Index: head/sys/dev/hyperv/utilities/hv_util.h =================================================================== --- head/sys/dev/hyperv/utilities/hv_util.h +++ head/sys/dev/hyperv/utilities/hv_util.h @@ -28,23 +28,19 @@ * $FreeBSD$ */ -#ifndef _HVUTIL_H_ -#define _HVUTIL_H_ +#ifndef _VMBUS_ICVAR_H_ +#define _VMBUS_ICVAR_H_ #include #include -/** - * hv_util related structures - * - */ -typedef struct hv_util_sc { +struct vmbus_ic_softc { device_t ic_dev; - uint8_t *receive_buffer; + uint8_t *ic_buf; int ic_buflen; uint32_t ic_fwver; /* framework version */ uint32_t ic_msgver; /* message version */ -} hv_util_sc; +}; struct vmbus_ic_desc { const struct hyperv_guid ic_guid; @@ -53,13 +49,13 @@ #define VMBUS_IC_DESC_END { .ic_desc = NULL } -int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); -int hv_util_detach(device_t dev); +int vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb); +int vmbus_ic_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); -int vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen, - uint32_t fw_ver, uint32_t msg_ver); -int vmbus_ic_sendresp(struct hv_util_sc *sc, +int vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, + int *dlen, uint32_t fw_ver, uint32_t msg_ver); +int vmbus_ic_sendresp(struct vmbus_ic_softc *sc, struct vmbus_channel *chan, void *data, int dlen, uint64_t xactid); -#endif +#endif /* !_VMBUS_ICVAR_H_ */ Index: head/sys/dev/hyperv/utilities/hv_util.c =================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c +++ head/sys/dev/hyperv/utilities/hv_util.c @@ -58,7 +58,7 @@ static int vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS); int -vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen0, +vmbus_ic_negomsg(struct vmbus_ic_softc *sc, void *data, int *dlen0, uint32_t fw_ver, uint32_t msg_ver) { struct vmbus_icmsg_negotiate *nego; @@ -214,9 +214,9 @@ } int -hv_util_attach(device_t dev, vmbus_chan_callback_t cb) +vmbus_ic_attach(device_t dev, vmbus_chan_callback_t cb) { - struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_ic_softc *sc = device_get_softc(dev); struct vmbus_channel *chan = vmbus_get_channel(dev); struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; @@ -224,8 +224,7 @@ sc->ic_dev = dev; sc->ic_buflen = VMBUS_IC_BRSIZE; - sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, - M_WAITOK | M_ZERO); + sc->ic_buf = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, M_WAITOK | M_ZERO); /* * These services are not performance critical and do not need @@ -239,7 +238,7 @@ error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0, cb, sc); if (error) { - free(sc->receive_buffer, M_DEVBUF); + free(sc->ic_buf, M_DEVBUF); return (error); } @@ -258,7 +257,7 @@ static int vmbus_ic_fwver_sysctl(SYSCTL_HANDLER_ARGS) { - struct hv_util_sc *sc = arg1; + struct vmbus_ic_softc *sc = arg1; char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", @@ -269,7 +268,7 @@ static int vmbus_ic_msgver_sysctl(SYSCTL_HANDLER_ARGS) { - struct hv_util_sc *sc = arg1; + struct vmbus_ic_softc *sc = arg1; char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", @@ -278,18 +277,18 @@ } int -hv_util_detach(device_t dev) +vmbus_ic_detach(device_t dev) { - struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_ic_softc *sc = device_get_softc(dev); vmbus_chan_close(vmbus_get_channel(dev)); - free(sc->receive_buffer, M_DEVBUF); + free(sc->ic_buf, M_DEVBUF); return (0); } int -vmbus_ic_sendresp(struct hv_util_sc *sc, struct vmbus_channel *chan, +vmbus_ic_sendresp(struct vmbus_ic_softc *sc, struct vmbus_channel *chan, void *data, int dlen, uint64_t xactid) { struct vmbus_icmsg_hdr *hdr;