Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb - move software parts into if_aue.c.



details:   https://anonhg.NetBSD.org/src/rev/ef779374063f
branches:  trunk
changeset: 1002948:ef779374063f
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Aug 22 09:16:08 2019 +0000

description:
- move software parts into if_aue.c.
- s/Static/static/.

diffstat:

 sys/dev/usb/if_aue.c    |  202 +++++++++++++++++++++++++++++++----------------
 sys/dev/usb/if_auereg.h |   72 +----------------
 2 files changed, 136 insertions(+), 138 deletions(-)

diffs (truncated from 554 to 300 lines):

diff -r f5621ff811b6 -r ef779374063f sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Thu Aug 22 08:32:34 2019 +0000
+++ b/sys/dev/usb/if_aue.c      Thu Aug 22 09:16:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.159 2019/08/22 07:38:06 mrg Exp $ */
+/*     $NetBSD: if_aue.c,v 1.160 2019/08/22 09:16:08 mrg 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.159 2019/08/22 07:38:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.160 2019/08/22 09:16:08 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -168,6 +167,73 @@
 #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 aue_chain {
+       struct aue_softc        *aue_sc;
+       struct usbd_xfer        *aue_xfer;
+       char                    *aue_buf;
+       struct mbuf             *aue_mbuf;
+};
+
+struct aue_cdata {
+       struct aue_chain        aue_tx_chain[AUE_TX_LIST_CNT];
+       struct aue_chain        aue_rx_chain[AUE_RX_LIST_CNT];
+       struct aue_intrpkt      aue_ibuf;
+       int                     aue_tx_prod;
+       int                     aue_tx_cnt;
+};
+
+struct aue_softc {
+       device_t aue_dev;
+
+       struct ethercom         aue_ec;
+       struct mii_data         aue_mii;
+       krndsource_t    rnd_source;
+       struct lwp              *aue_thread;
+       int                     aue_closing;
+       kcondvar_t              aue_domc;
+       kcondvar_t              aue_closemc;
+       kmutex_t                aue_mcmtx;
+#define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
+#define GET_MII(sc) (&(sc)->aue_mii)
+
+       struct callout aue_stat_ch;
+
+       struct usbd_device      *aue_udev;
+       struct usbd_interface   *aue_iface;
+       uint16_t                aue_vendor;
+       uint16_t                aue_product;
+       int                     aue_ed[AUE_ENDPT_MAX];
+       struct usbd_pipe        *aue_ep[AUE_ENDPT_MAX];
+       uint8_t                 aue_link;
+       int                     aue_if_flags;
+       struct aue_cdata        aue_cdata;
+
+       uint16_t                aue_flags;
+
+       int                     aue_refcnt;
+       char                    aue_dying;
+       char                    aue_attached;
+       u_int                   aue_rx_errs;
+       u_int                   aue_intr_errs;
+       struct timeval          aue_rx_notice;
+
+       struct usb_task         aue_tick_task;
+       struct usb_task         aue_stop_task;
+
+       kmutex_t                aue_mii_lock;
+};
+
+#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.
  */
@@ -179,7 +245,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 },
@@ -253,43 +319,43 @@
 CFATTACH_DECL_NEW(aue, sizeof(struct aue_softc), aue_match, aue_attach,
     aue_detach, aue_activate);
 
-Static void aue_multithread(void *);
+static void aue_multithread(void *);
 
-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 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 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 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 void aue_lock_mii(struct aue_softc *);
+static void aue_unlock_mii(struct aue_softc *);
 
-Static void aue_setmulti(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))
@@ -297,7 +363,7 @@
 #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)
 {
        usb_device_request_t    req;
@@ -325,7 +391,7 @@
        return val;
 }
 
-Static int
+static int
 aue_csr_read_2(struct aue_softc *sc, int reg)
 {
        usb_device_request_t    req;
@@ -353,7 +419,7 @@
        return UGETW(val);
 }
 
-Static int
+static int
 aue_csr_write_1(struct aue_softc *sc, int reg, int aval)
 {
        usb_device_request_t    req;
@@ -382,7 +448,7 @@
        return 0;
 }
 
-Static int
+static int
 aue_csr_write_2(struct aue_softc *sc, int reg, int aval)
 {
        usb_device_request_t    req;
@@ -414,7 +480,7 @@
 /*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
-Static int
+static int
 aue_eeprom_getword(struct aue_softc *sc, int addr)
 {
        int             i;
@@ -439,7 +505,7 @@
 /*
  * Read the MAC from the EEPROM.  It's at offset 0.
  */
-Static void
+static void
 aue_read_mac(struct aue_softc *sc, u_char *dest)
 {
        int                     i;
@@ -458,14 +524,14 @@
 }
 
 /* Get exclusive access to the MII registers */
-Static void
+static void
 aue_lock_mii(struct aue_softc *sc)
 {
        sc->aue_refcnt++;
        mutex_enter(&sc->aue_mii_lock);
 }
 
-Static void
+static void
 aue_unlock_mii(struct aue_softc *sc)
 {
        mutex_exit(&sc->aue_mii_lock);
@@ -473,7 +539,7 @@
                usb_detach_wakeupold(sc->aue_dev);
 }
 
-Static int
+static int
 aue_miibus_readreg(device_t dev, int phy, int reg, uint16_t *val)
 {
        struct aue_softc *sc = device_private(dev);
@@ -531,7 +597,7 @@
        return rv;
 }
 
-Static int
+static int
 aue_miibus_writereg(device_t dev, int phy, int reg, uint16_t val)
 {
        struct aue_softc *sc = device_private(dev);
@@ -569,7 +635,7 @@
        return rv;
 }
 
-Static void
+static void
 aue_miibus_statchg(struct ifnet *ifp)
 {
        struct aue_softc *sc = ifp->if_softc;
@@ -611,7 +677,7 @@
 #define AUE_POLY       0xEDB88320
 #define AUE_BITS       6
 
-Static uint32_t
+static uint32_t
 aue_crc(void *addrv)
 {
        uint32_t                idx, bit, data, crc;
@@ -628,7 +694,7 @@
        return crc & ((1 << AUE_BITS) - 1);
 }
 
-Static void
+static void
 aue_setmulti(struct aue_softc *sc)
 {
        struct ethercom         *ec = &sc->aue_ec;



Home | Main Index | Thread Index | Old Index