svn commit: r308514 - stable/10/sys/dev/hyperv/vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Fri Nov 11 07:45:05 UTC 2016
Author: sephe
Date: Fri Nov 11 07:45:03 2016
New Revision: 308514
URL: https://svnweb.freebsd.org/changeset/base/308514
Log:
MFC 308168
hyperv/vmbus: Avoid extra header copy.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8395
Modified:
stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Nov 11 07:41:38 2016 (r308513)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Nov 11 07:45:03 2016 (r308514)
@@ -926,28 +926,28 @@ vmbus_chan_recv(struct vmbus_channel *ch
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
}
*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);
More information about the svn-src-all
mailing list