Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb No need to keep TX/RX mbufs during xfers in stru...
details: https://anonhg.NetBSD.org/src/rev/d894882cda48
branches: trunk
changeset: 757089:d894882cda48
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sat Aug 14 10:30:11 2010 +0000
description:
No need to keep TX/RX mbufs during xfers in struct axe_chain.
All xfers are done against axe_buf allocated by usbd_alloc_buffer()
and nothing touched preserved mbufs during xfers.
diffstat:
sys/dev/usb/if_axe.c | 76 +++++++++---------------------------------------
sys/dev/usb/if_axereg.h | 3 +-
2 files changed, 16 insertions(+), 63 deletions(-)
diffs (174 lines):
diff -r 063458e72916 -r d894882cda48 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c Sat Aug 14 10:29:43 2010 +0000
+++ b/sys/dev/usb/if_axe.c Sat Aug 14 10:30:11 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.43 2010/08/14 09:57:13 tsutsui Exp $ */
+/* $NetBSD: if_axe.c,v 1.44 2010/08/14 10:30:11 tsutsui Exp $ */
/* $OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
/*
@@ -89,7 +89,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.43 2010/08/14 09:57:13 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.44 2010/08/14 10:30:11 tsutsui Exp $");
#if defined(__NetBSD__)
#include "opt_inet.h"
@@ -184,8 +184,6 @@
static int axe_tx_list_init(struct axe_softc *);
static int axe_rx_list_init(struct axe_softc *);
-static int axe_newbuf(struct axe_softc *, struct axe_chain *,
- struct mbuf *);
static int axe_encap(struct axe_softc *, struct mbuf *, int);
static void axe_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
static void axe_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
@@ -813,44 +811,6 @@
}
}
-/*
- * Initialize an RX descriptor and attach an MBUF cluster.
- */
-static int
-axe_newbuf(struct axe_softc *sc, struct axe_chain *c, struct mbuf *m)
-{
- struct mbuf *m_new = NULL;
-
- DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev),__func__));
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- aprint_error_dev(sc->axe_dev, "no memory for rx list "
- "-- packet dropped!\n");
- return ENOBUFS;
- }
-
- MCLGET(m_new, M_DONTWAIT);
- if ((m_new->m_flags & M_EXT) == 0) {
- aprint_error_dev(sc->axe_dev, "no memory for rx list "
- "-- packet dropped!\n");
- m_freem(m_new);
- return ENOBUFS;
- }
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- } else {
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- m_adj(m_new, ETHER_ALIGN);
- c->axe_mbuf = m_new;
-
- return 0;
-}
-
static int
axe_rx_list_init(struct axe_softc *sc)
{
@@ -865,8 +825,6 @@
c = &cd->axe_rx_chain[i];
c->axe_sc = sc;
c->axe_idx = i;
- if (axe_newbuf(sc, c, NULL) == ENOBUFS)
- return ENOBUFS;
if (c->axe_xfer == NULL) {
c->axe_xfer = usbd_alloc_xfer(sc->axe_udev);
if (c->axe_xfer == NULL)
@@ -897,7 +855,6 @@
c = &cd->axe_tx_chain[i];
c->axe_sc = sc;
c->axe_idx = i;
- c->axe_mbuf = NULL;
if (c->axe_xfer == NULL) {
c->axe_xfer = usbd_alloc_xfer(sc->axe_udev);
if (c->axe_xfer == NULL)
@@ -988,14 +945,22 @@
total_len = 0;
}
- m = c->axe_mbuf;
-
- /* XXX ugly */
- if (axe_newbuf(sc, c, NULL) == ENOBUFS) {
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ if (m == NULL) {
ifp->if_ierrors++;
goto done;
}
+ if (pktlen > MHLEN - ETHER_ALIGN) {
+ MCLGET(m, M_DONTWAIT);
+ if ((m->m_flags & M_EXT) == 0) {
+ m_freem(m);
+ ifp->if_ierrors++;
+ goto done;
+ }
+ }
+ m->m_data += ETHER_ALIGN;
+
ifp->if_ipackets++;
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = pktlen;
@@ -1066,9 +1031,6 @@
ifp->if_timer = 0;
ifp->if_flags &= ~IFF_OACTIVE;
- m_freem(c->axe_mbuf);
- c->axe_mbuf = NULL;
-
if (!IFQ_IS_EMPTY(&ifp->if_snd))
axe_start(ifp);
@@ -1170,7 +1132,7 @@
m_copydata(m, 0, m->m_pkthdr.len, c->axe_buf);
length = m->m_pkthdr.len;
}
- c->axe_mbuf = m;
+ m_freem(m);
usbd_setup_xfer(c->axe_xfer, sc->axe_ep[AXE_ENDPT_TX],
c, c->axe_buf, length, USBD_FORCE_SHORT_XFER | USBD_NO_COPY, 10000,
@@ -1477,10 +1439,6 @@
/* Free RX resources. */
for (i = 0; i < AXE_RX_LIST_CNT; i++) {
- if (sc->axe_cdata.axe_rx_chain[i].axe_mbuf != NULL) {
- m_freem(sc->axe_cdata.axe_rx_chain[i].axe_mbuf);
- sc->axe_cdata.axe_rx_chain[i].axe_mbuf = NULL;
- }
if (sc->axe_cdata.axe_rx_chain[i].axe_xfer != NULL) {
usbd_free_xfer(sc->axe_cdata.axe_rx_chain[i].axe_xfer);
sc->axe_cdata.axe_rx_chain[i].axe_xfer = NULL;
@@ -1489,10 +1447,6 @@
/* Free TX resources. */
for (i = 0; i < AXE_TX_LIST_CNT; i++) {
- if (sc->axe_cdata.axe_tx_chain[i].axe_mbuf != NULL) {
- m_freem(sc->axe_cdata.axe_tx_chain[i].axe_mbuf);
- sc->axe_cdata.axe_tx_chain[i].axe_mbuf = NULL;
- }
if (sc->axe_cdata.axe_tx_chain[i].axe_xfer != NULL) {
usbd_free_xfer(sc->axe_cdata.axe_tx_chain[i].axe_xfer);
sc->axe_cdata.axe_tx_chain[i].axe_xfer = NULL;
diff -r 063458e72916 -r d894882cda48 sys/dev/usb/if_axereg.h
--- a/sys/dev/usb/if_axereg.h Sat Aug 14 10:29:43 2010 +0000
+++ b/sys/dev/usb/if_axereg.h Sat Aug 14 10:30:11 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axereg.h,v 1.10 2010/06/24 15:01:45 tsutsui Exp $ */
+/* $NetBSD: if_axereg.h,v 1.11 2010/08/14 10:30:11 tsutsui Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003
@@ -177,7 +177,6 @@
struct axe_softc *axe_sc;
usbd_xfer_handle axe_xfer;
char *axe_buf;
- struct mbuf *axe_mbuf;
int axe_accum;
int axe_idx;
};
Home |
Main Index |
Thread Index |
Old Index