Module Name: src
Committed By: rin
Date: Wed Feb 6 08:06:59 UTC 2019
Modified Files:
src/sys/dev/usb: if_axen.c if_axenreg.h
Log Message:
Enable multiple outstanding transfers.
XXX Linux driver uses much larger numbers of transfers.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/usb/if_axenreg.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_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.32 src/sys/dev/usb/if_axen.c:1.33
--- src/sys/dev/usb/if_axen.c:1.32 Wed Feb 6 08:04:08 2019
+++ src/sys/dev/usb/if_axen.c Wed Feb 6 08:06:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axen.c,v 1.32 2019/02/06 08:04:08 rin Exp $ */
+/* $NetBSD: if_axen.c,v 1.33 2019/02/06 08:06:59 rin Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.32 2019/02/06 08:04:08 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.33 2019/02/06 08:06:59 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -987,6 +987,8 @@ axen_tx_list_init(struct axen_softc *sc)
}
}
+ cd->axen_tx_prod = cd->axen_tx_cnt = 0;
+
return 0;
}
@@ -1197,6 +1199,7 @@ axen_txeof(struct usbd_xfer *xfer, void
{
struct axen_chain *c = (struct axen_chain *)priv;
struct axen_softc *sc = c->axen_sc;
+ struct axen_cdata *cd = &sc->axen_cdata;
struct ifnet *ifp = GET_IFP(sc);
int s;
@@ -1204,7 +1207,8 @@ axen_txeof(struct usbd_xfer *xfer, void
return;
s = splnet();
-
+ KASSERT(cd->axen_tx_cnt > 0);
+ cd->axen_tx_cnt--;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
splx(s);
@@ -1328,18 +1332,16 @@ axen_encap(struct axen_softc *sc, struct
return EIO;
}
- sc->axen_cdata.axen_tx_cnt++;
-
return 0;
}
static void
axen_start(struct ifnet *ifp)
{
- struct axen_softc *sc;
+ struct axen_softc *sc = ifp->if_softc;
struct mbuf *m;
-
- sc = ifp->if_softc;
+ struct axen_cdata *cd = &sc->axen_cdata;
+ int idx;
if (sc->axen_link == 0)
return;
@@ -1347,24 +1349,33 @@ axen_start(struct ifnet *ifp)
if ((ifp->if_flags & (IFF_OACTIVE|IFF_RUNNING)) != IFF_RUNNING)
return;
- IFQ_POLL(&ifp->if_snd, m);
- if (m == NULL)
- return;
+ idx = cd->axen_tx_prod;
+ while (cd->axen_tx_cnt < AXEN_TX_LIST_CNT) {
+ IFQ_POLL(&ifp->if_snd, m);
+ if (m == NULL)
+ break;
- if (axen_encap(sc, m, 0)) {
- ifp->if_flags |= IFF_OACTIVE;
- return;
- }
- IFQ_DEQUEUE(&ifp->if_snd, m);
+ if (axen_encap(sc, m, idx)) {
+ ifp->if_flags |= IFF_OACTIVE; /* XXX */
+ ifp->if_oerrors++;
+ break;
+ }
+ IFQ_DEQUEUE(&ifp->if_snd, m);
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- bpf_mtap(ifp, m, BPF_D_OUT);
- m_freem(m);
+ /*
+ * If there's a BPF listener, bounce a copy of this frame
+ * to him.
+ */
+ bpf_mtap(ifp, m, BPF_D_OUT);
+ m_freem(m);
- ifp->if_flags |= IFF_OACTIVE;
+ idx = (idx + 1) % AXEN_TX_LIST_CNT;
+ cd->axen_tx_cnt++;
+ }
+ cd->axen_tx_prod = idx;
+
+ if (cd->axen_tx_cnt >= AXEN_TX_LIST_CNT)
+ ifp->if_flags |= IFF_OACTIVE;
/*
* Set a timeout in case the chip goes out to lunch.
Index: src/sys/dev/usb/if_axenreg.h
diff -u src/sys/dev/usb/if_axenreg.h:1.8 src/sys/dev/usb/if_axenreg.h:1.9
--- src/sys/dev/usb/if_axenreg.h:1.8 Wed Feb 6 07:56:14 2019
+++ src/sys/dev/usb/if_axenreg.h Wed Feb 6 08:06:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axenreg.h,v 1.8 2019/02/06 07:56:14 rin Exp $ */
+/* $NetBSD: if_axenreg.h,v 1.9 2019/02/06 08:06:59 rin Exp $ */
/* $OpenBSD: if_axenreg.h,v 1.1 2013/10/07 05:37:41 yuo Exp $ */
/*
@@ -210,8 +210,12 @@
#define AXEN_TIMEOUT 1000
-#define AXEN_RX_LIST_CNT 1
-#define AXEN_TX_LIST_CNT 1
+#ifndef AXEN_RX_LIST_CNT
+#define AXEN_RX_LIST_CNT 4 /* 22 for SS mode in Linux driver */
+#endif
+#ifndef AXEN_TX_LIST_CNT
+#define AXEN_TX_LIST_CNT 4 /* 60 */
+#endif
#define AXEN_CONFIG_NO 1