hyperv/vmbus: Avoid extra header copy.
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8395
This commit is contained in:
parent
8966e5d5b3
commit
a457fab84c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=308168
@ -926,28 +926,28 @@ vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen0,
|
||||
|
||||
int
|
||||
vmbus_chan_recv_pkt(struct vmbus_channel *chan,
|
||||
struct vmbus_chanpkt_hdr *pkt0, int *pktlen0)
|
||||
struct vmbus_chanpkt_hdr *pkt, int *pktlen0)
|
||||
{
|
||||
struct vmbus_chanpkt_hdr pkt;
|
||||
int error, pktlen;
|
||||
int error, pktlen, pkt_hlen;
|
||||
|
||||
error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt));
|
||||
pkt_hlen = sizeof(*pkt);
|
||||
error = vmbus_rxbr_peek(&chan->ch_rxbr, pkt, pkt_hlen);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) {
|
||||
vmbus_chan_printf(chan, "invalid hlen %u\n", pkt.cph_hlen);
|
||||
if (__predict_false(pkt->cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) {
|
||||
vmbus_chan_printf(chan, "invalid hlen %u\n", pkt->cph_hlen);
|
||||
/* XXX this channel is dead actually. */
|
||||
return (EIO);
|
||||
}
|
||||
if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) {
|
||||
if (__predict_false(pkt->cph_hlen > pkt->cph_tlen)) {
|
||||
vmbus_chan_printf(chan, "invalid hlen %u and tlen %u\n",
|
||||
pkt.cph_hlen, pkt.cph_tlen);
|
||||
pkt->cph_hlen, pkt->cph_tlen);
|
||||
/* XXX this channel is dead actually. */
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen);
|
||||
pktlen = VMBUS_CHANPKT_GETLEN(pkt->cph_tlen);
|
||||
if (*pktlen0 < pktlen) {
|
||||
/* Return the size of this packet. */
|
||||
*pktlen0 = pktlen;
|
||||
@ -955,8 +955,12 @@ vmbus_chan_recv_pkt(struct vmbus_channel *chan,
|
||||
}
|
||||
*pktlen0 = pktlen;
|
||||
|
||||
/* Include packet header */
|
||||
error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0);
|
||||
/*
|
||||
* Skip the fixed-size packet header, which has been filled
|
||||
* by the above vmbus_rxbr_peek().
|
||||
*/
|
||||
error = vmbus_rxbr_read(&chan->ch_rxbr, pkt + 1,
|
||||
pktlen - pkt_hlen, pkt_hlen);
|
||||
KASSERT(!error, ("vmbus_rxbr_read failed"));
|
||||
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user