Module Name:    src
Committed By:   skrll
Date:           Wed Aug 30 10:08:22 UTC 2017

Modified Files:
        src/sys/dev/usb [nick-nhusb]: if_smsc.c if_smscvar.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.36 -r1.22.2.37 src/sys/dev/usb/if_smsc.c
cvs rdiff -u -r1.3.4.7 -r1.3.4.8 src/sys/dev/usb/if_smscvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.36 src/sys/dev/usb/if_smsc.c:1.22.2.37
--- src/sys/dev/usb/if_smsc.c:1.22.2.36	Sat Apr 15 14:38:44 2017
+++ src/sys/dev/usb/if_smsc.c	Wed Aug 30 10:08:22 2017
@@ -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 @@ smsc_start_locked(struct ifnet *ifp)
 		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 @@ smsc_start_locked(struct ifnet *ifp)
 	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 @@ smsc_txeof(struct usbd_xfer *xfer, void 
 		return;
 	}
 
+	sc->sc_cdata.tx_free++;
 	ifp->if_timer = 0;
 	ifp->if_flags &= ~IFF_OACTIVE;
 
@@ -1608,6 +1621,9 @@ smsc_tx_list_init(struct smsc_softc *sc)
 		}
 	}
 
+	cd->tx_free = SMSC_TX_LIST_CNT;
+	cd->tx_next = 0;
+
 	return 0;
 }
 
@@ -1721,7 +1737,5 @@ smsc_encap(struct smsc_softc *sc, struct
 		return EIO;
 	}
 
-	sc->sc_cdata.tx_cnt++;
-
 	return 0;
 }

Index: src/sys/dev/usb/if_smscvar.h
diff -u src/sys/dev/usb/if_smscvar.h:1.3.4.7 src/sys/dev/usb/if_smscvar.h:1.3.4.8
--- src/sys/dev/usb/if_smscvar.h:1.3.4.7	Sat Apr 15 14:38:44 2017
+++ src/sys/dev/usb/if_smscvar.h	Wed Aug 30 10:08:22 2017
@@ -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_chain {
 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;
 };
 

Reply via email to