From: Sascha Wildner Date: Mon, 3 Nov 2014 10:38:48 +0000 (+0100) Subject: usb4bsd/if_mos: Sync with FreeBSD. X-Git-Tag: v4.2.0rc~1551 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/f85771991983a11fe47770088cd3a413871bdab0 usb4bsd/if_mos: Sync with FreeBSD. --- diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 4ed69d3893..f391e94116 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -2769,6 +2769,7 @@ TO_REMOVE+=/usr/share/man/man5/usbd.conf.5.gz TO_REMOVE+=/usr/share/man/man8/usbd.8.gz TO_REMOVE+=/usr/share/man/man8/usbdevs.8.gz .else +TO_REMOVE+=/boot/kernel/if_mos.ko TO_REMOVE+=/boot/kernel/if_rum.ko TO_REMOVE+=/boot/kernel/if_run.ko TO_REMOVE+=/boot/kernel/if_udav.ko @@ -3030,11 +3031,13 @@ TO_REMOVE+=/usr/share/man/cat3/usb_set_altinterface.3.gz TO_REMOVE+=/usr/share/man/cat3/usb_set_configuration.3.gz TO_REMOVE+=/usr/share/man/cat3/usb_set_debug.3.gz TO_REMOVE+=/usr/share/man/cat3/usb_strerror.3.gz +TO_REMOVE+=/usr/share/man/cat4/if_mos.4.gz TO_REMOVE+=/usr/share/man/cat4/if_rum.4.gz TO_REMOVE+=/usr/share/man/cat4/if_run.4.gz TO_REMOVE+=/usr/share/man/cat4/if_udav.4.gz TO_REMOVE+=/usr/share/man/cat4/if_urndis.4.gz TO_REMOVE+=/usr/share/man/cat4/if_urtwn.4.gz +TO_REMOVE+=/usr/share/man/cat4/mos.4.gz TO_REMOVE+=/usr/share/man/cat4/rum.4.gz TO_REMOVE+=/usr/share/man/cat4/run.4.gz TO_REMOVE+=/usr/share/man/cat4/runfw.4.gz @@ -3243,11 +3246,13 @@ TO_REMOVE+=/usr/share/man/man3/usb_set_altinterface.3.gz TO_REMOVE+=/usr/share/man/man3/usb_set_configuration.3.gz TO_REMOVE+=/usr/share/man/man3/usb_set_debug.3.gz TO_REMOVE+=/usr/share/man/man3/usb_strerror.3.gz +TO_REMOVE+=/usr/share/man/man4/if_mos.4.gz TO_REMOVE+=/usr/share/man/man4/if_rum.4.gz TO_REMOVE+=/usr/share/man/man4/if_run.4.gz TO_REMOVE+=/usr/share/man/man4/if_udav.4.gz TO_REMOVE+=/usr/share/man/man4/if_urndis.4.gz TO_REMOVE+=/usr/share/man/man4/if_urtwn.4.gz +TO_REMOVE+=/usr/share/man/man4/mos.4.gz TO_REMOVE+=/usr/share/man/man4/rum.4.gz TO_REMOVE+=/usr/share/man/man4/run.4.gz TO_REMOVE+=/usr/share/man/man4/runfw.4.gz diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 6d6cfed08c..c27aa4f7f9 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -532,7 +532,9 @@ MLINKS+=xe.4 if_xe.4 MLINKS+=xl.4 if_xl.4 .if !defined(WANT_OLDUSB) -MAN+= rum.4 \ +MAN+= \ + mos.4 \ + rum.4 \ run.4 \ runfw.4 \ ubser.4 \ @@ -551,6 +553,7 @@ MAN+= rum.4 \ usfs.4 \ u3g.4 \ xhci.4 +MLINKS+=mos.4 if_mos.4 MLINKS+=rum.4 if_rum.4 MLINKS+=run.4 if_run.4 MLINKS+=udav.4 if_udav.4 diff --git a/share/man/man4/mos.4 b/share/man/man4/mos.4 new file mode 100644 index 0000000000..7970d65b41 --- /dev/null +++ b/share/man/man4/mos.4 @@ -0,0 +1,98 @@ +.\" +.\" Copyright (c) 2011 Rick van der Zwet +.\" +.\" 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. +.\" +.\" $FreeBSD: head/share/man/man4/mos.4 233648 2012-03-29 05:02:12Z eadler $ +.\" +.Dd November 3, 2014 +.Dt MOS 4 +.Os +.Sh NAME +.Nm mos +.Nd Moschip MCS7730/MCS7830/MCS7832 USB Ethernet driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device uhci" +.Cd "device ohci" +.Cd "device ehci" +.Cd "device usb" +.Cd "device miibus" +.Cd "device mos" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_mos_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for USB Ethernet adapters based on the +Moschip MCS7730/MCS7830/MCS7832 chipset. +.Pp +The adapters that contain the Moschip MCS7730/MCS7830/MCS7832 chipset +will operate at 100Base-TX and full-duplex. +.Pp +The Moschip contains a 10/100 +Ethernet MAC with MII interface and is designed to work with both +Ethernet and HomePNA transceivers. +Although designed to interface with +100Mbps peripherals, this only works with USB 2.0. The existing USB 1.0 +standard specifies a maximum transfer speed of 12Mbps. +USB 1.0 Users should therefore not expect to actually achieve 100Mbps speeds +with these devices. +.Pp +The Moschip supports a 64-bit multicast hash table, single perfect +filter entry for the station address and promiscuous mode. +Packets are +received and transmitted over separate USB bulk transfer endpoints. +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +.Sh HARDWARE +Adapters supported by the +.Nm +driver include: +.Pp +.Bl -bullet -compact +.It +Sitecom LN030 +.El +.Sh SEE ALSO +.Xr altq 4 , +.Xr arp 4 , +.Xr ifmedia 4 , +.Xr miibus 4 , +.Xr netintro 4 , +.Xr ng_ether 4 , +.Xr ifconfig 8 +.Rs +.%T ADMtek AN986 data sheet +.%O http://www.moschip.com/data/products/MCS7830/Data%20Sheet_7830.pdf +.Re +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 8.2 . +.Sh AUTHORS +The +.Nm +driver was written by +.An Rick van der Zwet Aq Mt info@rickvanderzwet.nl . diff --git a/share/man/man4/usb.4 b/share/man/man4/usb.4 index f062cb8b3a..d3cbdd7e7e 100644 --- a/share/man/man4/usb.4 +++ b/share/man/man4/usb.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD: head/share/man/man4/usb.4 258618 2013-11-26 07:52:40Z lwhsu $ .\" -.Dd July 7, 2014 +.Dd November 3, 2014 .Dt USB 4 .Os .Sh NAME @@ -104,6 +104,8 @@ ASIX Electronics AX88x7x/760 USB Ethernet driver .\"Kawasaki LSI KL5KUSB101B Ethernet driver .\".It Xr lgue 4 .\"USB CDC (communication device class) driver for the LG P-500 smartphone +.It Xr mos 4 +Moschip MCS7730/MCS7830/MCS7832 USB Ethernet driver .\".It Xr rue 4 .\"RealTek RTL8150 Ethernet driver .It Xr udav 4 @@ -271,7 +273,7 @@ specifications can be found at: .\".Xr cue 4 , .Xr ehci 4 , .\".Xr kue 4 , -.\".Xr mos 4 , +.Xr mos 4 , .Xr ndis 4 , .Xr ohci 4 , .Xr pci 4 , diff --git a/sys/bus/u4b/net/if_mos.c b/sys/bus/u4b/net/if_mos.c index c021fca0ce..621937c91b 100644 --- a/sys/bus/u4b/net/if_mos.c +++ b/sys/bus/u4b/net/if_mos.c @@ -76,13 +76,12 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: head/sys/dev/usb/net/if_mos.c 271832 2014-09-18 21:09:22Z glebius $ */ -#include -__FBSDID("$FreeBSD$"); - /* - * Moschip MCS7730/MCS7830 USB to Ethernet controller + * Moschip MCS7730/MCS7830/MCS7832 USB to Ethernet controller * The datasheet is available at the following URL: * http://www.moschip.com/data/products/MCS7830/Data%20Sheet_7830.pdf */ @@ -101,6 +100,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -112,6 +112,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include @@ -148,6 +150,7 @@ SYSCTL_INT(_hw_usb_mos, OID_AUTO, debug, CTLFLAG_RW, &mos_debug, 0, static const STRUCT_USB_HOST_ID mos_devs[] = { {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7730, MCS7730)}, {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7830, MCS7830)}, + {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7832, MCS7832)}, {USB_VPI(USB_VENDOR_SITECOMEU, USB_PRODUCT_SITECOMEU_LN030, MCS7830)}, }; @@ -524,6 +527,7 @@ mos_ifmedia_upd(struct ifnet *ifp) struct mos_softc *sc = ifp->if_softc; struct mii_data *mii = GET_MII(sc); struct mii_softc *miisc; + int error; MOS_LOCK_ASSERT(sc); @@ -532,8 +536,8 @@ mos_ifmedia_upd(struct ifnet *ifp) LIST_FOREACH(miisc, &mii->mii_phys, mii_list) mii_phy_reset(miisc); } - mii_mediachg(mii); - return (0); + error = mii_mediachg(mii); + return (error); } /* @@ -712,6 +716,8 @@ mos_attach(device_t dev) MOS_DPRINTFN("model: MCS7730"); } else if (sc->mos_flags & MCS7830) { MOS_DPRINTFN("model: MCS7830"); + } else if (sc->mos_flags & MCS7832) { + MOS_DPRINTFN("model: MCS7832"); } error = uether_ifattach(ue); if (error) { @@ -783,7 +789,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: MOS_DPRINTFN("actlen : %d", actlen); if (actlen <= 1) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto tr_setup; } /* evaluate status byte at the end */ @@ -802,7 +808,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) MOS_DPRINTFN("CRC error"); if (rxstat & MOS_RXSTS_ALIGN_ERROR) MOS_DPRINTFN("alignment error"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto tr_setup; } /* Remember the last byte was used for the status fields */ @@ -811,7 +817,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) MOS_DPRINTFN("error: pktlen %d is smaller " "than ether_header %zd", pktlen, sizeof(struct ether_header)); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto tr_setup; } uether_rxbuf(ue, pc, 0, actlen); @@ -850,7 +856,7 @@ mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: MOS_DPRINTFN("transfer of complete"); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: @@ -877,11 +883,11 @@ tr_setup: usbd_transfer_submit(xfer); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); return; default: MOS_DPRINTFN("usb error on tx: %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); goto tr_setup; @@ -972,7 +978,7 @@ mos_intr_callback(struct usb_xfer *xfer, usb_error_t error) uint32_t pkt; int actlen; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); MOS_DPRINTFN("actlen %i", actlen); diff --git a/sys/bus/u4b/net/if_mosreg.h b/sys/bus/u4b/net/if_mosreg.h index 4aaafb8b54..98d2381f5c 100644 --- a/sys/bus/u4b/net/if_mosreg.h +++ b/sys/bus/u4b/net/if_mosreg.h @@ -152,6 +152,7 @@ #define MCS7730 0x0001 #define MCS7830 0x0002 +#define MCS7832 0x0004 #define MOS_INC(x, y) (x) = (x + 1) % y @@ -172,4 +173,4 @@ struct mos_softc { #define GET_MII(sc) uether_getmii(&(sc)->sc_ue) #define MOS_LOCK(_sc) lockmgr(&(_sc)->sc_lock, LK_EXCLUSIVE) #define MOS_UNLOCK(_sc) lockmgr(&(_sc)->sc_lock, LK_RELEASE) -#define MOS_LOCK_ASSERT(_sc) lockowned(&(_sc)->sc_lock) +#define MOS_LOCK_ASSERT(_sc) KKASSERT(lockowned(&(_sc)->sc_lock)) diff --git a/sys/config/LINT b/sys/config/LINT index a83842c346..4d2f479b21 100644 --- a/sys/config/LINT +++ b/sys/config/LINT @@ -2199,6 +2199,9 @@ device uether # LinkSys USB200M and various other adapters. device axe # +# Moschip MCS7730/MCS7840 USB to fast ethernet. Supports the Sitecom LN030. +device mos +# # Davicom DM9601E USB to fast ethernet. Supports the Corega FEther USB-TXC. device udav diff --git a/sys/config/LINT64 b/sys/config/LINT64 index 2ec1b323f4..499e3aca8a 100644 --- a/sys/config/LINT64 +++ b/sys/config/LINT64 @@ -2030,6 +2030,9 @@ device uether # LinkSys USB200M and various other adapters. device axe # +# Moschip MCS7730/MCS7840 USB to fast ethernet. Supports the Sitecom LN030. +device mos +# # Davicom DM9601E USB to fast ethernet. Supports the Corega FEther USB-TXC. device udav