static void vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { struct hv_util_sc *sc = xsc; struct vmbus_icmsg_hdr *hdr; const struct vmbus_icmsg_timesync *msg; int dlen, error; uint64_t xactid; void *data; /* * Receive request. */ data = sc->receive_buffer; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); if (error) return; if (dlen < sizeof(*hdr)) { device_printf(sc->ic_dev, "invalid data len %d\n", dlen); return; } hdr = data; /* * Update request, which will be echoed back as response. */ switch (hdr->ic_type) { case VMBUS_ICMSG_TYPE_NEGOTIATE: error = vmbus_ic_negomsg(sc, data, &dlen, VMBUS_TIMESYNC_FWVER, VMBUS_TIMESYNC_MSGVER); if (error) return; break; case VMBUS_ICMSG_TYPE_TIMESYNC: if (dlen < sizeof(*msg)) { device_printf(sc->ic_dev, "invalid timesync len %d\n", dlen); return; } msg = data; vmbus_timesync(sc, msg->ic_hvtime, msg->ic_tsflags); break; default: device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); break; } /* * Send response by echoing the updated 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); }
static void vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; int dlen, error; uint64_t xactid; void *data; /* * Receive request. */ data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); KASSERT(error != ENOBUFS, ("icbuf is not large enough")); if (error) return; if (dlen < sizeof(*hdr)) { device_printf(sc->ic_dev, "invalid data len %d\n", dlen); return; } hdr = data; /* * Update request, which will be echoed back as response. */ switch (hdr->ic_type) { case VMBUS_ICMSG_TYPE_NEGOTIATE: error = vmbus_ic_negomsg(sc, data, &dlen, VMBUS_TIMESYNC_FWVER, VMBUS_TIMESYNC_MSGVER); if (error) return; if (VMBUS_TIMESYNC_DORTT(sc)) device_printf(sc->ic_dev, "RTT\n"); break; case VMBUS_ICMSG_TYPE_TIMESYNC: 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); } break; default: device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); break; } /* * Send response by echoing the request back. */ vmbus_ic_sendresp(sc, chan, data, dlen, xactid); }