Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Update if_axe for additional chips and models. ...



details:   https://anonhg.NetBSD.org/src/rev/1d0ca88dcf61
branches:  trunk
changeset: 755820:1d0ca88dcf61
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Jun 23 19:00:26 2010 +0000

description:
Update if_axe for additional chips and models.  Mostly imported from
OpenBSD, with significant contribution from FUKAUMI Naoki.

Also addresses PR kern/40456

diffstat:

 sys/dev/usb/if_axe.c    |  944 +++++++++++++++++++++++++++++------------------
 sys/dev/usb/if_axereg.h |   96 +++-
 2 files changed, 640 insertions(+), 400 deletions(-)

diffs (truncated from 1743 to 300 lines):

diff -r 32d7555bc86f -r 1d0ca88dcf61 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Wed Jun 23 18:07:59 2010 +0000
+++ b/sys/dev/usb/if_axe.c      Wed Jun 23 19:00:26 2010 +0000
@@ -1,4 +1,21 @@
-/*     $NetBSD: if_axe.c,v 1.34 2010/06/23 06:25:17 pgoyette Exp $     */
+/*     $NetBSD: if_axe.c,v 1.35 2010/06/23 19:00:26 pgoyette Exp $     */
+/*     $OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg%openbsd.org@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003
@@ -38,7 +55,6 @@
  *
  * Manuals available from:
  * http://www.asix.com.tw/datasheet/mac/Ax88172.PDF
- * (also http://people.freebsd.org/~wpaul/ASIX/Ax88172.PDF)
  * Note: you need the manual for the AX88170 chip (USB 1.x ethernet
  * controller) to find the definitions for the RX control register.
  * http://www.asix.com.tw/datasheet/mac/Ax88170.PDF
@@ -73,7 +89,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.34 2010/06/23 06:25:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.35 2010/06/23 19:00:26 pgoyette Exp $");
 
 #if defined(__NetBSD__)
 #include "opt_inet.h"
@@ -82,60 +98,38 @@
 
 
 #include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mutex.h>
-#include <sys/mbuf.h>
+#include <sys/bus.h>
+#include <sys/device.h>
 #include <sys/kernel.h>
-#if defined(__OpenBSD__)
-#include <sys/proc.h>
-#endif
+#include <sys/mbuf.h>
+#include <sys/mutex.h>
 #include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/systm.h>
 
-#include <sys/device.h>
 #if NRND > 0
 #include <sys/rnd.h>
 #endif
 
 #include <net/if.h>
-#if defined(__NetBSD__)
-#include <net/if_arp.h>
-#endif
 #include <net/if_dl.h>
+#include <net/if_ether.h>
 #include <net/if_media.h>
 
 #include <net/bpf.h>
 
-#if defined(__NetBSD__)
-#include <net/if_ether.h>
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/if_inarp.h>
-#endif
-#endif /* defined(__NetBSD__) */
-
-#if defined(__OpenBSD__)
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#endif
-#endif /* defined(__OpenBSD__) */
-
-
 #include <dev/mii/mii.h>
 #include <dev/mii/miivar.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
 #include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdivar.h>
 #include <dev/usb/usbdevs.h>
 
 #include <dev/usb/if_axereg.h>
 
-#ifdef AXE_DEBUG
+#ifdef AXE_DEBUG
 #define DPRINTF(x)     do { if (axedebug) logprintf x; } while (0)
 #define DPRINTFN(n,x)  do { if (axedebug >= (n)) logprintf x; } while (0)
 int    axedebug = 0;
@@ -147,61 +141,85 @@
 /*
  * Various supported device vendors/products.
  */
-Static const struct axe_type axe_devs[] = {
+static const struct axe_type axe_devs[] = {
+       { { USB_VENDOR_ABOCOM,          USB_PRODUCT_ABOCOM_UFE2000}, 0 },
+       { { USB_VENDOR_ACERCM,          USB_PRODUCT_ACERCM_EP1427X2}, 0 },
+       { { USB_VENDOR_APPLE,           USB_PRODUCT_APPLE_ETHERNET }, AX772 },
        { { USB_VENDOR_ASIX,            USB_PRODUCT_ASIX_AX88172}, 0 },
+       { { USB_VENDOR_ASIX,            USB_PRODUCT_ASIX_AX88772}, AX772 },
+       { { USB_VENDOR_ASIX,            USB_PRODUCT_ASIX_AX88772A}, AX772 },
+       { { USB_VENDOR_ASIX,            USB_PRODUCT_ASIX_AX88178}, AX178 },
+       { { USB_VENDOR_ATEN,            USB_PRODUCT_ATEN_UC210T}, 0 },
+       { { USB_VENDOR_BELKIN,          USB_PRODUCT_BELKIN_F5D5055 }, AX178 },
+       { { USB_VENDOR_BILLIONTON,      USB_PRODUCT_BILLIONTON_USB2AR}, 0},
+       { { USB_VENDOR_CISCOLINKSYS,    USB_PRODUCT_CISCOLINKSYS_USB200MV2}, AX772 },
        { { USB_VENDOR_COREGA,          USB_PRODUCT_COREGA_FETHER_USB2_TX }, 0},
        { { USB_VENDOR_DLINK,           USB_PRODUCT_DLINK_DUBE100}, 0 },
+       { { USB_VENDOR_DLINK,           USB_PRODUCT_DLINK_DUBE100B1 }, AX772 },
+       { { USB_VENDOR_GOODWAY,         USB_PRODUCT_GOODWAY_GWUSB2E}, 0 },
+       { { USB_VENDOR_IODATA,          USB_PRODUCT_IODATA_ETGUS2 }, AX178 },
+       { { USB_VENDOR_JVC,             USB_PRODUCT_JVC_MP_PRX1}, 0 },
        { { USB_VENDOR_LINKSYS2,        USB_PRODUCT_LINKSYS2_USB200M}, 0 },
+       { { USB_VENDOR_LINKSYS4,        USB_PRODUCT_LINKSYS4_USB1000 }, AX178 },
+       { { USB_VENDOR_LOGITEC,         USB_PRODUCT_LOGITEC_LAN_GTJU2}, AX178 },
+       { { USB_VENDOR_MELCO,           USB_PRODUCT_MELCO_LUAU2GT}, AX178 },
        { { USB_VENDOR_MELCO,           USB_PRODUCT_MELCO_LUAU2KTX}, 0 },
+       { { USB_VENDOR_MSI,             USB_PRODUCT_MSI_AX88772A}, AX772 },
        { { USB_VENDOR_NETGEAR,         USB_PRODUCT_NETGEAR_FA120}, 0 },
+       { { USB_VENDOR_OQO,             USB_PRODUCT_OQO_ETHER01PLUS }, AX772 },
+       { { USB_VENDOR_PLANEX3,         USB_PRODUCT_PLANEX3_GU1000T }, AX178 },
+       { { USB_VENDOR_SYSTEMTALKS,     USB_PRODUCT_SYSTEMTALKS_SGCX2UL}, 0 },
        { { USB_VENDOR_SITECOM,         USB_PRODUCT_SITECOM_LN029}, 0 },
-       { { USB_VENDOR_SYSTEMTALKS,     USB_PRODUCT_SYSTEMTALKS_SGCX2UL}, 0 },
+       { { USB_VENDOR_SITECOMEU,       USB_PRODUCT_SITECOMEU_LN028 }, AX178 }
 };
 #define axe_lookup(v, p) ((const struct axe_type *)usb_lookup(axe_devs, v, p))
 
-int axe_match(device_t, cfdata_t, void *);
-void axe_attach(device_t, device_t, void *);
-int axe_detach(device_t, int);
-int axe_activate(device_t, enum devact);
-extern struct cfdriver axe_cd;
-CFATTACH_DECL_NEW(axe, sizeof(struct axe_softc), axe_match, axe_attach,
-    axe_detach, axe_activate);
+int    axe_match(device_t, cfdata_t, void *);
+void   axe_attach(device_t, device_t, void *);
+int    axe_detach(device_t, int);
+int    axe_activate(device_t, devact_t);
+
+CFATTACH_DECL_NEW(axe, sizeof(struct axe_softc),
+       axe_match, axe_attach, axe_detach, axe_activate);
 
-Static int axe_tx_list_init(struct axe_softc *);
-Static int axe_rx_list_init(struct axe_softc *);
-Static int axe_newbuf(struct axe_softc *, struct axe_chain *, struct mbuf *);
-Static int axe_encap(struct axe_softc *, struct mbuf *, int);
-Static void axe_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
-Static void axe_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
-Static void axe_tick(void *);
-Static void axe_tick_task(void *);
-#if 0
-Static void axe_rxstart(struct ifnet *);
-#endif
-Static void axe_start(struct ifnet *);
-Static int axe_ioctl(struct ifnet *, u_long, void *);
-Static void axe_init(void *);
-Static void axe_stop(struct axe_softc *);
-Static void axe_watchdog(struct ifnet *);
-Static int axe_miibus_readreg(device_t, int, int);
-Static void axe_miibus_writereg(device_t, int, int, int);
-Static void axe_miibus_statchg(device_t);
-Static int axe_cmd(struct axe_softc *, int, int, int, void *);
-Static void axe_reset(struct axe_softc *sc);
+static int     axe_tx_list_init(struct axe_softc *);
+static int     axe_rx_list_init(struct axe_softc *);
+static int     axe_newbuf(struct axe_softc *, struct axe_chain *,
+                   struct mbuf *);
+static int     axe_encap(struct axe_softc *, struct mbuf *, int);
+static void    axe_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
+static void    axe_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
+static void    axe_tick(void *);
+static void    axe_tick_task(void *);
+static void    axe_start(struct ifnet *);
+static int     axe_ioctl(struct ifnet *, u_long, void *);
+static int     axe_init(struct ifnet *);
+static void    axe_stop(struct ifnet *, int);
+static void    axe_watchdog(struct ifnet *);
+static int     axe_miibus_readreg(device_t, int, int);
+static void    axe_miibus_writereg(device_t, int, int, int);
+static void    axe_miibus_statchg(device_t);
+static int     axe_cmd(struct axe_softc *, int, int, int, void *);
+static void    axe_reset(struct axe_softc *sc);
+static int     axe_ifmedia_upd(struct ifnet *);
+static void    axe_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
-Static void axe_setmulti(struct axe_softc *);
-Static void axe_lock_mii(struct axe_softc *sc);
-Static void axe_unlock_mii(struct axe_softc *sc);
+static void    axe_setmulti(struct axe_softc *);
+static void    axe_lock_mii(struct axe_softc *sc);
+static void    axe_unlock_mii(struct axe_softc *sc);
+
+static void    axe_ax88178_init(struct axe_softc *);
+static void    axe_ax88772_init(struct axe_softc *);
 
 /* Get exclusive access to the MII registers */
-Static void
+static void
 axe_lock_mii(struct axe_softc *sc)
 {
        sc->axe_refcnt++;
        mutex_enter(&sc->axe_mii_lock);
 }
 
-Static void
+static void
 axe_unlock_mii(struct axe_softc *sc)
 {
        mutex_exit(&sc->axe_mii_lock);
@@ -209,7 +227,7 @@
                usb_detach_wakeup((sc->axe_dev));
 }
 
-Static int
+static int
 axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf)
 {
        usb_device_request_t    req;
@@ -218,7 +236,7 @@
        KASSERT(mutex_owned(&sc->axe_mii_lock));
 
        if (sc->axe_dying)
-               return(0);
+               return 0;
 
        if (AXE_CMD_DIR(cmd))
                req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
@@ -231,13 +249,14 @@
 
        err = usbd_do_request(sc->axe_udev, &req, buf);
 
-       if (err)
-               return(-1);
-
-       return(0);
+       if (err) {
+               DPRINTF(("axe_cmd err: cmd %d err %d\n", cmd, err));
+               return -1;
+       }
+       return 0;
 }
 
-Static int
+static int
 axe_miibus_readreg(device_t dev, int phy, int reg)
 {
        struct axe_softc *sc = device_private(dev);
@@ -246,47 +265,45 @@
 
        if (sc->axe_dying) {
                DPRINTF(("axe: dying\n"));
-               return(0);
+               return 0;
        }
 
-#ifdef notdef
        /*
         * The chip tells us the MII address of any supported
         * PHYs attached to the chip, so only read from those.
+        *
+        * But if the chip lies about its PHYs, read from any.
         */
-
-       if (sc->axe_phyaddrs[0] != AXE_NOPHY && phy != sc->axe_phyaddrs[0])
-               return (0);
-
-       if (sc->axe_phyaddrs[1] != AXE_NOPHY && phy != sc->axe_phyaddrs[1])
-               return (0);
-#endif
-       if (sc->axe_phyaddrs[0] != 0xFF && sc->axe_phyaddrs[0] != phy)
-               return (0);
-
        val = 0;
 
-       axe_lock_mii(sc);



Home | Main Index | Thread Index | Old Index