Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Use m_pullup to handle defragmentation.
details: https://anonhg.NetBSD.org/src/rev/e85f34f2246f
branches: trunk
changeset: 747993:e85f34f2246f
user: cegger <cegger%NetBSD.org@localhost>
date: Thu Oct 08 08:57:19 2009 +0000
description:
Use m_pullup to handle defragmentation.
Reinject mbuf into TX queue when it couldn't be loaded.
diff for age(4) reviewed/discussed with plunky@ several weeks ago.
diffstat:
sys/dev/pci/if_age.c | 31 +++++--------------------------
sys/dev/pci/if_ale.c | 31 +++++--------------------------
2 files changed, 10 insertions(+), 52 deletions(-)
diffs (140 lines):
diff -r 6ad55ee7dee3 -r e85f34f2246f sys/dev/pci/if_age.c
--- a/sys/dev/pci/if_age.c Thu Oct 08 06:41:43 2009 +0000
+++ b/sys/dev/pci/if_age.c Thu Oct 08 08:57:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_age.c,v 1.33 2009/09/05 14:09:55 tsutsui Exp $ */
+/* $NetBSD: if_age.c,v 1.34 2009/10/08 08:57:19 cegger Exp $ */
/* $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $ */
/*-
@@ -31,7 +31,7 @@
/* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.33 2009/09/05 14:09:55 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.34 2009/10/08 08:57:19 cegger Exp $");
#include "bpfilter.h"
#include "vlan.h"
@@ -1052,6 +1052,7 @@
if (age_encap(sc, &m_head)) {
if (m_head == NULL)
break;
+ IF_PREPEND(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
break;
}
@@ -1204,41 +1205,19 @@
if (error == EFBIG) {
error = 0;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
+ *m_head = m_pullup(*m_head, MHLEN);
+ if (*m_head == NULL) {
printf("%s: can't defrag TX mbuf\n",
device_xname(sc->sc_dev));
- m_freem(*m_head);
- *m_head = NULL;
return ENOBUFS;
}
- M_COPY_PKTHDR(m, *m_head);
- if ((*m_head)->m_pkthdr.len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if (!(m->m_flags & M_EXT)) {
- m_freem(*m_head);
- m_freem(m);
- *m_head = NULL;
- return ENOBUFS;
- }
- }
- m_copydata(*m_head, 0, (*m_head)->m_pkthdr.len,
- mtod(m, void *));
- m_freem(*m_head);
- m->m_len = m->m_pkthdr.len;
- *m_head = m;
-
error = bus_dmamap_load_mbuf(sc->sc_dmat, map, *m_head,
BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not load defragged TX mbuf\n",
device_xname(sc->sc_dev));
- if (!error) {
- bus_dmamap_unload(sc->sc_dmat, map);
- error = EFBIG;
- }
m_freem(*m_head);
*m_head = NULL;
return error;
diff -r 6ad55ee7dee3 -r e85f34f2246f sys/dev/pci/if_ale.c
--- a/sys/dev/pci/if_ale.c Thu Oct 08 06:41:43 2009 +0000
+++ b/sys/dev/pci/if_ale.c Thu Oct 08 08:57:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ale.c,v 1.8 2009/09/05 14:09:55 tsutsui Exp $ */
+/* $NetBSD: if_ale.c,v 1.9 2009/10/08 08:57:19 cegger Exp $ */
/*-
* Copyright (c) 2008, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -32,7 +32,7 @@
/* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.8 2009/09/05 14:09:55 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.9 2009/10/08 08:57:19 cegger Exp $");
#include "bpfilter.h"
#include "vlan.h"
@@ -933,41 +933,19 @@
if (error == EFBIG) {
error = 0;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
+ *m_head = m_pullup(*m_head, MHLEN);
+ if (*m_head == NULL) {
printf("%s: can't defrag TX mbuf\n",
device_xname(sc->sc_dev));
- m_freem(*m_head);
- *m_head = NULL;
return ENOBUFS;
}
- M_COPY_PKTHDR(m, *m_head);
- if ((*m_head)->m_pkthdr.len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if (!(m->m_flags & M_EXT)) {
- m_freem(*m_head);
- m_freem(m);
- *m_head = NULL;
- return ENOBUFS;
- }
- }
- m_copydata(*m_head, 0, (*m_head)->m_pkthdr.len,
- mtod(m, void *));
- m_freem(*m_head);
- m->m_len = m->m_pkthdr.len;
- *m_head = m;
-
error = bus_dmamap_load_mbuf(sc->sc_dmat, map, *m_head,
BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not load defragged TX mbuf\n",
device_xname(sc->sc_dev));
- if (!error) {
- bus_dmamap_unload(sc->sc_dmat, map);
- error = EFBIG;
- }
m_freem(*m_head);
*m_head = NULL;
return error;
@@ -1092,6 +1070,7 @@
if (ale_encap(sc, &m_head)) {
if (m_head == NULL)
break;
+ IF_PREPEND(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
break;
}
Home |
Main Index |
Thread Index |
Old Index