Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2007 19:00:21 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 113011 for review
Message-ID:  <200701161900.l0GJ0LMB097826@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113011

Change 113011 by hselasky@hselasky_mini_itx on 2007/01/16 18:59:40

	Update if_aue so that it works with newer device
	revisions, starting at bcdDevice = 0x0201.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/if_aue.c#16 edit
.. //depot/projects/usb/src/sys/dev/usb/if_auereg.h#11 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/if_aue.c#16 (text+ko) ====

@@ -816,6 +816,10 @@
 	sc->sc_product = uaa->product;
 	sc->sc_vendor = uaa->vendor;
 
+	if (uaa->release >= 0x0201) {
+	    sc->sc_flags |= AUE_FLAG_VER_2; /* XXX currently undocumented */
+	}
+
 	usbd_set_desc(dev, uaa->device);
 
 	snprintf(sc->sc_name, sizeof(sc->sc_name), "%s",
@@ -1120,28 +1124,39 @@
 	return;
 
  tr_transferred:
+	DPRINTF(sc, 10, "received %d bytes\n", xfer->actlen);
 
-	if (xfer->actlen <= (4 + ETHER_CRC_LEN)) {
-	    ifp->if_ierrors++;
-	    goto tr_setup;
-	}
+	if (sc->sc_flags & AUE_FLAG_VER_2) {
+
+	    if (xfer->actlen == 0) {
+		ifp->if_ierrors++;
+		goto tr_setup;
+	    }
+
+	} else {
+
+	    if (xfer->actlen <= (4 + ETHER_CRC_LEN)) {
+		ifp->if_ierrors++;
+		goto tr_setup;
+	    }
+
+	    usbd_copy_out(&(xfer->buf_data), xfer->actlen - 4, &(sc->sc_rxpkt), 
+			  sizeof(sc->sc_rxpkt));
 
-	usbd_copy_out(&(xfer->buf_data), xfer->actlen - 4, &(sc->sc_rxpkt), 
-		      sizeof(sc->sc_rxpkt));
+	    /* turn off all the non-error bits 
+	     * in the rx status word:
+	     */
+	    sc->sc_rxpkt.aue_rxstat &= AUE_RXSTAT_MASK;
 
-	/* turn off all the non-error bits 
-	 * in the rx status word:
-	 */
-	sc->sc_rxpkt.aue_rxstat &= AUE_RXSTAT_MASK;
+	    if (sc->sc_rxpkt.aue_rxstat) {
+		ifp->if_ierrors++;
+		goto tr_setup;
+	    }
 
-	if (sc->sc_rxpkt.aue_rxstat) {
-	    ifp->if_ierrors++;
-	    goto tr_setup;
+	    /* No errors; receive the packet. */
+	    xfer->actlen -= (4 + ETHER_CRC_LEN);
 	}
 
-	/* No errors; receive the packet. */
-	xfer->actlen -= (4 + ETHER_CRC_LEN);
-
 	m = usbd_ether_get_mbuf();
 
 	if (m == NULL) {
@@ -1221,7 +1236,7 @@
 	return;
 
  tr_transferred:
-	DPRINTF(sc, 10, "transfer complete\n");
+	DPRINTF(sc, 10, "transfer of %d bytes complete\n", xfer->actlen);
 
 	ifp->if_opackets++;
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
@@ -1250,21 +1265,31 @@
 	    m->m_pkthdr.len = MCLBYTES;
 	}
 
-	xfer->length = (m->m_pkthdr.len + 2);
+	if (sc->sc_flags & AUE_FLAG_VER_2) {
+
+	    xfer->length = m->m_pkthdr.len;
+
+	    usbd_m_copy_in(&(xfer->buf_data), 0, 
+			   m, 0, m->m_pkthdr.len);
+
+	} else {
+
+	    xfer->length = (m->m_pkthdr.len + 2);
 
-	/*
-	 * The ADMtek documentation says that the packet length is
-	 * supposed to be specified in the first two bytes of the
-	 * transfer, however it actually seems to ignore this info
-	 * and base the frame size on the bulk transfer length.
-	 */
-	buf[0] = (u_int8_t)(m->m_pkthdr.len);
-	buf[1] = (u_int8_t)(m->m_pkthdr.len >> 8);
+	    /*
+	     * The ADMtek documentation says that the packet length is
+	     * supposed to be specified in the first two bytes of the
+	     * transfer, however it actually seems to ignore this info
+	     * and base the frame size on the bulk transfer length.
+	     */
+	    buf[0] = (u_int8_t)(m->m_pkthdr.len);
+	    buf[1] = (u_int8_t)(m->m_pkthdr.len >> 8);
 
-	usbd_copy_in(&(xfer->buf_data), 0, buf, 2);
+	    usbd_copy_in(&(xfer->buf_data), 0, buf, 2);
 
-	usbd_m_copy_in(&(xfer->buf_data), 2, 
-		       m, 0, m->m_pkthdr.len);
+	    usbd_m_copy_in(&(xfer->buf_data), 2, 
+			   m, 0, m->m_pkthdr.len);
+	}
 
 	/*
 	 * if there's a BPF listener, bounce a copy 

==== //depot/projects/usb/src/sys/dev/usb/if_auereg.h#11 (text+ko) ====

@@ -227,6 +227,7 @@
 #define	AUE_FLAG_LL_READY	0x0040  /* Lower Layer Ready */
 #define	AUE_FLAG_HL_READY	0x0080  /* Higher Layer Ready */
 #define	AUE_FLAG_INTR_STALL	0x0100  /* wait for clearing of stall */
+#define	AUE_FLAG_VER_2		0x0200  /* chip is version 2 */
 
 	uint8_t			sc_name[16];
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701161900.l0GJ0LMB097826>