diff options
author | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-11-01 08:30:06 +0000 |
---|---|---|
committer | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-11-01 08:30:06 +0000 |
commit | a457fab84c8a110ec72d99feb26e7964c1e9c532 (patch) | |
tree | e99512ac745a7ef6b55df4a5de00ed1699620638 | |
parent | 8966e5d5b36fd95127787dfbaf604f1219c2e43d (diff) | |
download | src-a457fab84c8a110ec72d99feb26e7964c1e9c532.tar.gz src-a457fab84c8a110ec72d99feb26e7964c1e9c532.zip |
hyperv/vmbus: Avoid extra header copy.
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8395
Notes
Notes:
svn path=/head/; revision=308168
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus_chan.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sys/dev/hyperv/vmbus/vmbus_chan.c b/sys/dev/hyperv/vmbus/vmbus_chan.c index 1a86efdaf09e..40a0f8e2ef01 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chan.c +++ b/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -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); |