Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb internal to usbnet:



details:   https://anonhg.NetBSD.org/src/rev/5b700d6159ae
branches:  trunk
changeset: 453531:5b700d6159ae
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Aug 16 08:38:21 2019 +0000

description:
internal to usbnet:

add buflen param to usbnet_newbuf().  use this to skip allocating
an mbuf cluster for small packets (ported from kue(4).)

remove usbnet_rx_start_pipes()'s always usbnet_rxeof argument.

diffstat:

 sys/dev/usb/usbnet.c |  32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diffs (113 lines):

diff -r 5087b1f72f85 -r 5b700d6159ae sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Fri Aug 16 08:29:20 2019 +0000
+++ b/sys/dev/usb/usbnet.c      Fri Aug 16 08:38:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.15 2019/08/15 05:52:23 mrg Exp $  */
+/*     $NetBSD: usbnet.c,v 1.16 2019/08/16 08:38:21 mrg Exp $  */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.15 2019/08/15 05:52:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.16 2019/08/16 08:38:21 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -211,7 +211,7 @@
 /* Interrupt handling. */
 
 static struct mbuf *
-usbnet_newbuf(void)
+usbnet_newbuf(size_t buflen)
 {
        struct mbuf *m;
 
@@ -219,14 +219,16 @@
        if (m == NULL)
                return NULL;
 
-       MCLGET(m, M_DONTWAIT);
-       if (!(m->m_flags & M_EXT)) {
-               m_freem(m);
-               return NULL;
+       if (buflen > MHLEN - ETHER_ALIGN) {
+               MCLGET(m, M_DONTWAIT);
+               if (!(m->m_flags & M_EXT)) {
+                       m_freem(m);
+                       return NULL;
+               }
        }
 
-       m->m_len = m->m_pkthdr.len = MCLBYTES;
        m_adj(m, ETHER_ALIGN);
+       m->m_len = m->m_pkthdr.len = buflen;
 
        return m;
 }
@@ -248,18 +250,17 @@
 
        usbnet_isowned_rx(un);
 
-       m = usbnet_newbuf();
+       m = usbnet_newbuf(buflen);
        if (m == NULL) {
                ifp->if_ierrors++;
                return;
        }
 
        m_set_rcvif(m, ifp);
-       m->m_pkthdr.len = m->m_len = buflen;
        m->m_pkthdr.csum_flags = csum_flags;
        m->m_pkthdr.csum_data = csum_data;
        m->m_flags |= mbuf_flags;
-       memcpy(mtod(m, char *), buf, buflen);
+       memcpy(mtod(m, uint8_t *), buf, buflen);
 
        /* push the packet up */
        if_percpuq_enqueue(ifp->if_percpuq, m);
@@ -274,14 +275,13 @@
 
        usbnet_isowned_rx(un);
 
-       m = usbnet_newbuf();
+       m = usbnet_newbuf(buflen);
        if (m == NULL) {
                ifp->if_ierrors++;
                return;
        }
 
        m_set_rcvif(m, ifp);
-       m->m_pkthdr.len = m->m_len = buflen;
        memcpy(mtod(m, char *), buf, buflen);
 
        /* push the packet up */
@@ -576,7 +576,7 @@
 /* End of common RX functions */
 
 static void
-usbnet_rx_start_pipes(struct usbnet * const un, usbd_callback cb)
+usbnet_rx_start_pipes(struct usbnet * const un)
 {
        struct usbnet_cdata * const cd = un_cdata(un);
        struct usbnet_private * const unp = un->un_pri;
@@ -589,7 +589,7 @@
                struct usbnet_chain *c = &cd->uncd_rx_chain[i];
 
                usbd_setup_xfer(c->unc_xfer, c, c->unc_buf, un->un_rx_bufsz,
-                   un->un_rx_xfer_flags, USBD_NO_TIMEOUT, cb);
+                   un->un_rx_xfer_flags, USBD_NO_TIMEOUT, usbnet_rxeof);
                usbd_transfer(c->unc_xfer);
        }
 
@@ -769,7 +769,7 @@
        }
 
        /* Start up the receive pipe(s). */
-       usbnet_rx_start_pipes(un, usbnet_rxeof);
+       usbnet_rx_start_pipes(un);
 
        /* Indicate we are up and running. */
        KASSERT(ifp->if_softc == NULL || IFNET_LOCKED(ifp));



Home | Main Index | Thread Index | Old Index