Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb Track used TX trasnfers and check there's a...



details:   https://anonhg.NetBSD.org/src/rev/2748663cb744
branches:  nick-nhusb
changeset: 334650:2748663cb744
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Aug 30 10:08:22 2017 +0000

description:
Track used TX trasnfers and check there's a free transfer in
smsc_start_locked

diffstat:

 sys/dev/usb/if_smsc.c    |  24 +++++++++++++++++++-----
 sys/dev/usb/if_smscvar.h |   7 +++----
 2 files changed, 22 insertions(+), 9 deletions(-)

diffs (93 lines):

diff -r 416a2b4c256b -r 2748663cb744 sys/dev/usb/if_smsc.c
--- a/sys/dev/usb/if_smsc.c     Tue Aug 29 06:49:07 2017 +0000
+++ b/sys/dev/usb/if_smsc.c     Wed Aug 30 10:08:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smsc.c,v 1.22.2.36 2017/04/15 14:38:44 skrll Exp $  */
+/*     $NetBSD: if_smsc.c,v 1.22.2.37 2017/08/30 10:08:22 skrll Exp $  */
 
 /*     $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -694,6 +694,12 @@
                return;
        }
 
+       /* Any free USB transfers? */
+       if (sc->sc_cdata.tx_free == 0) {
+               smsc_dbg_printf(sc, "%s: all USB transfers in use\n", __func__);
+               return;
+       }
+
        if ((ifp->if_flags & (IFF_OACTIVE|IFF_RUNNING)) != IFF_RUNNING) {
                smsc_dbg_printf(sc, "%s: not running\n", __func__);
                return;
@@ -703,15 +709,21 @@
        if (m_head == NULL)
                return;
 
+       sc->sc_cdata.tx_free--;
+
        IFQ_DEQUEUE(&ifp->if_snd, m_head);
-       if (smsc_encap(sc, m_head, 0)) {
+       if (smsc_encap(sc, m_head, sc->sc_cdata.tx_next)) {
                m_free(m_head);
+               sc->sc_cdata.tx_free++;
                return;
        }
 
+       sc->sc_cdata.tx_next = (sc->sc_cdata.tx_next + 1) % SMSC_TX_LIST_CNT;
+
        bpf_mtap(ifp, m_head);
 
-       ifp->if_flags |= IFF_OACTIVE;
+       if (sc->sc_cdata.tx_free == 0)
+               ifp->if_flags |= IFF_OACTIVE;
 
        /*
         * Set a timeout in case the chip goes out to lunch.
@@ -1559,6 +1571,7 @@
                return;
        }
 
+       sc->sc_cdata.tx_free++;
        ifp->if_timer = 0;
        ifp->if_flags &= ~IFF_OACTIVE;
 
@@ -1608,6 +1621,9 @@
                }
        }
 
+       cd->tx_free = SMSC_TX_LIST_CNT;
+       cd->tx_next = 0;
+
        return 0;
 }
 
@@ -1721,7 +1737,5 @@
                return EIO;
        }
 
-       sc->sc_cdata.tx_cnt++;
-
        return 0;
 }
diff -r 416a2b4c256b -r 2748663cb744 sys/dev/usb/if_smscvar.h
--- a/sys/dev/usb/if_smscvar.h  Tue Aug 29 06:49:07 2017 +0000
+++ b/sys/dev/usb/if_smscvar.h  Wed Aug 30 10:08:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smscvar.h,v 1.3.4.7 2017/04/15 14:38:44 skrll Exp $ */
+/*     $NetBSD: if_smscvar.h,v 1.3.4.8 2017/08/30 10:08:22 skrll Exp $ */
 
 /*     $OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $      */
 /*-
@@ -46,9 +46,8 @@
 struct smsc_cdata {
        struct smsc_chain        tx_chain[SMSC_TX_LIST_CNT];
        struct smsc_chain        rx_chain[SMSC_RX_LIST_CNT];
-       int                      tx_prod;
-       int                      tx_cons;
-       int                      tx_cnt;
+       int                      tx_free;
+       int                      tx_next;
        int                      rx_prod;
 };
 



Home | Main Index | Thread Index | Old Index