tech-net archive

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

usbnet and devices without MII



I have a couple of questions about usbnet.

1) Comments about devices without MII in usbnet.h
  Should the devices _without_ MII set the have_mii of usbnet_attach_ifp()
or not?
As far as I read the usbnet.c the comments in usbnet.h should be:

--- src/sys/dev/usb/usbnet.h.orig	2019-08-07 08:32:16.523347871 +0000
+++ src/sys/dev/usb/usbnet.h	2019-08-08 22:38:42.533018662 +0000
@@ -167,9 +167,9 @@ typedef void (*usbnet_intr_cb)(struct us
  * Generic USB ethernet structure.  Use this as ifp->if_softc and
  * set as device_private() in attach.
  *
- * Devices without MII should call usbnet_attach_ifp() with have_mii set
+ * Devices with MII should call usbnet_attach_ifp() with have_mii set
  * to true, and should ensure that the un_statchg_cb callback sets the
- * un_link member.  Devices without MII have this forced to true.
+ * un_link member.  Devices without MII have this forced to false.
  */
 struct usbnet {
 	void			*un_sc;			/* real softc */

2) un_link for devices without MII
  AFAIU usbnet.c, usbnet.c always sets un_link to true for devices without MII.
In that case once un_link is cleared in usbnet_stop(), it's never set to true.
Should usbnet_stop() clear un_link only when have_mii is true?
  Unfortunatelly, struct usbnet does not have have_mii.
We should add have_mii member to struct usbnet (and bump kernel revision)
or use another variable as have_mii.
My patch abuses un_ec.ec_mii as have_mii.

--- src/sys/dev/usb/usbnet.c	2019-08-06 02:12:27.461843698 +0000
+++ src/sys/dev/usb/usbnet.c	2019-08-06 06:45:50.126613779 +0000
@@ -863,7 +863,9 @@ usbnet_stop(struct usbnet *un, struct if
 	un->un_timer = 0;
 
 	callout_stop(&un->un_stat_ch);
-	un->un_link = false;
+	/* XXX have_mii */
+	if (usbnet_mii(un) != NULL)
+		un->un_link = false;
 
 	/* Stop transfers. */
 	usbnet_ep_stop_pipes(un);


Thanks.


Home | Main Index | Thread Index | Old Index