Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/xen Try to be smarted in the rx path: if the pa...
details: https://anonhg.NetBSD.org/src/rev/1bb8fd8174b7
branches: trunk
changeset: 351897:1bb8fd8174b7
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sat Mar 04 19:11:01 2017 +0000
description:
Try to be smarted in the rx path: if the packet is small enough copy the
data to the mbuf's data area instead of allocating a new page from the pool.
While there fix a struct xennet_rxreq leak if xennet_checksum_fill()
fails with ENOMEM.
diffstat:
sys/arch/xen/xen/if_xennet_xenbus.c | 43 ++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 17 deletions(-)
diffs (69 lines):
diff -r fb83640f5dac -r 1bb8fd8174b7 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c Sat Mar 04 11:16:33 2017 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c Sat Mar 04 19:11:01 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.69 2016/12/15 09:28:04 ozaki-r Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.70 2017/03/04 19:11:01 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.69 2016/12/15 09:28:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.70 2017/03/04 19:11:01 bouyer Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -1074,26 +1074,35 @@
MCLAIM(m, &sc->sc_ethercom.ec_rx_mowner);
m_set_rcvif(m, ifp);
- req->rxreq_va = (vaddr_t)pool_cache_get_paddr(
- if_xennetrxbuf_cache, PR_NOWAIT, &req->rxreq_pa);
- if (__predict_false(req->rxreq_va == 0)) {
- printf("%s: rx no buf\n", ifp->if_xname);
- ifp->if_ierrors++;
- req->rxreq_va = va;
- req->rxreq_pa = pa;
- xennet_rx_free_req(req);
- m_freem(m);
- continue;
+ if (rx->status <= MHLEN) {
+ /* small packet; copy to mbuf data area */
+ m_copyback(m, 0, rx->status, pktp);
+ KASSERT(m->m_pkthdr.len == rx->status);
+ KASSERT(m->m_len == rx->status);
+ } else {
+ /* large packet; attach buffer to mbuf */
+ req->rxreq_va = (vaddr_t)pool_cache_get_paddr(
+ if_xennetrxbuf_cache, PR_NOWAIT, &req->rxreq_pa);
+ if (__predict_false(req->rxreq_va == 0)) {
+ printf("%s: rx no buf\n", ifp->if_xname);
+ ifp->if_ierrors++;
+ req->rxreq_va = va;
+ req->rxreq_pa = pa;
+ xennet_rx_free_req(req);
+ m_freem(m);
+ continue;
+ }
+ m->m_len = m->m_pkthdr.len = rx->status;
+ MEXTADD(m, pktp, rx->status,
+ M_DEVBUF, xennet_rx_mbuf_free, NULL);
+ m->m_ext.ext_paddr = pa;
+ m->m_flags |= M_EXT_RW; /* we own the buffer */
}
- m->m_len = m->m_pkthdr.len = rx->status;
- MEXTADD(m, pktp, rx->status,
- M_DEVBUF, xennet_rx_mbuf_free, NULL);
- m->m_flags |= M_EXT_RW; /* we own the buffer */
- m->m_ext.ext_paddr = pa;
if ((rx->flags & NETRXF_csum_blank) != 0) {
xennet_checksum_fill(&m);
if (m == NULL) {
ifp->if_ierrors++;
+ xennet_rx_free_req(req);
continue;
}
}
Home |
Main Index |
Thread Index |
Old Index