Module Name:    src
Committed By:   mrg
Date:           Thu Aug 15 05:52:23 UTC 2019

Modified Files:
        src/sys/dev/usb: if_axe.c if_axen.c if_cdce.c if_smsc.c if_udav.c
            if_ure.c if_urndis.c usbnet.c usbnet.h
        src/sys/sys: param.h

Log Message:
- usbnet_rx_loop_cb's usbd_xfer parameter is never used and available
  in the usbnet_chain if needed.  remove it
- usbnet media status change already set link to false, don't repeat
  this in every driver
- don't clear link in stop, nothing was re-enabling it for non-MII
- add optional uno_tick_cb(struct usbnet *un) that is called from the
  usbnet tick timer
- remove wrong debug sysctl prototype

rx_loop and timer are kernel versions changes, but hopefully this is
the last one for usbnet.  working with 3 more drivers now (cue, mue
and url), leaving only aue, kue, upl and umb undone (aue may work
with previously supported devices, mine doesn't work with our driver,
kue and upl have patches for testing and umb is undone.)


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/usb/if_cdce.c
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/usb/if_smsc.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/usb/if_udav.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/usb/if_urndis.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/usb/usbnet.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/usbnet.h
cvs rdiff -u -r1.607 -r1.608 src/sys/sys/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.114 src/sys/dev/usb/if_axe.c:1.115
--- src/sys/dev/usb/if_axe.c:1.114	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_axe.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.114 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.115 2019/08/15 05:52:23 mrg Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.114 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.115 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -262,8 +262,7 @@ static int	axe_init(struct ifnet *);
 static usbd_status axe_mii_read_reg(struct usbnet *, int, int, uint16_t *);
 static usbd_status axe_mii_write_reg(struct usbnet *, int, int, uint16_t);
 static void	axe_mii_statchg(struct ifnet *);
-static void	axe_rx_loop(struct usbnet *, struct usbd_xfer *,
-			    struct usbnet_chain *, uint32_t);
+static void	axe_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned axe_tx_prepare(struct usbnet *, struct mbuf *,
 			       struct usbnet_chain *);
 
@@ -380,7 +379,6 @@ axe_mii_statchg(struct ifnet *ifp)
 		return;
 
 	val = 0;
-	usbnet_set_link(un, false);
 	if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) {
 		val |= AXE_MEDIA_FULL_DUPLEX;
 		if (AXE_IS_178_FAMILY(un)) {
@@ -1010,8 +1008,7 @@ axe_attach(device_t parent, device_t sel
 }
 
 static void
-axe_rx_loop(struct usbnet * un, struct usbd_xfer *xfer,
-	    struct usbnet_chain *c, uint32_t total_len)
+axe_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len)
 {
 	AXEHIST_FUNC(); AXEHIST_CALLED();
 	struct axe_softc * const sc = usbnet_softc(un);

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.63 src/sys/dev/usb/if_axen.c:1.64
--- src/sys/dev/usb/if_axen.c:1.63	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_axen.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.63 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.64 2019/08/15 05:52:23 mrg Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.63 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.64 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -83,8 +83,7 @@ static int	axen_ioctl_cb(struct ifnet *,
 static usbd_status axen_mii_read_reg(struct usbnet *, int, int, uint16_t *);
 static usbd_status axen_mii_write_reg(struct usbnet *, int, int, uint16_t);
 static void	axen_mii_statchg(struct ifnet *);
-static void	axen_rxeof_loop(struct usbnet *, struct usbd_xfer *,
-		    struct usbnet_chain *, uint32_t);
+static void	axen_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned	axen_tx_prepare(struct usbnet *, struct mbuf *,
 			        struct usbnet_chain *);
 static int	axen_init(struct ifnet *);
@@ -96,7 +95,7 @@ static struct usbnet_ops axen_ops = {
 	.uno_write_reg = axen_mii_write_reg,
 	.uno_statchg = axen_mii_statchg,
 	.uno_tx_prepare = axen_tx_prepare,
-	.uno_rx_loop = axen_rxeof_loop,
+	.uno_rx_loop = axen_rx_loop,
 	.uno_init = axen_init,
 };
 
@@ -168,7 +167,6 @@ axen_mii_statchg(struct ifnet *ifp)
 	if (usbnet_isdying(un))
 		return;
 
-	usbnet_set_link(un, false);
 	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
 	    (IFM_ACTIVE | IFM_AVALID)) {
 		switch (IFM_SUBTYPE(mii->mii_media_active)) {
@@ -755,8 +753,7 @@ axen_csum_flags_rx(struct ifnet *ifp, ui
 }
 
 static void
-axen_rxeof_loop(struct usbnet *un, struct usbd_xfer *xfer,
-		struct usbnet_chain *c, uint32_t total_len)
+axen_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
 {
 	struct ifnet *ifp = usbnet_ifp(un);
 	uint8_t *buf = c->unc_buf;

Index: src/sys/dev/usb/if_cdce.c
diff -u src/sys/dev/usb/if_cdce.c:1.65 src/sys/dev/usb/if_cdce.c:1.66
--- src/sys/dev/usb/if_cdce.c:1.65	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_cdce.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cdce.c,v 1.65 2019/08/14 03:44:58 mrg Exp $ */
+/*	$NetBSD: if_cdce.c,v 1.66 2019/08/15 05:52:23 mrg Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wp...@windriver.com>
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.65 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.66 2019/08/15 05:52:23 mrg Exp $");
 
 #include <sys/param.h>
 
@@ -78,8 +78,7 @@ static void	cdce_attach(device_t, device
 CFATTACH_DECL_NEW(cdce, sizeof(struct usbnet), cdce_match, cdce_attach,
     usbnet_detach, usbnet_activate);
 
-static void	cdce_rx_loop(struct usbnet *, struct usbd_xfer *,
-			     struct usbnet_chain *, uint32_t);
+static void	cdce_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned	cdce_tx_prepare(struct usbnet *, struct mbuf *,
 				struct usbnet_chain *);
 static int	cdce_init(struct ifnet *);
@@ -272,8 +271,7 @@ cdce_init(struct ifnet *ifp)
 }
 
 static void
-cdce_rx_loop(struct usbnet * un, struct usbd_xfer *xfer,
-	     struct usbnet_chain *c, uint32_t total_len)
+cdce_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len)
 {
 	struct ifnet		*ifp = usbnet_ifp(un);
 

Index: src/sys/dev/usb/if_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.57 src/sys/dev/usb/if_smsc.c:1.58
--- src/sys/dev/usb/if_smsc.c:1.57	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_smsc.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.57 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.58 2019/08/15 05:52:23 mrg Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.57 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.58 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -190,8 +190,7 @@ usbd_status	 smsc_miibus_writereg(struct
 static int	 smsc_ioctl_cb(struct ifnet *, u_long, void *);
 static unsigned	 smsc_tx_prepare(struct usbnet *, struct mbuf *,
 		     struct usbnet_chain *);
-static void	 smsc_rxeof_loop(struct usbnet *, struct usbd_xfer *,
-		    struct usbnet_chain *, uint32_t);
+static void	 smsc_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 
 static struct usbnet_ops smsc_ops = {
 	.uno_stop = smsc_stop_cb,
@@ -200,7 +199,7 @@ static struct usbnet_ops smsc_ops = {
 	.uno_write_reg = smsc_miibus_writereg,
 	.uno_statchg = smsc_miibus_statchg,
 	.uno_tx_prepare = smsc_tx_prepare,
-	.uno_rx_loop = smsc_rxeof_loop,
+	.uno_rx_loop = smsc_rx_loop,
 	.uno_init = smsc_init,
 };
 
@@ -347,7 +346,6 @@ smsc_miibus_statchg(struct ifnet *ifp)
 	uint32_t flow;
 	uint32_t afc_cfg;
 
-	usbnet_set_link(un, false);
 	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
 	    (IFM_ACTIVE | IFM_AVALID)) {
 		switch (IFM_SUBTYPE(mii->mii_media_active)) {
@@ -938,8 +936,7 @@ smsc_attach(device_t parent, device_t se
 }
 
 void
-smsc_rxeof_loop(struct usbnet * un, struct usbd_xfer *xfer,
-    struct usbnet_chain *c, uint32_t total_len)
+smsc_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len)
 {
 	USMSCHIST_FUNC(); USMSCHIST_CALLED();
 	struct smsc_softc * const sc = usbnet_softc(un);

Index: src/sys/dev/usb/if_udav.c
diff -u src/sys/dev/usb/if_udav.c:1.67 src/sys/dev/usb/if_udav.c:1.68
--- src/sys/dev/usb/if_udav.c:1.67	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_udav.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_udav.c,v 1.67 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: if_udav.c,v 1.68 2019/08/15 05:52:23 mrg Exp $	*/
 /*	$nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.67 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.68 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -67,8 +67,7 @@ static void udav_chip_init(struct usbnet
 
 static unsigned udav_tx_prepare(struct usbnet *, struct mbuf *,
 			        struct usbnet_chain *);
-static void udav_rxeof_loop(struct usbnet *, struct usbd_xfer *,
-			    struct usbnet_chain *, uint32_t);
+static void udav_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static void udav_stop_cb(struct ifnet *, int);
 static int udav_ioctl_cb(struct ifnet *, u_long, void *);
 static usbd_status udav_mii_read_reg(struct usbnet *, int, int, uint16_t *);
@@ -139,7 +138,7 @@ static struct usbnet_ops udav_ops = {
 	.uno_write_reg = udav_mii_write_reg,
 	.uno_statchg = udav_mii_statchg,
 	.uno_tx_prepare = udav_tx_prepare,
-	.uno_rx_loop = udav_rxeof_loop,
+	.uno_rx_loop = udav_rx_loop,
 	.uno_init = udav_init,
 };
 
@@ -252,8 +251,6 @@ udav_attach(device_t parent, device_t se
 	}
 
 	bool have_mii = !ISSET(un->un_flags, UDAV_NO_PHY);
-	if (!have_mii)
-		usbnet_set_link(un, true);
 
 	/* initialize interface information */
 	usbnet_attach_ifp(un, have_mii,
@@ -688,8 +685,7 @@ udav_tx_prepare(struct usbnet *un, struc
 }
 
 static void
-udav_rxeof_loop(struct usbnet *un, struct usbd_xfer *xfer,
-	        struct usbnet_chain *c, uint32_t total_len)
+udav_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
 {
 	struct ifnet *ifp = usbnet_ifp(un);
 	uint8_t *buf = c->unc_buf;
@@ -863,7 +859,6 @@ udav_mii_statchg(struct ifnet *ifp)
 	if (usbnet_isdying(un))
 		return;
 
-	usbnet_set_link(un, false);
 	if (mii->mii_media_status & IFM_ACTIVE &&
 	    IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
 		DPRINTF(("%s: %s: got link\n",

Index: src/sys/dev/usb/if_ure.c
diff -u src/sys/dev/usb/if_ure.c:1.26 src/sys/dev/usb/if_ure.c:1.27
--- src/sys/dev/usb/if_ure.c:1.26	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_ure.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ure.c,v 1.26 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: if_ure.c,v 1.27 2019/08/15 05:52:23 mrg Exp $	*/
 /*	$OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $	*/
 
 /*-
@@ -30,7 +30,7 @@
 /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.26 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.27 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -88,8 +88,7 @@ static usbd_status ure_mii_write_reg(str
 static void	ure_miibus_statchg(struct ifnet *);
 static unsigned ure_tx_prepare(struct usbnet *, struct mbuf *,
 			       struct usbnet_chain *);
-static void	ure_rxeof_loop(struct usbnet *, struct usbd_xfer *,
-			       struct usbnet_chain *, uint32_t);
+static void	ure_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static int	ure_init(struct ifnet *);
 
 static int	ure_match(device_t, cfdata_t, void *);
@@ -105,7 +104,7 @@ static struct usbnet_ops ure_ops = {
 	.uno_write_reg = ure_mii_write_reg,
 	.uno_statchg = ure_miibus_statchg,
 	.uno_tx_prepare = ure_tx_prepare,
-	.uno_rx_loop = ure_rxeof_loop,
+	.uno_rx_loop = ure_rx_loop,
 	.uno_init = ure_init,
 };
 
@@ -300,7 +299,6 @@ ure_miibus_statchg(struct ifnet *ifp)
 	if (usbnet_isdying(un))
 		return;
 
-	usbnet_set_link(un, false);
 	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
 	    (IFM_ACTIVE | IFM_AVALID)) {
 		switch (IFM_SUBTYPE(mii->mii_media_active)) {
@@ -968,8 +966,7 @@ ure_attach(device_t parent, device_t sel
 }
 
 static void
-ure_rxeof_loop(struct usbnet *un, struct usbd_xfer *xfer,
-	       struct usbnet_chain *c, uint32_t total_len)
+ure_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
 {
 	struct ifnet *ifp = usbnet_ifp(un);
 	uint8_t *buf = c->unc_buf;

Index: src/sys/dev/usb/if_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.30 src/sys/dev/usb/if_urndis.c:1.31
--- src/sys/dev/usb/if_urndis.c:1.30	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/if_urndis.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.30 2019/08/14 03:44:58 mrg Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.31 2019/08/15 05:52:23 mrg Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.30 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.31 2019/08/15 05:52:23 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -67,8 +67,7 @@ static void urndis_watchdog(struct ifnet
 #endif
 
 static int urndis_init(struct ifnet *);
-static void urndis_rx_loop(struct usbnet *, struct usbd_xfer *,
-			   struct usbnet_chain *, uint32_t);
+static void urndis_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned urndis_tx_prepare(struct usbnet *, struct mbuf *,
 				  struct usbnet_chain *);
 
@@ -747,8 +746,7 @@ urndis_tx_prepare(struct usbnet *un, str
 }
 
 static void
-urndis_rx_loop(struct usbnet * un, struct usbd_xfer *xfer,
-	       struct usbnet_chain *c, uint32_t total_len)
+urndis_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len)
 {
 	struct rndis_packet_msg	*msg;
 	struct ifnet		*ifp = usbnet_ifp(un);

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.14 src/sys/dev/usb/usbnet.c:1.15
--- src/sys/dev/usb/usbnet.c:1.14	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/usbnet.c	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.14 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.15 2019/08/15 05:52:23 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.14 2019/08/14 03:44:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.15 2019/08/15 05:52:23 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -100,8 +100,6 @@ static int usbnet_modcmd(modcmd_t, void 
 #else
 static int usbnetdebug = 1;
 
-int     sysctl_hw_usbnet_setup(SYSCTLFN_PROTO);
-
 SYSCTL_SETUP(sysctl_hw_usbnet_setup, "sysctl hw.usbnet setup")
 {
 	int err;
@@ -191,10 +189,16 @@ uno_tx_prepare(struct usbnet *un, struct
 }
 
 static void
-uno_rx_loop(struct usbnet *un, struct usbd_xfer *xfer,
-	    struct usbnet_chain *c, uint32_t total_len)
+uno_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
+{
+	(*un->un_ops->uno_rx_loop)(un, c, total_len);
+}
+
+static void
+uno_tick(struct usbnet *un)
 {
-	(*un->un_ops->uno_rx_loop)(un, xfer, c, total_len);
+	if (un->un_ops->uno_tick)
+		(*un->un_ops->uno_tick)(un);
 }
 
 static void
@@ -323,7 +327,7 @@ usbnet_rxeof(struct usbd_xfer *xfer, voi
 		goto done;
 	}
 
-	uno_rx_loop(un, xfer, c, total_len);
+	uno_rx_loop(un, c, total_len);
 	usbnet_isowned_rx(un);
 
 done:
@@ -392,7 +396,6 @@ usbnet_txeof(struct usbd_xfer *xfer, voi
 static void
 usbnet_pipe_intr(struct usbd_xfer *xfer, void *priv, usbd_status status)
 {
-	USBNETHIST_FUNC(); USBNETHIST_CALLED();
 	struct usbnet * const un = priv;
 	struct usbnet_private * const unp = un->un_pri;
 	struct usbnet_intr * const uni = un->un_intr;
@@ -430,8 +433,11 @@ usbnet_start_locked(struct ifnet *ifp)
 	usbnet_isowned_tx(un);
 	KASSERT(cd->uncd_tx_cnt <= un->un_tx_list_cnt);
 
-	if (!unp->unp_link || (ifp->if_flags & IFF_RUNNING) == 0)
+	if (!unp->unp_link || (ifp->if_flags & IFF_RUNNING) == 0) {
+		DPRINTF("start called no link (%x) or running (flags %x)",
+		    unp->unp_link, ifp->if_flags, 0, 0);
 		return;
+	}
 
 	idx = cd->uncd_tx_prod;
 	while (cd->uncd_tx_cnt < un->un_tx_list_cnt) {
@@ -1015,7 +1021,6 @@ usbnet_stop(struct usbnet *un, struct if
 	unp->unp_timer = 0;
 
 	callout_stop(&unp->unp_stat_ch);
-	unp->unp_link = false;
 
 	/* Stop transfers. */
 	usbnet_ep_stop_pipes(un);
@@ -1111,6 +1116,9 @@ usbnet_tick_task(void *arg)
 			(*mii->mii_statchg)(ifp);
 	}
 
+	/* Call driver if requested. */
+	uno_tick(un);
+
 	mutex_enter(&unp->unp_lock);
 	if (--unp->unp_refcnt < 0)
 		cv_broadcast(&unp->unp_detachcv);

Index: src/sys/dev/usb/usbnet.h
diff -u src/sys/dev/usb/usbnet.h:1.11 src/sys/dev/usb/usbnet.h:1.12
--- src/sys/dev/usb/usbnet.h:1.11	Wed Aug 14 03:44:58 2019
+++ src/sys/dev/usb/usbnet.h	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.h,v 1.11 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: usbnet.h,v 1.12 2019/08/15 05:52:23 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -76,6 +76,9 @@
  *     transmit queue and use the send callback for the given mbuf.
  *     the usb callback will use usbnet_txeof() for the transmit
  *     completion function (internal to usbnet)
+ *   - there is special interrupt pipe handling
+ * - timer/tick:
+ *   - the uno_tick callback will be called once a second if present.
  */
 
 #include <sys/device.h>
@@ -146,8 +149,10 @@ typedef void (*usbnet_mii_statchg_cb)(st
 typedef unsigned (*usbnet_tx_prepare_cb)(struct usbnet *, struct mbuf *,
 					 struct usbnet_chain *);
 /* Receive some packets callback. */
-typedef void (*usbnet_rx_loop_cb)(struct usbnet *, struct usbd_xfer *,
-			          struct usbnet_chain *, uint32_t);
+typedef void (*usbnet_rx_loop_cb)(struct usbnet *, struct usbnet_chain *,
+				  uint32_t);
+/* Tick callback. */
+typedef void (*usbnet_tick_cb)(struct usbnet *);
 /* Interrupt pipe callback. */
 typedef void (*usbnet_intr_cb)(struct usbnet *, usbd_status);
 
@@ -161,6 +166,7 @@ struct usbnet_ops {
 	usbnet_mii_statchg_cb	uno_statchg;
 	usbnet_tx_prepare_cb	uno_tx_prepare;
 	usbnet_rx_loop_cb	uno_rx_loop;
+	usbnet_tick_cb		uno_tick;
 	usbnet_intr_cb		uno_intr;
 };
 

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.607 src/sys/sys/param.h:1.608
--- src/sys/sys/param.h:1.607	Wed Aug 14 03:44:58 2019
+++ src/sys/sys/param.h	Thu Aug 15 05:52:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.607 2019/08/14 03:44:58 mrg Exp $	*/
+/*	$NetBSD: param.h,v 1.608 2019/08/15 05:52:23 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999000800	/* NetBSD 9.99.8 */
+#define	__NetBSD_Version__	999000900	/* NetBSD 9.99.9 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

Reply via email to