Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Sep 2007 15:10:58 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 126695 for review
Message-ID:  <200709221510.l8MFAwZg015717@repoman.freebsd.org>

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

Change 126695 by hselasky@hselasky_laptop001 on 2007/09/22 15:10:53

	FYI; The comments follow the P4 diff from top to bottom.
	
	- convert kernel USB flags (USBD_XXX) into a bitfield (scripted)
	
	- passing a mutex to "usbd_do_request_flags()" and all
	  "usbreq_xxx()" functions is now mandatory.
	
	- "xfer->buffer" eliminated. Some times a temporary buffer is
	  used for quick parsing of information. Typically in relation
	  to USB interrupt endpoints.
	
	- All USB BULK/ISOC/INTR IN-transfers must setup
	  "xfer->frlengths[]" before calling "usbd_start_hardware()".
	  Else the actual length of the previous transfer will be 
	  used for transfer length of the next USB transfer.
	
	- "usbd_find_descriptor()" has got two new mask parameters.
	  The mask enables only certain bits to be compared when
	  searching for an USB descriptor by ID. The most commonly masks
	  used are 0 and 0-1. Note that there is a "0" in front of the
	  minus sign. This might look strange, but it actually kills
	  some C++ compiler warnings.
	
	- "usbreq_set_interface()" has been renamed
	  "usbd_set_alt_interface_index()" to clearly show that this
	  function does more than just an USB control request.
	
	- several serial port drivers have been added the flag
	  "force_short_xfer" to ensure that the data is flushed at the
	  receiving side. You would maybe think that USB dongles read
	  USB packet by USB packet, but that is not always the
	  case. They can have larger buffers, and then you need a short
	  packet last to terminate the transfer.
	
	- the maximum "if_ural" frame size has been increased from
	  0x780 to 0x980 and factored out into a the macro
	  "RAL_FRAME_SIZE". Even though we currently cannot actually
	  transmit or receive that large frames due to the MCLBYTES
	  limit, it is nice to support it.
	
	- "if_ural.c" and "if_rum.c" replaced;
		*(u_int16_t *)(wh->i_dur) = htole16(dur);
	   by;
		USETW(wh->i_dur, dur);
	
	   So that we don't hit any alignment issues in the future
	   on embedded platforms.
	
	- the "ubser.c" driver now searches the cached "manufacturer"
	  USB string to speed up the probe process.
	
	- the actlen variable pointer which can be passed to
	  "usbd_do_request_flags()" has changed type to "uint16_t *"
	  to match the USB specification.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/if_aue.c#28 edit
.. //depot/projects/usb/src/sys/dev/usb/if_axe.c#29 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#22 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cue.c#24 edit
.. //depot/projects/usb/src/sys/dev/usb/if_kue.c#26 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rue.c#25 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rum.c#8 edit
.. //depot/projects/usb/src/sys/dev/usb/if_udav.c#25 edit
.. //depot/projects/usb/src/sys/dev/usb/if_ural.c#31 edit
.. //depot/projects/usb/src/sys/dev/usb/if_uralreg.h#13 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zyd.c#14 edit
.. //depot/projects/usb/src/sys/dev/usb/uark.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/ubsa.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/ubser.c#15 edit
.. //depot/projects/usb/src/sys/dev/usb/ucycom.c#14 edit
.. //depot/projects/usb/src/sys/dev/usb/udbp.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/ufoma.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/uftdi.c#19 edit
.. //depot/projects/usb/src/sys/dev/usb/ugensa.c#7 edit
.. //depot/projects/usb/src/sys/dev/usb/uipaq.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/ukbd.c#20 edit
.. //depot/projects/usb/src/sys/dev/usb/ulpt.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/umct.c#15 edit
.. //depot/projects/usb/src/sys/dev/usb/umodem.c#24 edit
.. //depot/projects/usb/src/sys/dev/usb/umoscom.c#5 edit
.. //depot/projects/usb/src/sys/dev/usb/uplcom.c#22 edit
.. //depot/projects/usb/src/sys/dev/usb/urio.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/uscanner.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/uvisor.c#17 edit
.. //depot/projects/usb/src/sys/dev/usb/uvscom.c#22 edit
.. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c#13 edit
.. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c#8 edit

Differences ...

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

@@ -285,7 +285,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + 2),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &aue_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -295,7 +295,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 4 + ETHER_CRC_LEN),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &aue_bulk_read_callback,
     },
 
@@ -304,7 +304,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &aue_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -315,7 +315,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &aue_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -325,7 +325,7 @@
       .type      = UE_INTERRUPT,
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
-      .flags     = (USBD_PIPE_BOF|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .bufsize   = 0, /* use wMaxPacketSize */
       .callback  = &aue_intr_callback,
     },
@@ -335,7 +335,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &aue_intr_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -383,8 +383,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), req, 
-					data, 0, NULL, 1000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 1000);
 
 	if (err) {
 
@@ -1012,21 +1012,23 @@
 {
 	struct aue_softc *sc = xfer->priv_sc;
 	struct ifnet *ifp = sc->sc_ifp;
-	struct aue_intrpkt *p = xfer->buffer;
+	struct aue_intrpkt pkt;
 
 	USBD_CHECK_STATUS(xfer);
 
  tr_transferred:
 
 	if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) &&
-	    (xfer->actlen >= sizeof(*p))) {
+	    (xfer->actlen >= sizeof(pkt))) {
+
+	    usbd_copy_out(&(xfer->buf_data), 0, &pkt, sizeof(pkt));
 
-	    if (p->aue_txstat0) {
+	    if (pkt.aue_txstat0) {
 	        ifp->if_oerrors++;
 	    }
 
-	    if (p->aue_txstat0 & (AUE_TXSTAT0_LATECOLL & 
-				  AUE_TXSTAT0_EXCESSCOLL)) {
+	    if (pkt.aue_txstat0 & (AUE_TXSTAT0_LATECOLL & 
+				   AUE_TXSTAT0_EXCESSCOLL)) {
 	        ifp->if_collisions++;
 	    }
 	}
@@ -1035,6 +1037,7 @@
 	if (sc->sc_flags & AUE_FLAG_INTR_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[5]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 	return;
@@ -1135,6 +1138,7 @@
 	if (sc->sc_flags & AUE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -1219,14 +1223,14 @@
 
 	if (sc->sc_flags & AUE_FLAG_VER_2) {
 
-	    xfer->length = m->m_pkthdr.len;
+	    xfer->frlengths[0] = 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);
+	    xfer->frlengths[0] = (m->m_pkthdr.len + 2);
 
 	    /*
 	     * The ADMtek documentation says that the packet length is

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

@@ -234,7 +234,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = AXE_BULK_BUF_SIZE,
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &axe_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -247,7 +247,7 @@
 #error "(MCLBYTES < 2048)"
 #endif
       .bufsize   = MCLBYTES,
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &axe_bulk_read_callback,
       .timeout   = 0, /* no timeout */
     },
@@ -257,7 +257,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &axe_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -268,7 +268,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &axe_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -278,7 +278,7 @@
       .type      = UE_INTERRUPT,
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
-      .flags     = (USBD_PIPE_BOF|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .bufsize   = 0, /* use wMaxPacketSize */
       .callback  = &axe_intr_callback,
     },
@@ -288,7 +288,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &axe_intr_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -345,8 +345,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), &req, 
-					buf, 0, NULL, 1000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), &req, buf, 0, NULL, 1000);
 
 	if (err) {
 
@@ -590,16 +590,8 @@
 {
 	usbd_status err;
 
-	mtx_unlock(&(sc->sc_mtx));
-
-	mtx_lock(&Giant);
-
-	err = usbreq_set_config(sc->sc_udev, AXE_CONFIG_NO);
-
-	mtx_unlock(&Giant);
+	err = usbreq_set_config(sc->sc_udev, &(sc->sc_mtx), AXE_CONFIG_NO);
 
-	mtx_lock(&(sc->sc_mtx));
-
 	if (err) {
 	    DPRINTF(sc, 0, "reset failed (ignored)\n");
 	}
@@ -998,6 +990,7 @@
 	if (sc->sc_flags & AXE_FLAG_INTR_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[5]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 	return;
@@ -1139,6 +1132,7 @@
 	if (sc->sc_flags & AXE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -1284,8 +1278,7 @@
 	    }
 	}
 
-	xfer->length = pos;
-
+	xfer->frlengths[0] = pos;
 	usbd_start_hardware(xfer);
 
  done:

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

@@ -112,7 +112,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + 4),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &cdce_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -122,7 +122,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 4),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &cdce_bulk_read_callback,
     },
 
@@ -131,7 +131,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &cdce_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -142,7 +142,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &cdce_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -231,7 +231,7 @@
 	int error;
 	u_int8_t i;
 	u_int8_t eaddr[ETHER_ADDR_LEN];
-	u_int8_t eaddr_str[(ETHER_ADDR_LEN * 2) + 1];
+	u_int8_t eaddr_str[USB_STRING_DESC_LEN(ETHER_ADDR_LEN * 2) + 1];
 
 	if (sc == NULL) {
 	    return ENOMEM;
@@ -261,7 +261,7 @@
 
 	ud = usbd_find_descriptor
 	  (uaa->device, NULL, uaa->iface_index,
-	   UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION);
+	   UDESC_CS_INTERFACE, 0-1, UDESCSUB_CDC_UNION, 0-1);
 
 	if ((ud == NULL) || (ud->bLength < sizeof(*ud))) {
 	    device_printf(dev, "no union descriptor!\n");
@@ -312,7 +312,7 @@
 
 	for (i = 0; i < 32; i++) {
 
-	    error = usbreq_set_interface
+	    error = usbd_set_alt_interface_index
 	      (uaa->device, sc->sc_data_iface_index, i);
 
 	    if (error) {
@@ -336,11 +336,17 @@
 
 	ue = usbd_find_descriptor
 	  (uaa->device, NULL, uaa->iface_index,
-	   UDESC_CS_INTERFACE, UDESCSUB_CDC_ENF);
+	   UDESC_CS_INTERFACE, 0-1, UDESCSUB_CDC_ENF, 0-1);
+
+	if ((ue == NULL) || (ue->bLength < sizeof(*ue))) {
+	    error = USBD_INVAL;
+	} else {
+	    error = usbreq_get_string_any
+	      (uaa->device, &Giant, eaddr_str,
+	       sizeof(eaddr_str), ue->iMacAddress);
+	}
 
-	if ((ue == NULL) || (ue->bLength < sizeof(*ue)) || 
-	    usbreq_get_string_any(uaa->device, ue->iMacAddress, 
-				  eaddr_str, sizeof(eaddr_str))) {
+	if (error) {
 
 	    /* fake MAC address */
 
@@ -528,7 +534,7 @@
 	    m->m_pkthdr.len = MCLBYTES;
 	}
 
-	xfer->length = m->m_pkthdr.len;
+	xfer->frlengths[0] = m->m_pkthdr.len;
 
 	usbd_m_copy_in(&(xfer->buf_data), 0, 
 		       m, 0, m->m_pkthdr.len);
@@ -541,7 +547,7 @@
 	    usbd_copy_in(&(xfer->buf_data), 
 			 m->m_pkthdr.len, &crc, 4);
 
-	    xfer->length += 4;
+	    xfer->frlengths[0] += 4;
 	}
 
 	/*
@@ -750,6 +756,7 @@
 	if (sc->sc_flags & CDCE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 

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

@@ -168,7 +168,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + 2),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA),
+      .flags     = { .pipe_bof = 1, },
       .callback  = &cue_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -178,7 +178,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 2),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &cue_bulk_read_callback,
     },
 
@@ -187,7 +187,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &cue_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -198,7 +198,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &cue_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -238,8 +238,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), req, 
-					data, 0, NULL, 1000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 1000);
 
 	if (err) {
 
@@ -695,6 +695,7 @@
 	if (sc->sc_flags & CUE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -825,7 +826,7 @@
 	    m->m_pkthdr.len = MCLBYTES;
 	}
 
-	xfer->length = (m->m_pkthdr.len + 2);
+	xfer->frlengths[0] = (m->m_pkthdr.len + 2);
 
 	/* the first two bytes are the frame length */
 

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

@@ -202,7 +202,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + 2 + 64),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA),
+      .flags     = { .pipe_bof = 1, },
       .callback  = &kue_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -212,7 +212,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 2),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &kue_bulk_read_callback,
       .timeout   = 0, /* no timeout */
     },
@@ -222,7 +222,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &kue_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -233,7 +233,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &kue_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -280,8 +280,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), req, 
-					data, 0, NULL, 60000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 60000);
 
 	if (err) {
 	    DPRINTF(sc, 0, "device request failed, err=%s "
@@ -460,15 +460,7 @@
 {
         usbd_status err;
 
-        mtx_unlock(&(sc->sc_mtx));
-
-        mtx_lock(&Giant);
-
-        err = usbreq_set_config(sc->sc_udev, KUE_CONFIG_NO);
-
-        mtx_unlock(&Giant);
-
-        mtx_lock(&(sc->sc_mtx));
+        err = usbreq_set_config(sc->sc_udev, &(sc->sc_mtx), KUE_CONFIG_NO);
 
         if (err) {
             DPRINTF(sc, 0, "reset failed (ignored)\n");
@@ -747,6 +739,7 @@
 	if (sc->sc_flags & KUE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -784,6 +777,7 @@
 	struct ifnet *ifp = sc->sc_ifp;
 	struct mbuf *m;
 	u_int32_t total_len;
+	uint32_t temp_len;
 	u_int8_t buf[2];
 
 	USBD_CHECK_STATUS(xfer);
@@ -823,8 +817,8 @@
 	    m->m_pkthdr.len = MCLBYTES;
 	}
 
-	xfer->length = (m->m_pkthdr.len + 2);
-	total_len = (xfer->length + (64 - (xfer->length % 64)));
+	temp_len = (m->m_pkthdr.len + 2);
+	total_len = (temp_len + (64 - (temp_len % 64)));
 
 	/* the first two bytes are the frame length */
 
@@ -836,10 +830,10 @@
 	usbd_m_copy_in(&(xfer->buf_data), 2, 
 		       m, 0, m->m_pkthdr.len);
 
-	usbd_bzero(&(xfer->buf_data), xfer->length,
-		   total_len - xfer->length);
+	usbd_bzero(&(xfer->buf_data), temp_len,
+		   total_len - temp_len);
 
-	xfer->length = total_len;
+	xfer->frlengths[0] = total_len;
 
 	/*
 	 * if there's a BPF listener, bounce a copy 

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

@@ -214,7 +214,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = MCLBYTES,
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &rue_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -224,7 +224,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 4),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &rue_bulk_read_callback,
       .timeout   = 0, /* no timeout */
     },
@@ -234,7 +234,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &rue_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -245,7 +245,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &rue_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -255,7 +255,7 @@
       .type      = UE_INTERRUPT,
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
-      .flags     = (USBD_PIPE_BOF|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .bufsize   = 0, /* use wMaxPacketSize */
       .callback  = &rue_intr_callback,
     },
@@ -265,7 +265,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &rue_intr_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -316,8 +316,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), req, 
-					data, 0, NULL, 1000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 1000);
 
 	if (err) {
 
@@ -897,24 +897,27 @@
 {
 	struct rue_softc *sc = xfer->priv_sc;
 	struct ifnet *ifp = sc->sc_ifp;
-	struct rue_intrpkt *p = xfer->buffer;
+	struct rue_intrpkt pkt;
 
 	USBD_CHECK_STATUS(xfer);
 
  tr_transferred:
 
         if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) &&
-            (xfer->actlen >= sizeof(*p))) {
+            (xfer->actlen >= sizeof(pkt))) {
+
+	    usbd_copy_out(&(xfer->buf_data), 0, &pkt, sizeof(pkt));
 
-	    ifp->if_ierrors += p->rue_rxlost_cnt;
-	    ifp->if_ierrors += p->rue_crcerr_cnt;
-	    ifp->if_collisions += p->rue_col_cnt;
+	    ifp->if_ierrors += pkt.rue_rxlost_cnt;
+	    ifp->if_ierrors += pkt.rue_crcerr_cnt;
+	    ifp->if_collisions += pkt.rue_col_cnt;
         }
 
  tr_setup:
 	if (sc->sc_flags & RUE_FLAG_INTR_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[5]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 	return;
@@ -1008,6 +1011,7 @@
 	if (sc->sc_flags & RUE_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -1044,6 +1048,7 @@
 	struct rue_softc *sc = xfer->priv_sc;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct mbuf *m;
+	uint32_t temp_len;
 
 	USBD_CHECK_STATUS(xfer);
 
@@ -1089,7 +1094,7 @@
 	    m->m_pkthdr.len = MCLBYTES;
 	}
 
-	xfer->length = m->m_pkthdr.len;
+	temp_len = m->m_pkthdr.len;
 
 	usbd_m_copy_in(&(xfer->buf_data), 0, 
 		       m, 0, m->m_pkthdr.len);
@@ -1099,12 +1104,14 @@
 	 * RTL8150 chip doesn't send frame length smaller than
 	 * RUE_MIN_FRAMELEN (60) byte packet.
 	 */
-	if (xfer->length < RUE_MIN_FRAMELEN) {
-	    usbd_bzero(&(xfer->buf_data), xfer->length,
-		       RUE_MIN_FRAMELEN - xfer->length);
-	    xfer->length = RUE_MIN_FRAMELEN;
+	if (temp_len < RUE_MIN_FRAMELEN) {
+	    usbd_bzero(&(xfer->buf_data), temp_len,
+		       RUE_MIN_FRAMELEN - temp_len);
+	    temp_len = RUE_MIN_FRAMELEN;
 	}
 
+	xfer->frlengths[0] = temp_len;
+
 	/*
 	 * if there's a BPF listener, bounce a copy 
 	 * of this frame to him:

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

@@ -372,7 +372,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + RT2573_TX_DESC_SIZE + 8),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &rum_bulk_write_callback,
       .timeout   = 5000, /* ms */
     },
@@ -382,7 +382,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + RT2573_RX_DESC_SIZE),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &rum_bulk_read_callback,
     },
 
@@ -563,7 +563,7 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx
+	err = usbd_do_request_flags
 	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 1000);
 
 	if (err) {
@@ -1124,6 +1124,7 @@
 	if (sc->sc_flags & RUM_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -1312,6 +1313,7 @@
 {
 	struct rum_softc *sc = xfer->priv_sc;
 	struct ieee80211com *ic = &(sc->sc_ic);
+	uint32_t temp_len;
 	uint8_t align;
 
 	if (m->m_pkthdr.len > MCLBYTES) {
@@ -1341,25 +1343,25 @@
 		       m, 0, m->m_pkthdr.len);
 
 	/* compute transfer length */
-	xfer->length = (RT2573_TX_DESC_SIZE + m->m_pkthdr.len);
+	temp_len = (RT2573_TX_DESC_SIZE + m->m_pkthdr.len);
 
 	/* make transfer length 32-bit aligned */
-	if (xfer->length & 3) {
-	    align = (-(xfer->length)) & 3;
+	if (temp_len & 3) {
+	    align = (-(temp_len)) & 3;
 	    /* zero the extra byte(s) */
-	    usbd_bzero(&(xfer->buf_data), xfer->length, align);
-	    xfer->length += align;
+	    usbd_bzero(&(xfer->buf_data), temp_len, align);
+	    temp_len += align;
 	}
 
 	/* check if we need to add four extra bytes */
-	if ((xfer->length % 64) == 0) {
+	if ((temp_len % 64) == 0) {
 	    /* zero the extra bytes */
-	    usbd_bzero(&(xfer->buf_data), xfer->length, 4);
-	    xfer->length += 4;
+	    usbd_bzero(&(xfer->buf_data), temp_len, 4);
+	    temp_len += 4;
 	}
 
 	DPRINTF(sc, 10, "sending frame len=%u rate=%u xferlen=%u\n",
-		m->m_pkthdr.len, rate, xfer->length);
+		m->m_pkthdr.len, rate, temp_len);
 
 	if (m->m_flags & M_TXCB) {
 	    ieee80211_process_callback(ni, m, 0);
@@ -1371,6 +1373,7 @@
 	    ieee80211_free_node(ni);
 	}
 
+	xfer->frlengths[0] = temp_len;
 	usbd_start_hardware(xfer);
 	return;
 }
@@ -1447,7 +1450,7 @@
 
 		dur = rum_txtime(sc, RUM_ACK_SIZE, rum_ack_rate(ic, rate),
 				 ic->ic_flags) + sc->sc_sifs;
-		*(uint16_t *)(wh->i_dur) = htole16(dur);
+		USETW(wh->i_dur, dur);
 
 		/* tell hardware to add timestamp for probe responses */
 		if ((wh->i_fc[0] &
@@ -1523,7 +1526,7 @@
 		dur = rum_txtime(sc, RUM_ACK_SIZE, rum_ack_rate(ic,rate),
 				 ic->ic_flags) + sc->sc_sifs;
 
-		*(uint16_t *)(wh->i_dur) = htole16(dur);
+		USETW(wh->i_dur, dur);
 	    }
 
 	    rum_bulk_write_callback_sub(xfer, m, ni, flags, rate);

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

@@ -161,7 +161,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_OUT,
       .bufsize   = (MCLBYTES + 2),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_FORCE_SHORT_XFER),
+      .flags     = { .pipe_bof = 1, .force_short_xfer = 1, },
       .callback  = &udav_bulk_write_callback,
       .timeout   = 10000, /* 10 seconds */
     },
@@ -171,7 +171,7 @@
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
       .bufsize   = (MCLBYTES + 3),
-      .flags     = (USBD_PIPE_BOF|USBD_USE_DMA|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .callback  = &udav_bulk_read_callback,
       .timeout   = 0, /* no timeout */
     },
@@ -181,7 +181,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &udav_bulk_write_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -192,7 +192,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &udav_bulk_read_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -202,7 +202,7 @@
       .type      = UE_INTERRUPT,
       .endpoint  = UE_ADDR_ANY,
       .direction = UE_DIR_IN,
-      .flags     = (USBD_PIPE_BOF|USBD_SHORT_XFER_OK),
+      .flags     = { .pipe_bof = 1, .short_xfer_ok = 1, },
       .bufsize   = 0, /* use wMaxPacketSize */
       .callback  = &udav_intr_callback,
     },
@@ -212,7 +212,7 @@
       .endpoint  = 0x00, /* Control pipe */
       .direction = UE_DIR_ANY,
       .bufsize   = sizeof(usb_device_request_t),
-      .flags     = USBD_USE_DMA,
+      .flags     = { },
       .callback  = &udav_intr_clear_stall_callback,
       .timeout   = 1000, /* 1 second */
       .interval  = 50, /* 50ms */
@@ -499,8 +499,8 @@
 	    goto error;
 	}
 
-	err = usbd_do_request_flags_mtx(sc->sc_udev, &(sc->sc_mtx), req, 
-					data, 0, NULL, 1000);
+	err = usbd_do_request_flags
+	  (sc->sc_udev, &(sc->sc_mtx), req, data, 0, NULL, 1000);
 
 	if (err) {
 
@@ -879,6 +879,7 @@
 	struct ifnet *ifp = sc->sc_ifp;
 	struct mbuf *m;
 	u_int32_t extra_len;
+	uint32_t temp_len;
 	u_int8_t buf[2];
 
 	USBD_CHECK_STATUS(xfer);
@@ -931,16 +932,16 @@
 	    extra_len = 0;
 	}
 
-	xfer->length = (m->m_pkthdr.len + extra_len);
+	temp_len = (m->m_pkthdr.len + extra_len);
 
 	/* 
 	 * the frame length is specified 
 	 * in the first 2 bytes of the buffer
 	 */
-	buf[0] = (u_int8_t)(xfer->length);
-	buf[1] = (u_int8_t)(xfer->length >> 8);
+	buf[0] = (u_int8_t)(temp_len);
+	buf[1] = (u_int8_t)(temp_len >> 8);
 
-	xfer->length += 2;
+	temp_len += 2;
 
 	usbd_copy_in(&(xfer->buf_data), 0, buf, 2);
 
@@ -948,7 +949,7 @@
 		       m, 0, m->m_pkthdr.len);
 
 	if (extra_len) {
-	    usbd_bzero(&(xfer->buf_data), xfer->length - extra_len, 
+	    usbd_bzero(&(xfer->buf_data), temp_len - extra_len, 
 		       extra_len);
 	}
 
@@ -960,6 +961,7 @@
 
 	m_freem(m);
 
+	xfer->frlengths[0] = temp_len;
 	usbd_start_hardware(xfer);
 
  done:
@@ -1057,6 +1059,7 @@
 	if (sc->sc_flags & UDAV_FLAG_READ_STALL) {
 	    usbd_transfer_start(sc->sc_xfer[3]);
 	} else {
+	    xfer->frlengths[0] = xfer->max_data_length;
 	    usbd_start_hardware(xfer);
 	}
 
@@ -1100,6 +1103,7 @@
 	if (sc->sc_flags & UDAV_FLAG_INTR_STALL) {

>>> TRUNCATED FOR MAIL (1000 lines) <<<



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