From owner-svn-src-all@freebsd.org Thu May 24 16:34:07 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD591EF7887; Thu, 24 May 2018 16:34:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E3CB76C43; Thu, 24 May 2018 16:34:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6F5D514B55; Thu, 24 May 2018 16:34:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4OGY6hP070543; Thu, 24 May 2018 16:34:06 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4OGY6cN070542; Thu, 24 May 2018 16:34:06 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201805241634.w4OGY6cN070542@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 24 May 2018 16:34:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334167 - head/sys/dev/usb/net X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/dev/usb/net X-SVN-Commit-Revision: 334167 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2018 16:34:07 -0000 Author: emaste Date: Thu May 24 16:34:06 2018 New Revision: 334167 URL: https://svnweb.freebsd.org/changeset/base/334167 Log: if_muge: Add LAN78xx family USB ids but attach only to LAN7800 This driver was developed for the LAN7800 and the register-compatible LAN7515 and has only been tested on those devices. Adding support for other members of the family should be straightforward, once we have devices to test. With this change the driver will probe but fail to attach due to the Chip ID check, but will leave a hint leading to the driver that needs work. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15537 Modified: head/sys/dev/usb/net/if_muge.c Modified: head/sys/dev/usb/net/if_muge.c ============================================================================== --- head/sys/dev/usb/net/if_muge.c Thu May 24 16:31:18 2018 (r334166) +++ head/sys/dev/usb/net/if_muge.c Thu May 24 16:34:06 2018 (r334167) @@ -122,6 +122,8 @@ SYSCTL_INT(_hw_usb_muge, OID_AUTO, debug, CTLFLAG_RWTU static const struct usb_device_id lan78xx_devs[] = { #define MUGE_DEV(p,i) { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) } MUGE_DEV(LAN7800_ETH, 0), + MUGE_DEV(LAN7801_ETH, 0), + MUGE_DEV(LAN7850_ETH, 0), #undef MUGE_DEV }; @@ -174,7 +176,8 @@ struct muge_softc { uint32_t sc_pfilter_table[MUGE_NUM_PFILTER_ADDRS_][2]; uint32_t sc_flags; -#define MUGE_FLAG_LINK 0x0001 +#define MUGE_FLAG_LINK 0x0001 +#define MUGE_FLAG_INIT_DONE 0x0002 }; #define MUGE_IFACE_IDX 0 @@ -1125,6 +1128,7 @@ lan78xx_chip_init(struct muge_softc *sc) buf |= ETH_FCT_TX_CTL_EN_; err = lan78xx_write_reg(sc, ETH_FCT_RX_CTL, buf); + sc->sc_flags |= MUGE_FLAG_INIT_DONE; return (0); init_failed: @@ -2116,7 +2120,7 @@ muge_attach(device_t dev) muge_config, MUGE_N_TRANSFER, sc, &sc->sc_mtx); if (err) { device_printf(dev, "error: allocating USB transfers failed\n"); - goto detach; + goto err; } ue->ue_sc = sc; @@ -2128,12 +2132,22 @@ muge_attach(device_t dev) err = uether_ifattach(ue); if (err) { device_printf(dev, "error: could not attach interface\n"); - goto detach; + goto err_usbd; } + + /* Wait for lan78xx_chip_init from post-attach callback to complete. */ + uether_ifattach_wait(ue); + if (!(sc->sc_flags & MUGE_FLAG_INIT_DONE)) + goto err_attached; + return (0); -detach: - muge_detach(dev); +err_attached: + uether_ifdetach(ue); +err_usbd: + usbd_transfer_unsetup(sc->sc_xfer, MUGE_N_TRANSFER); +err: + mtx_destroy(&sc->sc_mtx); return (ENXIO); }