diff options
author | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-12-23 08:41:28 +0000 |
---|---|---|
committer | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-12-23 08:41:28 +0000 |
commit | 69b12e53db63e57d51e48486eaa5c24c31ff6fb1 (patch) | |
tree | 45ebf1dce1abe8baede83a15b59e94b692773b67 | |
parent | 650eded91712b610d20fc7a7981fc8934318dcc1 (diff) |
Notes
-rw-r--r-- | sys/dev/hyperv/utilities/vmbus_icreg.h | 9 | ||||
-rw-r--r-- | sys/dev/hyperv/utilities/vmbus_timesync.c | 34 |
2 files changed, 34 insertions, 9 deletions
diff --git a/sys/dev/hyperv/utilities/vmbus_icreg.h b/sys/dev/hyperv/utilities/vmbus_icreg.h index fea74f020b95..e962102d13dd 100644 --- a/sys/dev/hyperv/utilities/vmbus_icreg.h +++ b/sys/dev/hyperv/utilities/vmbus_icreg.h @@ -114,8 +114,17 @@ struct vmbus_icmsg_timesync { struct vmbus_icmsg_hdr ic_hdr; uint64_t ic_hvtime; uint64_t ic_vmtime; + uint64_t ic_rtt; + uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ +} __packed; + +/* VMBUS_ICMSG_TYPE_TIMESYNC, MSGVER4 */ +struct vmbus_icmsg_timesync4 { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_hvtime; uint64_t ic_sent_tc; uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ + uint8_t ic_rsvd[5]; } __packed; #define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 diff --git a/sys/dev/hyperv/utilities/vmbus_timesync.c b/sys/dev/hyperv/utilities/vmbus_timesync.c index 89e6b4768e25..d00e1e41ea09 100644 --- a/sys/dev/hyperv/utilities/vmbus_timesync.c +++ b/sys/dev/hyperv/utilities/vmbus_timesync.c @@ -48,8 +48,11 @@ __FBSDID("$FreeBSD$"); #define VMBUS_TIMESYNC_MSGVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_MSGVER_MAJOR, 0) +#define VMBUS_TIMESYNC_MSGVER4(sc) \ + VMBUS_ICVER_LE(VMBUS_IC_VERSION(4, 0), (sc)->ic_msgver) + #define VMBUS_TIMESYNC_DORTT(sc) \ - ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ + (VMBUS_TIMESYNC_MSGVER4((sc)) &&\ (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) static int vmbus_timesync_probe(device_t); @@ -174,7 +177,6 @@ vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; - const struct vmbus_icmsg_timesync *msg; int dlen, error; uint64_t xactid; void *data; @@ -209,14 +211,28 @@ vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) break; case VMBUS_ICMSG_TYPE_TIMESYNC: - if (dlen < sizeof(*msg)) { - device_printf(sc->ic_dev, "invalid timesync len %d\n", - dlen); - return; + if (VMBUS_TIMESYNC_MSGVER4(sc)) { + const struct vmbus_icmsg_timesync4 *msg4; + + if (dlen < sizeof(*msg4)) { + device_printf(sc->ic_dev, "invalid timesync4 " + "len %d\n", dlen); + return; + } + msg4 = data; + vmbus_timesync(sc, msg4->ic_hvtime, msg4->ic_sent_tc, + msg4->ic_tsflags); + } else { + const struct vmbus_icmsg_timesync *msg; + + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync " + "len %d\n", dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, 0, msg->ic_tsflags); } - msg = data; - vmbus_timesync(sc, msg->ic_hvtime, msg->ic_sent_tc, - msg->ic_tsflags); break; default: |