Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/usb Ticket #135: something went wrong in the pull...



details:   https://anonhg.NetBSD.org/src/rev/72bfbf86c736
branches:  netbsd-9
changeset: 962920:72bfbf86c736
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Sep 02 07:02:34 2019 +0000

description:
Ticket #135: something went wrong in the pullup process for this file
(likely overlooked conflict with previously applied rev. 156).
So now actually sync this up to rev 1.161, as the last pullup claimed

diffstat:

 sys/dev/usb/if_aue.c |  1416 ++++++++++++-------------------------------------
 1 files changed, 367 insertions(+), 1049 deletions(-)

diffs (truncated from 1880 to 300 lines):

diff -r ce1a49bc852a -r 72bfbf86c736 sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Sun Sep 01 19:35:17 2019 +0000
+++ b/sys/dev/usb/if_aue.c      Mon Sep 02 07:02:34 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $  */
+/*     $NetBSD: if_aue.c,v 1.154.2.2 2019/09/02 07:02:34 martin Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -70,14 +70,13 @@
 /*
  * TODO:
  * better error messages from rxstat
- * split out if_auevar.h
  * more error checks
  * investigate short rx problem
  * proper cleanup on errors
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154.2.2 2019/09/02 07:02:34 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -85,51 +84,75 @@
 #endif
 
 #include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mutex.h>
-#include <sys/mbuf.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/device.h>
-#include <sys/rndsource.h>
 
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
+#include <dev/usb/usbnet.h>
+#include <dev/usb/usbhist.h>
+#include <dev/usb/if_auereg.h>
 
-#include <net/bpf.h>
-
-#include <net/if_ether.h>
 #ifdef INET
 #include <netinet/in.h>
 #include <netinet/if_inarp.h>
 #endif
 
-
+#ifdef USB_DEBUG
+#ifndef AUE_DEBUG
+#define auedebug 0
+#else
+static int auedebug = 10;
 
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
+SYSCTL_SETUP(sysctl_hw_aue_setup, "sysctl hw.aue setup")
+{
+       int err;
+       const struct sysctlnode *rnode;
+       const struct sysctlnode *cnode;
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbdevs.h>
+       err = sysctl_createv(clog, 0, NULL, &rnode,
+           CTLFLAG_PERMANENT, CTLTYPE_NODE, "aue",
+           SYSCTL_DESCR("aue global controls"),
+           NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+       if (err)
+               goto fail;
+
+       /* control debugging printfs */
+       err = sysctl_createv(clog, 0, &rnode, &cnode,
+           CTLFLAG_PERMANENT | CTLFLAG_READWRITE, CTLTYPE_INT,
+           "debug", SYSCTL_DESCR("Enable debugging output"),
+           NULL, 0, &auedebug, sizeof(auedebug), CTL_CREATE, CTL_EOL);
+       if (err)
+               goto fail;
 
-#include <sys/condvar.h>
-#include <sys/kthread.h>
+       return;
+fail:
+       aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
 
-#include <dev/usb/if_auereg.h>
+#endif /* AXE_DEBUG */
+#endif /* USB_DEBUG */
 
-#ifdef AUE_DEBUG
-#define DPRINTF(x)     if (auedebug) printf x
-#define DPRINTFN(n, x) if (auedebug >= (n)) printf x
-int    auedebug = 0;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n, x)
-#endif
+#define DPRINTF(FMT,A,B,C,D)   USBHIST_LOGN(auedebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D)        USBHIST_LOGN(auedebug,N,FMT,A,B,C,D)
+#define AUEHIST_FUNC()         USBHIST_FUNC()
+#define AUEHIST_CALLED(name)   USBHIST_CALLED(auedebug)
+#define AUEHIST_CALLARGS(FMT,A,B,C,D) \
+                               USBHIST_CALLARGS(auedebug,FMT,A,B,C,D)
+#define AUEHIST_CALLARGSN(N,FMT,A,B,C,D) \
+                               USBHIST_CALLARGSN(auedebug,N,FMT,A,B,C,D)
+
+#define AUE_TX_LIST_CNT                1
+#define AUE_RX_LIST_CNT                1
+
+struct aue_softc {
+       struct usbnet           aue_un;
+       struct usbnet_intr      aue_intr;
+       struct aue_intrpkt      aue_ibuf;
+};
+
+#define AUE_TIMEOUT            1000
+#define AUE_BUFSZ              1536
+#define AUE_MIN_FRAMELEN       60
+#define AUE_TX_TIMEOUT         10000 /* ms */
+#define AUE_INTR_INTERVAL      100 /* ms */
 
 /*
  * Various supported device vendors/products.
@@ -142,7 +165,7 @@
 #define PII    0x0004          /* Pegasus II chip */
 };
 
-Static const struct aue_type aue_devs[] = {
+static const struct aue_type aue_devs[] = {
  {{ USB_VENDOR_3COM,           USB_PRODUCT_3COM_3C460B},         PII },
  {{ USB_VENDOR_ABOCOM,         USB_PRODUCT_ABOCOM_XX1},          PNA | PII },
  {{ USB_VENDOR_ABOCOM,         USB_PRODUCT_ABOCOM_XX2},          PII },
@@ -210,49 +233,42 @@
 
 int aue_match(device_t, cfdata_t, void *);
 void aue_attach(device_t, device_t, void *);
-int aue_detach(device_t, int);
-int aue_activate(device_t, enum devact);
 
 CFATTACH_DECL_NEW(aue, sizeof(struct aue_softc), aue_match, aue_attach,
-    aue_detach, aue_activate);
+    usbnet_detach, usbnet_activate);
+
+static void aue_reset_pegasus_II(struct aue_softc *);
 
-Static void aue_multithread(void *);
+static void aue_stop_cb(struct ifnet *, int);
+static int aue_ioctl_cb(struct ifnet *, u_long, void *);
+static int aue_mii_read_reg(struct usbnet *, int, int, uint16_t *);
+static int aue_mii_write_reg(struct usbnet *, int, int, uint16_t);
+static void aue_mii_statchg(struct ifnet *);
+static unsigned aue_tx_prepare(struct usbnet *, struct mbuf *,
+                              struct usbnet_chain *);
+static void aue_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
+static int aue_init(struct ifnet *);
+static void aue_intr(struct usbnet *, usbd_status);
 
-Static void aue_reset_pegasus_II(struct aue_softc *);
-Static int aue_tx_list_init(struct aue_softc *);
-Static int aue_rx_list_init(struct aue_softc *);
-Static int aue_newbuf(struct aue_softc *, struct aue_chain *, struct mbuf *);
-Static int aue_send(struct aue_softc *, struct mbuf *, int);
-Static void aue_intr(struct usbd_xfer *, void *, usbd_status);
-Static void aue_rxeof(struct usbd_xfer *, void *, usbd_status);
-Static void aue_txeof(struct usbd_xfer *, void *, usbd_status);
-Static void aue_tick(void *);
-Static void aue_tick_task(void *);
-Static void aue_start(struct ifnet *);
-Static int aue_ioctl(struct ifnet *, u_long, void *);
-Static void aue_init(void *);
-Static void aue_stop(struct aue_softc *);
-Static void aue_watchdog(struct ifnet *);
-Static int aue_openpipes(struct aue_softc *);
-Static int aue_ifmedia_upd(struct ifnet *);
+static struct usbnet_ops aue_ops = {
+       .uno_stop = aue_stop_cb,
+       .uno_ioctl = aue_ioctl_cb,
+       .uno_read_reg = aue_mii_read_reg,
+       .uno_write_reg = aue_mii_write_reg,
+       .uno_statchg = aue_mii_statchg,
+       .uno_tx_prepare = aue_tx_prepare,
+       .uno_rx_loop = aue_rx_loop,
+       .uno_init = aue_init,
+       .uno_intr = aue_intr,
+};
 
-Static int aue_eeprom_getword(struct aue_softc *, int);
-Static void aue_read_mac(struct aue_softc *, u_char *);
-Static int aue_miibus_readreg(device_t, int, int, uint16_t *);
-Static int aue_miibus_writereg(device_t, int, int, uint16_t);
-Static void aue_miibus_statchg(struct ifnet *);
-
-Static void aue_lock_mii(struct aue_softc *);
-Static void aue_unlock_mii(struct aue_softc *);
+static uint32_t aue_crc(void *);
+static void aue_reset(struct aue_softc *);
 
-Static void aue_setmulti(struct aue_softc *);
-Static uint32_t aue_crc(void *);
-Static void aue_reset(struct aue_softc *);
-
-Static int aue_csr_read_1(struct aue_softc *, int);
-Static int aue_csr_write_1(struct aue_softc *, int, int);
-Static int aue_csr_read_2(struct aue_softc *, int);
-Static int aue_csr_write_2(struct aue_softc *, int, int);
+static int aue_csr_read_1(struct aue_softc *, int);
+static int aue_csr_write_1(struct aue_softc *, int, int);
+static int aue_csr_read_2(struct aue_softc *, int);
+static int aue_csr_write_2(struct aue_softc *, int, int);
 
 #define AUE_SETBIT(sc, reg, x)                         \
        aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
@@ -260,14 +276,17 @@
 #define AUE_CLRBIT(sc, reg, x)                         \
        aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
 
-Static int
+static int
 aue_csr_read_1(struct aue_softc *sc, int reg)
 {
+       struct usbnet * const   un = &sc->aue_un;
        usb_device_request_t    req;
        usbd_status             err;
        uByte                   val = 0;
 
-       if (sc->aue_dying)
+       usbnet_isowned_mii(un);
+
+       if (usbnet_isdying(un))
                return 0;
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
@@ -276,25 +295,29 @@
        USETW(req.wIndex, reg);
        USETW(req.wLength, 1);
 
-       err = usbd_do_request(sc->aue_udev, &req, &val);
+       err = usbd_do_request(un->un_udev, &req, &val);
 
        if (err) {
-               DPRINTF(("%s: aue_csr_read_1: reg=0x%x err=%s\n",
-                   device_xname(sc->aue_dev), reg, usbd_errstr(err)));
+               AUEHIST_FUNC();
+               AUEHIST_CALLARGS("%d: aue_csr_read_1: reg=%#x err=%d",
+                   device_unit(un->un_dev), reg, err, 0);
                return 0;
        }
 
        return val;
 }
 
-Static int
+static int
 aue_csr_read_2(struct aue_softc *sc, int reg)
 {
+       struct usbnet * const   un = &sc->aue_un;
        usb_device_request_t    req;
        usbd_status             err;
        uWord                   val;
 
-       if (sc->aue_dying)
+       usbnet_isowned_mii(un);
+
+       if (usbnet_isdying(un))
                return 0;
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
@@ -303,25 +326,29 @@
        USETW(req.wIndex, reg);
        USETW(req.wLength, 2);
 
-       err = usbd_do_request(sc->aue_udev, &req, &val);
+       err = usbd_do_request(un->un_udev, &req, &val);
 
        if (err) {
-               DPRINTF(("%s: aue_csr_read_2: reg=0x%x err=%s\n",
-                   device_xname(sc->aue_dev), reg, usbd_errstr(err)));
+               AUEHIST_FUNC();
+               AUEHIST_CALLARGS("%d: aue_csr_read_2: reg=%#x err=%d",
+                   device_unit(un->un_dev), reg, err, 0);
                return 0;
        }
 
        return UGETW(val);
 }
 
-Static int
+static int
 aue_csr_write_1(struct aue_softc *sc, int reg, int aval)



Home | Main Index | Thread Index | Old Index