diff options
author | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-12-20 04:51:14 +0000 |
---|---|---|
committer | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-12-20 04:51:14 +0000 |
commit | 2438ba4ed4d5470df954a58c6424155974449049 (patch) | |
tree | 36c6ef00b2ccd82fc58ae9c78841552158ae6ed7 /sys/dev/hyperv | |
parent | 2e0ef629ee9b91503fc8bb67ef2b52eabe8958d8 (diff) | |
download | src-2438ba4ed4d5470df954a58c6424155974449049.tar.gz src-2438ba4ed4d5470df954a58c6424155974449049.zip |
hyperv/ic: Factor out function to send IC response
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8844
Notes
Notes:
svn path=/head/; revision=310312
Diffstat (limited to 'sys/dev/hyperv')
-rw-r--r-- | sys/dev/hyperv/utilities/hv_heartbeat.c | 8 | ||||
-rw-r--r-- | sys/dev/hyperv/utilities/hv_shutdown.c | 8 | ||||
-rw-r--r-- | sys/dev/hyperv/utilities/hv_timesync.c | 8 | ||||
-rw-r--r-- | sys/dev/hyperv/utilities/hv_util.c | 18 | ||||
-rw-r--r-- | sys/dev/hyperv/utilities/hv_util.h | 3 |
5 files changed, 27 insertions, 18 deletions
diff --git a/sys/dev/hyperv/utilities/hv_heartbeat.c b/sys/dev/hyperv/utilities/hv_heartbeat.c index 8fc7a0944eaf..f0a07d91a5f8 100644 --- a/sys/dev/hyperv/utilities/hv_heartbeat.c +++ b/sys/dev/hyperv/utilities/hv_heartbeat.c @@ -110,13 +110,9 @@ vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); } static int diff --git a/sys/dev/hyperv/utilities/hv_shutdown.c b/sys/dev/hyperv/utilities/hv_shutdown.c index e511b21a070c..420e4fe67721 100644 --- a/sys/dev/hyperv/utilities/hv_shutdown.c +++ b/sys/dev/hyperv/utilities/hv_shutdown.c @@ -122,13 +122,9 @@ vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); if (do_shutdown) shutdown_nice(RB_POWEROFF); diff --git a/sys/dev/hyperv/utilities/hv_timesync.c b/sys/dev/hyperv/utilities/hv_timesync.c index 4d166b0b671b..33142de06123 100644 --- a/sys/dev/hyperv/utilities/hv_timesync.c +++ b/sys/dev/hyperv/utilities/hv_timesync.c @@ -203,13 +203,9 @@ vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) } /* - * Send response by echoing the updated request back. + * Send response by echoing the request back. */ - hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; - error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, - data, dlen, xactid); - if (error) - device_printf(sc->ic_dev, "resp send failed: %d\n", error); + vmbus_ic_sendresp(sc, chan, data, dlen, xactid); } static int diff --git a/sys/dev/hyperv/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c index 20b8f84da94f..d5565f65785e 100644 --- a/sys/dev/hyperv/utilities/hv_util.c +++ b/sys/dev/hyperv/utilities/hv_util.c @@ -287,3 +287,21 @@ hv_util_detach(device_t dev) return (0); } + +int +vmbus_ic_sendresp(struct hv_util_sc *sc, struct vmbus_channel *chan, + void *data, int dlen, uint64_t xactid) +{ + struct vmbus_icmsg_hdr *hdr; + int error; + + KASSERT(dlen >= sizeof(*hdr), ("invalid data length %d", dlen)); + hdr = data; + + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); + return (error); +} diff --git a/sys/dev/hyperv/utilities/hv_util.h b/sys/dev/hyperv/utilities/hv_util.h index 7cf8d3171826..da212493414b 100644 --- a/sys/dev/hyperv/utilities/hv_util.h +++ b/sys/dev/hyperv/utilities/hv_util.h @@ -58,5 +58,8 @@ int hv_util_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, + struct vmbus_channel *chan, void *data, int dlen, + uint64_t xactid); #endif |