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 use m_defrag() instead of local code now th...
details: https://anonhg.NetBSD.org/src/rev/3cc96d12e247
branches: trunk
changeset: 1009512:3cc96d12e247
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sat Apr 25 11:33:28 2020 +0000
description:
use m_defrag() instead of local code now that it returns single mbuf
diffstat:
sys/arch/xen/xen/if_xennet_xenbus.c | 36 ++++++-------------------
sys/arch/xen/xen/xennetback_xenbus.c | 49 +++--------------------------------
2 files changed, 14 insertions(+), 71 deletions(-)
diffs (146 lines):
diff -r 62c4caf35dab -r 3cc96d12e247 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c Sat Apr 25 11:12:39 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c Sat Apr 25 11:33:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.116 2020/04/23 15:06:49 jdolecek Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.117 2020/04/25 11:33:28 jdolecek Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.116 2020/04/23 15:06:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.117 2020/04/25 11:33:28 jdolecek Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -1002,41 +1002,23 @@
txflags = NETTXF_data_validated;
}
- /* Try to load the mbuf as-is, if that fails allocate new */
+ /* Try to load the mbuf as-is, if that fails defrag */
if (__predict_false(bus_dmamap_load_mbuf(
sc->sc_xbusd->xbusd_dmat,
req->txreq_dmamap, m, BUS_DMA_NOWAIT) != 0)) {
- struct mbuf *new_m;
-
- MGETHDR(new_m, M_DONTWAIT, MT_DATA);
- if (__predict_false(new_m == NULL)) {
- printf("%s: cannot allocate new mbuf\n",
- device_xname(sc->sc_dev));
+ if (__predict_false(m_defrag(m, M_DONTWAIT) == NULL)) {
+ DPRINTF(("%s: defrag failed\n",
+ device_xname(sc->sc_dev)));
m_freem(m);
break;
}
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(new_m, M_DONTWAIT);
- if (__predict_false(
- (new_m->m_flags & M_EXT) == 0)) {
- DPRINTF(("%s: no mbuf cluster\n",
- device_xname(sc->sc_dev)));
- m_freem(new_m);
- m_freem(m);
- break;
- }
- }
-
- m_copydata(m, 0, m->m_pkthdr.len, mtod(new_m, void *));
- new_m->m_len = new_m->m_pkthdr.len = m->m_pkthdr.len;
- m_freem(m);
- m = new_m;
if (__predict_false(bus_dmamap_load_mbuf(
sc->sc_xbusd->xbusd_dmat,
req->txreq_dmamap, m, BUS_DMA_NOWAIT) != 0)) {
- printf("%s: cannot load new mbuf\n",
- device_xname(sc->sc_dev));
+ printf("%s: cannot load new mbuf len %d\n",
+ device_xname(sc->sc_dev),
+ m->m_pkthdr.len);
m_freem(m);
break;
}
diff -r 62c4caf35dab -r 3cc96d12e247 sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c Sat Apr 25 11:12:39 2020 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c Sat Apr 25 11:33:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennetback_xenbus.c,v 1.96 2020/04/11 11:48:20 jdolecek Exp $ */
+/* $NetBSD: xennetback_xenbus.c,v 1.97 2020/04/25 11:33:28 jdolecek Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.96 2020/04/11 11:48:20 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.97 2020/04/25 11:33:28 jdolecek Exp $");
#include "opt_xen.h"
@@ -860,44 +860,6 @@
xennetback_ifsoftstart_copy(xneti);
}
-/*
- * sighly different from m_dup(); for some reason m_dup() can return
- * a chain where the data area can cross a page boundary.
- * This doesn't happens with the function below.
- */
-static struct mbuf *
-xennetback_copymbuf(struct mbuf *m)
-{
- struct mbuf *new_m;
-
- MGETHDR(new_m, M_DONTWAIT, MT_DATA);
- if (__predict_false(new_m == NULL)) {
- m_freem(m);
- return NULL;
- }
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(new_m, M_DONTWAIT);
- if (__predict_false((new_m->m_flags & M_EXT) == 0)) {
- m_freem(new_m);
- m_freem(m);
- return NULL;
- }
- }
- m_copydata(m, 0, m->m_pkthdr.len,
- mtod(new_m, void *));
- new_m->m_len = new_m->m_pkthdr.len =
- m->m_pkthdr.len;
-
- /*
- * Need to retain csum flags to know if csum was actually computed.
- * This is used to set NETRXF_csum_blank/NETRXF_data_validated.
- */
- new_m->m_pkthdr.csum_flags = m->m_pkthdr.csum_flags;
-
- m_freem(m);
- return new_m;
-}
-
static void
xennetback_ifsoftstart_copy(struct xnetback_instance *xneti)
{
@@ -953,12 +915,11 @@
if (bus_dmamap_load_mbuf(
xneti->xni_xbusd->xbusd_dmat,
xst->xs_dmamap, m, BUS_DMA_NOWAIT) != 0) {
- /* Not possible to load, must copy */
- m = xennetback_copymbuf(m);
- if (__predict_false(m == NULL)) {
+ if (m_defrag(m, M_DONTWAIT) == NULL) {
+ m_freem(m);
static struct timeval lasttime;
if (ratecheck(&lasttime, &xni_pool_errintvl))
- printf("%s: cannot allocate new mbuf\n",
+ printf("%s: fail defrag mbuf\n",
ifp->if_xname);
abort = true;
break;
Home |
Main Index |
Thread Index |
Old Index