svn commit: r187977 - user/thompsa/usb/sys/dev/usb2/ethernet

Andrew Thompson thompsa at FreeBSD.org
Sat Jan 31 22:39:41 PST 2009


Author: thompsa
Date: Sun Feb  1 06:39:40 2009
New Revision: 187977
URL: http://svn.freebsd.org/changeset/base/187977

Log:
  Put the ethernet drivers on a further diet, use the built in stall handling and
  remove the clearstall xfers.

Modified:
  user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_auereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_axereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cdce2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cuereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_kuereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_rue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_ruereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_udavreg.h

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c	Sun Feb  1 06:39:40 2009	(r187977)
@@ -178,11 +178,8 @@ static miibus_readreg_t aue_miibus_readr
 static miibus_writereg_t aue_miibus_writereg;
 static miibus_statchg_t aue_miibus_statchg;
 
-static usb2_callback_t aue_intr_clear_stall_callback;
 static usb2_callback_t aue_intr_callback;
-static usb2_callback_t aue_bulk_read_clear_stall_callback;
 static usb2_callback_t aue_bulk_read_callback;
-static usb2_callback_t aue_bulk_write_clear_stall_callback;
 static usb2_callback_t aue_bulk_write_callback;
 
 static uint8_t	aue_csr_read_1(struct aue_softc *, uint16_t);
@@ -204,8 +201,7 @@ static int	aue_ifmedia_upd(struct ifnet 
 static void	aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
 static const struct usb2_config aue_config[AUE_N_TRANSFER] = {
-
-	[AUE_BULK_DT_WR] = {
+	[AUE_BULK_WR] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
@@ -214,8 +210,7 @@ static const struct usb2_config aue_conf
 		.mh.callback = aue_bulk_write_callback,
 		.mh.timeout = 10000,	/* 10 seconds */
 	},
-
-	[AUE_BULK_DT_RD] = {
+	[AUE_BULK_RD] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
@@ -223,29 +218,6 @@ static const struct usb2_config aue_conf
 		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
 		.mh.callback = aue_bulk_read_callback,
 	},
-
-	[AUE_BULK_CS_WR] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = aue_bulk_write_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
-	[AUE_BULK_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = aue_bulk_read_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
 	[AUE_INTR_DT_RD] = {
 		.type = UE_INTERRUPT,
 		.endpoint = UE_ADDR_ANY,
@@ -254,17 +226,6 @@ static const struct usb2_config aue_conf
 		.mh.bufsize = 0,	/* use wMaxPacketSize */
 		.mh.callback = aue_intr_callback,
 	},
-
-	[AUE_INTR_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = aue_intr_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
 };
 
 static device_method_t aue_methods[] = {
@@ -728,19 +689,6 @@ aue_detach(device_t dev)
 }
 
 static void
-aue_intr_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct aue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_INTR_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AUE_FLAG_INTR_STALL;
-		usb2_transfer_start(xfer_other);
-	}
-}
-
-static void
 aue_intr_callback(struct usb2_xfer *xfer)
 {
 	struct aue_softc *sc = xfer->priv_sc;
@@ -749,7 +697,6 @@ aue_intr_callback(struct usb2_xfer *xfer
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
-
 		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
 		    xfer->actlen >= sizeof(pkt)) {
 
@@ -763,34 +710,17 @@ aue_intr_callback(struct usb2_xfer *xfer
 		}
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
-		if (sc->sc_flags & AUE_FLAG_INTR_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AUE_INTR_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
-		return;
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);
+		break;
 
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* start clear stall */
-			sc->sc_flags |= AUE_FLAG_INTR_STALL;
-			usb2_transfer_start(sc->sc_xfer[AUE_INTR_CS_RD]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
-		return;
-	}
-}
-
-static void
-aue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct aue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_BULK_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AUE_FLAG_READ_STALL;
-		usb2_transfer_start(xfer_other);
+		break;
 	}
 }
 
@@ -838,39 +768,19 @@ aue_bulk_read_callback(struct usb2_xfer 
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 tr_setup:
-
-		if (sc->sc_flags & AUE_FLAG_READ_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);
 		usb2_ether_rxflush(ue);
-		return;
+		break;
 
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= AUE_FLAG_READ_STALL;
-			usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_RD]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
-		DPRINTF("bulk read error, %s\n",
-		    usb2_errstr(xfer->error));
-		return;
-
-	}
-}
-
-static void
-aue_bulk_write_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct aue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_BULK_DT_WR];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AUE_FLAG_WRITE_STALL;
-		usb2_transfer_start(xfer_other);
+		DPRINTF("bulk read error, %s\n", usb2_errstr(xfer->error));
+		break;
 	}
 }
 
@@ -889,22 +799,13 @@ aue_bulk_write_callback(struct usb2_xfer
 
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
+		if ((sc->sc_flags & AUE_FLAG_LINK) == 0)
+			break;
 
-		if (sc->sc_flags & AUE_FLAG_WRITE_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_WR]);
-			goto done;
-		}
-		if ((sc->sc_flags & AUE_FLAG_LINK) == 0) {
-			/*
-			 * don't send anything if there is no link !
-			 */
-			goto done;
-		}
 		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+		if (m == NULL)
+			break;
 
-		if (m == NULL) {
-			goto done;
-		}
 		if (m->m_pkthdr.len > MCLBYTES) {
 			m->m_pkthdr.len = MCLBYTES;
 		}
@@ -939,13 +840,9 @@ aue_bulk_write_callback(struct usb2_xfer
 		 * of this frame to him:
 		 */
 		BPF_MTAP(ifp, m);
-
 		m_freem(m);
-
 		usb2_start_hardware(xfer);
-
-done:
-		return;
+		break;
 
 	default:			/* Error */
 		DPRINTFN(11, "transfer error, %s\n",
@@ -953,12 +850,11 @@ done:
 
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= AUE_FLAG_WRITE_STALL;
-			usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_WR]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
 		ifp->if_oerrors++;
-		return;
-
+		break;
 	}
 }
 
@@ -988,8 +884,8 @@ aue_start(struct usb2_ether *ue)
 	 * start the USB transfers, if not already started:
 	 */
 	usb2_transfer_start(sc->sc_xfer[AUE_INTR_DT_RD]);
-	usb2_transfer_start(sc->sc_xfer[AUE_BULK_DT_RD]);
-	usb2_transfer_start(sc->sc_xfer[AUE_BULK_DT_WR]);
+	usb2_transfer_start(sc->sc_xfer[AUE_BULK_RD]);
+	usb2_transfer_start(sc->sc_xfer[AUE_BULK_WR]);
 }
 
 static void
@@ -1023,8 +919,6 @@ aue_init(struct usb2_ether *ue)
 	AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB);
 	AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR);
 
-	sc->sc_flags |= AUE_FLAG_READ_STALL | AUE_FLAG_WRITE_STALL;
-
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	aue_start(ue);
 }
@@ -1100,12 +994,9 @@ aue_stop(struct usb2_ether *ue)
 	/*
 	 * stop all the transfers, if not already stopped:
 	 */
-	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_DT_WR]);
-	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_DT_RD]);
-	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_CS_WR]);
-	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_CS_RD]);
+	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_WR]);
+	usb2_transfer_stop(sc->sc_xfer[AUE_BULK_RD]);
 	usb2_transfer_stop(sc->sc_xfer[AUE_INTR_DT_RD]);
-	usb2_transfer_stop(sc->sc_xfer[AUE_INTR_CS_RD]);
 
 	aue_csr_write_1(sc, AUE_CTL0, 0);
 	aue_csr_write_1(sc, AUE_CTL1, 0);

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_auereg.h
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_auereg.h	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_auereg.h	Sun Feb  1 06:39:40 2009	(r187977)
@@ -61,13 +61,10 @@
  * endpoint to be index 0 and work up from there.
  */
 enum {
-	AUE_BULK_DT_WR,
-	AUE_BULK_DT_RD,
-	AUE_BULK_CS_WR,
-	AUE_BULK_CS_RD,
+	AUE_BULK_WR,
+	AUE_BULK_RD,
 	AUE_INTR_DT_RD,
-	AUE_INTR_CS_RD,
-	AUE_N_TRANSFER = 6,
+	AUE_N_TRANSFER = 3,
 };
 
 #define	AUE_INTR_PKTLEN		0x8
@@ -216,12 +213,9 @@ struct aue_softc {
 #define	AUE_FLAG_PNA		0x0002	/* has Home PNA */
 #define	AUE_FLAG_PII		0x0004	/* Pegasus II chip */
 #define	AUE_FLAG_LINK		0x0008	/* wait for link to come up */
-#define	AUE_FLAG_READ_STALL	0x0010	/* wait for clearing of stall */
-#define	AUE_FLAG_WRITE_STALL	0x0020	/* wait for clearing of stall */
-#define	AUE_FLAG_INTR_STALL	0x0040	/* wait for clearing of stall */
-#define	AUE_FLAG_DETACH		0x0080	/* card gone */
-#define	AUE_FLAG_VER_2		0x0200	/* chip is version 2 */
-#define	AUE_FLAG_DUAL_PHY	0x0400	/* chip has two transcivers */
+#define	AUE_FLAG_DETACH		0x0010	/* card gone */
+#define	AUE_FLAG_VER_2		0x0020	/* chip is version 2 */
+#define	AUE_FLAG_DUAL_PHY	0x0040	/* chip has two transcivers */
 };
 
 #define	AUE_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c	Sun Feb  1 06:39:40 2009	(r187977)
@@ -153,11 +153,8 @@ static device_attach_t axe_attach;
 static device_detach_t axe_detach;
 static device_shutdown_t axe_shutdown;
 
-static usb2_callback_t axe_intr_clear_stall_callback;
 static usb2_callback_t axe_intr_callback;
-static usb2_callback_t axe_bulk_read_clear_stall_callback;
 static usb2_callback_t axe_bulk_read_callback;
-static usb2_callback_t axe_bulk_write_clear_stall_callback;
 static usb2_callback_t axe_bulk_write_callback;
 
 static miibus_readreg_t axe_miibus_readreg;
@@ -178,8 +175,7 @@ static void	axe_ax88772_init(struct axe_
 static int	axe_get_phyno(struct axe_softc *, int);
 
 static const struct usb2_config axe_config[AXE_N_TRANSFER] = {
-
-	[AXE_BULK_DT_WR] = {
+	[AXE_BULK_WR] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
@@ -188,42 +184,15 @@ static const struct usb2_config axe_conf
 		.mh.callback = axe_bulk_write_callback,
 		.mh.timeout = 10000,	/* 10 seconds */
 	},
-
-	[AXE_BULK_DT_RD] = {
+	[AXE_BULK_RD] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
-#if (MCLBYTES < 2048)
-#error "(MCLBYTES < 2048)"
-#endif
 		.mh.bufsize = MCLBYTES,
 		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
 		.mh.callback = axe_bulk_read_callback,
 		.mh.timeout = 0,	/* no timeout */
 	},
-
-	[AXE_BULK_CS_WR] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = axe_bulk_write_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
-	[AXE_BULK_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = axe_bulk_read_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
 	[AXE_INTR_DT_RD] = {
 		.type = UE_INTERRUPT,
 		.endpoint = UE_ADDR_ANY,
@@ -232,17 +201,6 @@ static const struct usb2_config axe_conf
 		.mh.bufsize = 0,	/* use wMaxPacketSize */
 		.mh.callback = axe_intr_callback,
 	},
-
-	[AXE_INTR_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = axe_intr_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
 };
 
 static device_method_t axe_methods[] = {
@@ -736,61 +694,26 @@ axe_detach(device_t dev)
 }
 
 static void
-axe_intr_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct axe_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_INTR_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AXE_FLAG_INTR_STALL;
-		usb2_transfer_start(xfer_other);
-	}
-}
-
-static void
 axe_intr_callback(struct usb2_xfer *xfer)
 {
-	struct axe_softc *sc = xfer->priv_sc;
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
 	case USB_ST_SETUP:
-		if (sc->sc_flags & AXE_FLAG_INTR_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AXE_INTR_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
-		return;
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);
+		break;
 
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* start clear stall */
-			sc->sc_flags |= AXE_FLAG_INTR_STALL;
-			usb2_transfer_start(sc->sc_xfer[AXE_INTR_CS_RD]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
-		return;
-	}
-}
-
-static void
-axe_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct axe_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_BULK_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AXE_FLAG_READ_STALL;
-		usb2_transfer_start(xfer_other);
+		break;
 	}
 }
 
-#if (AXE_BULK_BUF_SIZE >= 0x10000)
-#error "Please update axe_bulk_read_callback()!"
-#endif
-
 static void
 axe_bulk_read_callback(struct usb2_xfer *xfer)
 {
@@ -850,44 +773,22 @@ axe_bulk_read_callback(struct usb2_xfer 
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 tr_setup:
-		if (sc->sc_flags & AXE_FLAG_READ_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);
 		usb2_ether_rxflush(ue);
-		return;
+		break;
 
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= AXE_FLAG_READ_STALL;
-			usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_RD]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
 		DPRINTF("bulk read error, %s\n", usb2_errstr(xfer->error));
-		return;
-
-	}
-}
-
-static void
-axe_bulk_write_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct axe_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_BULK_DT_WR];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~AXE_FLAG_WRITE_STALL;
-		usb2_transfer_start(xfer_other);
+		break;
 	}
 }
 
-#if ((AXE_BULK_BUF_SIZE >= 0x10000) || (AXE_BULK_BUF_SIZE < (MCLBYTES+4)))
-#error "Please update axe_bulk_write_callback()!"
-#endif
-
 static void
 axe_bulk_write_callback(struct usb2_xfer *xfer)
 {
@@ -904,10 +805,6 @@ axe_bulk_write_callback(struct usb2_xfer
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 
-		if (sc->sc_flags & AXE_FLAG_WRITE_STALL) {
-			usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_WR]);
-			goto done;
-		}
 		if ((sc->sc_flags & AXE_FLAG_LINK) == 0) {
 			/*
 			 * don't send anything if there is no link !
@@ -974,7 +871,7 @@ axe_bulk_write_callback(struct usb2_xfer
 		usb2_start_hardware(xfer);
 
 done:
-		return;
+		break;
 
 	default:			/* Error */
 		DPRINTFN(11, "transfer error, %s\n",
@@ -982,12 +879,11 @@ done:
 
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= AXE_FLAG_WRITE_STALL;
-			usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_WR]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
 		ifp->if_oerrors++;
-		return;
-
+		break;
 	}
 }
 
@@ -1017,8 +913,8 @@ axe_start(struct usb2_ether *ue)
 	 * start the USB transfers, if not already started:
 	 */
 	usb2_transfer_start(sc->sc_xfer[AXE_INTR_DT_RD]);
-	usb2_transfer_start(sc->sc_xfer[AXE_BULK_DT_RD]);
-	usb2_transfer_start(sc->sc_xfer[AXE_BULK_DT_WR]);
+	usb2_transfer_start(sc->sc_xfer[AXE_BULK_RD]);
+	usb2_transfer_start(sc->sc_xfer[AXE_BULK_WR]);
 }
 
 static void
@@ -1071,8 +967,6 @@ axe_init(struct usb2_ether *ue)
 	/* Load the multicast filter. */
 	axe_setmulti(ue);
 
-	sc->sc_flags |= AXE_FLAG_READ_STALL | AXE_FLAG_WRITE_STALL;
-
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	axe_start(ue);
 }
@@ -1113,12 +1007,9 @@ axe_stop(struct usb2_ether *ue)
 	/*
 	 * stop all the transfers, if not already stopped:
 	 */
-	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_DT_WR]);
-	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_DT_RD]);
-	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_CS_WR]);
-	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_CS_RD]);
+	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_WR]);
+	usb2_transfer_stop(sc->sc_xfer[AXE_BULK_RD]);
 	usb2_transfer_stop(sc->sc_xfer[AXE_INTR_DT_RD]);
-	usb2_transfer_stop(sc->sc_xfer[AXE_INTR_CS_RD]);
 
 	axe_reset(sc);
 }

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_axereg.h
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_axereg.h	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_axereg.h	Sun Feb  1 06:39:40 2009	(r187977)
@@ -170,13 +170,10 @@ struct axe_sframe_hdr {
 
 /* The interrupt endpoint is currently unused by the ASIX part. */
 enum {
-	AXE_BULK_DT_WR,
-	AXE_BULK_DT_RD,
-	AXE_BULK_CS_WR,
-	AXE_BULK_CS_RD,
+	AXE_BULK_WR,
+	AXE_BULK_RD,
 	AXE_INTR_DT_RD,
-	AXE_INTR_CS_RD,
-	AXE_N_TRANSFER = 6,
+	AXE_N_TRANSFER = 3,
 };
 
 struct axe_softc {
@@ -189,12 +186,9 @@ struct axe_softc {
 
 	int			sc_flags;
 #define	AXE_FLAG_LINK		0x0001
-#define	AXE_FLAG_INTR_STALL	0x0002
-#define	AXE_FLAG_READ_STALL	0x0004
-#define	AXE_FLAG_WRITE_STALL	0x0008
-#define	AXE_FLAG_DETACH		0x0010
-#define	AXE_FLAG_772		0x1000	/* AX88772 */
-#define	AXE_FLAG_178		0x2000	/* AX88178 */
+#define	AXE_FLAG_DETACH		0x0002
+#define	AXE_FLAG_772		0x0004	/* AX88772 */
+#define	AXE_FLAG_178		0x0008	/* AX88178 */
 
 	uint8_t			sc_ipgs[3];
 	uint8_t			sc_phyaddrs[2];

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_cdce2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_cdce2.c	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_cdce2.c	Sun Feb  1 06:39:40 2009	(r187977)
@@ -99,7 +99,6 @@ SYSCTL_INT(_hw_usb2_cdce, OID_AUTO, forc
 #endif
 
 static const struct usb2_config cdce_config[CDCE_N_TRANSFER] = {
-
 	[CDCE_BULK_A] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
@@ -118,7 +117,6 @@ static const struct usb2_config cdce_con
 		.md.callback = cdce_bulk_read_callback,
 		.md.timeout = 0,	/* no timeout */
 	},
-
 	[CDCE_BULK_B] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
@@ -137,7 +135,6 @@ static const struct usb2_config cdce_con
 		.md.callback = cdce_bulk_write_callback,
 		.md.timeout = 10000,	/* 10 seconds */
 	},
-
 	[CDCE_INTR] = {
 		.type = UE_INTERRUPT,
 		.endpoint = UE_ADDR_ANY,

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c	Sun Feb  1 06:39:40 2009	(r187977)
@@ -88,9 +88,7 @@ static device_attach_t cue_attach;
 static device_detach_t cue_detach;
 static device_shutdown_t cue_shutdown;
 
-static usb2_callback_t cue_bulk_read_clear_stall_callback;
 static usb2_callback_t cue_bulk_read_callback;
-static usb2_callback_t cue_bulk_write_clear_stall_callback;
 static usb2_callback_t cue_bulk_write_callback;
 
 static uint8_t	cue_csr_read_1(struct cue_softc *, uint16_t);
@@ -116,8 +114,7 @@ SYSCTL_INT(_hw_usb2_cue, OID_AUTO, debug
 #endif
 
 static const struct usb2_config cue_config[CUE_N_TRANSFER] = {
-
-	[CUE_BULK_DT_WR] = {
+	[CUE_BULK_WR] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
@@ -126,8 +123,7 @@ static const struct usb2_config cue_conf
 		.mh.callback = cue_bulk_write_callback,
 		.mh.timeout = 10000,	/* 10 seconds */
 	},
-
-	[CUE_BULK_DT_RD] = {
+	[CUE_BULK_RD] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
@@ -135,28 +131,6 @@ static const struct usb2_config cue_conf
 		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
 		.mh.callback = cue_bulk_read_callback,
 	},
-
-	[CUE_BULK_CS_WR] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = cue_bulk_write_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
-	[CUE_BULK_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = cue_bulk_read_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
 };
 
 static device_method_t cue_methods[] = {
@@ -448,19 +422,6 @@ cue_detach(device_t dev)
 }
 
 static void
-cue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct cue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[CUE_BULK_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~CUE_FLAG_READ_STALL;
-		usb2_transfer_start(xfer_other);
-	}
-}
-
-static void
 cue_bulk_read_callback(struct usb2_xfer *xfer)
 {
 	struct cue_softc *sc = xfer->priv_sc;
@@ -485,39 +446,20 @@ cue_bulk_read_callback(struct usb2_xfer 
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 tr_setup:
-
-		if (sc->sc_flags & CUE_FLAG_READ_STALL) {
-			usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);
 		usb2_ether_rxflush(ue);
-		return;
+		break;
 
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= CUE_FLAG_READ_STALL;
-			usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_RD]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
 		DPRINTF("bulk read error, %s\n",
 		    usb2_errstr(xfer->error));
-		return;
-
-	}
-}
-
-static void
-cue_bulk_write_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct cue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[CUE_BULK_DT_WR];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~CUE_FLAG_WRITE_STALL;
-		usb2_transfer_start(xfer_other);
+		break;
 	}
 }
 
@@ -537,15 +479,10 @@ cue_bulk_write_callback(struct usb2_xfer
 		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 
-		if (sc->sc_flags & CUE_FLAG_WRITE_STALL) {
-			usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_WR]);
-			goto done;
-		}
 		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+		if (m == NULL)
+			break;
 
-		if (m == NULL) {
-			goto done;
-		}
 		if (m->m_pkthdr.len > MCLBYTES) {
 			m->m_pkthdr.len = MCLBYTES;
 		}
@@ -566,13 +503,9 @@ cue_bulk_write_callback(struct usb2_xfer
 		 * to him.
 		 */
 		BPF_MTAP(ifp, m);
-
 		m_freem(m);
-
 		usb2_start_hardware(xfer);
-
-done:
-		return;
+		break;
 
 	default:			/* Error */
 		DPRINTFN(11, "transfer error, %s\n",
@@ -580,12 +513,11 @@ done:
 
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* try to clear stall first */
-			sc->sc_flags |= CUE_FLAG_WRITE_STALL;
-			usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_WR]);
+			usb2_clear_endpoint_stall(xfer);
+			return;
 		}
 		ifp->if_oerrors++;
-		return;
-
+		break;
 	}
 }
 
@@ -613,8 +545,8 @@ cue_start(struct usb2_ether *ue)
 	/*
 	 * start the USB transfers, if not already started:
 	 */
-	usb2_transfer_start(sc->sc_xfer[CUE_BULK_DT_RD]);
-	usb2_transfer_start(sc->sc_xfer[CUE_BULK_DT_WR]);
+	usb2_transfer_start(sc->sc_xfer[CUE_BULK_RD]);
+	usb2_transfer_start(sc->sc_xfer[CUE_BULK_WR]);
 }
 
 static void
@@ -660,8 +592,6 @@ cue_init(struct usb2_ether *ue)
 	/* Program the LED operation. */
 	cue_csr_write_1(sc, CUE_LEDCTL, CUE_LEDCTL_FOLLOW_LINK);
 
-	sc->sc_flags |= CUE_FLAG_READ_STALL | CUE_FLAG_WRITE_STALL;
-
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	cue_start(ue);
 }
@@ -683,10 +613,8 @@ cue_stop(struct usb2_ether *ue)
 	/*
 	 * stop all the transfers, if not already stopped:
 	 */
-	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_DT_WR]);
-	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_DT_RD]);
-	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_CS_WR]);
-	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_CS_RD]);
+	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_WR]);
+	usb2_transfer_stop(sc->sc_xfer[CUE_BULK_RD]);
 
 	cue_csr_write_1(sc, CUE_ETHCTL, 0);
 	cue_reset(sc);

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_cuereg.h
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_cuereg.h	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_cuereg.h	Sun Feb  1 06:39:40 2009	(r187977)
@@ -113,11 +113,9 @@
 
 /* The interrupt endpoint is currently unused by the KLSI part. */
 enum {
-	CUE_BULK_DT_WR,
-	CUE_BULK_DT_RD,
-	CUE_BULK_CS_WR,
-	CUE_BULK_CS_RD,
-	CUE_N_TRANSFER = 4,
+	CUE_BULK_WR,
+	CUE_BULK_RD,
+	CUE_N_TRANSFER = 2,
 };
 
 struct cue_softc {
@@ -128,11 +126,8 @@ struct cue_softc {
 	device_t		sc_dev;
 
 	int			sc_flags;
-#define	CUE_FLAG_READ_STALL	0x0010	/* wait for clearing of stall */
-#define	CUE_FLAG_WRITE_STALL	0x0020	/* wait for clearing of stall */
-#define	CUE_FLAG_LINK		0x0040	/* got a link */
-#define	CUE_FLAG_DETACH		0x0080	/* card gone */
-#define	CUE_FLAG_INTR_STALL	0x0100	/* wait for clearing of stall */
+#define	CUE_FLAG_LINK		0x0001	/* got a link */
+#define	CUE_FLAG_DETACH		0x0002	/* card gone */
 };
 
 #define	CUE_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c	Sun Feb  1 06:15:46 2009	(r187976)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c	Sun Feb  1 06:39:40 2009	(r187977)
@@ -131,9 +131,7 @@ static device_attach_t kue_attach;
 static device_detach_t kue_detach;
 static device_shutdown_t kue_shutdown;
 
-static usb2_callback_t kue_bulk_read_clear_stall_callback;
 static usb2_callback_t kue_bulk_read_callback;
-static usb2_callback_t kue_bulk_write_clear_stall_callback;
 static usb2_callback_t kue_bulk_write_callback;
 
 static int	kue_do_request(struct kue_softc *,
@@ -158,8 +156,7 @@ SYSCTL_INT(_hw_usb2_kue, OID_AUTO, debug
 #endif
 
 static const struct usb2_config kue_config[KUE_N_TRANSFER] = {
-
-	[KUE_BULK_DT_WR] = {
+	[KUE_BULK_WR] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
@@ -168,8 +165,7 @@ static const struct usb2_config kue_conf
 		.mh.callback = kue_bulk_write_callback,
 		.mh.timeout = 10000,	/* 10 seconds */
 	},
-
-	[KUE_BULK_DT_RD] = {
+	[KUE_BULK_RD] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
@@ -178,28 +174,6 @@ static const struct usb2_config kue_conf
 		.mh.callback = kue_bulk_read_callback,
 		.mh.timeout = 0,	/* no timeout */
 	},
-
-	[KUE_BULK_CS_WR] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = kue_bulk_write_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
-	[KUE_BULK_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.flags = {},
-		.mh.callback = kue_bulk_read_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
 };
 
 static device_method_t kue_methods[] = {
@@ -525,23 +499,6 @@ kue_detach(device_t dev)
 	return (0);
 }
 
-/*
- * A frame has been uploaded: pass the resulting mbuf chain up to
- * the higher level protocols.
- */
-static void
-kue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
-{
-	struct kue_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_xfer[KUE_BULK_DT_RD];
-
-	if (usb2_clear_stall_callback(xfer, xfer_other)) {
-		DPRINTF("stall cleared\n");
-		sc->sc_flags &= ~KUE_FLAG_READ_STALL;
-		usb2_transfer_start(xfer_other);
-	}
-}
-
 static void
 kue_bulk_read_callback(struct usb2_xfer *xfer)
 {
@@ -568,42 +525,24 @@ kue_bulk_read_callback(struct usb2_xfer 
 	case USB_ST_SETUP:
 tr_setup:
 
-		if (sc->sc_flags & KUE_FLAG_READ_STALL) {
-			usb2_transfer_start(sc->sc_xfer[KUE_BULK_CS_RD]);
-		} else {
-			xfer->frlengths[0] = xfer->max_data_length;
-			usb2_start_hardware(xfer);
-		}
+		xfer->frlengths[0] = xfer->max_data_length;
+		usb2_start_hardware(xfer);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list