hyperv/ic: Factor out function to send IC response
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8844
This commit is contained in:
parent
1a837765c8
commit
e4bb7a507b
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user