Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Make size of transmit/receive queues variable. R...



details:   https://anonhg.NetBSD.org/src/rev/8cf93f185cfc
branches:  trunk
changeset: 996496:8cf93f185cfc
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Feb 03 13:11:07 2019 +0000

description:
Make size of transmit/receive queues variable. Restrict queue size again
to 1 for LAN7500 as some chips fail.

Read Chip revision register and report value. Maybe we can identify
chisp better now.

diffstat:

 sys/dev/usb/if_mue.c    |  45 ++++++++++++++++++++++++---------------------
 sys/dev/usb/if_muereg.h |   7 ++++++-
 sys/dev/usb/if_muevar.h |   6 +++++-
 3 files changed, 35 insertions(+), 23 deletions(-)

diffs (200 lines):

diff -r b2b7c6c1b314 -r 8cf93f185cfc sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c      Sun Feb 03 13:01:57 2019 +0000
+++ b/sys/dev/usb/if_mue.c      Sun Feb 03 13:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mue.c,v 1.30 2019/01/31 05:25:48 rin Exp $  */
+/*     $NetBSD: if_mue.c,v 1.31 2019/02/03 13:11:07 mlelstv Exp $      */
 /*     $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $  */
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Microchip LAN7500/LAN7800 chipsets. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.30 2019/01/31 05:25:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.31 2019/02/03 13:11:07 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -897,6 +897,7 @@
        struct mii_data *mii;
        struct ifnet *ifp;
        usbd_status err;
+       const char *descr;
        uint8_t i;
        int s;
 
@@ -932,12 +933,19 @@
        sc->mue_product = uaa->uaa_product;
        sc->mue_flags = MUE_LOOKUP(uaa)->mue_flags;
 
+       sc->mue_id_rev = mue_csr_read(sc, MUE_ID_REV);
+
        /* Decide on what our bufsize will be. */
-       if (sc->mue_flags & LAN7500)
+       if (sc->mue_flags & LAN7500) {
                sc->mue_rxbufsz = (sc->mue_udev->ud_speed == USB_SPEED_HIGH) ?
                    MUE_7500_HS_RX_BUFSIZE : MUE_7500_FS_RX_BUFSIZE;
-       else
+               sc->mue_rx_list_cnt = 1;
+               sc->mue_tx_list_cnt = 1;
+       } else {
                sc->mue_rxbufsz = MUE_7800_RX_BUFSIZE;
+               sc->mue_rx_list_cnt = MUE_RX_LIST_CNT;
+               sc->mue_tx_list_cnt = MUE_TX_LIST_CNT;
+       }
        sc->mue_txbufsz = MUE_TX_BUFSIZE;
 
        /* Find endpoints. */
@@ -974,10 +982,10 @@
        }
 
        /* A Microchip chip was detected.  Inform the world. */
-       if (sc->mue_flags & LAN7500)
-               aprint_normal_dev(self, "LAN7500\n");
-       else
-               aprint_normal_dev(self, "LAN7800\n");
+       descr = (sc->mue_flags & LAN7500) ? "LAN7500" : "LAN7800";
+       aprint_normal_dev(self, "%s id 0x%x rev 0x%x\n", descr,
+               (unsigned)__SHIFTOUT(sc->mue_id_rev, MUE_ID_REV_ID),
+               (unsigned)__SHIFTOUT(sc->mue_id_rev, MUE_ID_REV_REV));
 
        if (mue_get_macaddr(sc, dict)) {
                aprint_error_dev(self, "failed to read MAC address\n");
@@ -1125,7 +1133,7 @@
        int err;
 
        cd = &sc->mue_cdata;
-       for (i = 0; i < __arraycount(cd->mue_rx_chain); i++) {
+       for (i = 0; i < sc->mue_rx_list_cnt; i++) {
                c = &cd->mue_rx_chain[i];
                c->mue_sc = sc;
                c->mue_idx = i;
@@ -1150,7 +1158,7 @@
        int err;
 
        cd = &sc->mue_cdata;
-       for (i = 0; i < __arraycount(cd->mue_tx_chain); i++) {
+       for (i = 0; i < sc->mue_tx_list_cnt; i++) {
                c = &cd->mue_tx_chain[i];
                c->mue_sc = sc;
                c->mue_idx = i;
@@ -1198,7 +1206,7 @@
        size_t i;
 
        /* Start up the receive pipe. */
-       for (i = 0; i < __arraycount(sc->mue_cdata.mue_rx_chain); i++) {
+       for (i = 0; i < sc->mue_rx_list_cnt; i++) {
                c = &sc->mue_cdata.mue_rx_chain[i];
                usbd_setup_xfer(c->mue_xfer, c, c->mue_buf, sc->mue_rxbufsz,
                    USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, mue_rxeof);
@@ -1461,11 +1469,6 @@
                return;
        }
 
-       if (__predict_false(!(ifp->if_flags & IFF_RUNNING))) {
-               DPRINTF(sc, "not running\n");
-               return;
-       }
-
        if (__predict_false(status != USBD_NORMAL_COMPLETION)) {
                DPRINTF(sc, "%s\n", usbd_errstr(status));
                if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
@@ -1790,7 +1793,7 @@
        }
 
        idx = cd->mue_tx_prod;
-       while (cd->mue_tx_cnt < MUE_TX_LIST_CNT) {
+       while ((unsigned)cd->mue_tx_cnt < sc->mue_tx_list_cnt) {
                IFQ_POLL(&ifp->if_snd, m);
                if (m == NULL)
                        break;
@@ -1804,13 +1807,13 @@
                bpf_mtap(ifp, m, BPF_D_OUT);
                m_freem(m);
 
-               idx = (idx + 1) % MUE_TX_LIST_CNT;
+               idx = (idx + 1) % sc->mue_tx_list_cnt;
                cd->mue_tx_cnt++;
 
        }
        cd->mue_tx_prod = idx;
 
-       if (cd->mue_tx_cnt >= MUE_TX_LIST_CNT)
+       if ((unsigned)cd->mue_tx_cnt >= sc->mue_tx_list_cnt)
                ifp->if_flags |= IFF_OACTIVE;
 
        /* Set a timeout in case the chip goes out to lunch. */
@@ -1841,7 +1844,7 @@
                }
 
        /* Free RX resources. */
-       for (i = 0; i < __arraycount(sc->mue_cdata.mue_rx_chain); i++)
+       for (i = 0; i < sc->mue_rx_list_cnt; i++)
                if (sc->mue_cdata.mue_rx_chain[i].mue_xfer != NULL) {
                        usbd_destroy_xfer(
                            sc->mue_cdata.mue_rx_chain[i].mue_xfer);
@@ -1849,7 +1852,7 @@
                }
 
        /* Free TX resources. */
-       for (i = 0; i < __arraycount(sc->mue_cdata.mue_tx_chain); i++)
+       for (i = 0; i < sc->mue_tx_list_cnt; i++)
                if (sc->mue_cdata.mue_tx_chain[i].mue_xfer != NULL) {
                        usbd_destroy_xfer(
                            sc->mue_cdata.mue_tx_chain[i].mue_xfer);
diff -r b2b7c6c1b314 -r 8cf93f185cfc sys/dev/usb/if_muereg.h
--- a/sys/dev/usb/if_muereg.h   Sun Feb 03 13:01:57 2019 +0000
+++ b/sys/dev/usb/if_muereg.h   Sun Feb 03 13:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_muereg.h,v 1.4 2018/12/11 13:35:02 rin Exp $        */
+/*     $NetBSD: if_muereg.h,v 1.5 2019/02/03 13:11:07 mlelstv Exp $    */
 /*     $OpenBSD: if_muereg.h,v 1.1 2018/08/03 01:50:15 kevlo Exp $     */
 
 /*
@@ -34,6 +34,7 @@
 #define MUE_UR_READREG         0xa1
 
 /* registers */
+#define MUE_ID_REV                     0x000
 #define MUE_INT_STATUS                 0x00c
 #define MUE_HW_CFG                     0x010
 #define MUE_PMT_CTL                    0x014
@@ -81,6 +82,10 @@
 #define MUE_7800_ADDR_FILTX(i)         (MUE_7800_ADDR_FILTX_BASE + 8 * (i))
 #define MUE_NUM_ADDR_FILTX             33
 
+/* device ID and revision register */
+#define MUE_ID_REV_ID          __BITS(16,31)
+#define MUE_ID_REV_REV         __BITS(0,15)
+
 /* hardware configuration register */
 #define MUE_HW_CFG_SRST                0x00000001
 #define MUE_HW_CFG_LRST                0x00000002
diff -r b2b7c6c1b314 -r 8cf93f185cfc sys/dev/usb/if_muevar.h
--- a/sys/dev/usb/if_muevar.h   Sun Feb 03 13:01:57 2019 +0000
+++ b/sys/dev/usb/if_muevar.h   Sun Feb 03 13:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_muevar.h,v 1.5 2019/01/31 05:25:07 rin Exp $        */
+/*     $NetBSD: if_muevar.h,v 1.6 2019/02/03 13:11:07 mlelstv Exp $    */
 /*     $OpenBSD: if_muereg.h,v 1.1 2018/08/03 01:50:15 kevlo Exp $     */
 
 /*
@@ -111,6 +111,7 @@
 
        uint16_t                mue_product;
        uint16_t                mue_flags;
+       uint32_t                mue_id_rev;
 
        int                     mue_if_flags;
        int                     mue_refcnt;
@@ -121,6 +122,9 @@
        uint32_t                mue_rxbufsz;
        uint32_t                mue_txbufsz;
        int                     mue_link;
+
+       unsigned                mue_rx_list_cnt;
+       unsigned                mue_tx_list_cnt;
 };
 
 #endif /* _IF_MUEVAR_H_ */



Home | Main Index | Thread Index | Old Index