aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2009-06-23 02:19:59 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2009-06-23 02:19:59 +0000
commited6d949afdbe3f25e6ef640881d8a0a72d7b7aa8 (patch)
treeee5c9acfe716a9835136731811e9e1a68751e278 /sys/dev/usb
parent8c8fff3177f8d9611f191878b3864dc8ca3e5965 (diff)
downloadsrc-ed6d949afdbe3f25e6ef640881d8a0a72d7b7aa8.tar.gz
src-ed6d949afdbe3f25e6ef640881d8a0a72d7b7aa8.zip
- Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just usb.h and usbdi.h
Notes
Notes: svn path=/head/; revision=194677
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/controller/at91dci.c25
-rw-r--r--sys/dev/usb/controller/at91dci_atmelarm.c21
-rw-r--r--sys/dev/usb/controller/atmegadci.c25
-rw-r--r--sys/dev/usb/controller/atmegadci_atmelarm.c21
-rw-r--r--sys/dev/usb/controller/avr32dci.c25
-rw-r--r--sys/dev/usb/controller/ehci.c25
-rw-r--r--sys/dev/usb/controller/ehci_ixp4xx.c22
-rw-r--r--sys/dev/usb/controller/ehci_mbus.c22
-rw-r--r--sys/dev/usb/controller/ehci_pci.c22
-rw-r--r--sys/dev/usb/controller/musb_otg.c25
-rw-r--r--sys/dev/usb/controller/musb_otg_atmelarm.c22
-rw-r--r--sys/dev/usb/controller/ohci.c51
-rw-r--r--sys/dev/usb/controller/ohci_atmelarm.c22
-rw-r--r--sys/dev/usb/controller/ohci_pci.c23
-rw-r--r--sys/dev/usb/controller/uhci.c25
-rw-r--r--sys/dev/usb/controller/uhci_pci.c24
-rw-r--r--sys/dev/usb/controller/usb_controller.c25
-rw-r--r--sys/dev/usb/controller/uss820dci.c24
-rw-r--r--sys/dev/usb/controller/uss820dci_atmelarm.c22
-rw-r--r--sys/dev/usb/input/uhid.c126
-rw-r--r--sys/dev/usb/input/ukbd.c77
-rw-r--r--sys/dev/usb/input/ums.c71
-rw-r--r--sys/dev/usb/misc/udbp.c77
-rw-r--r--sys/dev/usb/misc/ufm.c41
-rw-r--r--sys/dev/usb/net/if_aue.c116
-rw-r--r--sys/dev/usb/net/if_axe.c104
-rw-r--r--sys/dev/usb/net/if_cdce.c129
-rw-r--r--sys/dev/usb/net/if_cue.c83
-rw-r--r--sys/dev/usb/net/if_kue.c87
-rw-r--r--sys/dev/usb/net/if_rue.c100
-rw-r--r--sys/dev/usb/net/if_udav.c97
-rw-r--r--sys/dev/usb/net/usb_ethernet.c29
-rw-r--r--sys/dev/usb/quirk/usb_quirk.c25
-rw-r--r--sys/dev/usb/quirk/usb_quirk.h2
-rw-r--r--sys/dev/usb/serial/u3g.c71
-rw-r--r--sys/dev/usb/serial/uark.c70
-rw-r--r--sys/dev/usb/serial/ubsa.c91
-rw-r--r--sys/dev/usb/serial/ubser.c76
-rw-r--r--sys/dev/usb/serial/uchcom.c91
-rw-r--r--sys/dev/usb/serial/ucycom.c100
-rw-r--r--sys/dev/usb/serial/ufoma.c161
-rw-r--r--sys/dev/usb/serial/uftdi.c79
-rw-r--r--sys/dev/usb/serial/ugensa.c68
-rw-r--r--sys/dev/usb/serial/uipaq.c68
-rw-r--r--sys/dev/usb/serial/ulpt.c134
-rw-r--r--sys/dev/usb/serial/umct.c91
-rw-r--r--sys/dev/usb/serial/umodem.c108
-rw-r--r--sys/dev/usb/serial/umoscom.c85
-rw-r--r--sys/dev/usb/serial/uplcom.c88
-rw-r--r--sys/dev/usb/serial/usb_serial.c32
-rw-r--r--sys/dev/usb/serial/uslcom.c67
-rw-r--r--sys/dev/usb/serial/uvisor.c69
-rw-r--r--sys/dev/usb/serial/uvscom.c87
-rw-r--r--sys/dev/usb/storage/umass.c377
-rw-r--r--sys/dev/usb/storage/urio.c94
-rw-r--r--sys/dev/usb/storage/ustorage_fs.c185
-rw-r--r--sys/dev/usb/template/usb_template.c37
-rw-r--r--sys/dev/usb/template/usb_template_cdce.c24
-rw-r--r--sys/dev/usb/template/usb_template_msc.c24
-rw-r--r--sys/dev/usb/template/usb_template_mtp.c25
-rw-r--r--sys/dev/usb/usb.h85
-rw-r--r--sys/dev/usb/usb_busdma.c26
-rw-r--r--sys/dev/usb/usb_busdma.h14
-rw-r--r--sys/dev/usb/usb_compat_linux.c78
-rw-r--r--sys/dev/usb/usb_compat_linux.h40
-rw-r--r--sys/dev/usb/usb_controller.h8
-rw-r--r--sys/dev/usb/usb_core.c24
-rw-r--r--sys/dev/usb/usb_core.h393
-rw-r--r--sys/dev/usb/usb_debug.c24
-rw-r--r--sys/dev/usb/usb_debug.h3
-rw-r--r--sys/dev/usb/usb_dev.c37
-rw-r--r--sys/dev/usb/usb_dev.h79
-rw-r--r--sys/dev/usb/usb_device.c38
-rw-r--r--sys/dev/usb/usb_device.h46
-rw-r--r--sys/dev/usb/usb_dynamic.c25
-rw-r--r--sys/dev/usb/usb_dynamic.h2
-rw-r--r--sys/dev/usb/usb_error.c24
-rw-r--r--sys/dev/usb/usb_error.h63
-rw-r--r--sys/dev/usb/usb_freebsd.h (renamed from sys/dev/usb/usb_defs.h)62
-rw-r--r--sys/dev/usb/usb_generic.c90
-rw-r--r--sys/dev/usb/usb_handle_request.c48
-rw-r--r--sys/dev/usb/usb_handle_request.h30
-rw-r--r--sys/dev/usb/usb_hid.c26
-rw-r--r--sys/dev/usb/usb_hid.h95
-rw-r--r--sys/dev/usb/usb_hub.c35
-rw-r--r--sys/dev/usb/usb_ioctl.h5
-rw-r--r--sys/dev/usb/usb_lookup.c24
-rw-r--r--sys/dev/usb/usb_lookup.h122
-rw-r--r--sys/dev/usb/usb_mbuf.c24
-rw-r--r--sys/dev/usb/usb_mbuf.h12
-rw-r--r--sys/dev/usb/usb_mfunc.h78
-rw-r--r--sys/dev/usb/usb_msctest.c110
-rw-r--r--sys/dev/usb/usb_parse.c25
-rw-r--r--sys/dev/usb/usb_parse.h54
-rw-r--r--sys/dev/usb/usb_process.c26
-rw-r--r--sys/dev/usb/usb_process.h13
-rw-r--r--sys/dev/usb/usb_request.c38
-rw-r--r--sys/dev/usb/usb_request.h31
-rw-r--r--sys/dev/usb/usb_revision.h77
-rw-r--r--sys/dev/usb/usb_transfer.c228
-rw-r--r--sys/dev/usb/usb_transfer.h1
-rw-r--r--sys/dev/usb/usb_util.c25
-rw-r--r--sys/dev/usb/usb_util.h2
-rw-r--r--sys/dev/usb/usbdi.h532
-rw-r--r--sys/dev/usb/usbdi_util.h81
-rw-r--r--sys/dev/usb/usbhid.h63
-rw-r--r--sys/dev/usb/wlan/if_rum.c79
-rw-r--r--sys/dev/usb/wlan/if_uath.c71
-rw-r--r--sys/dev/usb/wlan/if_upgt.c41
-rw-r--r--sys/dev/usb/wlan/if_ural.c77
-rw-r--r--sys/dev/usb/wlan/if_urtw.c36
-rw-r--r--sys/dev/usb/wlan/if_zyd.c137
112 files changed, 4431 insertions, 3013 deletions
diff --git a/sys/dev/usb/controller/at91dci.c b/sys/dev/usb/controller/at91dci.c
index fd1b684dd164..6c0ae081f8bb 100644
--- a/sys/dev/usb/controller/at91dci.c
+++ b/sys/dev/usb/controller/at91dci.c
@@ -44,9 +44,28 @@ __FBSDID("$FreeBSD$");
* endpoints, Function-address and more.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR at91dcidebug
@@ -70,7 +89,7 @@ __FBSDID("$FreeBSD$");
#define AT9100_DCI_PC2SC(pc) \
AT9100_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int at91dcidebug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, at91dci, CTLFLAG_RW, 0, "USB at91dci");
diff --git a/sys/dev/usb/controller/at91dci_atmelarm.c b/sys/dev/usb/controller/at91dci_atmelarm.c
index 37d79e561cef..39089752d3f3 100644
--- a/sys/dev/usb/controller/at91dci_atmelarm.c
+++ b/sys/dev/usb/controller/at91dci_atmelarm.c
@@ -26,9 +26,28 @@ __FBSDID("$FreeBSD$");
* SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
-#include <dev/usb/usb_mfunc.h>
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/atmegadci.c b/sys/dev/usb/controller/atmegadci.c
index 79d9fcbeae08..ef7e643dcd2e 100644
--- a/sys/dev/usb/controller/atmegadci.c
+++ b/sys/dev/usb/controller/atmegadci.c
@@ -36,9 +36,28 @@ __FBSDID("$FreeBSD$");
* endpoints, Function-address and more.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR atmegadci_debug
@@ -62,7 +81,7 @@ __FBSDID("$FreeBSD$");
#define ATMEGA_PC2SC(pc) \
ATMEGA_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int atmegadci_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, atmegadci, CTLFLAG_RW, 0, "USB ATMEGA DCI");
diff --git a/sys/dev/usb/controller/atmegadci_atmelarm.c b/sys/dev/usb/controller/atmegadci_atmelarm.c
index 3a85b50c2fe8..084554c0655f 100644
--- a/sys/dev/usb/controller/atmegadci_atmelarm.c
+++ b/sys/dev/usb/controller/atmegadci_atmelarm.c
@@ -26,7 +26,28 @@ __FBSDID("$FreeBSD$");
* SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/avr32dci.c b/sys/dev/usb/controller/avr32dci.c
index edf78792d4d5..07bf2ca9b820 100644
--- a/sys/dev/usb/controller/avr32dci.c
+++ b/sys/dev/usb/controller/avr32dci.c
@@ -36,9 +36,28 @@ __FBSDID("$FreeBSD$");
* endpoints, Function-address and more.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR avr32dci_debug
@@ -62,7 +81,7 @@ __FBSDID("$FreeBSD$");
#define AVR32_PC2SC(pc) \
AVR32_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int avr32dci_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, avr32dci, CTLFLAG_RW, 0, "USB AVR32 DCI");
diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c
index 9bbb7c4fbc68..a326a73f7abd 100644
--- a/sys/dev/usb/controller/ehci.c
+++ b/sys/dev/usb/controller/ehci.c
@@ -46,9 +46,28 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR ehcidebug
@@ -1133,7 +1152,7 @@ ehci_non_isoc_done_sub(struct usb_xfer *xfer)
td_alt_next = td->alt_next;
if (xfer->aframes != xfer->nframes) {
- xfer->frlengths[xfer->aframes] = 0;
+ usbd_xfer_set_frame_len(xfer, xfer->aframes, 0);
}
while (1) {
diff --git a/sys/dev/usb/controller/ehci_ixp4xx.c b/sys/dev/usb/controller/ehci_ixp4xx.c
index a29375fda59b..7668d8608e0a 100644
--- a/sys/dev/usb/controller/ehci_ixp4xx.c
+++ b/sys/dev/usb/controller/ehci_ixp4xx.c
@@ -31,8 +31,28 @@ __FBSDID("$FreeBSD$");
#include "opt_bus.h"
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/ehci_mbus.c b/sys/dev/usb/controller/ehci_mbus.c
index 73a8fafecb6c..7076854d6f2f 100644
--- a/sys/dev/usb/controller/ehci_mbus.c
+++ b/sys/dev/usb/controller/ehci_mbus.c
@@ -38,8 +38,28 @@ __FBSDID("$FreeBSD$");
#include "opt_bus.h"
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/ehci_pci.c b/sys/dev/usb/controller/ehci_pci.c
index 77efeb361cea..76f4247bcfe9 100644
--- a/sys/dev/usb/controller/ehci_pci.c
+++ b/sys/dev/usb/controller/ehci_pci.c
@@ -52,8 +52,28 @@ __FBSDID("$FreeBSD$");
* sharing of code between *BSD's
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c
index 22ce005b151e..c9e4bf680ca4 100644
--- a/sys/dev/usb/controller/musb_otg.c
+++ b/sys/dev/usb/controller/musb_otg.c
@@ -36,9 +36,28 @@
* NOTE: The current implementation only supports Device Side Mode!
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR musbotgdebug
@@ -64,7 +83,7 @@
#define MUSBOTG_PC2SC(pc) \
MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int musbotgdebug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, musbotg, CTLFLAG_RW, 0, "USB musbotg");
diff --git a/sys/dev/usb/controller/musb_otg_atmelarm.c b/sys/dev/usb/controller/musb_otg_atmelarm.c
index fa5f7ed8b942..0900a48f8b7b 100644
--- a/sys/dev/usb/controller/musb_otg_atmelarm.c
+++ b/sys/dev/usb/controller/musb_otg_atmelarm.c
@@ -24,8 +24,28 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c
index 5bce062a5795..1e4c317a584d 100644
--- a/sys/dev/usb/controller/ohci.c
+++ b/sys/dev/usb/controller/ohci.c
@@ -35,9 +35,28 @@ __FBSDID("$FreeBSD$");
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR ohcidebug
@@ -58,7 +77,7 @@ __FBSDID("$FreeBSD$");
((ohci_softc_t *)(((uint8_t *)(bus)) - \
((uint8_t *)&(((ohci_softc_t *)0)->sc_bus))))
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int ohcidebug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, ohci, CTLFLAG_RW, 0, "USB ohci");
@@ -205,7 +224,7 @@ reset:
device_printf(sc->sc_bus.bdev, "reset timeout\n");
return (USB_ERR_IOERROR);
}
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 15) {
ohci_dumpregs(sc);
}
@@ -264,7 +283,7 @@ reset:
sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
}
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 5) {
ohci_dumpregs(sc);
}
@@ -380,7 +399,7 @@ ohci_init(ohci_softc_t *sc)
usb_callout_init_mtx(&sc->sc_tmo_rhsc, &sc->sc_bus.bus_mtx, 0);
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 15) {
for (i = 0; i != OHCI_NO_EDS; i++) {
printf("ed#%d ", i);
@@ -433,7 +452,7 @@ ohci_suspend(ohci_softc_t *sc)
USB_BUS_LOCK(&sc->sc_bus);
-#if USB_DEBUG
+#ifdef USB_DEBUG
DPRINTF("\n");
if (ohcidebug > 2) {
ohci_dumpregs(sc);
@@ -463,7 +482,7 @@ ohci_resume(ohci_softc_t *sc)
{
uint32_t ctl;
-#if USB_DEBUG
+#ifdef USB_DEBUG
DPRINTF("\n");
if (ohcidebug > 2) {
ohci_dumpregs(sc);
@@ -497,7 +516,7 @@ ohci_resume(ohci_softc_t *sc)
ohci_do_poll(&sc->sc_bus);
}
-#if USB_DEBUG
+#ifdef USB_DEBUG
static void
ohci_dumpregs(ohci_softc_t *sc)
{
@@ -744,7 +763,7 @@ ohci_isoc_done(struct usb_xfer *xfer)
panic("%s:%d: out of TD's\n",
__FUNCTION__, __LINE__);
}
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 5) {
DPRINTF("isoc TD\n");
ohci_dump_itd(td);
@@ -785,7 +804,7 @@ ohci_isoc_done(struct usb_xfer *xfer)
ohci_device_done(xfer, USB_ERR_NORMAL_COMPLETION);
}
-#if USB_DEBUG
+#ifdef USB_DEBUG
static const char *const
ohci_cc_strs[] =
{
@@ -828,7 +847,7 @@ ohci_non_isoc_done_sub(struct usb_xfer *xfer)
td_flags = 0;
if (xfer->aframes != xfer->nframes) {
- xfer->frlengths[xfer->aframes] = 0;
+ usbd_xfer_set_frame_len(xfer, xfer->aframes, 0);
}
while (1) {
@@ -913,7 +932,7 @@ ohci_non_isoc_done(struct usb_xfer *xfer)
DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n",
xfer, xfer->endpoint);
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 10) {
ohci_dump_tds(xfer->td_transfer_first);
}
@@ -1138,7 +1157,7 @@ ohci_interrupt(ohci_softc_t *sc)
DPRINTFN(16, "real interrupt\n");
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 15) {
ohci_dumpregs(sc);
}
@@ -1564,7 +1583,7 @@ ohci_setup_standard_chain(struct usb_xfer *xfer, ohci_ed_t **ed_last)
xfer->td_transfer_last = td;
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 8) {
DPRINTF("nexttog=%d; data before transfer:\n",
xfer->endpoint->toggle_next);
@@ -1995,7 +2014,7 @@ ohci_device_isoc_enter(struct usb_xfer *xfer)
xfer->td_transfer_last = td_last;
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (ohcidebug > 8) {
DPRINTF("data before transfer:\n");
ohci_dump_itds(xfer->td_transfer_first);
diff --git a/sys/dev/usb/controller/ohci_atmelarm.c b/sys/dev/usb/controller/ohci_atmelarm.c
index a757611d6049..a4fe9f397b94 100644
--- a/sys/dev/usb/controller/ohci_atmelarm.c
+++ b/sys/dev/usb/controller/ohci_atmelarm.c
@@ -25,8 +25,28 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/ohci_pci.c b/sys/dev/usb/controller/ohci_pci.c
index 76943c411b9a..09abafd57eb4 100644
--- a/sys/dev/usb/controller/ohci_pci.c
+++ b/sys/dev/usb/controller/ohci_pci.c
@@ -49,9 +49,28 @@ __FBSDID("$FreeBSD$");
* sharing of code between *BSD's
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c
index 6d6a67ede3e6..77e95d3ad8be 100644
--- a/sys/dev/usb/controller/uhci.c
+++ b/sys/dev/usb/controller/uhci.c
@@ -38,9 +38,28 @@ __FBSDID("$FreeBSD$");
* ftp://download.intel.com/design/intarch/datashts/29056201.pdf
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR uhcidebug
@@ -1103,7 +1122,7 @@ uhci_non_isoc_done_sub(struct usb_xfer *xfer)
td_alt_next = td->alt_next;
if (xfer->aframes != xfer->nframes) {
- xfer->frlengths[xfer->aframes] = 0;
+ usbd_xfer_set_frame_len(xfer, xfer->aframes, 0);
}
while (1) {
diff --git a/sys/dev/usb/controller/uhci_pci.c b/sys/dev/usb/controller/uhci_pci.c
index ed7819e65b13..4fcf5d34a713 100644
--- a/sys/dev/usb/controller/uhci_pci.c
+++ b/sys/dev/usb/controller/uhci_pci.c
@@ -48,8 +48,28 @@ __FBSDID("$FreeBSD$");
* sharing of code between *BSD's
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
@@ -339,7 +359,7 @@ uhci_pci_attach(device_t self)
* that the BIOS won't touch the keyboard anymore if it is connected
* to the ports of the root hub?
*/
-#if USB_DEBUG
+#ifdef USB_DEBUG
if (pci_read_config(self, PCI_LEGSUP, 2) != PCI_LEGSUP_USBPIRQDEN) {
device_printf(self, "LegSup = 0x%04x\n",
pci_read_config(self, PCI_LEGSUP, 2));
diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c
index 3e7c0a7eaa20..b2f94c63e1c3 100644
--- a/sys/dev/usb/controller/usb_controller.c
+++ b/sys/dev/usb/controller/usb_controller.c
@@ -24,9 +24,28 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR usb_ctrl_debug
@@ -52,7 +71,7 @@ static void usb_post_init(void *);
/* static variables */
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int usb_ctrl_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, ctrl, CTLFLAG_RW, 0, "USB controller");
diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c
index 9f29bbf72aa8..c1c5b35251d3 100644
--- a/sys/dev/usb/controller/uss820dci.c
+++ b/sys/dev/usb/controller/uss820dci.c
@@ -32,10 +32,28 @@
* NOTE: The datasheet does not document everything.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_revision.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR uss820dcidebug
diff --git a/sys/dev/usb/controller/uss820dci_atmelarm.c b/sys/dev/usb/controller/uss820dci_atmelarm.c
index f8988b8fdfed..52a7364bdb95 100644
--- a/sys/dev/usb/controller/uss820dci_atmelarm.c
+++ b/sys/dev/usb/controller/uss820dci_atmelarm.c
@@ -27,8 +27,28 @@ __FBSDID("$FreeBSD$");
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index 9390a69e6664..411aeb6170da 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -48,29 +48,39 @@ __FBSDID("$FreeBSD$");
* HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include "usbdevs.h"
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usb_ioctl.h>
#define USB_DEBUG_VAR uhid_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_util.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_dynamic.h>
-#include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
-#include <dev/usb/usb_hid.h>
#include <dev/usb/input/usb_rdesc.h>
-
#include <dev/usb/quirk/usb_quirk.h>
#if USB_DEBUG
@@ -150,38 +160,40 @@ static struct usb_fifo_methods uhid_fifo_methods = {
};
static void
-uhid_intr_callback(struct usb_xfer *xfer)
+uhid_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uhid_softc *sc = xfer->priv_sc;
+ struct uhid_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
DPRINTF("transferred!\n");
- if (xfer->actlen >= sc->sc_isize) {
- usb_fifo_put_data(
- sc->sc_fifo.fp[USB_FIFO_RX],
- xfer->frbuffers,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (actlen >= sc->sc_isize) {
+ usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], pc,
0, sc->sc_isize, 1);
} else {
/* ignore it */
- DPRINTF("ignored short transfer, "
- "%d bytes\n", xfer->actlen);
+ DPRINTF("ignored short transfer, %d bytes\n", actlen);
}
case USB_ST_SETUP:
re_submit:
if (usb_fifo_put_bytes_max(
sc->sc_fifo.fp[USB_FIFO_RX]) != 0) {
- xfer->frlengths[0] = sc->sc_isize;
+ usbd_xfer_set_frame_len(xfer, 0, sc->sc_isize);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto re_submit;
}
return;
@@ -213,10 +225,11 @@ uhid_fill_get_report(struct usb_device_request *req, uint8_t iface_no,
}
static void
-uhid_write_callback(struct usb_xfer *xfer)
+uhid_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uhid_softc *sc = xfer->priv_sc;
+ struct uhid_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
uint32_t size = sc->sc_osize;
uint32_t actlen;
uint8_t id;
@@ -226,15 +239,13 @@ uhid_write_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
/* try to extract the ID byte */
if (sc->sc_oid) {
-
- if (usb_fifo_get_data(
- sc->sc_fifo.fp[USB_FIFO_TX],
- xfer->frbuffers,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (usb_fifo_get_data(sc->sc_fifo.fp[USB_FIFO_TX], pc,
0, 1, &actlen, 0)) {
if (actlen != 1) {
goto tr_error;
}
- usbd_copy_out(xfer->frbuffers, 0, &id, 1);
+ usbd_copy_out(pc, 0, &id, 1);
} else {
return;
@@ -246,9 +257,8 @@ uhid_write_callback(struct usb_xfer *xfer)
id = 0;
}
- if (usb_fifo_get_data(
- sc->sc_fifo.fp[USB_FIFO_TX],
- xfer->frbuffers + 1,
+ pc = usbd_xfer_get_frame(xfer, 1);
+ if (usb_fifo_get_data(sc->sc_fifo.fp[USB_FIFO_TX], pc,
0, UHID_BSIZE, &actlen, 1)) {
if (actlen != size) {
goto tr_error;
@@ -257,11 +267,12 @@ uhid_write_callback(struct usb_xfer *xfer)
(&req, sc->sc_iface_no,
UHID_OUTPUT_REPORT, id, size);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = size;
- xfer->nframes = xfer->frlengths[1] ? 2 : 1;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, size);
+ usbd_xfer_set_frames(xfer, size ? 2 : 1);
usbd_transfer_submit(xfer);
}
return;
@@ -275,15 +286,18 @@ tr_error:
}
static void
-uhid_read_callback(struct usb_xfer *xfer)
+uhid_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uhid_softc *sc = xfer->priv_sc;
+ struct uhid_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
+
+ pc = usbd_xfer_get_frame(xfer, 0);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], xfer->frbuffers,
- sizeof(req), sc->sc_isize, 1);
+ usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], pc, sizeof(req),
+ sc->sc_isize, 1);
return;
case USB_ST_SETUP:
@@ -294,11 +308,11 @@ uhid_read_callback(struct usb_xfer *xfer)
(&req, sc->sc_iface_no, UHID_INPUT_REPORT,
sc->sc_iid, sc->sc_isize);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ usbd_copy_in(pc, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = sc->sc_isize;
- xfer->nframes = xfer->frlengths[1] ? 2 : 1;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, sc->sc_isize);
+ usbd_xfer_set_frames(xfer, sc->sc_isize ? 2 : 1);
usbd_transfer_submit(xfer);
}
return;
@@ -343,7 +357,7 @@ static const struct usb_config uhid_config[UHID_N_TRANSFER] = {
static void
uhid_start_read(struct usb_fifo *fifo)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
if (sc->sc_flags & UHID_FLAG_IMMED) {
usbd_transfer_start(sc->sc_xfer[UHID_CTRL_DT_RD]);
@@ -355,7 +369,7 @@ uhid_start_read(struct usb_fifo *fifo)
static void
uhid_stop_read(struct usb_fifo *fifo)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[UHID_CTRL_DT_RD]);
usbd_transfer_stop(sc->sc_xfer[UHID_INTR_DT_RD]);
@@ -364,7 +378,7 @@ uhid_stop_read(struct usb_fifo *fifo)
static void
uhid_start_write(struct usb_fifo *fifo)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[UHID_CTRL_DT_WR]);
}
@@ -372,7 +386,7 @@ uhid_start_write(struct usb_fifo *fifo)
static void
uhid_stop_write(struct usb_fifo *fifo)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[UHID_CTRL_DT_WR]);
}
@@ -449,7 +463,7 @@ done:
static int
uhid_open(struct usb_fifo *fifo, int fflags)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
/*
* The buffers are one byte larger than maximum so that one
@@ -485,7 +499,7 @@ static int
uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
int fflags)
{
- struct uhid_softc *sc = fifo->priv_sc0;
+ struct uhid_softc *sc = usb_fifo_softc(fifo);
struct usb_gen_descriptor *ugd;
uint32_t size;
int error = 0;
@@ -656,7 +670,7 @@ uhid_attach(device_t dev)
if (uaa->info.idProduct == USB_PRODUCT_WACOM_GRAPHIRE) {
sc->sc_repdesc_size = sizeof(uhid_graphire_report_descr);
- sc->sc_repdesc_ptr = USB_ADD_BYTES(uhid_graphire_report_descr, 0);
+ sc->sc_repdesc_ptr = &uhid_graphire_report_descr;
sc->sc_flags |= UHID_FLAG_STATIC_DESC;
} else if (uaa->info.idProduct == USB_PRODUCT_WACOM_GRAPHIRE3_4X5) {
@@ -677,7 +691,7 @@ uhid_attach(device_t dev)
usbd_errstr(error));
}
sc->sc_repdesc_size = sizeof(uhid_graphire3_4x5_report_descr);
- sc->sc_repdesc_ptr = USB_ADD_BYTES(uhid_graphire3_4x5_report_descr, 0);
+ sc->sc_repdesc_ptr = &uhid_graphire3_4x5_report_descr;
sc->sc_flags |= UHID_FLAG_STATIC_DESC;
}
} else if ((uaa->info.bInterfaceClass == UICLASS_VENDOR) &&
@@ -686,7 +700,7 @@ uhid_attach(device_t dev)
/* the Xbox 360 gamepad has no report descriptor */
sc->sc_repdesc_size = sizeof(uhid_xb360gp_report_descr);
- sc->sc_repdesc_ptr = USB_ADD_BYTES(uhid_xb360gp_report_descr, 0);
+ sc->sc_repdesc_ptr = &uhid_xb360gp_report_descr;
sc->sc_flags |= UHID_FLAG_STATIC_DESC;
}
if (sc->sc_repdesc_ptr == NULL) {
diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c
index 52062fce1110..29546a5c2a84 100644
--- a/sys/dev/usb/input/ukbd.c
+++ b/sys/dev/usb/input/ukbd.c
@@ -48,22 +48,33 @@ __FBSDID("$FreeBSD$");
#include "opt_kbd.h"
#include "opt_ukbd.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#define USB_DEBUG_VAR ukbd_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_util.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_dynamic.h>
-#include <dev/usb/usb_hid.h>
#include <dev/usb/quirk/usb_quirk.h>
@@ -304,7 +315,7 @@ ukbd_get_key(struct ukbd_softc *sc, uint8_t wait)
while (sc->sc_inputs == 0) {
- usbd_do_poll(sc->sc_xfer, UKBD_N_TRANSFER);
+ usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER);
DELAY(1000); /* delay 1 ms */
@@ -480,15 +491,19 @@ ukbd_apple_swap(uint8_t keycode) {
}
static void
-ukbd_intr_callback(struct usb_xfer *xfer)
+ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ukbd_softc *sc = xfer->priv_sc;
- uint16_t len = xfer->actlen;
+ struct ukbd_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t i;
uint8_t offset;
uint8_t id;
uint8_t apple_fn;
uint8_t apple_eject;
+ int len;
+
+ usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
+ pc = usbd_xfer_get_frame(xfer, 0);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -501,7 +516,7 @@ ukbd_intr_callback(struct usb_xfer *xfer)
if (sc->sc_kbd_id != 0) {
/* check and remove HID ID byte */
- usbd_copy_out(xfer->frbuffers, 0, &id, 1);
+ usbd_copy_out(pc, 0, &id, 1);
if (id != sc->sc_kbd_id) {
DPRINTF("wrong HID ID\n");
goto tr_setup;
@@ -518,8 +533,7 @@ ukbd_intr_callback(struct usb_xfer *xfer)
if (len) {
memset(&sc->sc_ndata, 0, sizeof(sc->sc_ndata));
- usbd_copy_out(xfer->frbuffers, offset,
- &sc->sc_ndata, len);
+ usbd_copy_out(pc, offset, &sc->sc_ndata, len);
if ((sc->sc_flags & UKBD_FLAG_APPLE_EJECT) &&
hid_get_data((uint8_t *)&sc->sc_ndata,
@@ -567,7 +581,7 @@ ukbd_intr_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
if (sc->sc_inputs < UKBD_IN_BUF_FULL) {
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
} else {
DPRINTF("input queue is full!\n");
@@ -575,11 +589,11 @@ tr_setup:
break;
default: /* Error */
- DPRINTF("error=%s\n", usbd_errstr(xfer->error));
+ DPRINTF("error=%s\n", usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -587,11 +601,12 @@ tr_setup:
}
static void
-ukbd_set_leds_callback(struct usb_xfer *xfer)
+ukbd_set_leds_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct usb_device_request req;
+ struct usb_page_cache *pc;
uint8_t buf[2];
- struct ukbd_softc *sc = xfer->priv_sc;
+ struct ukbd_softc *sc = usbd_xfer_softc(xfer);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -617,18 +632,20 @@ ukbd_set_leds_callback(struct usb_xfer *xfer)
buf[1] = 0;
}
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
- usbd_copy_in(xfer->frbuffers + 1, 0, buf, sizeof(buf));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 1);
+ usbd_copy_in(pc, 0, buf, sizeof(buf));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = req.wLength[0];
- xfer->nframes = 2;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, req.wLength[0]);
+ usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- DPRINTFN(0, "error=%s\n", usbd_errstr(xfer->error));
+ DPRINTFN(0, "error=%s\n", usbd_errstr(error));
return;
}
}
diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c
index 4eff1f2addf1..c4cc103bde3e 100644
--- a/sys/dev/usb/input/ums.c
+++ b/sys/dev/usb/input/ums.c
@@ -42,25 +42,36 @@ __FBSDID("$FreeBSD$");
* HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR ums_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_util.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_dynamic.h>
-#include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
-#include <dev/usb/usb_hid.h>
#include <dev/usb/quirk/usb_quirk.h>
@@ -170,12 +181,12 @@ ums_put_queue_timeout(void *__sc)
}
static void
-ums_intr_callback(struct usb_xfer *xfer)
+ums_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ums_softc *sc = xfer->priv_sc;
+ struct ums_softc *sc = usbd_xfer_softc(xfer);
struct ums_info *info = &sc->sc_info[0];
+ struct usb_page_cache *pc;
uint8_t *buf = sc->sc_temp;
- uint16_t len = xfer->actlen;
int32_t buttons = 0;
int32_t dw = 0;
int32_t dx = 0;
@@ -184,6 +195,9 @@ ums_intr_callback(struct usb_xfer *xfer)
int32_t dt = 0;
uint8_t i;
uint8_t id;
+ int len;
+
+ usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -197,7 +211,8 @@ ums_intr_callback(struct usb_xfer *xfer)
if (len == 0)
goto tr_setup;
- usbd_copy_out(xfer->frbuffers, 0, buf, len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, len);
DPRINTFN(6, "data = %02x %02x %02x %02x "
"%02x %02x %02x %02x\n",
@@ -301,15 +316,15 @@ tr_setup:
/* check if we can put more data into the FIFO */
if (usb_fifo_put_bytes_max(
sc->sc_fifo.fp[USB_FIFO_RX]) != 0) {
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -547,10 +562,10 @@ ums_attach(device_t dev)
/* Some wheels need the Z axis reversed. */
info->sc_flags |= UMS_FLAG_REVZ;
}
- if (isize > sc->sc_xfer[UMS_INTR_DT]->max_frame_size) {
+ if (isize > usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])) {
DPRINTF("WARNING: report size, %d bytes, is larger "
- "than interrupt size, %d bytes!\n",
- isize, sc->sc_xfer[UMS_INTR_DT]->max_frame_size);
+ "than interrupt size, %d bytes!\n", isize,
+ usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT]));
}
free(d_ptr, M_TEMP);
d_ptr = NULL;
@@ -637,7 +652,7 @@ ums_detach(device_t self)
static void
ums_start_read(struct usb_fifo *fifo)
{
- struct ums_softc *sc = fifo->priv_sc0;
+ struct ums_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[UMS_INTR_DT]);
}
@@ -645,7 +660,7 @@ ums_start_read(struct usb_fifo *fifo)
static void
ums_stop_read(struct usb_fifo *fifo)
{
- struct ums_softc *sc = fifo->priv_sc0;
+ struct ums_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[UMS_INTR_DT]);
usb_callout_stop(&sc->sc_callout);
@@ -712,7 +727,7 @@ ums_reset_buf(struct ums_softc *sc)
static int
ums_open(struct usb_fifo *fifo, int fflags)
{
- struct ums_softc *sc = fifo->priv_sc0;
+ struct ums_softc *sc = usb_fifo_softc(fifo);
DPRINTFN(2, "\n");
@@ -747,7 +762,7 @@ ums_close(struct usb_fifo *fifo, int fflags)
static int
ums_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
{
- struct ums_softc *sc = fifo->priv_sc0;
+ struct ums_softc *sc = usb_fifo_softc(fifo);
mousemode_t mode;
int error = 0;
diff --git a/sys/dev/usb/misc/udbp.c b/sys/dev/usb/misc/udbp.c
index e856296c5434..ada6b3c0a29e 100644
--- a/sys/dev/usb/misc/udbp.c
+++ b/sys/dev/usb/misc/udbp.c
@@ -57,19 +57,33 @@ __FBSDID("$FreeBSD$");
*
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR udbp_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_parse.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <sys/mbuf.h>
@@ -395,10 +409,14 @@ udbp_detach(device_t dev)
}
static void
-udbp_bulk_read_callback(struct usb_xfer *xfer)
+udbp_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udbp_softc *sc = xfer->priv_sc;
+ struct udbp_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
struct mbuf *m;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -416,14 +434,14 @@ udbp_bulk_read_callback(struct usb_xfer *xfer)
m_freem(m);
goto tr_setup;
}
- m->m_pkthdr.len = m->m_len = xfer->actlen;
+ m->m_pkthdr.len = m->m_len = actlen;
- usbd_copy_out(xfer->frbuffers, 0, m->m_data, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, m->m_data, actlen);
sc->sc_bulk_in_buffer = m;
- DPRINTF("received package %d "
- "bytes\n", xfer->actlen);
+ DPRINTF("received package %d bytes\n", actlen);
case USB_ST_SETUP:
tr_setup:
@@ -435,12 +453,12 @@ tr_setup:
usbd_transfer_start(sc->sc_xfer[UDBP_T_RD_CS]);
return;
}
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
sc->sc_flags |= UDBP_FLAG_READ_STALL;
usbd_transfer_start(sc->sc_xfer[UDBP_T_RD_CS]);
@@ -451,9 +469,9 @@ tr_setup:
}
static void
-udbp_bulk_read_clear_stall_callback(struct usb_xfer *xfer)
+udbp_bulk_read_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udbp_softc *sc = xfer->priv_sc;
+ struct udbp_softc *sc = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = sc->sc_xfer[UDBP_T_RD];
if (usbd_clear_stall_callback(xfer, xfer_other)) {
@@ -504,9 +522,10 @@ done:
}
static void
-udbp_bulk_write_callback(struct usb_xfer *xfer)
+udbp_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udbp_softc *sc = xfer->priv_sc;
+ struct udbp_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
struct mbuf *m;
switch (USB_GET_STATE(xfer)) {
@@ -535,20 +554,20 @@ udbp_bulk_write_callback(struct usb_xfer *xfer)
MCLBYTES);
m->m_pkthdr.len = MCLBYTES;
}
- usbd_m_copy_in(xfer->frbuffers, 0, m, 0, m->m_pkthdr.len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
- xfer->frlengths[0] = m->m_pkthdr.len;
+ usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
- m_freem(m);
+ DPRINTF("packet out: %d bytes\n", m->m_pkthdr.len);
- DPRINTF("packet out: %d bytes\n",
- xfer->frlengths[0]);
+ m_freem(m);
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
sc->sc_flags |= UDBP_FLAG_WRITE_STALL;
usbd_transfer_start(sc->sc_xfer[UDBP_T_WR_CS]);
@@ -559,9 +578,9 @@ udbp_bulk_write_callback(struct usb_xfer *xfer)
}
static void
-udbp_bulk_write_clear_stall_callback(struct usb_xfer *xfer)
+udbp_bulk_write_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udbp_softc *sc = xfer->priv_sc;
+ struct udbp_softc *sc = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = sc->sc_xfer[UDBP_T_WR];
if (usbd_clear_stall_callback(xfer, xfer_other)) {
diff --git a/sys/dev/usb/misc/ufm.c b/sys/dev/usb/misc/ufm.c
index d8e4a9e7e319..c10166a5bf0e 100644
--- a/sys/dev/usb/misc/ufm.c
+++ b/sys/dev/usb/misc/ufm.c
@@ -32,23 +32,36 @@
__FBSDID("$FreeBSD$");
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/ufm_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
+
+#include <dev/usb/ufm_ioctl.h>
#define UFM_CMD0 0x00
#define UFM_CMD_SET_FREQ 0x01
@@ -299,7 +312,7 @@ static int
ufm_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
int fflags)
{
- struct ufm_softc *sc = fifo->priv_sc0;
+ struct ufm_softc *sc = usb_fifo_softc(fifo);
int error = 0;
switch (cmd) {
diff --git a/sys/dev/usb/net/if_aue.c b/sys/dev/usb/net/if_aue.c
index 46ec9016b4ba..550186d82f8a 100644
--- a/sys/dev/usb/net/if_aue.c
+++ b/sys/dev/usb/net/if_aue.c
@@ -68,20 +68,34 @@ __FBSDID("$FreeBSD$");
* transfers are done using usbd_transfer() and friends.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR aue_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_auereg.h>
@@ -711,19 +725,24 @@ aue_detach(device_t dev)
}
static void
-aue_intr_callback(struct usb_xfer *xfer)
+aue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct aue_softc *sc = xfer->priv_sc;
+ struct aue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
struct aue_intrpkt pkt;
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
- xfer->actlen >= sizeof(pkt)) {
+ actlen >= sizeof(pkt)) {
- usbd_copy_out(xfer->frbuffers, 0, &pkt, sizeof(pkt));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &pkt, sizeof(pkt));
if (pkt.aue_txstat0)
ifp->if_oerrors++;
@@ -734,14 +753,14 @@ aue_intr_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -749,31 +768,36 @@ tr_setup:
}
static void
-aue_bulk_read_callback(struct usb_xfer *xfer)
+aue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct aue_softc *sc = xfer->priv_sc;
+ struct aue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
struct aue_rxpkt stat;
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+ pc = usbd_xfer_get_frame(xfer, 0);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(11, "received %d bytes\n", xfer->actlen);
+ DPRINTFN(11, "received %d bytes\n", actlen);
if (sc->sc_flags & AUE_FLAG_VER_2) {
- if (xfer->actlen == 0) {
+ if (actlen == 0) {
ifp->if_ierrors++;
goto tr_setup;
}
} else {
- if (xfer->actlen <= (sizeof(stat) + ETHER_CRC_LEN)) {
+ if (actlen <= sizeof(stat) + ETHER_CRC_LEN) {
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers,
- xfer->actlen - sizeof(stat), &stat, sizeof(stat));
+ usbd_copy_out(pc, actlen - sizeof(stat), &stat,
+ sizeof(stat));
/*
* turn off all the non-error bits in the rx status
@@ -785,25 +809,25 @@ aue_bulk_read_callback(struct usb_xfer *xfer)
goto tr_setup;
}
/* No errors; receive the packet. */
- xfer->actlen -= (sizeof(stat) + ETHER_CRC_LEN);
+ actlen -= (sizeof(stat) + ETHER_CRC_LEN);
}
- uether_rxbuf(ue, xfer->frbuffers, 0, xfer->actlen);
+ uether_rxbuf(ue, pc, 0, actlen);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -811,16 +835,21 @@ tr_setup:
}
static void
-aue_bulk_write_callback(struct usb_xfer *xfer)
+aue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct aue_softc *sc = xfer->priv_sc;
+ struct aue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
uint8_t buf[2];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+ pc = usbd_xfer_get_frame(xfer, 0);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(11, "transfer of %d bytes complete\n", xfer->actlen);
+ DPRINTFN(11, "transfer of %d bytes complete\n", actlen);
ifp->if_opackets++;
/* FALLTHROUGH */
@@ -840,14 +869,13 @@ tr_setup:
m->m_pkthdr.len = MCLBYTES;
if (sc->sc_flags & AUE_FLAG_VER_2) {
- xfer->frlengths[0] = m->m_pkthdr.len;
+ usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
- usbd_m_copy_in(xfer->frbuffers, 0,
- m, 0, m->m_pkthdr.len);
+ usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
} else {
- xfer->frlengths[0] = (m->m_pkthdr.len + 2);
+ usbd_xfer_set_frame_len(xfer, 0, (m->m_pkthdr.len + 2));
/*
* The ADMtek documentation says that the
@@ -860,10 +888,8 @@ tr_setup:
buf[0] = (uint8_t)(m->m_pkthdr.len);
buf[1] = (uint8_t)(m->m_pkthdr.len >> 8);
- usbd_copy_in(xfer->frbuffers, 0, buf, 2);
-
- usbd_m_copy_in(xfer->frbuffers, 2,
- m, 0, m->m_pkthdr.len);
+ usbd_copy_in(pc, 0, buf, 2);
+ usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
}
/*
@@ -879,13 +905,13 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -951,7 +977,7 @@ aue_init(struct usb_ether *ue)
AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB);
AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR);
- usbd_transfer_set_stall(sc->sc_xfer[AUE_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[AUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
aue_start(ue);
diff --git a/sys/dev/usb/net/if_axe.c b/sys/dev/usb/net/if_axe.c
index 83caec01c88b..3c72b383e4ca 100644
--- a/sys/dev/usb/net/if_axe.c
+++ b/sys/dev/usb/net/if_axe.c
@@ -76,20 +76,34 @@ __FBSDID("$FreeBSD$");
* http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR axe_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_axereg.h>
@@ -731,20 +745,20 @@ axe_detach(device_t dev)
}
static void
-axe_intr_callback(struct usb_xfer *xfer)
+axe_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -756,56 +770,61 @@ tr_setup:
#endif
static void
-axe_bulk_read_callback(struct usb_xfer *xfer)
+axe_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct axe_softc *sc = xfer->priv_sc;
+ struct axe_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
struct axe_sframe_hdr hdr;
- int error, pos, len, adjust;
+ struct usb_page_cache *pc;
+ int err, pos, len, adjust;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
pos = 0;
+ pc = usbd_xfer_get_frame(xfer, 0);
while (1) {
if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
- if (xfer->actlen < sizeof(hdr)) {
+ if (actlen < sizeof(hdr)) {
/* too little data */
break;
}
- usbd_copy_out(xfer->frbuffers, pos, &hdr, sizeof(hdr));
+ usbd_copy_out(pc, pos, &hdr, sizeof(hdr));
if ((hdr.len ^ hdr.ilen) != 0xFFFF) {
/* we lost sync */
break;
}
- xfer->actlen -= sizeof(hdr);
+ actlen -= sizeof(hdr);
pos += sizeof(hdr);
len = le16toh(hdr.len);
- if (len > xfer->actlen) {
+ if (len > actlen) {
/* invalid length */
break;
}
adjust = (len & 1);
} else {
- len = xfer->actlen;
+ len = actlen;
adjust = 0;
}
- error = uether_rxbuf(ue, xfer->frbuffers, pos, len);
- if (error)
+ err = uether_rxbuf(ue, pc, pos, len);
+ if (err)
break;
pos += len;
- xfer->actlen -= len;
+ actlen -= len;
- if (xfer->actlen <= adjust) {
+ if (actlen <= adjust) {
/* we are finished */
goto tr_setup;
}
pos += adjust;
- xfer->actlen -= adjust;
+ actlen -= adjust;
}
/* count an error */
@@ -814,18 +833,17 @@ axe_bulk_read_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
- DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ DPRINTF("bulk read error, %s\n", usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -838,11 +856,12 @@ tr_setup:
#endif
static void
-axe_bulk_write_callback(struct usb_xfer *xfer)
+axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct axe_softc *sc = xfer->priv_sc;
+ struct axe_softc *sc = usbd_xfer_softc(xfer);
struct axe_sframe_hdr hdr;
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
int pos;
@@ -860,6 +879,7 @@ tr_setup:
return;
}
pos = 0;
+ pc = usbd_xfer_get_frame(xfer, 0);
while (1) {
@@ -878,7 +898,7 @@ tr_setup:
hdr.len = htole16(m->m_pkthdr.len);
hdr.ilen = ~hdr.len;
- usbd_copy_in(xfer->frbuffers, pos, &hdr, sizeof(hdr));
+ usbd_copy_in(pc, pos, &hdr, sizeof(hdr));
pos += sizeof(hdr);
@@ -890,9 +910,7 @@ tr_setup:
* USB_FORCE_SHORT_XFER flag instead.
*/
}
- usbd_m_copy_in(xfer->frbuffers, pos,
- m, 0, m->m_pkthdr.len);
-
+ usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len);
pos += m->m_pkthdr.len;
/*
@@ -914,19 +932,19 @@ tr_setup:
}
}
- xfer->frlengths[0] = pos;
+ usbd_xfer_set_frame_len(xfer, 0, pos);
usbd_transfer_submit(xfer);
return;
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -1010,7 +1028,7 @@ axe_init(struct usb_ether *ue)
/* Load the multicast filter. */
axe_setmulti(ue);
- usbd_transfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
axe_start(ue);
diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c
index 624760b18306..532776ed3fa6 100644
--- a/sys/dev/usb/net/if_cdce.c
+++ b/sys/dev/usb/net/if_cdce.c
@@ -43,23 +43,36 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR cdce_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_parse.h>
-#include <dev/usb/usb_device.h>
+#include <dev/usb/usb_process.h>
+#include "usb_if.h"
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_cdcereg.h>
@@ -426,22 +439,24 @@ cdce_free_queue(struct mbuf **ppm, uint8_t n)
}
static void
-cdce_bulk_write_callback(struct usb_xfer *xfer)
+cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct cdce_softc *sc = xfer->priv_sc;
+ struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
struct mbuf *m;
struct mbuf *mt;
uint32_t crc;
uint8_t x;
+ int actlen, aframes;
+
+ usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL);
DPRINTFN(1, "\n");
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(11, "transfer complete: "
- "%u bytes in %u frames\n", xfer->actlen,
- xfer->aframes);
+ DPRINTFN(11, "transfer complete: %u bytes in %u frames\n",
+ actlen, aframes);
ifp->if_opackets++;
@@ -486,8 +501,7 @@ tr_setup:
m->m_pkthdr.len = MCLBYTES;
}
sc->sc_tx_buf[x] = m;
- xfer->frlengths[x] = m->m_len;
- usbd_set_frame_data(xfer, m->m_data, x);
+ usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len);
/*
* If there's a BPF listener, bounce a copy of
@@ -496,14 +510,15 @@ tr_setup:
BPF_MTAP(ifp, m);
}
if (x != 0) {
- xfer->nframes = x;
+ usbd_xfer_set_frames(xfer, x);
+
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
/* free all previous TX buffers */
cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX);
@@ -511,9 +526,9 @@ tr_setup:
/* count output errors */
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -554,7 +569,7 @@ cdce_init(struct usb_ether *ue)
usbd_transfer_start(sc->sc_xfer[CDCE_INTR_TX]);
/* stall data write direction, which depends on USB mode */
- usbd_transfer_set_stall(sc->sc_xfer[CDCE_BULK_TX]);
+ usbd_xfer_set_stall(sc->sc_xfer[CDCE_BULK_TX]);
/* start data transfers */
cdce_start(ue);
@@ -608,34 +623,36 @@ cdce_resume(device_t dev)
}
static void
-cdce_bulk_read_callback(struct usb_xfer *xfer)
+cdce_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct cdce_softc *sc = xfer->priv_sc;
+ struct cdce_softc *sc = usbd_xfer_softc(xfer);
struct mbuf *m;
uint8_t x;
+ int actlen, aframes, len;
+
+ usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("received %u bytes in %u frames\n",
- xfer->actlen, xfer->aframes);
+ DPRINTF("received %u bytes in %u frames\n", actlen, aframes);
- for (x = 0; x != xfer->aframes; x++) {
+ for (x = 0; x != aframes; x++) {
m = sc->sc_rx_buf[x];
sc->sc_rx_buf[x] = NULL;
+ len = usbd_xfer_get_frame_len(xfer, x);
/* Strip off CRC added by Zaurus, if any */
- if ((sc->sc_flags & CDCE_FLAG_ZAURUS) &&
- (xfer->frlengths[x] >= 14))
- xfer->frlengths[x] -= 4;
+ if ((sc->sc_flags & CDCE_FLAG_ZAURUS) && len >= 14)
+ len -= 4;
- if (xfer->frlengths[x] < sizeof(struct ether_header)) {
+ if (len < sizeof(struct ether_header)) {
m_freem(m);
continue;
}
/* queue up mbuf */
- uether_rxmbuf(&sc->sc_ue, m, xfer->frlengths[x]);
+ uether_rxmbuf(&sc->sc_ue, m, len);
}
/* FALLTHROUGH */
@@ -654,11 +671,10 @@ cdce_bulk_read_callback(struct usb_xfer *xfer)
m = sc->sc_rx_buf[x];
}
- usbd_set_frame_data(xfer, m->m_data, x);
- xfer->frlengths[x] = m->m_len;
+ usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len);
}
/* set number of frames and start hardware */
- xfer->nframes = x;
+ usbd_xfer_set_frames(xfer, x);
usbd_transfer_submit(xfer);
/* flush any received frames */
uether_rxflush(&sc->sc_ue);
@@ -666,13 +682,13 @@ cdce_bulk_read_callback(struct usb_xfer *xfer)
default: /* Error */
DPRINTF("error = %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
tr_stall:
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
- xfer->nframes = 0;
+ usbd_xfer_set_stall(xfer);
+ usbd_xfer_set_frames(xfer, 0);
usbd_transfer_submit(xfer);
break;
}
@@ -684,28 +700,30 @@ tr_stall:
}
static void
-cdce_intr_read_callback(struct usb_xfer *xfer)
+cdce_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- ; /* style fix */
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("Received %d bytes\n",
- xfer->actlen);
+ DPRINTF("Received %d bytes\n", actlen);
/* TODO: decode some indications */
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* start clear stall */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -713,27 +731,30 @@ tr_setup:
}
static void
-cdce_intr_write_callback(struct usb_xfer *xfer)
+cdce_intr_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- ; /* style fix */
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("Transferred %d bytes\n", xfer->actlen);
+ DPRINTF("Transferred %d bytes\n", actlen);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
#if 0
- xfer->frlengths[0] = XXX;
+ usbd_xfer_set_frame_len(xfer, 0, XXX);
usbd_transfer_submit(xfer);
#endif
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* start clear stall */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
diff --git a/sys/dev/usb/net/if_cue.c b/sys/dev/usb/net/if_cue.c
index 648722fe0a7d..4bb0da2cfd4e 100644
--- a/sys/dev/usb/net/if_cue.c
+++ b/sys/dev/usb/net/if_cue.c
@@ -51,20 +51,34 @@ __FBSDID("$FreeBSD$");
* transaction, which helps performance a great deal.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR cue_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_cuereg.h>
@@ -426,42 +440,47 @@ cue_detach(device_t dev)
}
static void
-cue_bulk_read_callback(struct usb_xfer *xfer)
+cue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct cue_softc *sc = xfer->priv_sc;
+ struct cue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
+ struct usb_page_cache *pc;
uint8_t buf[2];
int len;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen <= (2 + sizeof(struct ether_header))) {
+ if (actlen <= (2 + sizeof(struct ether_header))) {
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 2);
- xfer->actlen -= 2;
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, 2);
+ actlen -= 2;
len = buf[0] | (buf[1] << 8);
- len = min(xfer->actlen, len);
+ len = min(actlen, len);
- uether_rxbuf(ue, xfer->frbuffers, 2, len);
+ uether_rxbuf(ue, pc, 2, len);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -470,10 +489,11 @@ tr_setup:
}
static void
-cue_bulk_write_callback(struct usb_xfer *xfer)
+cue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct cue_softc *sc = xfer->priv_sc;
+ struct cue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
uint8_t buf[2];
@@ -491,17 +511,16 @@ tr_setup:
return;
if (m->m_pkthdr.len > MCLBYTES)
m->m_pkthdr.len = MCLBYTES;
- xfer->frlengths[0] = (m->m_pkthdr.len + 2);
+ usbd_xfer_set_frame_len(xfer, 0, (m->m_pkthdr.len + 2));
/* the first two bytes are the frame length */
buf[0] = (uint8_t)(m->m_pkthdr.len);
buf[1] = (uint8_t)(m->m_pkthdr.len >> 8);
- usbd_copy_in(xfer->frbuffers, 0, buf, 2);
-
- usbd_m_copy_in(xfer->frbuffers, 2,
- m, 0, m->m_pkthdr.len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, buf, 2);
+ usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
/*
* If there's a BPF listener, bounce a copy of this frame
@@ -517,13 +536,13 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -598,7 +617,7 @@ cue_init(struct usb_ether *ue)
/* Program the LED operation. */
cue_csr_write_1(sc, CUE_LEDCTL, CUE_LEDCTL_FOLLOW_LINK);
- usbd_transfer_set_stall(sc->sc_xfer[CUE_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[CUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
cue_start(ue);
diff --git a/sys/dev/usb/net/if_kue.c b/sys/dev/usb/net/if_kue.c
index 555b49322bbd..85a43a2d6800 100644
--- a/sys/dev/usb/net/if_kue.c
+++ b/sys/dev/usb/net/if_kue.c
@@ -65,20 +65,34 @@ __FBSDID("$FreeBSD$");
* the development of this driver.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR kue_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_kuereg.h>
@@ -514,42 +528,47 @@ kue_detach(device_t dev)
* the higher level protocols.
*/
static void
-kue_bulk_read_callback(struct usb_xfer *xfer)
+kue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct kue_softc *sc = xfer->priv_sc;
+ struct kue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
+ struct usb_page_cache *pc;
uint8_t buf[2];
int len;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen <= (2 + sizeof(struct ether_header))) {
+ if (actlen <= (2 + sizeof(struct ether_header))) {
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 2);
- xfer->actlen -= 2;
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, 2);
+ actlen -= 2;
len = buf[0] | (buf[1] << 8);
- len = min(xfer->actlen, len);
+ len = min(actlen, len);
- uether_rxbuf(ue, xfer->frbuffers, 2, len);
+ uether_rxbuf(ue, pc, 2, len);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -558,10 +577,11 @@ tr_setup:
}
static void
-kue_bulk_write_callback(struct usb_xfer *xfer)
+kue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct kue_softc *sc = xfer->priv_sc;
+ struct kue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
int total_len;
int temp_len;
@@ -589,15 +609,12 @@ tr_setup:
buf[0] = (uint8_t)(m->m_pkthdr.len);
buf[1] = (uint8_t)(m->m_pkthdr.len >> 8);
- usbd_copy_in(xfer->frbuffers, 0, buf, 2);
-
- usbd_m_copy_in(xfer->frbuffers, 2,
- m, 0, m->m_pkthdr.len);
-
- usbd_frame_zero(xfer->frbuffers, temp_len,
- total_len - temp_len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, buf, 2);
+ usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
- xfer->frlengths[0] = total_len;
+ usbd_frame_zero(pc, temp_len, total_len - temp_len);
+ usbd_xfer_set_frame_len(xfer, 0, total_len);
/*
* if there's a BPF listener, bounce a copy
@@ -613,13 +630,13 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -664,7 +681,7 @@ kue_init(struct usb_ether *ue)
/* load the multicast filter */
kue_setpromisc(ue);
- usbd_transfer_set_stall(sc->sc_xfer[KUE_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[KUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
kue_start(ue);
diff --git a/sys/dev/usb/net/if_rue.c b/sys/dev/usb/net/if_rue.c
index 36960d117e4f..b942e502eeee 100644
--- a/sys/dev/usb/net/if_rue.c
+++ b/sys/dev/usb/net/if_rue.c
@@ -65,20 +65,34 @@ __FBSDID("$FreeBSD$");
* ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR rue_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_ruereg.h>
@@ -613,19 +627,24 @@ rue_detach(device_t dev)
}
static void
-rue_intr_callback(struct usb_xfer *xfer)
+rue_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct rue_softc *sc = xfer->priv_sc;
+ struct rue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
struct rue_intrpkt pkt;
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) &&
- (xfer->actlen >= sizeof(pkt))) {
+ actlen >= sizeof(pkt)) {
- usbd_copy_out(xfer->frbuffers, 0, &pkt, sizeof(pkt));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &pkt, sizeof(pkt));
ifp->if_ierrors += pkt.rue_rxlost_cnt;
ifp->if_ierrors += pkt.rue_crcerr_cnt;
@@ -634,14 +653,14 @@ rue_intr_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -649,23 +668,27 @@ tr_setup:
}
static void
-rue_bulk_read_callback(struct usb_xfer *xfer)
+rue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct rue_softc *sc = xfer->priv_sc;
+ struct rue_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
+ struct usb_page_cache *pc;
uint16_t status;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 4) {
+ if (actlen < 4) {
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, xfer->actlen - 4,
- &status, sizeof(status));
- xfer->actlen -= 4;
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, actlen - 4, &status, sizeof(status));
+ actlen -= 4;
/* check recieve packet was valid or not */
status = le16toh(status);
@@ -673,22 +696,22 @@ rue_bulk_read_callback(struct usb_xfer *xfer)
ifp->if_ierrors++;
goto tr_setup;
}
- uether_rxbuf(ue, xfer->frbuffers, 0, xfer->actlen);
+ uether_rxbuf(ue, pc, 0, actlen);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -696,10 +719,11 @@ tr_setup:
}
static void
-rue_bulk_write_callback(struct usb_xfer *xfer)
+rue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct rue_softc *sc = xfer->priv_sc;
+ struct rue_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
int temp_len;
@@ -725,8 +749,8 @@ tr_setup:
m->m_pkthdr.len = MCLBYTES;
temp_len = m->m_pkthdr.len;
- usbd_m_copy_in(xfer->frbuffers, 0,
- m, 0, m->m_pkthdr.len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
/*
* This is an undocumented behavior.
@@ -734,11 +758,11 @@ tr_setup:
* RUE_MIN_FRAMELEN (60) byte packet.
*/
if (temp_len < RUE_MIN_FRAMELEN) {
- usbd_frame_zero(xfer->frbuffers, temp_len,
+ usbd_frame_zero(pc, temp_len,
RUE_MIN_FRAMELEN - temp_len);
temp_len = RUE_MIN_FRAMELEN;
}
- xfer->frlengths[0] = temp_len;
+ usbd_xfer_set_frame_len(xfer, 0, temp_len);
/*
* if there's a BPF listener, bounce a copy
@@ -754,13 +778,13 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -829,7 +853,7 @@ rue_init(struct usb_ether *ue)
/* Enable RX and TX */
rue_csr_write_1(sc, RUE_CR, (RUE_CR_TE | RUE_CR_RE | RUE_CR_EP3CLREN));
- usbd_transfer_set_stall(sc->sc_xfer[RUE_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[RUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
rue_start(ue);
diff --git a/sys/dev/usb/net/if_udav.c b/sys/dev/usb/net/if_udav.c
index be9af1521e3b..926b0a3e60ea 100644
--- a/sys/dev/usb/net/if_udav.c
+++ b/sys/dev/usb/net/if_udav.c
@@ -46,20 +46,34 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR udav_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_udavreg.h>
@@ -420,7 +434,7 @@ udav_init(struct usb_ether *ue)
UDAV_SETBIT(sc, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0);
UDAV_CLRBIT(sc, UDAV_GPR, UDAV_GPR_GEPIO0);
- usbd_transfer_set_stall(sc->sc_xfer[UDAV_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UDAV_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
udav_start(ue);
@@ -531,10 +545,11 @@ udav_start(struct usb_ether *ue)
}
static void
-udav_bulk_write_callback(struct usb_xfer *xfer)
+udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udav_softc *sc = xfer->priv_sc;
+ struct udav_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = uether_getifp(&sc->sc_ue);
+ struct usb_page_cache *pc;
struct mbuf *m;
int extra_len;
int temp_len;
@@ -577,15 +592,12 @@ tr_setup:
temp_len += 2;
- usbd_copy_in(xfer->frbuffers, 0, buf, 2);
-
- usbd_m_copy_in(xfer->frbuffers, 2,
- m, 0, m->m_pkthdr.len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, buf, 2);
+ usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
- if (extra_len) {
- usbd_frame_zero(xfer->frbuffers, temp_len - extra_len,
- extra_len);
- }
+ if (extra_len)
+ usbd_frame_zero(pc, temp_len - extra_len, extra_len);
/*
* if there's a BPF listener, bounce a copy
* of this frame to him:
@@ -594,19 +606,19 @@ tr_setup:
m_freem(m);
- xfer->frlengths[0] = temp_len;
+ usbd_xfer_set_frame_len(xfer, 0, temp_len);
usbd_transfer_submit(xfer);
return;
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -614,24 +626,29 @@ tr_setup:
}
static void
-udav_bulk_read_callback(struct usb_xfer *xfer)
+udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct udav_softc *sc = xfer->priv_sc;
+ struct udav_softc *sc = usbd_xfer_softc(xfer);
struct usb_ether *ue = &sc->sc_ue;
struct ifnet *ifp = uether_getifp(ue);
+ struct usb_page_cache *pc;
struct udav_rxpkt stat;
int len;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < sizeof(stat) + ETHER_CRC_LEN) {
+ if (actlen < sizeof(stat) + ETHER_CRC_LEN) {
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, &stat, sizeof(stat));
- xfer->actlen -= sizeof(stat);
- len = min(xfer->actlen, le16toh(stat.pktlen));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &stat, sizeof(stat));
+ actlen -= sizeof(stat);
+ len = min(actlen, le16toh(stat.pktlen));
len -= ETHER_CRC_LEN;
if (stat.rxstat & UDAV_RSR_LCS) {
@@ -642,22 +659,22 @@ udav_bulk_read_callback(struct usb_xfer *xfer)
ifp->if_ierrors++;
goto tr_setup;
}
- uether_rxbuf(ue, xfer->frbuffers, sizeof(stat), len);
+ uether_rxbuf(ue, pc, sizeof(stat), len);
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
uether_rxflush(ue);
return;
default: /* Error */
DPRINTF("bulk read error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -665,20 +682,20 @@ tr_setup:
}
static void
-udav_intr_callback(struct usb_xfer *xfer)
+udav_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c
index 3c42be6ac994..6cf446016e75 100644
--- a/sys/dev/usb/net/usb_ethernet.c
+++ b/sys/dev/usb/net/usb_ethernet.c
@@ -24,17 +24,30 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_endian.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_util.h>
-
#include <dev/usb/net/usb_ethernet.h>
SYSCTL_NODE(_net, OID_AUTO, ue, CTLFLAG_RD, 0, "USB Ethernet parameters");
diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c
index 3228aa20fe50..92c2ab05ad44 100644
--- a/sys/dev/usb/quirk/usb_quirk.c
+++ b/sys/dev/usb/quirk/usb_quirk.c
@@ -26,15 +26,32 @@
* SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
#include <dev/usb/usb_ioctl.h>
-#include <dev/usb/usb_mfunc.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_dynamic.h>
diff --git a/sys/dev/usb/quirk/usb_quirk.h b/sys/dev/usb/quirk/usb_quirk.h
index 4912440a899e..f4fb9b9fdc95 100644
--- a/sys/dev/usb/quirk/usb_quirk.h
+++ b/sys/dev/usb/quirk/usb_quirk.h
@@ -56,4 +56,6 @@ enum { /* keep in sync with usb_quirk_str table */
USB_QUIRK_MAX
};
+uint8_t usb_test_quirk(const struct usb_attach_arg *uaa, uint16_t quirk);
+
#endif /* _USB_QUIRK_H_ */
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index fb25936c26be..eb12f8a68dd0 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -30,22 +30,37 @@
*
*/
-#include "usbdevs.h"
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR u3g_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_msctest.h>
#include <dev/usb/usb_dynamic.h>
+#include <dev/usb/usb_msctest.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/serial/usb_serial.h>
@@ -501,8 +516,8 @@ u3g_attach(device_t dev)
/* set stall by default */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[nports][U3G_BULK_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[nports][U3G_BULK_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[nports][U3G_BULK_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[nports][U3G_BULK_RD]);
mtx_unlock(&sc->sc_mtx);
nports++; /* found one port */
@@ -588,26 +603,27 @@ u3g_stop_write(struct ucom_softc *ucom)
}
static void
-u3g_write_callback(struct usb_xfer *xfer)
+u3g_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ucom_softc *ucom = xfer->priv_sc;
+ struct ucom_softc *ucom = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
- if (ucom_get_data(ucom, xfer->frbuffers, 0,
- U3G_BSIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(ucom, pc, 0, U3G_BSIZE, &actlen)) {
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* do a builtin clear-stall */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -616,24 +632,29 @@ tr_setup:
}
static void
-u3g_read_callback(struct usb_xfer *xfer)
+u3g_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ucom_softc *ucom = xfer->priv_sc;
+ struct ucom_softc *ucom = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* do a builtin clear-stall */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
diff --git a/sys/dev/usb/serial/uark.c b/sys/dev/usb/serial/uark.c
index 04861babd612..cff124eb0749 100644
--- a/sys/dev/usb/serial/uark.c
+++ b/sys/dev/usb/serial/uark.c
@@ -23,20 +23,36 @@
* be called from within the config thread function !
*/
-#include "usbdevs.h"
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbhid.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
#include <dev/usb/serial/usb_serial.h>
@@ -198,8 +214,8 @@ uark_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UARK_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UARK_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -228,26 +244,28 @@ uark_detach(device_t dev)
}
static void
-uark_bulk_write_callback(struct usb_xfer *xfer)
+uark_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uark_softc *sc = xfer->priv_sc;
+ struct uark_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UARK_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -256,25 +274,29 @@ tr_setup:
}
static void
-uark_bulk_read_callback(struct usb_xfer *xfer)
+uark_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uark_softc *sc = xfer->priv_sc;
+ struct uark_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0,
- xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ubsa.c b/sys/dev/usb/serial/ubsa.c
index cc584c3f64df..3e8e61b7c6fd 100644
--- a/sys/dev/usb/serial/ubsa.c
+++ b/sys/dev/usb/serial/ubsa.c
@@ -62,21 +62,34 @@ __FBSDID("$FreeBSD$");
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR ubsa_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -305,8 +318,8 @@ ubsa_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UBSA_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -537,27 +550,29 @@ ubsa_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr)
}
static void
-ubsa_write_callback(struct usb_xfer *xfer)
+ubsa_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ubsa_softc *sc = xfer->priv_sc;
+ struct ubsa_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UBSA_BSIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -566,24 +581,29 @@ tr_setup:
}
static void
-ubsa_read_callback(struct usb_xfer *xfer)
+ubsa_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ubsa_softc *sc = xfer->priv_sc;
+ struct ubsa_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -592,17 +612,21 @@ tr_setup:
}
static void
-ubsa_intr_callback(struct usb_xfer *xfer)
+ubsa_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ubsa_softc *sc = xfer->priv_sc;
+ struct ubsa_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[4];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen >= sizeof(buf)) {
-
- usbd_copy_out(xfer->frbuffers, 0, buf, sizeof(buf));
+ if (actlen >= sizeof(buf)) {
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, sizeof(buf));
/*
* incidentally, Belkin adapter status bits match
@@ -616,20 +640,19 @@ ubsa_intr_callback(struct usb_xfer *xfer)
ucom_status_change(&sc->sc_ucom);
} else {
- DPRINTF("ignoring short packet, %d bytes\n",
- xfer->actlen);
+ DPRINTF("ignoring short packet, %d bytes\n", actlen);
}
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ubser.c b/sys/dev/usb/serial/ubser.c
index f184ecd6353d..a2c29f94b3bb 100644
--- a/sys/dev/usb/serial/ubser.c
+++ b/sys/dev/usb/serial/ubser.c
@@ -76,20 +76,34 @@ __FBSDID("$FreeBSD$");
* BWCT serial adapter driver
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR ubser_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/serial/usb_serial.h>
@@ -263,7 +277,7 @@ ubser_attach(device_t dev)
if (error) {
goto detach;
}
- sc->sc_tx_size = sc->sc_xfer[UBSER_BULK_DT_WR]->max_data_length;
+ sc->sc_tx_size = usbd_xfer_max_len(sc->sc_xfer[UBSER_BULK_DT_WR]);
if (sc->sc_tx_size == 0) {
DPRINTFN(0, "invalid tx_size!\n");
@@ -282,8 +296,8 @@ ubser_attach(device_t dev)
}
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_RD]);
usbd_transfer_start(sc->sc_xfer[UBSER_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
@@ -367,9 +381,10 @@ ubser_inc_tx_unit(struct ubser_softc *sc)
}
static void
-ubser_write_callback(struct usb_xfer *xfer)
+ubser_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ubser_softc *sc = xfer->priv_sc;
+ struct ubser_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[1];
uint8_t first_unit = sc->sc_curr_tx_unit;
uint32_t actlen;
@@ -378,16 +393,17 @@ ubser_write_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
+ pc = usbd_xfer_get_frame(xfer, 0);
do {
if (ucom_get_data(sc->sc_ucom + sc->sc_curr_tx_unit,
- xfer->frbuffers, 1, sc->sc_tx_size - 1,
+ pc, 1, sc->sc_tx_size - 1,
&actlen)) {
buf[0] = sc->sc_curr_tx_unit;
- usbd_copy_in(xfer->frbuffers, 0, buf, 1);
+ usbd_copy_in(pc, 0, buf, 1);
- xfer->frlengths[0] = actlen + 1;
+ usbd_xfer_set_frame_len(xfer, 0, actlen + 1);
usbd_transfer_submit(xfer);
ubser_inc_tx_unit(sc); /* round robin */
@@ -401,9 +417,9 @@ tr_setup:
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -412,36 +428,40 @@ tr_setup:
}
static void
-ubser_read_callback(struct usb_xfer *xfer)
+ubser_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ubser_softc *sc = xfer->priv_sc;
+ struct ubser_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[1];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 1) {
+ if (actlen < 1) {
DPRINTF("invalid actlen=0!\n");
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 1);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, 1);
if (buf[0] >= sc->sc_numser) {
DPRINTF("invalid serial number!\n");
goto tr_setup;
}
- ucom_put_data(sc->sc_ucom + buf[0],
- xfer->frbuffers, 1, xfer->actlen - 1);
+ ucom_put_data(sc->sc_ucom + buf[0], pc, 1, actlen - 1);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uchcom.c b/sys/dev/usb/serial/uchcom.c
index 009a37db756d..705d3e6fdf08 100644
--- a/sys/dev/usb/serial/uchcom.c
+++ b/sys/dev/usb/serial/uchcom.c
@@ -69,22 +69,34 @@ __FBSDID("$FreeBSD$");
* driver for WinChipHead CH341/340, the worst USB-serial chip in the world.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uchcom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -341,8 +353,8 @@ uchcom_attach(device_t dev)
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UCHCOM_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -772,19 +784,23 @@ uchcom_stop_write(struct ucom_softc *ucom)
* callback when the modem status is changed.
*/
static void
-uchcom_intr_callback(struct usb_xfer *xfer)
+uchcom_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uchcom_softc *sc = xfer->priv_sc;
+ struct uchcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[UCHCOM_INTR_LEAST];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("actlen = %u\n", xfer->actlen);
+ DPRINTF("actlen = %u\n", actlen);
- if (xfer->actlen >= UCHCOM_INTR_LEAST) {
- usbd_copy_out(xfer->frbuffers, 0, buf,
- UCHCOM_INTR_LEAST);
+ if (actlen >= UCHCOM_INTR_LEAST) {
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, UCHCOM_INTR_LEAST);
DPRINTF("data = 0x%02X 0x%02X 0x%02X 0x%02X\n",
(unsigned)buf[0], (unsigned)buf[1],
@@ -795,14 +811,14 @@ uchcom_intr_callback(struct usb_xfer *xfer)
}
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -810,29 +826,31 @@ tr_setup:
}
static void
-uchcom_write_callback(struct usb_xfer *xfer)
+uchcom_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uchcom_softc *sc = xfer->priv_sc;
+ struct uchcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UCHCOM_BULK_BUF_SIZE, &actlen)) {
DPRINTF("actlen = %d\n", actlen);
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -841,24 +859,29 @@ tr_setup:
}
static void
-uchcom_read_callback(struct usb_xfer *xfer)
+uchcom_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uchcom_softc *sc = xfer->priv_sc;
+ struct uchcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ucycom.c b/sys/dev/usb/serial/ucycom.c
index 7825a2276695..1eb246089531 100644
--- a/sys/dev/usb/serial/ucycom.c
+++ b/sys/dev/usb/serial/ucycom.c
@@ -34,24 +34,35 @@ __FBSDID("$FreeBSD$");
* RS232 bridges.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_hid.h>
#include <dev/usb/serial/usb_serial.h>
@@ -329,14 +340,18 @@ ucycom_stop_write(struct ucom_softc *ucom)
}
static void
-ucycom_ctrl_write_callback(struct usb_xfer *xfer)
+ucycom_ctrl_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ucycom_softc *sc = xfer->priv_sc;
+ struct ucycom_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc0, *pc1;
uint8_t data[2];
uint8_t offset;
uint32_t actlen;
+ pc0 = usbd_xfer_get_frame(xfer, 0);
+ pc1 = usbd_xfer_get_frame(xfer, 1);
+
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
tr_transferred:
@@ -354,7 +369,7 @@ tr_transferred:
break;
}
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers + 1, offset,
+ if (ucom_get_data(&sc->sc_ucom, pc1, offset,
sc->sc_olen - offset, &actlen)) {
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
@@ -376,22 +391,22 @@ tr_transferred:
break;
}
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
- usbd_copy_in(xfer->frbuffers + 1, 0, data, offset);
+ usbd_copy_in(pc0, 0, &req, sizeof(req));
+ usbd_copy_in(pc1, 0, data, offset);
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = sc->sc_olen;
- xfer->nframes = xfer->frlengths[1] ? 2 : 1;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, sc->sc_olen);
+ usbd_xfer_set_frames(xfer, sc->sc_olen ? 2 : 1);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
return;
}
DPRINTF("error=%s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
goto tr_transferred;
}
}
@@ -494,42 +509,45 @@ ucycom_cfg_param(struct ucom_softc *ucom, struct termios *t)
}
static void
-ucycom_intr_read_callback(struct usb_xfer *xfer)
+ucycom_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ucycom_softc *sc = xfer->priv_sc;
+ struct ucycom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[2];
uint32_t offset;
uint32_t len;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+ pc = usbd_xfer_get_frame(xfer, 0);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
switch (sc->sc_model) {
case MODEL_CY7C63743:
- if (xfer->actlen < 1) {
+ if (actlen < 1) {
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 1);
+ usbd_copy_out(pc, 0, buf, 1);
sc->sc_ist = buf[0] & ~0x07;
len = buf[0] & 0x07;
- (xfer->actlen)--;
-
+ actlen--;
offset = 1;
break;
case MODEL_CY7C64013:
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 2);
+ usbd_copy_out(pc, 0, buf, 2);
sc->sc_ist = buf[0] & ~0x07;
len = buf[1];
- (xfer->actlen) -= 2;
-
+ actlen -= 2;
offset = 2;
break;
@@ -539,23 +557,21 @@ ucycom_intr_read_callback(struct usb_xfer *xfer)
goto tr_setup;
}
- if (len > xfer->actlen) {
- len = xfer->actlen;
- }
- if (len) {
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers,
- offset, len);
- }
+ if (len > actlen)
+ len = actlen;
+ if (len)
+ ucom_put_data(&sc->sc_ucom, pc, offset, len);
+ /* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = sc->sc_ilen;
+ usbd_xfer_set_frame_len(xfer, 0, sc->sc_ilen);
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ufoma.c b/sys/dev/usb/serial/ufoma.c
index 89285edd213e..8b354e3355d1 100644
--- a/sys/dev/usb/serial/ufoma.c
+++ b/sys/dev/usb/serial/ufoma.c
@@ -82,26 +82,38 @@ __FBSDID("$FreeBSD$");
* be called from within the config thread function !
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/sbuf.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_parse.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
-#include <sys/sysctl.h>
-#include <sys/sbuf.h>
typedef struct ufoma_mobile_acm_descriptor {
uint8_t bFunctionLength;
@@ -426,8 +438,8 @@ ufoma_attach(device_t dev)
/* clear stall at first run, if any */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE]);
- usbd_transfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ]);
+ usbd_xfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE]);
+ usbd_xfer_set_stall(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -544,21 +556,25 @@ ufoma_cfg_activate_state(struct ufoma_softc *sc, uint16_t state)
}
static void
-ufoma_ctrl_read_callback(struct usb_xfer *xfer)
+ufoma_ctrl_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ufoma_softc *sc = xfer->priv_sc;
+ struct ufoma_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc0, *pc1;
+ int len, aframes, nframes;
+
+ usbd_xfer_status(xfer, NULL, NULL, &aframes, &nframes);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
tr_transferred:
- if (xfer->aframes != xfer->nframes) {
+ if (aframes != nframes)
goto tr_setup;
- }
- if (xfer->frlengths[1] > 0) {
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers + 1,
- 0, xfer->frlengths[1]);
- }
+ pc1 = usbd_xfer_get_frame(xfer, 1);
+ len = usbd_xfer_get_frame_len(xfer, 1);
+ if (len > 0)
+ ucom_put_data(&sc->sc_ucom, pc1, 0, len);
+ /* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
if (sc->sc_num_msg) {
@@ -570,20 +586,21 @@ tr_setup:
USETW(req.wValue, 0);
USETW(req.wLength, UFOMA_CMD_BUF_SIZE);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ pc0 = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc0, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = UFOMA_CMD_BUF_SIZE;
- xfer->nframes = 2;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, UFOMA_CMD_BUF_SIZE);
+ usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
DPRINTF("error = %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
return;
} else {
goto tr_setup;
@@ -594,10 +611,11 @@ tr_setup:
}
static void
-ufoma_ctrl_write_callback(struct usb_xfer *xfer)
+ufoma_ctrl_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ufoma_softc *sc = xfer->priv_sc;
+ struct ufoma_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
@@ -605,8 +623,8 @@ ufoma_ctrl_write_callback(struct usb_xfer *xfer)
tr_transferred:
case USB_ST_SETUP:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers + 1,
- 0, 1, &actlen)) {
+ pc = usbd_xfer_get_frame(xfer, 1);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0, 1, &actlen)) {
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UCDC_SEND_ENCAPSULATED_COMMAND;
@@ -614,21 +632,21 @@ tr_setup:
USETW(req.wValue, 0);
USETW(req.wLength, 1);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = 1;
- xfer->nframes = 2;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, 1);
+ usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- DPRINTF("error = %s\n",
- usbd_errstr(xfer->error));
+ DPRINTF("error = %s\n", usbd_errstr(error));
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
return;
} else {
goto tr_setup;
@@ -639,31 +657,36 @@ tr_setup:
}
static void
-ufoma_intr_callback(struct usb_xfer *xfer)
+ufoma_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ufoma_softc *sc = xfer->priv_sc;
+ struct ufoma_softc *sc = usbd_xfer_softc(xfer);
struct usb_cdc_notification pkt;
+ struct usb_page_cache *pc;
uint16_t wLen;
uint16_t temp;
uint8_t mstatus;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 8) {
+ if (actlen < 8) {
DPRINTF("too short message\n");
goto tr_setup;
}
- if (xfer->actlen > sizeof(pkt)) {
+ if (actlen > sizeof(pkt)) {
DPRINTF("truncating message\n");
- xfer->actlen = sizeof(pkt);
+ actlen = sizeof(pkt);
}
- usbd_copy_out(xfer->frbuffers, 0, &pkt, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &pkt, actlen);
- xfer->actlen -= 8;
+ actlen -= 8;
wLen = UGETW(pkt.wLength);
- if (xfer->actlen > wLen) {
- xfer->actlen = wLen;
+ if (actlen > wLen) {
+ actlen = wLen;
}
if ((pkt.bmRequestType == UT_READ_VENDOR_INTERFACE) &&
(pkt.bNotification == UMCPC_REQUEST_ACKNOWLEDGE)) {
@@ -698,9 +721,9 @@ ufoma_intr_callback(struct usb_xfer *xfer)
* Set the serial state in ucom driver based on
* the bits from the notify message
*/
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
DPRINTF("invalid notification "
- "length, %d bytes!\n", xfer->actlen);
+ "length, %d bytes!\n", actlen);
break;
}
DPRINTF("notify bytes = 0x%02x, 0x%02x\n",
@@ -730,14 +753,14 @@ ufoma_intr_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -745,26 +768,28 @@ tr_setup:
}
static void
-ufoma_bulk_write_callback(struct usb_xfer *xfer)
+ufoma_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ufoma_softc *sc = xfer->priv_sc;
+ struct ufoma_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UFOMA_BULK_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -772,25 +797,29 @@ tr_setup:
}
static void
-ufoma_bulk_read_callback(struct usb_xfer *xfer)
+ufoma_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ufoma_softc *sc = xfer->priv_sc;
+ struct ufoma_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0,
- xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c
index 700d68b138e3..52a070b7015c 100644
--- a/sys/dev/usb/serial/uftdi.c
+++ b/sys/dev/usb/serial/uftdi.c
@@ -48,21 +48,34 @@ __FBSDID("$FreeBSD$");
* FTDI FT8U100AX serial adapter driver
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uftdi_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
#include <dev/usb/serial/uftdi_reg.h>
@@ -296,8 +309,8 @@ uftdi_attach(device_t dev)
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
/* set a valid "lcr" value */
@@ -368,9 +381,10 @@ uftdi_cfg_open(struct ucom_softc *ucom)
}
static void
-uftdi_write_callback(struct usb_xfer *xfer)
+uftdi_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uftdi_softc *sc = xfer->priv_sc;
+ struct uftdi_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
uint8_t buf[1];
@@ -378,24 +392,25 @@ uftdi_write_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc,
sc->sc_hdrlen, UFTDI_OBUFSIZE - sc->sc_hdrlen,
&actlen)) {
if (sc->sc_hdrlen > 0) {
buf[0] =
FTDI_OUT_TAG(actlen, sc->sc_ucom.sc_portno);
- usbd_copy_in(xfer->frbuffers, 0, buf, 1);
+ usbd_copy_in(pc, 0, buf, 1);
}
- xfer->frlengths[0] = actlen + sc->sc_hdrlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen + sc->sc_hdrlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -403,21 +418,26 @@ tr_setup:
}
static void
-uftdi_read_callback(struct usb_xfer *xfer)
+uftdi_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uftdi_softc *sc = xfer->priv_sc;
+ struct uftdi_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[2];
uint8_t ftdi_msr;
uint8_t msr;
uint8_t lsr;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, 2);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, 2);
ftdi_msr = FTDI_GET_MSR(buf);
lsr = FTDI_GET_LSR(buf);
@@ -443,22 +463,21 @@ uftdi_read_callback(struct usb_xfer *xfer)
ucom_status_change(&sc->sc_ucom);
}
- xfer->actlen -= 2;
+ actlen -= 2;
- if (xfer->actlen > 0) {
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 2,
- xfer->actlen);
+ if (actlen > 0) {
+ ucom_put_data(&sc->sc_ucom, pc, 2, actlen);
}
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ugensa.c b/sys/dev/usb/serial/ugensa.c
index eada5da3d35f..86e858638a7d 100644
--- a/sys/dev/usb/serial/ugensa.c
+++ b/sys/dev/usb/serial/ugensa.c
@@ -42,21 +42,33 @@
* be called from within the config thread function !
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_device.h>
#include <dev/usb/serial/usb_serial.h>
@@ -221,8 +233,8 @@ ugensa_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_WR]);
- usbd_transfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_RD]);
+ usbd_xfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_WR]);
+ usbd_xfer_set_stall(ssc->sc_xfer[UGENSA_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
/* initialize port number */
@@ -264,26 +276,28 @@ ugensa_detach(device_t dev)
}
static void
-ugensa_bulk_write_callback(struct usb_xfer *xfer)
+ugensa_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ugensa_sub_softc *ssc = xfer->priv_sc;
+ struct ugensa_sub_softc *ssc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(ssc->sc_ucom_ptr, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(ssc->sc_ucom_ptr, pc, 0,
UGENSA_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -291,25 +305,29 @@ tr_setup:
}
static void
-ugensa_bulk_read_callback(struct usb_xfer *xfer)
+ugensa_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ugensa_sub_softc *ssc = xfer->priv_sc;
+ struct ugensa_sub_softc *ssc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(ssc->sc_ucom_ptr, xfer->frbuffers, 0,
- xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(ssc->sc_ucom_ptr, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uipaq.c b/sys/dev/usb/serial/uipaq.c
index ca66866dde07..79fe21e5c2c4 100644
--- a/sys/dev/usb/serial/uipaq.c
+++ b/sys/dev/usb/serial/uipaq.c
@@ -51,21 +51,35 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -1136,8 +1150,8 @@ uipaq_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UIPAQ_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -1267,26 +1281,28 @@ uipaq_cfg_set_break(struct ucom_softc *ucom, uint8_t onoff)
}
static void
-uipaq_write_callback(struct usb_xfer *xfer)
+uipaq_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uipaq_softc *sc = xfer->priv_sc;
+ struct uipaq_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UIPAQ_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -1294,25 +1310,29 @@ tr_setup:
}
static void
-uipaq_read_callback(struct usb_xfer *xfer)
+uipaq_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uipaq_softc *sc = xfer->priv_sc;
+ struct uipaq_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0,
- xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/ulpt.c b/sys/dev/usb/serial/ulpt.c
index b7b622d163aa..fd21a1d05ded 100644
--- a/sys/dev/usb/serial/ulpt.c
+++ b/sys/dev/usb/serial/ulpt.c
@@ -45,25 +45,39 @@ __FBSDID("$FreeBSD$");
* Printer Class spec: http://www.usb.org/developers/devclass_docs/usbprint11.pdf
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/syslog.h>
+#include <sys/selinfo.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbhid.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR ulpt_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
-#include <dev/usb/usb_parse.h>
-
-#include <sys/syslog.h>
#if USB_DEBUG
static int ulpt_debug = 0;
@@ -189,35 +203,38 @@ ulpt_reset(struct ulpt_softc *sc)
}
static void
-ulpt_write_callback(struct usb_xfer *xfer)
+ulpt_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ulpt_softc *sc = xfer->priv_sc;
+ struct ulpt_softc *sc = usbd_xfer_softc(xfer);
struct usb_fifo *f = sc->sc_fifo_open[USB_FIFO_TX];
- uint32_t actlen;
+ struct usb_page_cache *pc;
+ int actlen, max;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
if (f == NULL) {
/* should not happen */
DPRINTF("no FIFO\n");
return;
}
- DPRINTF("state=0x%x actlen=%u\n",
- USB_GET_STATE(xfer), xfer->actlen);
+ DPRINTF("state=0x%x actlen=%d\n", USB_GET_STATE(xfer), actlen);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
- if (usb_fifo_get_data(f, xfer->frbuffers,
- 0, xfer->max_data_length, &actlen, 0)) {
- xfer->frlengths[0] = actlen;
+ pc = usbd_xfer_get_frame(xfer, 0);
+ max = usbd_xfer_max_len(xfer);
+ if (usb_fifo_get_data(f, pc, 0, max, &actlen, 0)) {
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -225,10 +242,14 @@ tr_setup:
}
static void
-ulpt_read_callback(struct usb_xfer *xfer)
+ulpt_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ulpt_softc *sc = xfer->priv_sc;
+ struct ulpt_softc *sc = usbd_xfer_softc(xfer);
struct usb_fifo *f = sc->sc_fifo_open[USB_FIFO_RX];
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
if (f == NULL) {
/* should not happen */
@@ -240,40 +261,40 @@ ulpt_read_callback(struct usb_xfer *xfer)
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen == 0) {
+ if (actlen == 0) {
if (sc->sc_zlps == 4) {
/* enable BULK throttle */
- xfer->interval = 500; /* ms */
+ usbd_xfer_set_interval(xfer, 500); /* ms */
} else {
sc->sc_zlps++;
}
} else {
/* disable BULK throttle */
- xfer->interval = 0;
+ usbd_xfer_set_interval(xfer, 0);
sc->sc_zlps = 0;
}
- usb_fifo_put_data(f, xfer->frbuffers,
- 0, xfer->actlen, 1);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usb_fifo_put_data(f, pc, 0, actlen, 1);
case USB_ST_SETUP:
tr_setup:
if (usb_fifo_put_bytes_max(f) != 0) {
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
/* disable BULK throttle */
- xfer->interval = 0;
+ usbd_xfer_set_interval(xfer, 0);
sc->sc_zlps = 0;
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -281,17 +302,19 @@ tr_setup:
}
static void
-ulpt_status_callback(struct usb_xfer *xfer)
+ulpt_status_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ulpt_softc *sc = xfer->priv_sc;
+ struct ulpt_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
uint8_t cur_status;
uint8_t new_status;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- usbd_copy_out(xfer->frbuffers + 1, 0, &cur_status, 1);
+ pc = usbd_xfer_get_frame(xfer, 1);
+ usbd_copy_out(pc, 0, &cur_status, 1);
cur_status = (cur_status ^ LPS_INVERT) & LPS_MASK;
new_status = cur_status & ~sc->sc_last_status;
@@ -316,17 +339,18 @@ ulpt_status_callback(struct usb_xfer *xfer)
req.wIndex[1] = 0;
USETW(req.wLength, 1);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = 1;
- xfer->nframes = 2;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, 1);
+ usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
break;
default: /* Error */
- DPRINTF("error=%s\n", usbd_errstr(xfer->error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ DPRINTF("error=%s\n", usbd_errstr(error));
+ if (error != USB_ERR_CANCELLED) {
/* wait for next watchdog timeout */
}
break;
@@ -365,7 +389,7 @@ static const struct usb_config ulpt_config[ULPT_N_TRANSFER] = {
static void
ulpt_start_read(struct usb_fifo *fifo)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[ULPT_BULK_DT_RD]);
}
@@ -373,7 +397,7 @@ ulpt_start_read(struct usb_fifo *fifo)
static void
ulpt_stop_read(struct usb_fifo *fifo)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[ULPT_BULK_DT_RD]);
}
@@ -381,7 +405,7 @@ ulpt_stop_read(struct usb_fifo *fifo)
static void
ulpt_start_write(struct usb_fifo *fifo)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[ULPT_BULK_DT_WR]);
}
@@ -389,7 +413,7 @@ ulpt_start_write(struct usb_fifo *fifo)
static void
ulpt_stop_write(struct usb_fifo *fifo)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[ULPT_BULK_DT_WR]);
}
@@ -397,7 +421,7 @@ ulpt_stop_write(struct usb_fifo *fifo)
static int
ulpt_open(struct usb_fifo *fifo, int fflags)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
/* we assume that open is a serial process */
@@ -410,7 +434,7 @@ ulpt_open(struct usb_fifo *fifo, int fflags)
static int
unlpt_open(struct usb_fifo *fifo, int fflags)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
if (sc->sc_fflags & fflags) {
return (EBUSY);
@@ -418,10 +442,10 @@ unlpt_open(struct usb_fifo *fifo, int fflags)
if (fflags & FREAD) {
/* clear stall first */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[ULPT_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[ULPT_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
if (usb_fifo_alloc_buffer(fifo,
- sc->sc_xfer[ULPT_BULK_DT_RD]->max_data_length,
+ usbd_xfer_max_len(sc->sc_xfer[ULPT_BULK_DT_RD]),
ULPT_IFQ_MAXLEN)) {
return (ENOMEM);
}
@@ -431,10 +455,10 @@ unlpt_open(struct usb_fifo *fifo, int fflags)
if (fflags & FWRITE) {
/* clear stall first */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[ULPT_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[ULPT_BULK_DT_WR]);
mtx_unlock(&sc->sc_mtx);
if (usb_fifo_alloc_buffer(fifo,
- sc->sc_xfer[ULPT_BULK_DT_WR]->max_data_length,
+ usbd_xfer_max_len(sc->sc_xfer[ULPT_BULK_DT_WR]),
ULPT_IFQ_MAXLEN)) {
return (ENOMEM);
}
@@ -448,7 +472,7 @@ unlpt_open(struct usb_fifo *fifo, int fflags)
static void
ulpt_close(struct usb_fifo *fifo, int fflags)
{
- struct ulpt_softc *sc = fifo->priv_sc0;
+ struct ulpt_softc *sc = usb_fifo_softc(fifo);
sc->sc_fflags &= ~(fflags & (FREAD | FWRITE));
diff --git a/sys/dev/usb/serial/umct.c b/sys/dev/usb/serial/umct.c
index 879b09071846..557a511adc04 100644
--- a/sys/dev/usb/serial/umct.c
+++ b/sys/dev/usb/serial/umct.c
@@ -44,22 +44,34 @@ __FBSDID("$FreeBSD$");
* be called from within the config thread function !
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_device.h>
#include <dev/usb/serial/usb_serial.h>
@@ -226,7 +238,7 @@ umct_attach(device_t dev)
struct usb_attach_arg *uaa = device_get_ivars(dev);
struct umct_softc *sc = device_get_softc(dev);
int32_t error;
- uint16_t maxp;
+ //uint16_t maxp;
uint8_t iface_index;
sc->sc_udev = uaa->device;
@@ -254,6 +266,7 @@ umct_attach(device_t dev)
* The only way to differentiate it from the real interrupt
* endpoint is to look at the wMaxPacketSize field.
*/
+#ifdef XXX
maxp = UGETW(sc->sc_xfer[UMCT_BULK_DT_RD]->endpoint->edesc->wMaxPacketSize);
if (maxp == 0x2) {
@@ -267,7 +280,8 @@ umct_attach(device_t dev)
sc->sc_xfer[UMCT_BULK_DT_RD]->callback = &umct_read_callback;
sc->sc_xfer[UMCT_INTR_DT_RD]->callback = &umct_intr_callback;
}
- sc->sc_obufsize = sc->sc_xfer[UMCT_BULK_DT_WR]->max_data_length;
+#endif
+ sc->sc_obufsize = usbd_xfer_max_len(sc->sc_xfer[UMCT_BULK_DT_WR]);
if (uaa->info.idProduct == USB_PRODUCT_MCT_SITECOM_USB232) {
if (sc->sc_obufsize > 16) {
@@ -326,18 +340,23 @@ umct_cfg_do_request(struct umct_softc *sc, uint8_t request,
}
static void
-umct_intr_callback(struct usb_xfer *xfer)
+umct_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umct_softc *sc = xfer->priv_sc;
+ struct umct_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[2];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
DPRINTF("too short message\n");
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, buf, sizeof(buf));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, sizeof(buf));
sc->sc_msr = buf[0];
sc->sc_lsr = buf[1];
@@ -346,14 +365,14 @@ umct_intr_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -526,27 +545,29 @@ umct_stop_write(struct ucom_softc *ucom)
}
static void
-umct_write_callback(struct usb_xfer *xfer)
+umct_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umct_softc *sc = xfer->priv_sc;
+ struct umct_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
sc->sc_obufsize, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -554,25 +575,29 @@ tr_setup:
}
static void
-umct_read_callback(struct usb_xfer *xfer)
+umct_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umct_softc *sc = xfer->priv_sc;
+ struct umct_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers,
- 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/umodem.c b/sys/dev/usb/serial/umodem.c
index e409d07e8ab2..fc658c5b6649 100644
--- a/sys/dev/usb/serial/umodem.c
+++ b/sys/dev/usb/serial/umodem.c
@@ -80,23 +80,38 @@ __FBSDID("$FreeBSD$");
*
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbhid.h>
#include <dev/usb/usb_cdc.h>
+#include "usbdevs.h"
+
#include <dev/usb/usb_ioctl.h>
#define USB_DEBUG_VAR umodem_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_device.h>
#include <dev/usb/serial/usb_serial.h>
@@ -353,8 +368,8 @@ umodem_attach(device_t dev)
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UMODEM_BULK_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UMODEM_BULK_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -600,31 +615,36 @@ umodem_cfg_set_break(struct ucom_softc *ucom, uint8_t onoff)
}
static void
-umodem_intr_callback(struct usb_xfer *xfer)
+umodem_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct usb_cdc_notification pkt;
- struct umodem_softc *sc = xfer->priv_sc;
+ struct umodem_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint16_t wLen;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 8) {
+ if (actlen < 8) {
DPRINTF("received short packet, "
- "%d bytes\n", xfer->actlen);
+ "%d bytes\n", actlen);
goto tr_setup;
}
- if (xfer->actlen > sizeof(pkt)) {
+ if (actlen > sizeof(pkt)) {
DPRINTF("truncating message\n");
- xfer->actlen = sizeof(pkt);
+ actlen = sizeof(pkt);
}
- usbd_copy_out(xfer->frbuffers, 0, &pkt, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &pkt, actlen);
- xfer->actlen -= 8;
+ actlen -= 8;
wLen = UGETW(pkt.wLength);
- if (xfer->actlen > wLen) {
- xfer->actlen = wLen;
+ if (actlen > wLen) {
+ actlen = wLen;
}
if (pkt.bmRequestType != UCDC_NOTIFICATION) {
DPRINTF("unknown message type, "
@@ -638,9 +658,9 @@ umodem_intr_callback(struct usb_xfer *xfer)
* Set the serial state in ucom driver based on
* the bits from the notify message
*/
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
DPRINTF("invalid notification "
- "length, %d bytes!\n", xfer->actlen);
+ "length, %d bytes!\n", actlen);
break;
}
DPRINTF("notify bytes = %02x%02x\n",
@@ -671,14 +691,14 @@ umodem_intr_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -687,27 +707,29 @@ tr_setup:
}
static void
-umodem_write_callback(struct usb_xfer *xfer)
+umodem_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umodem_softc *sc = xfer->priv_sc;
+ struct umodem_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UMODEM_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -715,28 +737,32 @@ tr_setup:
}
static void
-umodem_read_callback(struct usb_xfer *xfer)
+umodem_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umodem_softc *sc = xfer->priv_sc;
+ struct umodem_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("actlen=%d\n", xfer->actlen);
+ DPRINTF("actlen=%d\n", actlen);
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0,
- xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/umoscom.c b/sys/dev/usb/serial/umoscom.c
index 7fd52c31f641..47f70f1f4d3a 100644
--- a/sys/dev/usb/serial/umoscom.c
+++ b/sys/dev/usb/serial/umoscom.c
@@ -17,21 +17,34 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR umoscom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -313,8 +326,8 @@ umoscom_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UMOSCOM_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -583,9 +596,10 @@ umoscom_stop_write(struct ucom_softc *ucom)
}
static void
-umoscom_write_callback(struct usb_xfer *xfer)
+umoscom_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umoscom_softc *sc = xfer->priv_sc;
+ struct umoscom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
@@ -594,19 +608,20 @@ umoscom_write_callback(struct usb_xfer *xfer)
tr_setup:
DPRINTF("\n");
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UMOSCOM_BUFSIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
DPRINTFN(0, "transfer failed\n");
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -614,28 +629,33 @@ tr_setup:
}
static void
-umoscom_read_callback(struct usb_xfer *xfer)
+umoscom_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umoscom_softc *sc = xfer->priv_sc;
+ struct umoscom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("got %d bytes\n", xfer->actlen);
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ DPRINTF("got %d bytes\n", actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
DPRINTF("\n");
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
DPRINTFN(0, "transfer failed\n");
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -643,13 +663,16 @@ tr_setup:
}
static void
-umoscom_intr_callback(struct usb_xfer *xfer)
+umoscom_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umoscom_softc *sc = xfer->priv_sc;
+ struct umoscom_softc *sc = usbd_xfer_softc(xfer);
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < 2) {
+ if (actlen < 2) {
DPRINTF("too short message\n");
goto tr_setup;
}
@@ -657,15 +680,15 @@ umoscom_intr_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
DPRINTFN(0, "transfer failed\n");
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uplcom.c b/sys/dev/usb/serial/uplcom.c
index 0604b42fb9e1..399792f1ef15 100644
--- a/sys/dev/usb/serial/uplcom.c
+++ b/sys/dev/usb/serial/uplcom.c
@@ -84,21 +84,35 @@ __FBSDID("$FreeBSD$");
* documented in the datasheet.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uplcom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -389,8 +403,8 @@ uplcom_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -736,19 +750,24 @@ uplcom_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr)
}
static void
-uplcom_intr_callback(struct usb_xfer *xfer)
+uplcom_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uplcom_softc *sc = xfer->priv_sc;
+ struct uplcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[9];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF("actlen = %u\n", xfer->actlen);
+ DPRINTF("actlen = %u\n", actlen);
- if (xfer->actlen >= 9) {
+ if (actlen >= 9) {
- usbd_copy_out(xfer->frbuffers, 0, buf, sizeof(buf));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, sizeof(buf));
DPRINTF("status = 0x%02x\n", buf[8]);
@@ -768,14 +787,14 @@ uplcom_intr_callback(struct usb_xfer *xfer)
}
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -783,29 +802,31 @@ tr_setup:
}
static void
-uplcom_write_callback(struct usb_xfer *xfer)
+uplcom_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uplcom_softc *sc = xfer->priv_sc;
+ struct uplcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UPLCOM_BULK_BUF_SIZE, &actlen)) {
DPRINTF("actlen = %d\n", actlen);
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -813,24 +834,29 @@ tr_setup:
}
static void
-uplcom_read_callback(struct usb_xfer *xfer)
+uplcom_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uplcom_softc *sc = xfer->priv_sc;
+ struct uplcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index d6c4c1abd6da..e1b68d69d4f8 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -67,20 +67,34 @@ __FBSDID("$FreeBSD$");
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR ucom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_process.h>
#include <dev/usb/serial/usb_serial.h>
diff --git a/sys/dev/usb/serial/uslcom.c b/sys/dev/usb/serial/uslcom.c
index 2047cb292539..c319dfd74e54 100644
--- a/sys/dev/usb/serial/uslcom.c
+++ b/sys/dev/usb/serial/uslcom.c
@@ -19,20 +19,34 @@ __FBSDID("$FreeBSD$");
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uslcom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -242,8 +256,8 @@ uslcom_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -454,29 +468,31 @@ uslcom_set_break(struct ucom_softc *ucom, uint8_t onoff)
}
static void
-uslcom_write_callback(struct usb_xfer *xfer)
+uslcom_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uslcom_softc *sc = xfer->priv_sc;
+ struct uslcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
USLCOM_BULK_BUF_SIZE, &actlen)) {
DPRINTF("actlen = %d\n", actlen);
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -484,24 +500,29 @@ tr_setup:
}
static void
-uslcom_read_callback(struct usb_xfer *xfer)
+uslcom_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uslcom_softc *sc = xfer->priv_sc;
+ struct uslcom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uvisor.c b/sys/dev/usb/serial/uvisor.c
index 1e39947ae798..c7175e31a630 100644
--- a/sys/dev/usb/serial/uvisor.c
+++ b/sys/dev/usb/serial/uvisor.c
@@ -54,22 +54,34 @@
* Handspring Visor (Palmpilot compatible PDA) driver
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uvisor_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -324,8 +336,8 @@ uvisor_attach(device_t dev)
}
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UVISOR_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -562,27 +574,29 @@ uvisor_stop_write(struct ucom_softc *ucom)
}
static void
-uvisor_write_callback(struct usb_xfer *xfer)
+uvisor_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uvisor_softc *sc = xfer->priv_sc;
+ struct uvisor_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UVISOR_BUFSIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -590,24 +604,29 @@ tr_setup:
}
static void
-uvisor_read_callback(struct usb_xfer *xfer)
+uvisor_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uvisor_softc *sc = xfer->priv_sc;
+ struct uvisor_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/serial/uvscom.c b/sys/dev/usb/serial/uvscom.c
index 40b09a655ffa..27f3919b286a 100644
--- a/sys/dev/usb/serial/uvscom.c
+++ b/sys/dev/usb/serial/uvscom.c
@@ -37,21 +37,34 @@ __FBSDID("$FreeBSD$");
* P-in m@ater and various data communication card adapters.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_cdc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
#define USB_DEBUG_VAR uvscom_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/serial/usb_serial.h>
@@ -297,8 +310,8 @@ uvscom_attach(device_t dev)
/* clear stall at first run */
mtx_lock(&sc->sc_mtx);
- usbd_transfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_WR]);
- usbd_transfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_RD]);
+ usbd_xfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[UVSCOM_BULK_DT_RD]);
mtx_unlock(&sc->sc_mtx);
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -338,27 +351,29 @@ uvscom_detach(device_t dev)
}
static void
-uvscom_write_callback(struct usb_xfer *xfer)
+uvscom_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uvscom_softc *sc = xfer->priv_sc;
+ struct uvscom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
tr_setup:
- if (ucom_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (ucom_get_data(&sc->sc_ucom, pc, 0,
UVSCOM_BULK_BUF_SIZE, &actlen)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -366,24 +381,29 @@ tr_setup:
}
static void
-uvscom_read_callback(struct usb_xfer *xfer)
+uvscom_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uvscom_softc *sc = xfer->priv_sc;
+ struct uvscom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- ucom_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -391,16 +411,21 @@ tr_setup:
}
static void
-uvscom_intr_callback(struct usb_xfer *xfer)
+uvscom_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uvscom_softc *sc = xfer->priv_sc;
+ struct uvscom_softc *sc = usbd_xfer_softc(xfer);
+ struct usb_page_cache *pc;
uint8_t buf[2];
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen >= 2) {
+ if (actlen >= 2) {
- usbd_copy_out(xfer->frbuffers, 0, buf, sizeof(buf));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, buf, sizeof(buf));
sc->sc_lsr = 0;
sc->sc_msr = 0;
@@ -429,14 +454,14 @@ uvscom_intr_callback(struct usb_xfer *xfer)
}
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c
index d042348f76ea..da019c544de4 100644
--- a/sys/dev/usb/storage/umass.c
+++ b/sys/dev/usb/storage/umass.c
@@ -102,18 +102,29 @@ __FBSDID("$FreeBSD$");
* umass_cam_cb again to complete the CAM command.
*/
-#include "usbdevs.h"
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_transfer.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include "usbdevs.h"
#include <cam/cam.h>
#include <cam/cam_ccb.h>
@@ -124,7 +135,8 @@ __FBSDID("$FreeBSD$");
#include <cam/cam_periph.h>
-#if 1
+#define UMASS_EXT_BUFFER
+#ifdef UMASS_EXT_BUFFER
/* this enables loading of virtual buffers into DMA */
#define UMASS_USB_FLAGS .ext_buffer=1,
#else
@@ -1041,13 +1053,13 @@ static void umass_cancel_ccb(struct umass_softc *);
static void umass_init_shuttle(struct umass_softc *);
static void umass_reset(struct umass_softc *);
static void umass_t_bbb_data_clear_stall_callback(struct usb_xfer *,
- uint8_t, uint8_t);
+ uint8_t, uint8_t, usb_error_t);
static void umass_command_start(struct umass_softc *, uint8_t, void *,
uint32_t, uint32_t, umass_callback_t *, union ccb *);
static uint8_t umass_bbb_get_max_lun(struct umass_softc *);
static void umass_cbi_start_status(struct umass_softc *);
static void umass_t_cbi_data_clear_stall_callback(struct usb_xfer *,
- uint8_t, uint8_t);
+ uint8_t, uint8_t, usb_error_t);
static int umass_cam_attach_sim(struct umass_softc *);
static void umass_cam_rescan_callback(struct cam_periph *, union ccb *);
static void umass_cam_rescan(struct umass_softc *);
@@ -1712,14 +1724,14 @@ umass_cancel_ccb(struct umass_softc *sc)
}
static void
-umass_tr_error(struct usb_xfer *xfer)
+umass_tr_error(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
DPRINTF(sc, UDMASS_GEN, "transfer error, %s -> "
- "reset\n", usbd_errstr(xfer->error));
+ "reset\n", usbd_errstr(error));
}
umass_cancel_ccb(sc);
}
@@ -1729,10 +1741,11 @@ umass_tr_error(struct usb_xfer *xfer)
*/
static void
-umass_t_bbb_reset1_callback(struct usb_xfer *xfer)
+umass_t_bbb_reset1_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -1763,40 +1776,40 @@ umass_t_bbb_reset1_callback(struct usb_xfer *xfer)
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->nframes = 1;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frames(xfer, 1);
usbd_transfer_submit(xfer);
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_bbb_reset2_callback(struct usb_xfer *xfer)
+umass_t_bbb_reset2_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_bbb_data_clear_stall_callback(xfer, UMASS_T_BBB_RESET3,
- UMASS_T_BBB_DATA_READ);
+ UMASS_T_BBB_DATA_READ, error);
}
static void
-umass_t_bbb_reset3_callback(struct usb_xfer *xfer)
+umass_t_bbb_reset3_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_bbb_data_clear_stall_callback(xfer, UMASS_T_BBB_COMMAND,
- UMASS_T_BBB_DATA_WRITE);
+ UMASS_T_BBB_DATA_WRITE, error);
}
static void
umass_t_bbb_data_clear_stall_callback(struct usb_xfer *xfer,
- uint8_t next_xfer,
- uint8_t stall_xfer)
+ uint8_t next_xfer, uint8_t stall_xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -1811,17 +1824,18 @@ tr_transferred:
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_bbb_command_callback(struct usb_xfer *xfer)
+umass_t_bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
union ccb *ccb = sc->sc_transfer.ccb;
+ struct usb_page_cache *pc;
uint32_t tag;
switch (USB_GET_STATE(xfer)) {
@@ -1885,37 +1899,44 @@ umass_t_bbb_command_callback(struct usb_xfer *xfer)
DIF(UDMASS_BBB, umass_bbb_dump_cbw(sc, &sc->cbw));
- usbd_copy_in(xfer->frbuffers, 0, &sc->cbw, sizeof(sc->cbw));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &sc->cbw, sizeof(sc->cbw));
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(sc->cbw));
- xfer->frlengths[0] = sizeof(sc->cbw);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_bbb_data_read_callback(struct usb_xfer *xfer)
+umass_t_bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+#ifndef UMASS_EXT_BUFFER
+ struct usb_page_cache *pc;
+#endif
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (!xfer->flags.ext_buffer) {
- usbd_copy_out(xfer->frbuffers, 0,
- sc->sc_transfer.data_ptr, xfer->actlen);
- }
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.actlen += xfer->actlen;
+#ifndef UMASS_EXT_BUFFER
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, sc->sc_transfer.data_ptr, actlen);
+#endif
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->sc_transfer.data_rem = 0;
}
@@ -1930,18 +1951,20 @@ umass_t_bbb_data_read_callback(struct usb_xfer *xfer)
if (max_bulk > sc->sc_transfer.data_rem) {
max_bulk = sc->sc_transfer.data_rem;
}
- xfer->timeout = sc->sc_transfer.data_timeout;
- xfer->frlengths[0] = max_bulk;
+ usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
- if (xfer->flags.ext_buffer) {
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
- }
+#ifdef UMASS_EXT_BUFFER
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
+#else
+ usbd_xfer_set_frame_len(xfer, 0, max_bulk);
+#endif
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
- umass_tr_error(xfer);
+ if (error == USB_ERR_CANCELLED) {
+ umass_tr_error(xfer, error);
} else {
umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
}
@@ -1951,25 +1974,31 @@ umass_t_bbb_data_read_callback(struct usb_xfer *xfer)
}
static void
-umass_t_bbb_data_rd_cs_callback(struct usb_xfer *xfer)
+umass_t_bbb_data_rd_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_bbb_data_clear_stall_callback(xfer, UMASS_T_BBB_STATUS,
- UMASS_T_BBB_DATA_READ);
+ UMASS_T_BBB_DATA_READ, error);
}
static void
-umass_t_bbb_data_write_callback(struct usb_xfer *xfer)
+umass_t_bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+#ifndef UMASS_EXT_BUFFER
+ struct usb_page_cache *pc;
+#endif
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.actlen += xfer->actlen;
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->sc_transfer.data_rem = 0;
}
@@ -1984,22 +2013,23 @@ umass_t_bbb_data_write_callback(struct usb_xfer *xfer)
if (max_bulk > sc->sc_transfer.data_rem) {
max_bulk = sc->sc_transfer.data_rem;
}
- xfer->timeout = sc->sc_transfer.data_timeout;
- xfer->frlengths[0] = max_bulk;
+ usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
- if (xfer->flags.ext_buffer) {
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
- } else {
- usbd_copy_in(xfer->frbuffers, 0,
- sc->sc_transfer.data_ptr, max_bulk);
- }
+#ifdef UMASS_EXT_BUFFER
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
+#else
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, sc->sc_transfer.data_ptr, max_bulk);
+ usbd_xfer_set_frame_len(xfer, 0, max_bulk);
+#endif
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
- umass_tr_error(xfer);
+ if (error == USB_ERR_CANCELLED) {
+ umass_tr_error(xfer, error);
} else {
umass_transfer_start(sc, UMASS_T_BBB_DATA_WR_CS);
}
@@ -2009,18 +2039,22 @@ umass_t_bbb_data_write_callback(struct usb_xfer *xfer)
}
static void
-umass_t_bbb_data_wr_cs_callback(struct usb_xfer *xfer)
+umass_t_bbb_data_wr_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_bbb_data_clear_stall_callback(xfer, UMASS_T_BBB_STATUS,
- UMASS_T_BBB_DATA_WRITE);
+ UMASS_T_BBB_DATA_WRITE, error);
}
static void
-umass_t_bbb_status_callback(struct usb_xfer *xfer)
+umass_t_bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
union ccb *ccb = sc->sc_transfer.ccb;
+ struct usb_page_cache *pc;
uint32_t residue;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -2032,10 +2066,11 @@ umass_t_bbb_status_callback(struct usb_xfer *xfer)
/* Zero missing parts of the CSW: */
- if (xfer->actlen < sizeof(sc->csw)) {
+ if (actlen < sizeof(sc->csw)) {
bzero(&sc->csw, sizeof(sc->csw));
}
- usbd_copy_out(xfer->frbuffers, 0, &sc->csw, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &sc->csw, actlen);
DIF(UDMASS_BBB, umass_bbb_dump_csw(sc, &sc->csw));
@@ -2108,18 +2143,18 @@ umass_t_bbb_status_callback(struct usb_xfer *xfer)
return;
case USB_ST_SETUP:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default:
tr_error:
DPRINTF(sc, UDMASS_BBB, "Failed to read CSW: %s, try %d\n",
- usbd_errstr(xfer->error), sc->sc_status_try);
+ usbd_errstr(error), sc->sc_status_try);
- if ((xfer->error == USB_ERR_CANCELLED) ||
+ if ((error == USB_ERR_CANCELLED) ||
(sc->sc_status_try)) {
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
} else {
sc->sc_status_try = 1;
umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
@@ -2210,10 +2245,11 @@ umass_cbi_start_status(struct umass_softc *sc)
}
static void
-umass_t_cbi_reset1_callback(struct usb_xfer *xfer)
+umass_t_cbi_reset1_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
struct usb_device_request req;
+ struct usb_page_cache *pc;
uint8_t buf[UMASS_CBI_DIAGNOSTIC_CMDLEN];
uint8_t i;
@@ -2259,54 +2295,55 @@ umass_t_cbi_reset1_callback(struct usb_xfer *xfer)
buf[i] = 0xff;
}
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
- usbd_copy_in(xfer->frbuffers + 1, 0, buf, sizeof(buf));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 1);
+ usbd_copy_in(pc, 0, buf, sizeof(buf));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = sizeof(buf);
- xfer->nframes = 2;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, sizeof(buf));
+ usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_cbi_reset2_callback(struct usb_xfer *xfer)
+umass_t_cbi_reset2_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_cbi_data_clear_stall_callback(xfer, UMASS_T_CBI_RESET3,
- UMASS_T_CBI_DATA_READ);
+ UMASS_T_CBI_DATA_READ, error);
}
static void
-umass_t_cbi_reset3_callback(struct usb_xfer *xfer)
+umass_t_cbi_reset3_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
umass_t_cbi_data_clear_stall_callback
(xfer, (sc->sc_xfer[UMASS_T_CBI_RESET4] &&
sc->sc_xfer[UMASS_T_CBI_STATUS]) ?
UMASS_T_CBI_RESET4 : UMASS_T_CBI_COMMAND,
- UMASS_T_CBI_DATA_WRITE);
+ UMASS_T_CBI_DATA_WRITE, error);
}
static void
-umass_t_cbi_reset4_callback(struct usb_xfer *xfer)
+umass_t_cbi_reset4_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_cbi_data_clear_stall_callback(xfer, UMASS_T_CBI_COMMAND,
- UMASS_T_CBI_STATUS);
+ UMASS_T_CBI_STATUS, error);
}
static void
umass_t_cbi_data_clear_stall_callback(struct usb_xfer *xfer,
- uint8_t next_xfer,
- uint8_t stall_xfer)
+ uint8_t next_xfer, uint8_t stall_xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -2325,18 +2362,19 @@ tr_transferred:
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_cbi_command_callback(struct usb_xfer *xfer)
+umass_t_cbi_command_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
union ccb *ccb = sc->sc_transfer.ccb;
struct usb_device_request req;
+ struct usb_page_cache *pc;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -2369,13 +2407,16 @@ umass_t_cbi_command_callback(struct usb_xfer *xfer)
req.wLength[0] = sc->sc_transfer.cmd_len;
req.wLength[1] = 0;
- usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
- usbd_copy_in(xfer->frbuffers + 1, 0, sc->sc_transfer.cmd_data,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &req, sizeof(req));
+ pc = usbd_xfer_get_frame(xfer, 1);
+ usbd_copy_in(pc, 0, sc->sc_transfer.cmd_data,
sc->sc_transfer.cmd_len);
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = sc->sc_transfer.cmd_len;
- xfer->nframes = xfer->frlengths[1] ? 2 : 1;
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
+ usbd_xfer_set_frame_len(xfer, 1, sc->sc_transfer.cmd_len);
+ usbd_xfer_set_frames(xfer,
+ sc->sc_transfer.cmd_len ? 2 : 1);
DIF(UDMASS_CBI,
umass_cbi_dump_cmd(sc,
@@ -2387,29 +2428,35 @@ umass_t_cbi_command_callback(struct usb_xfer *xfer)
return;
default: /* Error */
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
return;
}
}
static void
-umass_t_cbi_data_read_callback(struct usb_xfer *xfer)
+umass_t_cbi_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+#ifndef UMASS_EXT_BUFFER
+ struct usb_page_cache *pc;
+#endif
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (!xfer->flags.ext_buffer) {
- usbd_copy_out(xfer->frbuffers, 0,
- sc->sc_transfer.data_ptr, xfer->actlen);
- }
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.actlen += xfer->actlen;
+#ifndef UMASS_EXT_BUFFER
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, sc->sc_transfer.data_ptr, actlen);
+#endif
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->sc_transfer.data_rem = 0;
}
@@ -2424,19 +2471,21 @@ umass_t_cbi_data_read_callback(struct usb_xfer *xfer)
if (max_bulk > sc->sc_transfer.data_rem) {
max_bulk = sc->sc_transfer.data_rem;
}
- xfer->timeout = sc->sc_transfer.data_timeout;
+ usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
- if (xfer->flags.ext_buffer) {
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
- }
- xfer->frlengths[0] = max_bulk;
+#ifdef UMASS_EXT_BUFFER
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
+#else
+ usbd_xfer_set_frame_len(xfer, 0, max_bulk);
+#endif
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if ((xfer->error == USB_ERR_CANCELLED) ||
+ if ((error == USB_ERR_CANCELLED) ||
(sc->sc_transfer.callback != &umass_cam_cb)) {
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
} else {
umass_transfer_start(sc, UMASS_T_CBI_DATA_RD_CS);
}
@@ -2446,25 +2495,31 @@ umass_t_cbi_data_read_callback(struct usb_xfer *xfer)
}
static void
-umass_t_cbi_data_rd_cs_callback(struct usb_xfer *xfer)
+umass_t_cbi_data_rd_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_cbi_data_clear_stall_callback(xfer, UMASS_T_CBI_STATUS,
- UMASS_T_CBI_DATA_READ);
+ UMASS_T_CBI_DATA_READ, error);
}
static void
-umass_t_cbi_data_write_callback(struct usb_xfer *xfer)
+umass_t_cbi_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+#ifndef UMASS_EXT_BUFFER
+ struct usb_page_cache *pc;
+#endif
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.actlen += xfer->actlen;
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->sc_transfer.data_rem = 0;
}
@@ -2479,23 +2534,24 @@ umass_t_cbi_data_write_callback(struct usb_xfer *xfer)
if (max_bulk > sc->sc_transfer.data_rem) {
max_bulk = sc->sc_transfer.data_rem;
}
- xfer->timeout = sc->sc_transfer.data_timeout;
+ usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
- if (xfer->flags.ext_buffer) {
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
- } else {
- usbd_copy_in(xfer->frbuffers, 0,
- sc->sc_transfer.data_ptr, max_bulk);
- }
+#ifdef UMASS_EXT_BUFFER
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
+#else
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, sc->sc_transfer.data_ptr, max_bulk);
+ usbd_xfer_set_frame_len(xfer, 0, max_bulk);
+#endif
- xfer->frlengths[0] = max_bulk;
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if ((xfer->error == USB_ERR_CANCELLED) ||
+ if ((error == USB_ERR_CANCELLED) ||
(sc->sc_transfer.callback != &umass_cam_cb)) {
- umass_tr_error(xfer);
+ umass_tr_error(xfer, error);
} else {
umass_transfer_start(sc, UMASS_T_CBI_DATA_WR_CS);
}
@@ -2505,27 +2561,32 @@ umass_t_cbi_data_write_callback(struct usb_xfer *xfer)
}
static void
-umass_t_cbi_data_wr_cs_callback(struct usb_xfer *xfer)
+umass_t_cbi_data_wr_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
umass_t_cbi_data_clear_stall_callback(xfer, UMASS_T_CBI_STATUS,
- UMASS_T_CBI_DATA_WRITE);
+ UMASS_T_CBI_DATA_WRITE, error);
}
static void
-umass_t_cbi_status_callback(struct usb_xfer *xfer)
+umass_t_cbi_status_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct umass_softc *sc = xfer->priv_sc;
+ struct umass_softc *sc = usbd_xfer_softc(xfer);
union ccb *ccb = sc->sc_transfer.ccb;
+ struct usb_page_cache *pc;
uint32_t residue;
uint8_t status;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- if (xfer->actlen < sizeof(sc->sbl)) {
+ if (actlen < sizeof(sc->sbl)) {
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, &sc->sbl, sizeof(sc->sbl));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &sc->sbl, sizeof(sc->sbl));
residue = (sc->sc_transfer.data_len -
sc->sc_transfer.actlen);
@@ -2588,14 +2649,14 @@ umass_t_cbi_status_callback(struct usb_xfer *xfer)
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
return;
default: /* Error */
DPRINTF(sc, UDMASS_CBI, "Failed to read CSW: %s\n",
- usbd_errstr(xfer->error));
- umass_tr_error(xfer);
+ usbd_errstr(error));
+ umass_tr_error(xfer, error);
return;
}
@@ -3085,7 +3146,7 @@ umass_cam_poll(struct cam_sim *sim)
DPRINTF(sc, UDMASS_SCSI, "CAM poll\n");
- usbd_do_poll(sc->sc_xfer, UMASS_T_MAX);
+ usbd_transfer_poll(sc->sc_xfer, UMASS_T_MAX);
}
diff --git a/sys/dev/usb/storage/urio.c b/sys/dev/usb/storage/urio.c
index 01502bba83a7..6bb2e889e405 100644
--- a/sys/dev/usb/storage/urio.c
+++ b/sys/dev/usb/storage/urio.c
@@ -44,25 +44,39 @@ __FBSDID("$FreeBSD$");
* 2000/2/24 first version.
*/
-#include "usbdevs.h"
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include "usbdevs.h"
+
#include <dev/usb/usb_ioctl.h>
-#include <dev/usb/storage/rio500_usb.h>
+#include <dev/usb/usb_generic.h>
#define USB_DEBUG_VAR urio_debug
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
-#include <dev/usb/usb_generic.h>
+
+#include <dev/usb/storage/rio500_usb.h>
#if USB_DEBUG
static int urio_debug = 0;
@@ -242,10 +256,11 @@ detach:
}
static void
-urio_write_callback(struct usb_xfer *xfer)
+urio_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urio_softc *sc = xfer->priv_sc;
+ struct urio_softc *sc = usbd_xfer_softc(xfer);
struct usb_fifo *f = sc->sc_fifo.fp[USB_FIFO_TX];
+ struct usb_page_cache *pc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
@@ -255,16 +270,17 @@ urio_write_callback(struct usb_xfer *xfer)
usbd_transfer_start(sc->sc_xfer[URIO_T_WR_CS]);
return;
}
- if (usb_fifo_get_data(f, xfer->frbuffers, 0,
- xfer->max_data_length, &actlen, 0)) {
+ pc = usbd_xfer_get_frame(xfer, 0);
+ if (usb_fifo_get_data(f, pc, 0,
+ usbd_xfer_max_len(xfer), &actlen, 0)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
sc->sc_flags |= URIO_FLAG_WRITE_STALL;
usbd_transfer_start(sc->sc_xfer[URIO_T_WR_CS]);
@@ -274,9 +290,9 @@ urio_write_callback(struct usb_xfer *xfer)
}
static void
-urio_write_clear_stall_callback(struct usb_xfer *xfer)
+urio_write_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urio_softc *sc = xfer->priv_sc;
+ struct urio_softc *sc = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = sc->sc_xfer[URIO_T_WR];
if (usbd_clear_stall_callback(xfer, xfer_other)) {
@@ -287,15 +303,19 @@ urio_write_clear_stall_callback(struct usb_xfer *xfer)
}
static void
-urio_read_callback(struct usb_xfer *xfer)
+urio_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urio_softc *sc = xfer->priv_sc;
+ struct urio_softc *sc = usbd_xfer_softc(xfer);
struct usb_fifo *f = sc->sc_fifo.fp[USB_FIFO_RX];
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- usb_fifo_put_data(f, xfer->frbuffers, 0,
- xfer->actlen, 1);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usb_fifo_put_data(f, pc, 0, actlen, 1);
case USB_ST_SETUP:
if (sc->sc_flags & URIO_FLAG_READ_STALL) {
@@ -303,13 +323,13 @@ urio_read_callback(struct usb_xfer *xfer)
return;
}
if (usb_fifo_put_bytes_max(f) != 0) {
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
}
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
sc->sc_flags |= URIO_FLAG_READ_STALL;
usbd_transfer_start(sc->sc_xfer[URIO_T_RD_CS]);
@@ -319,9 +339,9 @@ urio_read_callback(struct usb_xfer *xfer)
}
static void
-urio_read_clear_stall_callback(struct usb_xfer *xfer)
+urio_read_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urio_softc *sc = xfer->priv_sc;
+ struct urio_softc *sc = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = sc->sc_xfer[URIO_T_RD];
if (usbd_clear_stall_callback(xfer, xfer_other)) {
@@ -334,7 +354,7 @@ urio_read_clear_stall_callback(struct usb_xfer *xfer)
static void
urio_start_read(struct usb_fifo *fifo)
{
- struct urio_softc *sc = fifo->priv_sc0;
+ struct urio_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[URIO_T_RD]);
}
@@ -342,7 +362,7 @@ urio_start_read(struct usb_fifo *fifo)
static void
urio_stop_read(struct usb_fifo *fifo)
{
- struct urio_softc *sc = fifo->priv_sc0;
+ struct urio_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[URIO_T_RD_CS]);
usbd_transfer_stop(sc->sc_xfer[URIO_T_RD]);
@@ -351,7 +371,7 @@ urio_stop_read(struct usb_fifo *fifo)
static void
urio_start_write(struct usb_fifo *fifo)
{
- struct urio_softc *sc = fifo->priv_sc0;
+ struct urio_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_start(sc->sc_xfer[URIO_T_WR]);
}
@@ -359,7 +379,7 @@ urio_start_write(struct usb_fifo *fifo)
static void
urio_stop_write(struct usb_fifo *fifo)
{
- struct urio_softc *sc = fifo->priv_sc0;
+ struct urio_softc *sc = usb_fifo_softc(fifo);
usbd_transfer_stop(sc->sc_xfer[URIO_T_WR_CS]);
usbd_transfer_stop(sc->sc_xfer[URIO_T_WR]);
@@ -368,7 +388,7 @@ urio_stop_write(struct usb_fifo *fifo)
static int
urio_open(struct usb_fifo *fifo, int fflags)
{
- struct urio_softc *sc = fifo->priv_sc0;
+ struct urio_softc *sc = usb_fifo_softc(fifo);
if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
return (EACCES);
@@ -380,7 +400,7 @@ urio_open(struct usb_fifo *fifo, int fflags)
mtx_unlock(&sc->sc_mtx);
if (usb_fifo_alloc_buffer(fifo,
- sc->sc_xfer[URIO_T_RD]->max_data_length,
+ usbd_xfer_max_len(sc->sc_xfer[URIO_T_RD]),
URIO_IFQ_MAXLEN)) {
return (ENOMEM);
}
@@ -390,7 +410,7 @@ urio_open(struct usb_fifo *fifo, int fflags)
sc->sc_flags |= URIO_FLAG_WRITE_STALL;
if (usb_fifo_alloc_buffer(fifo,
- sc->sc_xfer[URIO_T_WR]->max_data_length,
+ usbd_xfer_max_len(sc->sc_xfer[URIO_T_WR]),
URIO_IFQ_MAXLEN)) {
return (ENOMEM);
}
diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c
index 2af5d6695c1d..b7e64bbe0cca 100644
--- a/sys/dev/usb/storage/ustorage_fs.c
+++ b/sys/dev/usb/storage/ustorage_fs.c
@@ -35,19 +35,34 @@
* NOTE: Much of the SCSI statemachine handling code derives from the
* Linux USB gadget stack.
*/
-#include "usbdevs.h"
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include "usbdevs.h"
+#include "usb_if.h"
#define USB_DEBUG_VAR ustorage_fs_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_device.h>
#if USB_DEBUG
static int ustorage_fs_debug = 0;
@@ -491,11 +506,11 @@ ustorage_fs_handle_request(device_t dev,
}
static void
-ustorage_fs_t_bbb_command_callback(struct usb_xfer *xfer)
+ustorage_fs_t_bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ustorage_fs_softc *sc = xfer->priv_sc;
+ struct ustorage_fs_softc *sc = usbd_xfer_softc(xfer);
uint32_t tag;
- uint8_t error = 0;
+ uint8_t err = 0;
DPRINTF("\n");
@@ -547,8 +562,8 @@ ustorage_fs_t_bbb_command_callback(struct usb_xfer *xfer)
break;
}
- error = ustorage_fs_do_cmd(sc);
- if (error) {
+ err = ustorage_fs_do_cmd(sc);
+ if (err) {
/* got an error */
DPRINTF("command failed\n");
break;
@@ -556,7 +571,7 @@ ustorage_fs_t_bbb_command_callback(struct usb_xfer *xfer)
if ((sc->sc_transfer.data_rem > 0) &&
(sc->sc_transfer.cbw_dir != sc->sc_transfer.cmd_dir)) {
/* contradicting data transfer direction */
- error = 1;
+ err = 1;
DPRINTF("data direction mismatch\n");
break;
}
@@ -578,30 +593,28 @@ ustorage_fs_t_bbb_command_callback(struct usb_xfer *xfer)
tr_setup:
if (sc->sc_transfer.data_error) {
sc->sc_transfer.data_error = 0;
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
DPRINTF("stall pipe\n");
- } else {
- xfer->flags.stall_pipe = 0;
}
- xfer->frlengths[0] = sizeof(sc->sc_cbw);
- usbd_set_frame_data(xfer, &sc->sc_cbw, 0);
+ usbd_xfer_set_frame_data(xfer, 0, &sc->sc_cbw,
+ sizeof(sc->sc_cbw));
usbd_transfer_submit(xfer);
break;
default: /* Error */
DPRINTF("error\n");
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
break;
}
/* If the pipe is already stalled, don't do another stall */
- if (!xfer->endpoint->is_stalled) {
+ if (!usbd_xfer_is_stalled(xfer))
sc->sc_transfer.data_error = 1;
- }
+
/* try again */
goto tr_setup;
}
- if (error) {
+ if (err) {
if (sc->sc_csw.bCSWStatus == 0) {
/* set some default error code */
sc->sc_csw.bCSWStatus = CSWSTATUS_FAILED;
@@ -621,20 +634,22 @@ tr_setup:
}
static void
-ustorage_fs_t_bbb_data_dump_callback(struct usb_xfer *xfer)
+ustorage_fs_t_bbb_data_dump_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ustorage_fs_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct ustorage_fs_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
DPRINTF("\n");
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.offset += xfer->actlen;
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.offset += actlen;
- if ((xfer->actlen != xfer->sumlen) ||
- (sc->sc_transfer.data_rem == 0)) {
+ if (actlen != sumlen || sc->sc_transfer.data_rem == 0) {
/* short transfer or end of data */
ustorage_fs_transfer_start(sc,
USTORAGE_FS_T_BBB_STATUS);
@@ -649,45 +664,45 @@ tr_setup:
}
if (sc->sc_transfer.data_error) {
sc->sc_transfer.data_error = 0;
- xfer->flags.stall_pipe = 1;
- } else {
- xfer->flags.stall_pipe = 0;
+ usbd_xfer_set_stall(xfer);
}
- xfer->frlengths[0] = max_bulk;
+ usbd_xfer_set_frame_len(xfer, 0, max_bulk);
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
break;
}
/*
* If the pipe is already stalled, don't do another stall:
*/
- if (!xfer->endpoint->is_stalled) {
+ if (!usbd_xfer_is_stalled(xfer))
sc->sc_transfer.data_error = 1;
- }
+
/* try again */
goto tr_setup;
}
}
static void
-ustorage_fs_t_bbb_data_read_callback(struct usb_xfer *xfer)
+ustorage_fs_t_bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ustorage_fs_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct ustorage_fs_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
DPRINTF("\n");
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.offset += xfer->actlen;
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.offset += actlen;
- if ((xfer->actlen != xfer->sumlen) ||
- (sc->sc_transfer.data_rem == 0)) {
+ if (actlen != sumlen || sc->sc_transfer.data_rem == 0) {
/* short transfer or end of data */
ustorage_fs_transfer_start(sc,
USTORAGE_FS_T_BBB_STATUS);
@@ -702,45 +717,45 @@ tr_setup:
}
if (sc->sc_transfer.data_error) {
sc->sc_transfer.data_error = 0;
- xfer->flags.stall_pipe = 1;
- } else {
- xfer->flags.stall_pipe = 0;
+ usbd_xfer_set_stall(xfer);
}
- xfer->frlengths[0] = max_bulk;
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
break;
}
/* If the pipe is already stalled, don't do another stall */
- if (!xfer->endpoint->is_stalled) {
+ if (!usbd_xfer_is_stalled(xfer))
sc->sc_transfer.data_error = 1;
- }
+
/* try again */
goto tr_setup;
}
}
static void
-ustorage_fs_t_bbb_data_write_callback(struct usb_xfer *xfer)
+ustorage_fs_t_bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ustorage_fs_softc *sc = xfer->priv_sc;
- uint32_t max_bulk = xfer->max_data_length;
+ struct ustorage_fs_softc *sc = usbd_xfer_softc(xfer);
+ uint32_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
DPRINTF("\n");
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->sc_transfer.data_rem -= xfer->actlen;
- sc->sc_transfer.data_ptr += xfer->actlen;
- sc->sc_transfer.offset += xfer->actlen;
+ sc->sc_transfer.data_rem -= actlen;
+ sc->sc_transfer.data_ptr += actlen;
+ sc->sc_transfer.offset += actlen;
- if ((xfer->actlen != xfer->sumlen) ||
- (sc->sc_transfer.data_rem == 0)) {
+ if (actlen != sumlen || sc->sc_transfer.data_rem == 0) {
/* short transfer or end of data */
ustorage_fs_transfer_start(sc,
USTORAGE_FS_T_BBB_STATUS);
@@ -750,47 +765,43 @@ ustorage_fs_t_bbb_data_write_callback(struct usb_xfer *xfer)
tr_setup:
if (max_bulk >= sc->sc_transfer.data_rem) {
max_bulk = sc->sc_transfer.data_rem;
- if (sc->sc_transfer.data_short) {
- xfer->flags.force_short_xfer = 1;
- } else {
- xfer->flags.force_short_xfer = 0;
- }
- } else {
- xfer->flags.force_short_xfer = 0;
- }
+ if (sc->sc_transfer.data_short)
+ usbd_xfer_set_flag(xfer, USB_FORCE_SHORT_XFER);
+ else
+ usbd_xfer_clr_flag(xfer, USB_FORCE_SHORT_XFER);
+ } else
+ usbd_xfer_clr_flag(xfer, USB_FORCE_SHORT_XFER);
if (sc->sc_transfer.data_error) {
sc->sc_transfer.data_error = 0;
- xfer->flags.stall_pipe = 1;
- } else {
- xfer->flags.stall_pipe = 0;
+ usbd_xfer_set_stall(xfer);
}
- xfer->frlengths[0] = max_bulk;
- usbd_set_frame_data(xfer, sc->sc_transfer.data_ptr, 0);
+ usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
+ max_bulk);
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
break;
}
/*
* If the pipe is already stalled, don't do another
* stall
*/
- if (!xfer->endpoint->is_stalled) {
+ if (!usbd_xfer_is_stalled(xfer))
sc->sc_transfer.data_error = 1;
- }
+
/* try again */
goto tr_setup;
}
}
static void
-ustorage_fs_t_bbb_status_callback(struct usb_xfer *xfer)
+ustorage_fs_t_bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ustorage_fs_softc *sc = xfer->priv_sc;
+ struct ustorage_fs_softc *sc = usbd_xfer_softc(xfer);
DPRINTF("\n");
@@ -806,24 +817,22 @@ tr_setup:
if (sc->sc_transfer.data_error) {
sc->sc_transfer.data_error = 0;
- xfer->flags.stall_pipe = 1;
- } else {
- xfer->flags.stall_pipe = 0;
+ usbd_xfer_set_stall(xfer);
}
- xfer->frlengths[0] = sizeof(sc->sc_csw);
- usbd_set_frame_data(xfer, &sc->sc_csw, 0);
+ usbd_xfer_set_frame_data(xfer, 0, &sc->sc_csw,
+ sizeof(sc->sc_csw));
usbd_transfer_submit(xfer);
break;
default:
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
break;
}
/* If the pipe is already stalled, don't do another stall */
- if (!xfer->endpoint->is_stalled) {
+ if (!usbd_xfer_is_stalled(xfer))
sc->sc_transfer.data_error = 1;
- }
+
/* try again */
goto tr_setup;
}
diff --git a/sys/dev/usb/template/usb_template.c b/sys/dev/usb/template/usb_template.c
index d4c192d9f56f..d9e0dc167519 100644
--- a/sys/dev/usb/template/usb_template.c
+++ b/sys/dev/usb/template/usb_template.c
@@ -29,24 +29,43 @@
* USB templates.
*/
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
-#define USB_DEBUG_VAR usb_debug
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include "usbdevs.h"
+#include <dev/usb/usb_cdc.h>
#include <dev/usb/usb_core.h>
+#include <dev/usb/usb_dynamic.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_parse.h>
#include <dev/usb/usb_device.h>
-#include <dev/usb/usb_dynamic.h>
+
+#define USB_DEBUG_VAR usb_debug
+#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
-
#include <dev/usb/template/usb_template.h>
MODULE_DEPEND(usb_template, usb, 1, 1, 1);
diff --git a/sys/dev/usb/template/usb_template_cdce.c b/sys/dev/usb/template/usb_template_cdce.c
index f648dd880989..7e4f2ae055a9 100644
--- a/sys/dev/usb/template/usb_template_cdce.c
+++ b/sys/dev/usb/template/usb_template_cdce.c
@@ -31,11 +31,29 @@ __FBSDID("$FreeBSD$");
* This file contains the USB templates for a CDC USB ethernet device.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_mfunc.h>
-
-#include <dev/usb/usb_core.h>
#include <dev/usb/template/usb_template.h>
diff --git a/sys/dev/usb/template/usb_template_msc.c b/sys/dev/usb/template/usb_template_msc.c
index b42cdb6be4f5..f55be3301005 100644
--- a/sys/dev/usb/template/usb_template_msc.c
+++ b/sys/dev/usb/template/usb_template_msc.c
@@ -31,10 +31,28 @@ __FBSDID("$FreeBSD$");
* This file contains the USB templates for an USB Mass Storage Device.
*/
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
-#include <dev/usb/usb_core.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/template/usb_template.h>
diff --git a/sys/dev/usb/template/usb_template_mtp.c b/sys/dev/usb/template/usb_template_mtp.c
index acc088aab49b..a98a242e1f3b 100644
--- a/sys/dev/usb/template/usb_template_mtp.c
+++ b/sys/dev/usb/template/usb_template_mtp.c
@@ -38,11 +38,28 @@ __FBSDID("$FreeBSD$");
* operating system the VID and PID of your device.
*/
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-
-#include <dev/usb/usb_core.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/template/usb_template.h>
#define MTP_BREQUEST 0x08
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index e9fc6a5ea8e1..68c3caf6a056 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -39,7 +39,45 @@
#ifndef _USB_STANDARD_H_
#define _USB_STANDARD_H_
+#if defined(_KERNEL)
+#include "opt_usb.h"
+
+/* Declare parent SYSCTL USB node. */
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_hw_usb);
+#endif
+
+#include <sys/malloc.h>
+
+MALLOC_DECLARE(M_USB);
+MALLOC_DECLARE(M_USBDEV);
+MALLOC_DECLARE(M_USBHC);
+#endif /* _KERNEL */
+
#include <dev/usb/usb_endian.h>
+#include <dev/usb/usb_freebsd.h>
+
+#define USB_STACK_VERSION 2000 /* 2.0 */
+
+/* Definition of some hardcoded USB constants. */
+
+#define USB_MAX_IPACKET 8 /* initial USB packet size */
+#define USB_EP_MAX (2*16) /* hardcoded */
+#define USB_ROOT_HUB_ADDR 1 /* index */
+#define USB_MIN_DEVICES 2 /* unused + root HUB */
+#define USB_UNCONFIG_INDEX 0xFF /* internal use only */
+#define USB_IFACE_INDEX_ANY 0xFF /* internal use only */
+#define USB_START_ADDR 0 /* default USB device BUS address
+ * after USB bus reset */
+#define USB_CONTROL_ENDPOINT 0 /* default control endpoint */
+
+#define USB_FRAMES_PER_SECOND_FS 1000 /* full speed */
+#define USB_FRAMES_PER_SECOND_HS 8000 /* high speed */
+
+#define USB_FS_BYTES_PER_HS_UFRAME 188 /* bytes */
+#define USB_HS_MICRO_FRAMES_MAX 8 /* units */
+
+#define USB_ISOC_TIME_MAX 128 /* ms */
/*
* Minimum time a device needs to be powered down to go through a
@@ -642,4 +680,51 @@ struct usb_port_status {
} __packed;
typedef struct usb_port_status usb_port_status_t;
+/*
+ * The "USB_SPEED" macros defines all the supported USB speeds.
+ */
+enum usb_dev_speed {
+ USB_SPEED_VARIABLE,
+ USB_SPEED_LOW,
+ USB_SPEED_FULL,
+ USB_SPEED_HIGH,
+ USB_SPEED_SUPER,
+};
+#define USB_SPEED_MAX (USB_SPEED_SUPER+1)
+
+/*
+ * The "USB_REV" macros defines all the supported USB revisions.
+ */
+enum usb_revision {
+ USB_REV_UNKNOWN,
+ USB_REV_PRE_1_0,
+ USB_REV_1_0,
+ USB_REV_1_1,
+ USB_REV_2_0,
+ USB_REV_2_5,
+ USB_REV_3_0
+};
+#define USB_REV_MAX (USB_REV_3_0+1)
+
+/*
+ * Supported host contoller modes.
+ */
+enum usb_hc_mode {
+ USB_MODE_HOST, /* initiates transfers */
+ USB_MODE_DEVICE, /* bus transfer target */
+ USB_MODE_DUAL /* can be host or device */
+};
+#define USB_MODE_MAX (USB_MODE_DUAL+1)
+
+/*
+ * The "USB_MODE" macros defines all the supported device states.
+ */
+enum usb_dev_state {
+ USB_STATE_DETACHED,
+ USB_STATE_ATTACHED,
+ USB_STATE_POWERED,
+ USB_STATE_ADDRESSED,
+ USB_STATE_CONFIGURED,
+};
+#define USB_STATE_MAX (USB_STATE_CONFIGURED+1)
#endif /* _USB_STANDARD_H_ */
diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c
index 48fb603d0670..4127449ea110 100644
--- a/sys/dev/usb/usb_busdma.c
+++ b/sys/dev/usb/usb_busdma.c
@@ -24,9 +24,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR usb_debug
@@ -419,7 +439,7 @@ usb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs,
pc->page_offset_buf = rem;
pc->page_offset_end += rem;
nseg--;
-#if (USB_DEBUG != 0)
+#ifdef USB_DEBUG
if (rem != (USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1))) {
/*
* This check verifies that the physical address is correct:
diff --git a/sys/dev/usb/usb_busdma.h b/sys/dev/usb/usb_busdma.h
index 86cb65c48f57..6b6e4039ef33 100644
--- a/sys/dev/usb/usb_busdma.h
+++ b/sys/dev/usb/usb_busdma.h
@@ -149,24 +149,10 @@ void usb_bdma_done_event(struct usb_dma_parent_tag *udpt);
void usb_bdma_post_sync(struct usb_xfer *xfer);
void usb_bdma_pre_sync(struct usb_xfer *xfer);
void usb_bdma_work_loop(struct usb_xfer_queue *pq);
-void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset,
- usb_frlength_t len);
-void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset,
- const void *ptr, usb_frlength_t len);
-int usbd_copy_in_user(struct usb_page_cache *cache, usb_frlength_t offset,
- const void *ptr, usb_frlength_t len);
-void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset,
- void *ptr, usb_frlength_t len);
-int usbd_copy_out_user(struct usb_page_cache *cache, usb_frlength_t offset,
- void *ptr, usb_frlength_t len);
void usb_dma_tag_setup(struct usb_dma_parent_tag *udpt,
struct usb_dma_tag *udt, bus_dma_tag_t dmat, struct mtx *mtx,
usb_dma_callback_t *func, uint8_t ndmabits, uint8_t nudt);
void usb_dma_tag_unsetup(struct usb_dma_parent_tag *udpt);
-void usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
- struct usb_page_search *res);
-void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset,
- struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len);
void usb_pc_cpu_flush(struct usb_page_cache *pc);
void usb_pc_cpu_invalidate(struct usb_page_cache *pc);
void usb_pc_dmamap_destroy(struct usb_page_cache *pc);
diff --git a/sys/dev/usb/usb_compat_linux.c b/sys/dev/usb/usb_compat_linux.c
index f971fe373444..7385fa222f3b 100644
--- a/sys/dev/usb/usb_compat_linux.c
+++ b/sys/dev/usb/usb_compat_linux.c
@@ -25,10 +25,30 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_error.h>
#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR usb_debug
@@ -39,7 +59,6 @@
#include <dev/usb/usb_util.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_parse.h>
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_request.h>
#include <dev/usb/usb_debug.h>
@@ -1265,8 +1284,8 @@ usb_linux_complete(struct usb_xfer *xfer)
{
struct urb *urb;
- urb = xfer->priv_fifo;
- xfer->priv_fifo = NULL;
+ urb = usbd_xfer_get_priv(xfer);
+ usbd_xfer_set_priv(xfer, NULL);
if (urb->complete) {
(urb->complete) (urb);
}
@@ -1281,13 +1300,13 @@ usb_linux_complete(struct usb_xfer *xfer)
* used.
*------------------------------------------------------------------------*/
static void
-usb_linux_isoc_callback(struct usb_xfer *xfer)
+usb_linux_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
{
usb_frlength_t max_frame = xfer->max_frame_size;
usb_frlength_t offset;
usb_frcount_t x;
- struct urb *urb = xfer->priv_fifo;
- struct usb_host_endpoint *uhe = xfer->priv_sc;
+ struct urb *urb = usbd_xfer_get_priv(xfer);
+ struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
struct usb_iso_packet_descriptor *uipd;
DPRINTF("\n");
@@ -1362,11 +1381,15 @@ tr_setup:
DPRINTF("Already got a transfer\n");
/* already got a transfer (should not happen) */
- urb = xfer->priv_fifo;
+ urb = usbd_xfer_get_priv(xfer);
}
urb->bsd_isread = (uhe->desc.bEndpointAddress & UE_DIR_IN) ? 1 : 0;
+ if (xfer->flags.ext_buffer) {
+ /* set virtual address to load */
+ usbd_xfer_set_frame_data(xfer, 0, urb->transfer_buffer, 0);
+ }
if (!(urb->bsd_isread)) {
/* copy out data with regard to the URB */
@@ -1375,7 +1398,7 @@ tr_setup:
for (x = 0; x < urb->number_of_packets; x++) {
uipd = urb->iso_frame_desc + x;
- xfer->frlengths[x] = uipd->length;
+ usbd_xfer_set_frame_len(xfer, x, uipd->length);
if (!xfer->flags.ext_buffer) {
usbd_copy_in(xfer->frbuffers, offset,
USB_ADD_BYTES(urb->transfer_buffer,
@@ -1396,16 +1419,10 @@ tr_setup:
for (x = 0; x < urb->number_of_packets; x++) {
uipd = urb->iso_frame_desc + x;
- xfer->frlengths[x] = max_frame;
+ usbd_xfer_set_frame_len(xfer, x, max_frame);
}
}
-
- if (xfer->flags.ext_buffer) {
- /* set virtual address to load */
- usbd_set_frame_data(xfer,
- urb->transfer_buffer, 0);
- }
- xfer->priv_fifo = urb;
+ usbd_xfer_set_priv(xfer, urb);
xfer->flags.force_short_xfer = 0;
xfer->timeout = urb->timeout;
xfer->nframes = urb->number_of_packets;
@@ -1449,15 +1466,15 @@ tr_setup:
* callback is called.
*------------------------------------------------------------------------*/
static void
-usb_linux_non_isoc_callback(struct usb_xfer *xfer)
+usb_linux_non_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
{
enum {
REQ_SIZE = sizeof(struct usb_device_request)
};
- struct urb *urb = xfer->priv_fifo;
- struct usb_host_endpoint *uhe = xfer->priv_sc;
+ struct urb *urb = usbd_xfer_get_priv(xfer);
+ struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
uint8_t *ptr;
- usb_frlength_t max_bulk = xfer->max_data_length;
+ usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
uint8_t data_frame = xfer->flags_int.control_xfr ? 1 : 0;
DPRINTF("\n");
@@ -1469,7 +1486,7 @@ usb_linux_non_isoc_callback(struct usb_xfer *xfer)
/* don't transfer the setup packet again: */
- xfer->frlengths[0] = 0;
+ usbd_xfer_set_frame_len(xfer, 0, 0);
}
if (urb->bsd_isread && (!xfer->flags.ext_buffer)) {
/* copy in data with regard to the URB */
@@ -1513,7 +1530,7 @@ tr_setup:
TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
urb->bsd_urb_list.tqe_prev = NULL;
- xfer->priv_fifo = urb;
+ usbd_xfer_set_priv(xfer, urb);
xfer->flags.force_short_xfer = 0;
xfer->timeout = urb->timeout;
@@ -1526,14 +1543,13 @@ tr_setup:
if (!xfer->flags.ext_buffer) {
usbd_copy_in(xfer->frbuffers, 0,
urb->setup_packet, REQ_SIZE);
+ usbd_xfer_set_frame_len(xfer, 0, REQ_SIZE);
} else {
/* set virtual address to load */
- usbd_set_frame_data(xfer,
- urb->setup_packet, 0);
+ usbd_xfer_set_frame_data(xfer, 0,
+ urb->setup_packet, REQ_SIZE);
}
- xfer->frlengths[0] = REQ_SIZE;
-
ptr = urb->setup_packet;
/* setup data transfer direction and length */
@@ -1567,14 +1583,14 @@ setup_bulk:
if (xfer->flags.ext_buffer) {
/* set virtual address to load */
- usbd_set_frame_data(xfer, urb->bsd_data_ptr,
- data_frame);
+ usbd_xfer_set_frame_data(xfer, data_frame,
+ urb->bsd_data_ptr, max_bulk);
} else if (!urb->bsd_isread) {
/* copy out data with regard to the URB */
usbd_copy_in(xfer->frbuffers + data_frame, 0,
urb->bsd_data_ptr, max_bulk);
+ usbd_xfer_set_frame_len(xfer, data_frame, max_bulk);
}
- xfer->frlengths[data_frame] = max_bulk;
if (xfer->flags_int.control_xfr) {
if (max_bulk > 0) {
xfer->nframes = 2;
diff --git a/sys/dev/usb/usb_compat_linux.h b/sys/dev/usb/usb_compat_linux.h
index 5ce8196f78b7..38545d8be175 100644
--- a/sys/dev/usb/usb_compat_linux.h
+++ b/sys/dev/usb/usb_compat_linux.h
@@ -39,46 +39,6 @@ typedef void (usb_complete_t)(struct urb *);
#define USB_MAX_FULL_SPEED_ISOC_FRAMES (60 * 1)
#define USB_MAX_HIGH_SPEED_ISOC_FRAMES (60 * 8)
-/*
- * Linux compatible USB device drivers put their device information
- * into the "usb_device_id" structure using the "USB_DEVICE()" macro.
- * The "MODULE_DEVICE_TABLE()" macro can be used to export this
- * information to userland.
- */
-struct usb_device_id {
- /* which fields to match against */
- uint16_t match_flags;
-#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
-#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
-#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
-#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
-#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
-#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
-#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
-#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
-#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
-#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
-
- /* Used for product specific matches; the BCD range is inclusive */
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice_lo;
- uint16_t bcdDevice_hi;
-
- /* Used for device class matches */
- uint8_t bDeviceClass;
- uint8_t bDeviceSubClass;
- uint8_t bDeviceProtocol;
-
- /* Used for interface class matches */
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
-
- /* Hook for driver specific information */
- unsigned long driver_info;
-};
-
#define USB_DEVICE_ID_MATCH_DEVICE \
(USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
diff --git a/sys/dev/usb/usb_controller.h b/sys/dev/usb/usb_controller.h
index 623c0f557707..952cd19d7247 100644
--- a/sys/dev/usb/usb_controller.h
+++ b/sys/dev/usb/usb_controller.h
@@ -109,11 +109,11 @@ struct usb_pipe_methods {
/* Mandatory USB Device and Host mode callbacks: */
- usb_callback_t *open;
- usb_callback_t *close;
+ void (*open)(struct usb_xfer *);
+ void (*close)(struct usb_xfer *);
- usb_callback_t *enter;
- usb_callback_t *start;
+ void (*enter)(struct usb_xfer *);
+ void (*start)(struct usb_xfer *);
/* Optional */
diff --git a/sys/dev/usb/usb_core.c b/sys/dev/usb/usb_core.c
index a4191adabd43..b273a3c932ef 100644
--- a/sys/dev/usb/usb_core.c
+++ b/sys/dev/usb/usb_core.c
@@ -30,8 +30,28 @@
* http://www.usb.org/developers/devclass_docs/
*/
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_mbuf.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
MALLOC_DEFINE(M_USB, "USB", "USB");
MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
diff --git a/sys/dev/usb/usb_core.h b/sys/dev/usb/usb_core.h
index ad302bce5f95..84c163b381c0 100644
--- a/sys/dev/usb/usb_core.h
+++ b/sys/dev/usb/usb_core.h
@@ -31,193 +31,6 @@
#ifndef _USB_CORE_H_
#define _USB_CORE_H_
-#define USB_STACK_VERSION 2000 /* 2.0 */
-
-/* Allow defines in "opt_usb.h" to override configuration */
-
-#include "opt_usb.h"
-#include "opt_bus.h"
-
-/* Default USB configuration */
-
-/*
- * The following macro defines if the code shall support
- * /dev/usb/x.y.z.
- */
-#ifndef USB_HAVE_UGEN
-#define USB_HAVE_UGEN 1
-#endif
-
-/*
- * The following macro defines if the code shall support BUS-DMA.
- */
-#ifndef USB_HAVE_BUSDMA
-#define USB_HAVE_BUSDMA 1
-#endif
-
-/*
- * The following macro defines if the code shall support the Linux
- * compatibility layer.
- */
-#ifndef USB_HAVE_COMPAT_LINUX
-#define USB_HAVE_COMPAT_LINUX 1
-#endif
-
-/*
- * The following macro defines if the code shall support
- * userland data transfer via copyin() and copyout()
- */
-#ifndef USB_HAVE_USER_IO
-#define USB_HAVE_USER_IO 1
-#endif
-
-/*
- * The following macro defines if the code shall support copy in via
- * bsd-mbufs to USB.
- */
-#ifndef USB_HAVE_MBUF
-#define USB_HAVE_MBUF 1
-#endif
-
-/*
- * The following macro defines if the code shall compile a table
- * describing USB vendor and product IDs.
- */
-#ifndef USB_VERBOSE
-#define USB_VERBOSE 1
-#endif
-
-/*
- * The following macro defines if USB debugging support shall be
- * compiled for the USB core and all drivers.
- */
-#ifndef USB_DEBUG
-#define USB_DEBUG 1
-#endif
-
-/*
- * The following macro defines if USB transaction translator support
- * shall be supported for the USB HUB and USB controller drivers.
- */
-#ifndef USB_HAVE_TT_SUPPORT
-#define USB_HAVE_TT_SUPPORT 1
-#endif
-
-/*
- * The following macro defines if the USB power daemon shall
- * be supported in the USB core.
- */
-#ifndef USB_HAVE_POWERD
-#define USB_HAVE_POWERD 1
-#endif
-
-/*
- * The following macro defines if the USB autoinstall detection shall
- * be supported in the USB core.
- */
-#ifndef USB_HAVE_MSCTEST
-#define USB_HAVE_MSCTEST 1
-#endif
-
-#ifndef USB_TD_GET_PROC
-#define USB_TD_GET_PROC(td) (td)->td_proc
-#endif
-
-#ifndef USB_PROC_GET_GID
-#define USB_PROC_GET_GID(td) (td)->p_pgid
-#endif
-
-/* Include files */
-
-#include <sys/stdint.h>
-#include <sys/stddef.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/linker_set.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/condvar.h>
-#include <sys/sysctl.h>
-#include <sys/sx.h>
-#include <sys/unistd.h>
-#include <sys/callout.h>
-#include <sys/malloc.h>
-#include <sys/priv.h>
-
-#include <dev/usb/usb_defs.h>
-#include <dev/usb/usb_revision.h>
-
-#include "usb_if.h"
-
-#ifndef USB_HOST_ALIGN
-#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
-#endif
-
-#ifndef USB_FS_ISOC_UFRAME_MAX
-#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
-#endif
-
-#if (USB_FS_ISOC_UFRAME_MAX > 6)
-#error "USB_FS_ISOC_UFRAME_MAX cannot be set higher than 6"
-#endif
-
-#ifndef USB_BUS_MAX
-#define USB_BUS_MAX 256 /* units */
-#endif
-
-#ifndef USB_MAX_DEVICES
-#define USB_MAX_DEVICES 128 /* units */
-#endif
-
-#if (USB_MAX_DEVICES < USB_MIN_DEVICES)
-#error "Minimum number of devices is greater than maximum number of devices."
-#endif
-
-#ifndef USB_IFACE_MAX
-#define USB_IFACE_MAX 32 /* units */
-#endif
-
-#ifndef USB_FIFO_MAX
-#define USB_FIFO_MAX 128 /* units */
-#endif
-
-#if (USB_FIFO_MAX & 1)
-#error "Number of FIFOs must be odd."
-#endif
-
-#define USB_MAX_FS_ISOC_FRAMES_PER_XFER (120) /* units */
-#define USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120) /* units */
-
-#ifndef USB_HUB_MAX_DEPTH
-#define USB_HUB_MAX_DEPTH 5
-#endif
-
-#ifndef USB_EP0_BUFSIZE
-#define USB_EP0_BUFSIZE 1024 /* bytes */
-#endif
-
-/* USB transfer states */
-
-#define USB_ST_SETUP 0
-#define USB_ST_TRANSFERRED 1
-#define USB_ST_ERROR 2
-
-/* USB handle request states */
-#define USB_HR_NOT_COMPLETE 0
-#define USB_HR_COMPLETE_OK 1
-#define USB_HR_COMPLETE_ERR 2
-
-/*
- * The following macro will return the current state of an USB
- * transfer like defined by the "USB_ST_XXX" enums.
- */
-#define USB_GET_STATE(xfer) ((xfer)->usb_state)
-
/*
* The following macro will tell if an USB transfer is currently
* receiving or transferring data.
@@ -226,30 +39,26 @@
USB_MODE_DEVICE ? (((xfer)->endpointno & UE_DIR_IN) ? 0 : 1) : \
(((xfer)->endpointno & UE_DIR_IN) ? 1 : 0))
-/*
- * The following macros are used used to convert milliseconds into
- * HZ. We use 1024 instead of 1000 milliseconds per second to save a
- * full division.
- */
-#define USB_MS_HZ 1024
-
-#define USB_MS_TO_TICKS(ms) \
- (((uint32_t)((((uint32_t)(ms)) * ((uint32_t)(hz))) + USB_MS_HZ - 1)) / USB_MS_HZ)
-
/* macros */
-#define usb_callout_init_mtx(c,m,f) callout_init_mtx(&(c)->co,m,f)
-#define usb_callout_reset(c,t,f,d) callout_reset(&(c)->co,t,f,d)
-#define usb_callout_stop(c) callout_stop(&(c)->co)
-#define usb_callout_drain(c) callout_drain(&(c)->co)
-#define usb_callout_pending(c) callout_pending(&(c)->co)
-
#define USB_BUS_LOCK(_b) mtx_lock(&(_b)->bus_mtx)
#define USB_BUS_UNLOCK(_b) mtx_unlock(&(_b)->bus_mtx)
#define USB_BUS_LOCK_ASSERT(_b, _t) mtx_assert(&(_b)->bus_mtx, _t)
#define USB_XFER_LOCK(_x) mtx_lock((_x)->xroot->xfer_mtx)
#define USB_XFER_UNLOCK(_x) mtx_unlock((_x)->xroot->xfer_mtx)
#define USB_XFER_LOCK_ASSERT(_x, _t) mtx_assert((_x)->xroot->xfer_mtx, _t)
+
+/* helper for converting pointers to integers */
+#define USB_P2U(ptr) \
+ (((const uint8_t *)(ptr)) - ((const uint8_t *)0))
+
+/* helper for computing offsets */
+#define USB_ADD_BYTES(ptr,size) \
+ ((void *)(USB_P2U(ptr) + (size)))
+
+/* debug macro */
+#define USB_ASSERT KASSERT
+
/* structure prototypes */
struct file;
@@ -263,82 +72,9 @@ struct usb_xfer_root;
/* typedefs */
-typedef void (usb_callback_t)(struct usb_xfer *);
-
-#ifndef USB_HAVE_USB_ERROR_T
-typedef uint8_t usb_error_t; /* see "USB_ERR_XXX" */
-#endif
-
-#ifndef USB_HAVE_TIMEOUT_T
-typedef uint32_t usb_timeout_t; /* milliseconds */
-#endif
-
-#ifndef USB_HAVE_FRLENGTH_T
-typedef uint32_t usb_frlength_t; /* bytes */
-#endif
-
-#ifndef USB_HAVE_FRCOUNT_T
-typedef uint32_t usb_frcount_t; /* units */
-#endif
-
-#ifndef USB_HAVE_SIZE_T
-typedef uint32_t usb_size_t; /* bytes */
-#endif
-
-#ifndef USB_HAVE_TICKS_T
-typedef uint32_t usb_ticks_t; /* system defined */
-#endif
-
-#ifndef USB_HAVE_POWER_MASK_T
-typedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */
-#endif
-
-typedef usb_error_t (usb_handle_req_t)(struct usb_device *,
- struct usb_device_request *, const void **, uint16_t *);
-
/* structures */
/*
- * Common queue structure for USB transfers.
- */
-struct usb_xfer_queue {
- TAILQ_HEAD(, usb_xfer) head;
- struct usb_xfer *curr; /* current USB transfer processed */
- void (*command) (struct usb_xfer_queue *pq);
- uint8_t recurse_1:1;
- uint8_t recurse_2:1;
-};
-
-/*
- * The following is a wrapper for the callout structure to ease
- * porting the code to other platforms.
- */
-struct usb_callout {
- struct callout co;
-};
-
-/*
- * The following structure defines a set of USB transfer flags.
- */
-struct usb_xfer_flags {
- uint8_t force_short_xfer:1; /* force a short transmit transfer
- * last */
- uint8_t short_xfer_ok:1; /* allow short receive transfers */
- uint8_t short_frames_ok:1; /* allow short frames */
- uint8_t pipe_bof:1; /* block pipe on failure */
- uint8_t proxy_buffer:1; /* makes buffer size a factor of
- * "max_frame_size" */
- uint8_t ext_buffer:1; /* uses external DMA buffer */
- uint8_t manual_status:1; /* non automatic status stage on
- * control transfers */
- uint8_t no_pipe_ok:1; /* set if "USB_ERR_NO_PIPE" error can
- * be ignored */
- uint8_t stall_pipe:1; /* set if the endpoint belonging to
- * this USB transfer should be stalled
- * before starting this transfer! */
-};
-
-/*
* The following structure defines a set of internal USB transfer
* flags.
*/
@@ -379,26 +115,6 @@ struct usb_xfer_flags_int {
};
/*
- * The following structure define an USB configuration, that basically
- * is used when setting up an USB transfer.
- */
-struct usb_config {
- usb_callback_t *callback; /* USB transfer callback */
- usb_frlength_t bufsize; /* total pipe buffer size in bytes */
- usb_frcount_t frames; /* maximum number of USB frames */
- usb_timeout_t interval; /* interval in milliseconds */
-#define USB_DEFAULT_INTERVAL 0
- usb_timeout_t timeout; /* transfer timeout in milliseconds */
- struct usb_xfer_flags flags; /* transfer flags */
- enum usb_hc_mode usb_mode; /* host or device mode */
- uint8_t type; /* pipe type */
- uint8_t endpoint; /* pipe number */
- uint8_t direction; /* pipe direction */
- uint8_t ep_index; /* pipe index match to use */
- uint8_t if_index; /* "ifaces" index to use */
-};
-
-/*
* The following structure defines an USB transfer.
*/
struct usb_xfer {
@@ -428,8 +144,6 @@ struct usb_xfer {
usb_frlength_t sumlen; /* sum of all lengths in bytes */
usb_frlength_t actlen; /* actual length in bytes */
usb_timeout_t timeout; /* milliseconds */
-#define USB_NO_TIMEOUT 0
-#define USB_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */
usb_frcount_t max_frame_count; /* initial value of "nframes" after
* setup */
@@ -457,89 +171,14 @@ struct usb_xfer {
struct usb_xfer_flags_int flags_int;
};
-/*
- * The following structure keeps information that is used to match
- * against an array of "usb_device_id" elements.
- */
-struct usbd_lookup_info {
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice;
- uint8_t bDeviceClass;
- uint8_t bDeviceSubClass;
- uint8_t bDeviceProtocol;
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
- uint8_t bIfaceIndex;
- uint8_t bIfaceNum;
- uint8_t bConfigIndex;
- uint8_t bConfigNum;
-};
-
-/* Structure used by probe and attach */
-
-struct usb_attach_arg {
- struct usbd_lookup_info info;
- device_t temp_dev; /* for internal use */
- unsigned long driver_info; /* for internal use */
- void *driver_ivar;
- struct usb_device *device; /* current device */
- struct usb_interface *iface; /* current interface */
- enum usb_hc_mode usb_mode; /* host or device mode */
- uint8_t port;
- uint8_t use_generic; /* hint for generic drivers */
-};
-
/* external variables */
-MALLOC_DECLARE(M_USB);
-MALLOC_DECLARE(M_USBDEV);
-MALLOC_DECLARE(M_USBHC);
-
extern struct mtx usb_ref_lock;
-/* prototypes */
+/* typedefs */
-const char *usbd_errstr(usb_error_t error);
-const char *usb_statestr(enum usb_dev_state state);
-struct usb_config_descriptor *usbd_get_config_descriptor(
- struct usb_device *udev);
-struct usb_device_descriptor *usbd_get_device_descriptor(
- struct usb_device *udev);
-struct usb_interface *usbd_get_iface(struct usb_device *udev,
- uint8_t iface_index);
-struct usb_interface_descriptor *usbd_get_interface_descriptor(
- struct usb_interface *iface);
-uint8_t usbd_clear_stall_callback(struct usb_xfer *xfer1,
- struct usb_xfer *xfer2);
-uint8_t usbd_get_interface_altindex(struct usb_interface *iface);
-usb_error_t usbd_set_alt_interface_index(struct usb_device *udev,
- uint8_t iface_index, uint8_t alt_index);
-enum usb_hc_mode usbd_get_mode(struct usb_device *udev);
-enum usb_dev_speed usbd_get_speed(struct usb_device *udev);
-uint32_t usbd_get_isoc_fps(struct usb_device *udev);
-usb_error_t usbd_transfer_setup(struct usb_device *udev,
- const uint8_t *ifaces, struct usb_xfer **pxfer,
- const struct usb_config *setup_start, uint16_t n_setup,
- void *priv_sc, struct mtx *priv_mtx);
-void usbd_set_frame_data(struct usb_xfer *xfer, void *ptr,
- usb_frcount_t frindex);
-void usbd_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset,
- usb_frcount_t frindex);
-void usbd_transfer_submit(struct usb_xfer *xfer);
-void usbd_transfer_clear_stall(struct usb_xfer *xfer);
-void usbd_transfer_drain(struct usb_xfer *xfer);
-void usbd_transfer_set_stall(struct usb_xfer *xfer);
-uint8_t usbd_transfer_pending(struct usb_xfer *xfer);
-void usbd_transfer_start(struct usb_xfer *xfer);
-void usbd_transfer_stop(struct usb_xfer *xfer);
-void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup);
-void usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index,
- uint8_t parent_index);
-uint8_t usbd_get_bus_index(struct usb_device *udev);
-uint8_t usbd_get_device_index(struct usb_device *udev);
-void usbd_set_power_mode(struct usb_device *udev, uint8_t power_mode);
-uint8_t usbd_device_attached(struct usb_device *udev);
+typedef struct malloc_type *usb_malloc_type;
+
+/* prototypes */
#endif /* _USB_CORE_H_ */
diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c
index d8be33a30733..7f1e4e921a06 100644
--- a/sys/dev/usb/usb_debug.c
+++ b/sys/dev/usb/usb_debug.c
@@ -24,7 +24,28 @@
* SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
@@ -33,6 +54,9 @@
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_transfer.h>
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
/*
* Define this unconditionally in case a kernel module is loaded that
* has been compiled with debugging options.
diff --git a/sys/dev/usb/usb_debug.h b/sys/dev/usb/usb_debug.h
index f49f24f49637..dfe2edf55dfa 100644
--- a/sys/dev/usb/usb_debug.h
+++ b/sys/dev/usb/usb_debug.h
@@ -29,9 +29,6 @@
#ifndef _USB_DEBUG_H_
#define _USB_DEBUG_H_
-/* Declare parent SYSCTL USB node. */
-SYSCTL_DECL(_hw_usb);
-
/* Declare global USB debug variable. */
extern int usb_debug;
diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c
index 39c395171926..de2e15699f60 100644
--- a/sys/dev/usb/usb_dev.c
+++ b/sys/dev/usb/usb_dev.c
@@ -27,16 +27,39 @@
* usb_dev.c - An abstraction layer for creating devices under /dev/...
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/vnode.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
#include <dev/usb/usb_ioctl.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR usb_fifo_debug
#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_mbuf.h>
#include <dev/usb/usb_dev.h>
+#include <dev/usb/usb_mbuf.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_debug.h>
@@ -56,7 +79,7 @@
#if USB_HAVE_UGEN
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int usb_fifo_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, dev, CTLFLAG_RW, 0, "USB device");
@@ -2196,4 +2219,10 @@ usb_fifo_set_close_zlp(struct usb_fifo *f, uint8_t onoff)
/* send a Zero Length Packet, ZLP, before close */
f->flag_short = onoff;
}
+
+void *
+usb_fifo_softc(struct usb_fifo *f)
+{
+ return (f->priv_sc0);
+}
#endif /* USB_HAVE_UGEN */
diff --git a/sys/dev/usb/usb_dev.h b/sys/dev/usb/usb_dev.h
index 71ee064f0545..040916b5df35 100644
--- a/sys/dev/usb/usb_dev.h
+++ b/sys/dev/usb/usb_dev.h
@@ -28,25 +28,14 @@
#define _USB_DEV_H_
#include <sys/file.h>
-#include <sys/vnode.h>
+#include <sys/selinfo.h>
#include <sys/poll.h>
#include <sys/signalvar.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
#include <sys/proc.h>
-#define USB_FIFO_TX 0
-#define USB_FIFO_RX 1
-
struct usb_fifo;
struct usb_mbuf;
-typedef int (usb_fifo_open_t)(struct usb_fifo *fifo, int fflags);
-typedef void (usb_fifo_close_t)(struct usb_fifo *fifo, int fflags);
-typedef int (usb_fifo_ioctl_t)(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags);
-typedef void (usb_fifo_cmd_t)(struct usb_fifo *fifo);
-typedef void (usb_fifo_filter_t)(struct usb_fifo *fifo, struct usb_mbuf *m);
-
struct usb_symlink {
TAILQ_ENTRY(usb_symlink) sym_entry;
char src_path[32]; /* Source path - including terminating
@@ -58,30 +47,6 @@ struct usb_symlink {
};
/*
- * Locking note for the following functions. All the
- * "usb_fifo_cmd_t" and "usb_fifo_filter_t" functions are called
- * locked. The others are called unlocked.
- */
-struct usb_fifo_methods {
- usb_fifo_open_t *f_open;
- usb_fifo_close_t *f_close;
- usb_fifo_ioctl_t *f_ioctl;
- /*
- * NOTE: The post-ioctl callback is called after the USB reference
- * gets locked in the IOCTL handler:
- */
- usb_fifo_ioctl_t *f_ioctl_post;
- usb_fifo_cmd_t *f_start_read;
- usb_fifo_cmd_t *f_stop_read;
- usb_fifo_cmd_t *f_start_write;
- usb_fifo_cmd_t *f_stop_write;
- usb_fifo_filter_t *f_filter_read;
- usb_fifo_filter_t *f_filter_write;
- const char *basename[4];
- const char *postfix[4];
-};
-
-/*
* Private per-device information.
*/
struct usb_cdev_privdata {
@@ -96,6 +61,18 @@ struct usb_cdev_privdata {
};
/*
+ * The following structure defines a minimum re-implementation of the
+ * ifqueue structure in the kernel.
+ */
+struct usb_ifqueue {
+ struct usb_mbuf *ifq_head;
+ struct usb_mbuf *ifq_tail;
+
+ usb_size_t ifq_len;
+ usb_size_t ifq_maxlen;
+};
+
+/*
* Private per-device and per-thread reference information
*/
struct usb_cdev_refdata {
@@ -162,42 +139,12 @@ struct usb_fifo {
#define USB_FIFO_REF_MAX 0xFF
};
-struct usb_fifo_sc {
- struct usb_fifo *fp[2];
- struct cdev* dev;
-};
-
extern struct cdevsw usb_devsw;
int usb_fifo_wait(struct usb_fifo *fifo);
void usb_fifo_signal(struct usb_fifo *fifo);
-int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize,
- uint16_t nbuf);
-void usb_fifo_free_buffer(struct usb_fifo *f);
-int usb_fifo_attach(struct usb_device *udev, void *priv_sc,
- struct mtx *priv_mtx, struct usb_fifo_methods *pm,
- struct usb_fifo_sc *f_sc, uint16_t unit, uint16_t subunit,
- uint8_t iface_index, uid_t uid, gid_t gid, int mode);
-void usb_fifo_detach(struct usb_fifo_sc *f_sc);
-uint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo);
-void usb_fifo_put_data(struct usb_fifo *fifo, struct usb_page_cache *pc,
- usb_frlength_t offset, usb_frlength_t len, uint8_t what);
-void usb_fifo_put_data_linear(struct usb_fifo *fifo, void *ptr,
- usb_size_t len, uint8_t what);
-uint8_t usb_fifo_put_data_buffer(struct usb_fifo *f, void *ptr, usb_size_t len);
-void usb_fifo_put_data_error(struct usb_fifo *fifo);
-uint8_t usb_fifo_get_data(struct usb_fifo *fifo, struct usb_page_cache *pc,
- usb_frlength_t offset, usb_frlength_t len, usb_frlength_t *actlen,
- uint8_t what);
-uint8_t usb_fifo_get_data_linear(struct usb_fifo *fifo, void *ptr,
- usb_size_t len, usb_size_t *actlen, uint8_t what);
-uint8_t usb_fifo_get_data_buffer(struct usb_fifo *f, void **pptr,
- usb_size_t *plen);
-void usb_fifo_get_data_error(struct usb_fifo *fifo);
uint8_t usb_fifo_opened(struct usb_fifo *fifo);
void usb_fifo_free(struct usb_fifo *f);
-void usb_fifo_reset(struct usb_fifo *f);
-void usb_fifo_wakeup(struct usb_fifo *f);
struct usb_symlink *usb_alloc_symlink(const char *target);
void usb_free_symlink(struct usb_symlink *ps);
int usb_read_symlink(uint8_t *user_ptr, uint32_t startentry,
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index d919d3a6e35d..8439c698edf7 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -24,9 +24,31 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_ioctl.h>
#include "usbdevs.h"
@@ -38,12 +60,10 @@
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_parse.h>
#include <dev/usb/usb_request.h>
#include <dev/usb/usb_dynamic.h>
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_mbuf.h>
#include <dev/usb/usb_msctest.h>
#if USB_HAVE_UGEN
#include <dev/usb/usb_dev.h>
@@ -277,7 +297,7 @@ found:
}
/*------------------------------------------------------------------------*
- * usb_interface_count
+ * usbd_interface_count
*
* This function stores the number of USB interfaces excluding
* alternate settings, which the USB config descriptor reports into
@@ -288,7 +308,7 @@ found:
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb_interface_count(struct usb_device *udev, uint8_t *count)
+usbd_interface_count(struct usb_device *udev, uint8_t *count)
{
if (udev->cdesc == NULL) {
*count = 0;
@@ -2105,7 +2125,7 @@ usb_devinfo(struct usb_device *udev, char *dst_ptr, uint16_t dst_len)
}
}
-#if USB_VERBOSE
+#ifdef USB_VERBOSE
/*
* Descriptions of of known vendors and devices ("products").
*/
@@ -2127,7 +2147,7 @@ static void
usbd_set_device_strings(struct usb_device *udev)
{
struct usb_device_descriptor *udd = &udev->ddesc;
-#if USB_VERBOSE
+#ifdef USB_VERBOSE
const struct usb_knowndev *kdp;
#endif
char temp[64];
@@ -2159,7 +2179,7 @@ usbd_set_device_strings(struct usb_device *udev)
if (temp[0] != '\0')
udev->product = strdup(temp, M_USB);
-#if USB_VERBOSE
+#ifdef USB_VERBOSE
if (udev->manufacturer == NULL || udev->product == NULL) {
for (kdp = usb_knowndevs; kdp->vendorname != NULL; kdp++) {
if (kdp->vendor == vendor_id &&
diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h
index 9a3bc2325304..d601c146a210 100644
--- a/sys/dev/usb/usb_device.h
+++ b/sys/dev/usb/usb_device.h
@@ -77,44 +77,6 @@ struct usb_host_interface {
} __aligned(USB_HOST_ALIGN);
/*
- * The following structure defines an USB endpoint
- * USB endpoint.
- */
-struct usb_endpoint {
- struct usb_xfer_queue endpoint_q; /* queue of USB transfers */
-
- struct usb_endpoint_descriptor *edesc;
- struct usb_pipe_methods *methods; /* set by HC driver */
-
- uint16_t isoc_next;
- uint16_t refcount;
-
- uint8_t toggle_next:1; /* next data toggle value */
- uint8_t is_stalled:1; /* set if endpoint is stalled */
- uint8_t is_synced:1; /* set if we a synchronised */
- uint8_t unused:5;
- uint8_t iface_index; /* not used by "default endpoint" */
-};
-
-/*
- * The following structure defines an USB interface.
- */
-struct usb_interface {
- struct usb_interface_descriptor *idesc;
- device_t subdev;
- uint8_t alt_index;
- uint8_t parent_iface_index;
-
- /* Linux compat */
- struct usb_host_interface *altsetting;
- struct usb_host_interface *cur_altsetting;
- struct usb_device *linux_udev;
- void *bsd_priv_sc; /* device specific information */
- uint8_t num_altsetting; /* number of alternate settings */
- uint8_t bsd_iface_index;
-};
-
-/*
* The following structure defines the USB device flags.
*/
struct usb_device_flags {
@@ -228,14 +190,11 @@ extern int usb_template;
/* function prototypes */
+const char *usb_statestr(enum usb_dev_state state);
struct usb_device *usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
struct usb_device *parent_hub, uint8_t depth,
uint8_t port_index, uint8_t port_no,
enum usb_dev_speed speed, enum usb_hc_mode mode);
-struct usb_endpoint *usbd_get_endpoint(struct usb_device *udev, uint8_t iface_index,
- const struct usb_config *setup);
-struct usb_endpoint *usbd_get_ep_by_addr(struct usb_device *udev, uint8_t ea_val);
-usb_error_t usb_interface_count(struct usb_device *udev, uint8_t *count);
usb_error_t usb_probe_and_attach(struct usb_device *udev,
uint8_t iface_index);
usb_error_t usb_reset_iface_endpoints(struct usb_device *udev,
@@ -247,9 +206,6 @@ usb_error_t usb_suspend_resume(struct usb_device *udev,
uint8_t do_suspend);
void usb_devinfo(struct usb_device *udev, char *dst_ptr, uint16_t dst_len);
void usb_free_device(struct usb_device *, uint8_t);
-void *usbd_find_descriptor(struct usb_device *udev, void *id,
- uint8_t iface_index, uint8_t type, uint8_t type_mask,
- uint8_t subtype, uint8_t subtype_mask);
void usb_linux_free_device(struct usb_device *dev);
uint8_t usb_peer_can_wakeup(struct usb_device *udev);
struct usb_endpoint *usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep);
diff --git a/sys/dev/usb/usb_dynamic.c b/sys/dev/usb/usb_dynamic.c
index eabb9dfae388..b64712fc3406 100644
--- a/sys/dev/usb/usb_dynamic.c
+++ b/sys/dev/usb/usb_dynamic.c
@@ -24,9 +24,28 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_process.h>
@@ -86,7 +105,7 @@ usb_temp_unsetup_w(struct usb_device *udev)
}
}
-static uint8_t
+static usb_error_t
usb_test_huawei_autoinst_w(struct usb_device *udev,
struct usb_attach_arg *uaa)
{
diff --git a/sys/dev/usb/usb_dynamic.h b/sys/dev/usb/usb_dynamic.h
index 14dde20fa552..f8b7caf69f3c 100644
--- a/sys/dev/usb/usb_dynamic.h
+++ b/sys/dev/usb/usb_dynamic.h
@@ -62,6 +62,4 @@ void usb_temp_unload(void *);
void usb_quirk_unload(void *);
void usb_bus_unload(void *);
-uint8_t usb_test_quirk(const struct usb_attach_arg *uaa, uint16_t quirk);
-
#endif /* _USB_DYNAMIC_H_ */
diff --git a/sys/dev/usb/usb_error.c b/sys/dev/usb/usb_error.c
index 68a811f407e5..a6393154d918 100644
--- a/sys/dev/usb/usb_error.c
+++ b/sys/dev/usb/usb_error.c
@@ -24,10 +24,28 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
-#include <dev/usb/usb_core.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
static const char* usb_errstr_table[USB_ERR_MAX] = {
[USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION",
diff --git a/sys/dev/usb/usb_error.h b/sys/dev/usb/usb_error.h
deleted file mode 100644
index 48d217a0e307..000000000000
--- a/sys/dev/usb/usb_error.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_ERROR_H_
-#define _USB_ERROR_H_
-
-enum { /* keep in sync with usb_errstr_table */
- USB_ERR_NORMAL_COMPLETION = 0,
- USB_ERR_PENDING_REQUESTS, /* 1 */
- USB_ERR_NOT_STARTED, /* 2 */
- USB_ERR_INVAL, /* 3 */
- USB_ERR_NOMEM, /* 4 */
- USB_ERR_CANCELLED, /* 5 */
- USB_ERR_BAD_ADDRESS, /* 6 */
- USB_ERR_BAD_BUFSIZE, /* 7 */
- USB_ERR_BAD_FLAG, /* 8 */
- USB_ERR_NO_CALLBACK, /* 9 */
- USB_ERR_IN_USE, /* 10 */
- USB_ERR_NO_ADDR, /* 11 */
- USB_ERR_NO_PIPE, /* 12 */
- USB_ERR_ZERO_NFRAMES, /* 13 */
- USB_ERR_ZERO_MAXP, /* 14 */
- USB_ERR_SET_ADDR_FAILED, /* 15 */
- USB_ERR_NO_POWER, /* 16 */
- USB_ERR_TOO_DEEP, /* 17 */
- USB_ERR_IOERROR, /* 18 */
- USB_ERR_NOT_CONFIGURED, /* 19 */
- USB_ERR_TIMEOUT, /* 20 */
- USB_ERR_SHORT_XFER, /* 21 */
- USB_ERR_STALLED, /* 22 */
- USB_ERR_INTERRUPTED, /* 23 */
- USB_ERR_DMA_LOAD_FAILED, /* 24 */
- USB_ERR_BAD_CONTEXT, /* 25 */
- USB_ERR_NO_ROOT_HUB, /* 26 */
- USB_ERR_NO_INTR_THREAD, /* 27 */
- USB_ERR_NOT_LOCKED, /* 28 */
- USB_ERR_MAX
-};
-
-#endif /* _USB_ERROR_H_ */
diff --git a/sys/dev/usb/usb_defs.h b/sys/dev/usb/usb_freebsd.h
index a303ca95940c..1f34317d667d 100644
--- a/sys/dev/usb/usb_defs.h
+++ b/sys/dev/usb/usb_freebsd.h
@@ -24,38 +24,48 @@
* SUCH DAMAGE.
*/
-#ifndef _USB_DEFS_H_
-#define _USB_DEFS_H_
-
-/* Definition of some hardcoded USB constants. */
-
-#define USB_MAX_IPACKET 8 /* initial USB packet size */
-
-#define USB_EP_MAX (2*16) /* hardcoded */
-
-#define USB_ROOT_HUB_ADDR 1 /* index */
+/*
+ * Including this file is mandatory for all USB related c-files in the kernel.
+ */
-#define USB_MIN_DEVICES 2 /* unused + root HUB */
+#ifndef _USB_FREEBSD_H_
+#define _USB_FREEBSD_H_
-#define USB_UNCONFIG_INDEX 0xFF /* internal use only */
-#define USB_IFACE_INDEX_ANY 0xFF /* internal use only */
+/* Default USB configuration */
+#define USB_HAVE_UGEN 1
+#define USB_HAVE_BUSDMA 1
+#define USB_HAVE_COMPAT_LINUX 1
+#define USB_HAVE_USER_IO 1
+#define USB_HAVE_MBUF 1
+#define USB_HAVE_TT_SUPPORT 1
+#define USB_HAVE_POWERD 1
+#define USB_HAVE_MSCTEST 1
-#define USB_START_ADDR 0 /* default USB device BUS address
- * after USB bus reset */
+#define USB_TD_GET_PROC(td) (td)->td_proc
+#define USB_PROC_GET_GID(td) (td)->p_pgid
-#define USB_CONTROL_ENDPOINT 0 /* default control endpoint */
+#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
+#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
+#define USB_BUS_MAX 256 /* units */
+#define USB_MAX_DEVICES 128 /* units */
+#define USB_IFACE_MAX 32 /* units */
+#define USB_FIFO_MAX 128 /* units */
-#define USB_FRAMES_PER_SECOND_FS 1000 /* full speed */
-#define USB_FRAMES_PER_SECOND_HS 8000 /* high speed */
+#define USB_MAX_FS_ISOC_FRAMES_PER_XFER (120) /* units */
+#define USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120) /* units */
-#define USB_FS_BYTES_PER_HS_UFRAME 188 /* bytes */
-#define USB_HS_MICRO_FRAMES_MAX 8 /* units */
+#define USB_HUB_MAX_DEPTH 5
+#define USB_EP0_BUFSIZE 1024 /* bytes */
-#define USB_ISOC_TIME_MAX 128 /* ms */
+#ifndef USB_DEBUG
+#define USB_DEBUG 1
+#endif
-/* sanity checks */
+typedef uint32_t usb_timeout_t; /* milliseconds */
+typedef uint32_t usb_frlength_t; /* bytes */
+typedef uint32_t usb_frcount_t; /* units */
+typedef uint32_t usb_size_t; /* bytes */
+typedef uint32_t usb_ticks_t; /* system defined */
+typedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */
-#if (USB_ROOT_HUB_ADDR >= USB_MIN_DEVICES)
-#error "The root hub address must be less than USB_MIN_DEVICES."
-#endif
-#endif /* _USB_DEFS_H_ */
+#endif /* _USB_FREEBSD_H_ */
diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c
index 90a055193ae4..5990cd5ff943 100644
--- a/sys/dev/usb/usb_generic.c
+++ b/sys/dev/usb/usb_generic.c
@@ -24,16 +24,38 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+
#include <dev/usb/usb.h>
#include <dev/usb/usb_ioctl.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR ugen_debug
#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_mbuf.h>
#include <dev/usb/usb_dev.h>
+#include <dev/usb/usb_mbuf.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_debug.h>
@@ -102,7 +124,7 @@ struct usb_fifo_methods usb_ugen_methods = {
.f_stop_write = &ugen_stop_io,
};
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int ugen_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, ugen, CTLFLAG_RW, 0, "USB generic");
@@ -117,7 +139,7 @@ static int
ugen_transfer_setup(struct usb_fifo *f,
const struct usb_config *setup, uint8_t n_setup)
{
- struct usb_endpoint *ep = f->priv_sc0;
+ struct usb_endpoint *ep = usb_fifo_softc(f);
struct usb_device *udev = f->udev;
uint8_t iface_index = ep->iface_index;
int error;
@@ -152,7 +174,7 @@ ugen_transfer_setup(struct usb_fifo *f,
static int
ugen_open(struct usb_fifo *f, int fflags)
{
- struct usb_endpoint *ep = f->priv_sc0;
+ struct usb_endpoint *ep = usb_fifo_softc(f);
struct usb_endpoint_descriptor *ed = ep->edesc;
uint8_t type;
@@ -208,7 +230,7 @@ static int
ugen_open_pipe_write(struct usb_fifo *f)
{
struct usb_config usb_config[2];
- struct usb_endpoint *ep = f->priv_sc0;
+ struct usb_endpoint *ep = usb_fifo_softc(f);
struct usb_endpoint_descriptor *ed = ep->edesc;
mtx_assert(f->priv_mtx, MA_OWNED);
@@ -276,7 +298,7 @@ static int
ugen_open_pipe_read(struct usb_fifo *f)
{
struct usb_config usb_config[2];
- struct usb_endpoint *ep = f->priv_sc0;
+ struct usb_endpoint *ep = usb_fifo_softc(f);
struct usb_endpoint_descriptor *ed = ep->edesc;
mtx_assert(f->priv_mtx, MA_OWNED);
@@ -377,9 +399,9 @@ ugen_stop_io(struct usb_fifo *f)
}
static void
-ugen_default_read_callback(struct usb_xfer *xfer)
+ugen_default_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
struct usb_mbuf *m;
DPRINTFN(4, "actlen=%u, aframes=%u\n", xfer->actlen, xfer->aframes);
@@ -411,7 +433,7 @@ ugen_default_read_callback(struct usb_xfer *xfer)
}
USB_IF_POLL(&f->free_q, m);
if (m) {
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
}
break;
@@ -429,9 +451,9 @@ ugen_default_read_callback(struct usb_xfer *xfer)
}
static void
-ugen_default_write_callback(struct usb_xfer *xfer)
+ugen_default_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
usb_frlength_t actlen;
DPRINTFN(4, "actlen=%u, aframes=%u\n", xfer->actlen, xfer->aframes);
@@ -452,7 +474,7 @@ ugen_default_write_callback(struct usb_xfer *xfer)
*/
if (usb_fifo_get_data(f, xfer->frbuffers, 0,
xfer->max_data_length, &actlen, 0)) {
- xfer->frlengths[0] = actlen;
+ usbd_xfer_set_frame_len(xfer, 0, actlen);
usbd_transfer_submit(xfer);
}
break;
@@ -467,9 +489,9 @@ ugen_default_write_callback(struct usb_xfer *xfer)
}
static void
-ugen_read_clear_stall_callback(struct usb_xfer *xfer)
+ugen_read_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = f->xfer[0];
if (f->flag_stall == 0) {
@@ -484,9 +506,9 @@ ugen_read_clear_stall_callback(struct usb_xfer *xfer)
}
static void
-ugen_write_clear_stall_callback(struct usb_xfer *xfer)
+ugen_write_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
struct usb_xfer *xfer_other = f->xfer[0];
if (f->flag_stall == 0) {
@@ -501,9 +523,9 @@ ugen_write_clear_stall_callback(struct usb_xfer *xfer)
}
static void
-ugen_isoc_read_callback(struct usb_xfer *xfer)
+ugen_isoc_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
usb_frlength_t offset;
usb_frcount_t n;
@@ -526,7 +548,7 @@ ugen_isoc_read_callback(struct usb_xfer *xfer)
tr_setup:
for (n = 0; n != xfer->nframes; n++) {
/* setup size for next transfer */
- xfer->frlengths[n] = xfer->max_frame_size;
+ usbd_xfer_set_frame_len(xfer, n, xfer->max_frame_size);
}
usbd_transfer_submit(xfer);
break;
@@ -540,9 +562,9 @@ tr_setup:
}
static void
-ugen_isoc_write_callback(struct usb_xfer *xfer)
+ugen_isoc_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct usb_fifo *f = xfer->priv_sc;
+ struct usb_fifo *f = usbd_xfer_softc(xfer);
usb_frlength_t actlen;
usb_frlength_t offset;
usb_frcount_t n;
@@ -557,7 +579,7 @@ tr_setup:
for (n = 0; n != xfer->nframes; n++) {
if (usb_fifo_get_data(f, xfer->frbuffers, offset,
xfer->max_frame_size, &actlen, 1)) {
- xfer->frlengths[n] = actlen;
+ usbd_xfer_set_frame_len(xfer, n, actlen);
offset += actlen;
} else {
break;
@@ -566,7 +588,7 @@ tr_setup:
for (; n != xfer->nframes; n++) {
/* fill in zero frames */
- xfer->frlengths[n] = 0;
+ usbd_xfer_set_frame_len(xfer, n, 0);
}
usbd_transfer_submit(xfer);
break;
@@ -1059,7 +1081,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
return (error);
}
/* reset first frame */
- usbd_set_frame_offset(xfer, 0, 0);
+ usbd_xfer_set_frame_offset(xfer, 0, 0);
if (xfer->flags_int.control_xfr) {
@@ -1084,7 +1106,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
xfer->error = USB_ERR_INVAL;
goto complete;
}
- xfer->frlengths[0] = length;
+ usbd_xfer_set_frame_len(xfer, 0, length);
/* Host mode only ! */
if ((req->bmRequestType &
@@ -1107,7 +1129,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
offset = 0;
}
- rem = xfer->max_data_length;
+ rem = usbd_xfer_max_len(xfer);
xfer->nframes = fs_ep.nFrames;
xfer->timeout = fs_ep.timeout;
if (xfer->timeout > 65535) {
@@ -1129,7 +1151,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
xfer->flags.force_short_xfer = 0;
if (fs_ep.flags & USB_FS_FLAG_CLEAR_STALL)
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
else
xfer->flags.stall_pipe = 0;
@@ -1140,7 +1162,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
if (error) {
break;
}
- xfer->frlengths[n] = length;
+ usbd_xfer_set_frame_len(xfer, n, length);
if (length > rem) {
xfer->error = USB_ERR_INVAL;
@@ -1162,7 +1184,7 @@ ugen_fs_copy_in(struct usb_fifo *f, uint8_t ep_index)
kaddr = USB_ADD_BYTES(kaddr, offset);
} else {
/* set current frame offset */
- usbd_set_frame_offset(xfer, offset, n);
+ usbd_xfer_set_frame_offset(xfer, offset, n);
/* get kernel buffer address */
kaddr = xfer->frbuffers[n].buffer;
@@ -1252,7 +1274,7 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
/* Update lengths and copy out data */
- rem = xfer->max_data_length;
+ rem = usbd_xfer_max_len(xfer);
offset = 0;
for (; n != xfer->nframes; n++) {
@@ -1660,7 +1682,7 @@ ugen_get_endpoint_desc(struct usb_fifo *f,
{
struct usb_endpoint *ep;
- ep = f->priv_sc0;
+ ep = usb_fifo_softc(f);
if (ep && ep->edesc) {
*ed = *ep->edesc;
@@ -2162,7 +2184,7 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
}
static void
-ugen_default_fs_callback(struct usb_xfer *xfer)
+ugen_default_fs_callback(struct usb_xfer *xfer, usb_error_t error)
{
; /* workaround for a bug in "indent" */
diff --git a/sys/dev/usb/usb_handle_request.c b/sys/dev/usb/usb_handle_request.c
index e6f89f6d07c6..7f78d9258584 100644
--- a/sys/dev/usb/usb_handle_request.c
+++ b/sys/dev/usb/usb_handle_request.c
@@ -24,9 +24,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include "usb_if.h"
#define USB_DEBUG_VAR usb_debug
@@ -61,7 +81,7 @@ static usb_error_t usb_handle_iface_request(struct usb_xfer *, void **,
* transfers.
*------------------------------------------------------------------------*/
void
-usb_handle_request_callback(struct usb_xfer *xfer)
+usb_handle_request_callback(struct usb_xfer *xfer, usb_error_t error)
{
usb_error_t err;
@@ -105,11 +125,11 @@ tr_restart:
* If a control transfer is active, stall it, and wait for the
* next control transfer.
*/
- xfer->frlengths[0] = sizeof(struct usb_device_request);
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(struct usb_device_request));
xfer->nframes = 1;
xfer->flags.manual_status = 1;
xfer->flags.force_short_xfer = 0;
- xfer->flags.stall_pipe = 1; /* cancel previous transfer, if any */
+ usbd_xfer_set_stall(xfer); /* cancel previous transfer, if any */
usbd_transfer_submit(xfer);
}
@@ -458,10 +478,10 @@ usb_handle_request(struct usb_xfer *xfer)
/* reset frame stuff */
- xfer->frlengths[0] = 0;
+ usbd_xfer_set_frame_len(xfer, 0, 0);
- usbd_set_frame_offset(xfer, 0, 0);
- usbd_set_frame_offset(xfer, sizeof(req), 1);
+ usbd_xfer_set_frame_offset(xfer, 0, 0);
+ usbd_xfer_set_frame_offset(xfer, sizeof(req), 1);
/* get the current request, if any */
@@ -702,7 +722,7 @@ tr_valid:
/* Compute the real maximum data length */
if (max_len > xfer->max_data_length) {
- max_len = xfer->max_data_length;
+ max_len = usbd_xfer_max_len(xfer);
}
if (max_len > rem) {
max_len = rem;
@@ -713,7 +733,7 @@ tr_valid:
* comparison below:
*/
if (rem > xfer->max_data_length) {
- rem = xfer->max_data_length;
+ rem = usbd_xfer_max_len(xfer);
}
if (rem != max_len) {
/*
@@ -734,15 +754,15 @@ tr_valid:
src_mcopy = USB_ADD_BYTES(src_mcopy, off);
usbd_copy_in(xfer->frbuffers + 1, 0,
src_mcopy, max_len);
+ usbd_xfer_set_frame_len(xfer, 1, max_len);
} else {
- usbd_set_frame_data(xfer,
- USB_ADD_BYTES(src_zcopy, off), 1);
+ usbd_xfer_set_frame_data(xfer, 1,
+ USB_ADD_BYTES(src_zcopy, off), max_len);
}
- xfer->frlengths[1] = max_len;
} else {
/* the end is reached, send status */
xfer->flags.manual_status = 0;
- xfer->frlengths[1] = 0;
+ usbd_xfer_set_frame_len(xfer, 1, 0);
}
DPRINTF("success\n");
return (0); /* success */
diff --git a/sys/dev/usb/usb_handle_request.h b/sys/dev/usb/usb_handle_request.h
deleted file mode 100644
index 120f21050dbe..000000000000
--- a/sys/dev/usb/usb_handle_request.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_HANDLE_REQUEST_H_
-#define _USB_HANDLE_REQUEST_H_
-
-#endif /* _USB_HANDLE_REQUEST_H_ */
diff --git a/sys/dev/usb/usb_hid.c b/sys/dev/usb/usb_hid.c
index 63c625cf3a21..220ffa2bd874 100644
--- a/sys/dev/usb/usb_hid.c
+++ b/sys/dev/usb/usb_hid.c
@@ -40,20 +40,38 @@ __FBSDID("$FreeBSD$");
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#define USB_DEBUG_VAR usb_debug
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_parse.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_hid.h>
static void hid_clear_local(struct hid_item *);
static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize);
diff --git a/sys/dev/usb/usb_hid.h b/sys/dev/usb/usb_hid.h
deleted file mode 100644
index f9de2a93eb31..000000000000
--- a/sys/dev/usb/usb_hid.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
- * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_CORE_HID_H_
-#define _USB_CORE_HID_H_
-
-struct usb_hid_descriptor;
-struct usb_config_descriptor;
-
-enum hid_kind {
- hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
-};
-
-struct hid_location {
- uint32_t size;
- uint32_t count;
- uint32_t pos;
-};
-
-struct hid_item {
- /* Global */
- int32_t _usage_page;
- int32_t logical_minimum;
- int32_t logical_maximum;
- int32_t physical_minimum;
- int32_t physical_maximum;
- int32_t unit_exponent;
- int32_t unit;
- int32_t report_ID;
- /* Local */
- int32_t usage;
- int32_t usage_minimum;
- int32_t usage_maximum;
- int32_t designator_index;
- int32_t designator_minimum;
- int32_t designator_maximum;
- int32_t string_index;
- int32_t string_minimum;
- int32_t string_maximum;
- int32_t set_delimiter;
- /* Misc */
- int32_t collection;
- int collevel;
- enum hid_kind kind;
- uint32_t flags;
- /* Location */
- struct hid_location loc;
-};
-
-/* prototypes from "usb_hid.c" */
-
-struct hid_data *hid_start_parse(const void *d, usb_size_t len, int kindset);
-void hid_end_parse(struct hid_data *s);
-int hid_get_item(struct hid_data *s, struct hid_item *h);
-int hid_report_size(const void *buf, usb_size_t len, enum hid_kind k,
- uint8_t *id);
-int hid_locate(const void *desc, usb_size_t size, uint32_t usage,
- enum hid_kind kind, uint8_t index, struct hid_location *loc,
- uint32_t *flags, uint8_t *id);
-uint32_t hid_get_data(const uint8_t *buf, usb_size_t len,
- struct hid_location *loc);
-int hid_is_collection(const void *desc, usb_size_t size, uint32_t usage);
-struct usb_hid_descriptor *hid_get_descriptor_from_usb(
- struct usb_config_descriptor *cd,
- struct usb_interface_descriptor *id);
-usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx,
- void **descp, uint16_t *sizep, struct malloc_type *mem,
- uint8_t iface_index);
-
-#endif /* _USB_CORE_HID_H_ */
diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c
index 2b487524b8b8..8fbd5730f6bb 100644
--- a/sys/dev/usb/usb_hub.c
+++ b/sys/dev/usb/usb_hub.c
@@ -30,10 +30,29 @@
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usbdi.h>
#define USB_DEBUG_VAR uhub_debug
@@ -54,7 +73,7 @@
#define UHUB_INTR_INTERVAL 250 /* ms */
#define UHUB_N_TRANSFER 1
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int uhub_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB HUB");
@@ -149,9 +168,9 @@ DRIVER_MODULE(uhub, usbus, uhub_driver, uhub_devclass, 0, 0);
DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, NULL, 0);
static void
-uhub_intr_callback(struct usb_xfer *xfer)
+uhub_intr_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uhub_softc *sc = xfer->priv_sc;
+ struct uhub_softc *sc = usbd_xfer_softc(xfer);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
@@ -165,7 +184,7 @@ uhub_intr_callback(struct usb_xfer *xfer)
usb_needs_explore(sc->sc_udev->bus, 0);
case USB_ST_SETUP:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
@@ -176,8 +195,8 @@ uhub_intr_callback(struct usb_xfer *xfer)
* will get cleared before next callback by
* the USB stack.
*/
- xfer->flags.stall_pipe = 1;
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_stall(xfer);
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
}
break;
diff --git a/sys/dev/usb/usb_ioctl.h b/sys/dev/usb/usb_ioctl.h
index 7043c5517057..f9018e283ec7 100644
--- a/sys/dev/usb/usb_ioctl.h
+++ b/sys/dev/usb/usb_ioctl.h
@@ -49,9 +49,6 @@ struct usb_read_dir {
struct usb_ctl_request {
void *ucr_data;
uint16_t ucr_flags;
-#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */
-#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */
-#define USB_USER_DATA_PTR 0x0020 /* internal flag */
uint16_t ucr_actlen; /* actual length transferred */
uint8_t ucr_addr; /* zero - currently not used */
struct usb_device_request ucr_request;
@@ -148,7 +145,7 @@ struct usb_fs_endpoint {
uint16_t isoc_time_complete;
/* timeout value for no timeout */
#define USB_FS_TIMEOUT_NONE 0
- uint8_t status; /* see USB_ERR_XXX */
+ int status; /* see USB_ERR_XXX */
};
struct usb_fs_init {
diff --git a/sys/dev/usb/usb_lookup.c b/sys/dev/usb/usb_lookup.c
index 4950eaf07220..aced2d03136d 100644
--- a/sys/dev/usb/usb_lookup.c
+++ b/sys/dev/usb/usb_lookup.c
@@ -24,8 +24,28 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
/*------------------------------------------------------------------------*
* usbd_lookup_id_by_info
diff --git a/sys/dev/usb/usb_lookup.h b/sys/dev/usb/usb_lookup.h
deleted file mode 100644
index 375ca06ee191..000000000000
--- a/sys/dev/usb/usb_lookup.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_LOOKUP_H_
-#define _USB_LOOKUP_H_
-
-struct usb_attach_arg;
-
-/*
- * The following structure is used when looking up an USB driver for
- * an USB device. It is inspired by the Linux structure called
- * "usb_device_id".
- */
-struct usb_device_id {
-
- /* Hook for driver specific information */
- unsigned long driver_info;
-
- /* Used for product specific matches; the BCD range is inclusive */
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice_lo;
- uint16_t bcdDevice_hi;
-
- /* Used for device class matches */
- uint8_t bDeviceClass;
- uint8_t bDeviceSubClass;
- uint8_t bDeviceProtocol;
-
- /* Used for interface class matches */
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
-
- /* Select which fields to match against */
- uint8_t match_flag_vendor:1;
- uint8_t match_flag_product:1;
- uint8_t match_flag_dev_lo:1;
- uint8_t match_flag_dev_hi:1;
- uint8_t match_flag_dev_class:1;
- uint8_t match_flag_dev_subclass:1;
- uint8_t match_flag_dev_protocol:1;
- uint8_t match_flag_int_class:1;
- uint8_t match_flag_int_subclass:1;
- uint8_t match_flag_int_protocol:1;
-};
-
-#define USB_VENDOR(vend) \
- .match_flag_vendor = 1, .idVendor = (vend)
-
-#define USB_PRODUCT(prod) \
- .match_flag_product = 1, .idProduct = (prod)
-
-#define USB_VP(vend,prod) \
- USB_VENDOR(vend), USB_PRODUCT(prod)
-
-#define USB_VPI(vend,prod,info) \
- USB_VENDOR(vend), USB_PRODUCT(prod), USB_DRIVER_INFO(info)
-
-#define USB_DEV_BCD_GTEQ(lo) /* greater than or equal */ \
- .match_flag_dev_lo = 1, .bcdDevice_lo = (lo)
-
-#define USB_DEV_BCD_LTEQ(hi) /* less than or equal */ \
- .match_flag_dev_hi = 1, .bcdDevice_hi = (hi)
-
-#define USB_DEV_CLASS(dc) \
- .match_flag_dev_class = 1, .bDeviceClass = (dc)
-
-#define USB_DEV_SUBCLASS(dsc) \
- .match_flag_dev_subclass = 1, .bDeviceSubClass = (dsc)
-
-#define USB_DEV_PROTOCOL(dp) \
- .match_flag_dev_protocol = 1, .bDeviceProtocol = (dp)
-
-#define USB_IFACE_CLASS(ic) \
- .match_flag_int_class = 1, .bInterfaceClass = (ic)
-
-#define USB_IFACE_SUBCLASS(isc) \
- .match_flag_int_subclass = 1, .bInterfaceSubClass = (isc)
-
-#define USB_IFACE_PROTOCOL(ip) \
- .match_flag_int_protocol = 1, .bInterfaceProtocol = (ip)
-
-#define USB_IF_CSI(class,subclass,info) \
- USB_IFACE_CLASS(class), USB_IFACE_SUBCLASS(subclass), USB_DRIVER_INFO(info)
-
-#define USB_DRIVER_INFO(n) \
- .driver_info = (n)
-
-#define USB_GET_DRIVER_INFO(did) \
- (did)->driver_info
-
-const struct usb_device_id *usbd_lookup_id_by_info(
- const struct usb_device_id *id, usb_size_t sizeof_id,
- const struct usbd_lookup_info *info);
-int usbd_lookup_id_by_uaa(const struct usb_device_id *id,
- usb_size_t sizeof_id, struct usb_attach_arg *uaa);
-
-#endif /* _USB_LOOKUP_H_ */
diff --git a/sys/dev/usb/usb_mbuf.c b/sys/dev/usb/usb_mbuf.c
index f8ce15448acc..d9b14abab9a7 100644
--- a/sys/dev/usb/usb_mbuf.c
+++ b/sys/dev/usb/usb_mbuf.c
@@ -24,7 +24,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_core.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usb_dev.h>
#include <dev/usb/usb_mbuf.h>
/*------------------------------------------------------------------------*
diff --git a/sys/dev/usb/usb_mbuf.h b/sys/dev/usb/usb_mbuf.h
index e959fce9a0d7..3b331ffce68b 100644
--- a/sys/dev/usb/usb_mbuf.h
+++ b/sys/dev/usb/usb_mbuf.h
@@ -43,18 +43,6 @@ struct usb_mbuf {
uint8_t unused:7;
};
-/*
- * The following structure defines a minimum re-implementation of the
- * ifqueue structure in the kernel.
- */
-struct usb_ifqueue {
- struct usb_mbuf *ifq_head;
- struct usb_mbuf *ifq_tail;
-
- usb_size_t ifq_len;
- usb_size_t ifq_maxlen;
-};
-
#define USB_IF_ENQUEUE(ifq, m) do { \
(m)->usb_nextpkt = NULL; \
if ((ifq)->ifq_tail == NULL) \
diff --git a/sys/dev/usb/usb_mfunc.h b/sys/dev/usb/usb_mfunc.h
deleted file mode 100644
index cc9df35e9fb9..000000000000
--- a/sys/dev/usb/usb_mfunc.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* This file contains various macro functions. */
-
-#ifndef _USB_MFUNC_H_
-#define _USB_MFUNC_H_
-
-#define USB_LOG2(n) ( \
-((x) <= (1<<0x00)) ? 0x00 : \
-((x) <= (1<<0x01)) ? 0x01 : \
-((x) <= (1<<0x02)) ? 0x02 : \
-((x) <= (1<<0x03)) ? 0x03 : \
-((x) <= (1<<0x04)) ? 0x04 : \
-((x) <= (1<<0x05)) ? 0x05 : \
-((x) <= (1<<0x06)) ? 0x06 : \
-((x) <= (1<<0x07)) ? 0x07 : \
-((x) <= (1<<0x08)) ? 0x08 : \
-((x) <= (1<<0x09)) ? 0x09 : \
-((x) <= (1<<0x0A)) ? 0x0A : \
-((x) <= (1<<0x0B)) ? 0x0B : \
-((x) <= (1<<0x0C)) ? 0x0C : \
-((x) <= (1<<0x0D)) ? 0x0D : \
-((x) <= (1<<0x0E)) ? 0x0E : \
-((x) <= (1<<0x0F)) ? 0x0F : \
-((x) <= (1<<0x10)) ? 0x10 : \
-((x) <= (1<<0x11)) ? 0x11 : \
-((x) <= (1<<0x12)) ? 0x12 : \
-((x) <= (1<<0x13)) ? 0x13 : \
-((x) <= (1<<0x14)) ? 0x14 : \
-((x) <= (1<<0x15)) ? 0x15 : \
-((x) <= (1<<0x16)) ? 0x16 : \
-((x) <= (1<<0x17)) ? 0x17 : \
-((x) <= (1<<0x18)) ? 0x18 : \
-((x) <= (1<<0x19)) ? 0x19 : \
-((x) <= (1<<0x1A)) ? 0x1A : \
-((x) <= (1<<0x1B)) ? 0x1B : \
-((x) <= (1<<0x1C)) ? 0x1C : \
-((x) <= (1<<0x1D)) ? 0x1D : \
-((x) <= (1<<0x1E)) ? 0x1E : \
-0x1F)
-
-
-/* helper for converting pointers to integers */
-#define USB_P2U(ptr) \
- (((const uint8_t *)(ptr)) - ((const uint8_t *)0))
-
-/* helper for computing offsets */
-#define USB_ADD_BYTES(ptr,size) \
- ((void *)(USB_P2U(ptr) + (size)))
-
-/* debug macro */
-#define USB_ASSERT KASSERT
-
-#endif /* _USB_MFUNC_H_ */
diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c
index e813bcc31578..4af0766eb184 100644
--- a/sys/dev/usb/usb_msctest.c
+++ b/sys/dev/usb/usb_msctest.c
@@ -32,13 +32,32 @@
* mass storage quirks for not supported SCSI commands!
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR usb_debug
-#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_transfer.h>
@@ -48,10 +67,7 @@
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_request.h>
#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
#include <dev/usb/usb.h>
enum {
@@ -228,7 +244,7 @@ static void
bbb_data_clear_stall_callback(struct usb_xfer *xfer,
uint8_t next_xfer, uint8_t stall_xfer)
{
- struct bbb_transfer *sc = xfer->priv_sc;
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
if (usbd_clear_stall_callback(xfer, sc->xfer[stall_xfer])) {
switch (USB_GET_STATE(xfer)) {
@@ -244,9 +260,9 @@ bbb_data_clear_stall_callback(struct usb_xfer *xfer,
}
static void
-bbb_command_callback(struct usb_xfer *xfer)
+bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct bbb_transfer *sc = xfer->priv_sc;
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
uint32_t tag;
switch (USB_GET_STATE(xfer)) {
@@ -270,9 +286,7 @@ bbb_command_callback(struct usb_xfer *xfer)
sc->cbw.bCDBLength = sizeof(sc->cbw.CBWCDB);
DPRINTFN(0, "Truncating long command!\n");
}
- xfer->frlengths[0] = sizeof(sc->cbw);
-
- usbd_set_frame_data(xfer, &sc->cbw, 0);
+ usbd_xfer_set_frame_data(xfer, 0, &sc->cbw, sizeof(sc->cbw));
usbd_transfer_submit(xfer);
break;
@@ -283,18 +297,21 @@ bbb_command_callback(struct usb_xfer *xfer)
}
static void
-bbb_data_read_callback(struct usb_xfer *xfer)
+bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct bbb_transfer *sc = xfer->priv_sc;
- usb_frlength_t max_bulk = xfer->max_data_length;
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
+ usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->data_rem -= xfer->actlen;
- sc->data_ptr += xfer->actlen;
- sc->actlen += xfer->actlen;
+ sc->data_rem -= actlen;
+ sc->data_ptr += actlen;
+ sc->actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->data_rem = 0;
}
@@ -309,15 +326,13 @@ bbb_data_read_callback(struct usb_xfer *xfer)
if (max_bulk > sc->data_rem) {
max_bulk = sc->data_rem;
}
- xfer->timeout = sc->data_timeout;
- xfer->frlengths[0] = max_bulk;
-
- usbd_set_frame_data(xfer, sc->data_ptr, 0);
+ usbd_xfer_set_timeout(xfer, sc->data_timeout);
+ usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
usbd_transfer_submit(xfer);
break;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
bbb_done(sc, 1);
} else {
bbb_transfer_start(sc, ST_DATA_RD_CS);
@@ -327,25 +342,28 @@ bbb_data_read_callback(struct usb_xfer *xfer)
}
static void
-bbb_data_rd_cs_callback(struct usb_xfer *xfer)
+bbb_data_rd_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
bbb_data_clear_stall_callback(xfer, ST_STATUS,
ST_DATA_RD);
}
static void
-bbb_data_write_callback(struct usb_xfer *xfer)
+bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct bbb_transfer *sc = xfer->priv_sc;
- usb_frlength_t max_bulk = xfer->max_data_length;
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
+ usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- sc->data_rem -= xfer->actlen;
- sc->data_ptr += xfer->actlen;
- sc->actlen += xfer->actlen;
+ sc->data_rem -= actlen;
+ sc->data_ptr += actlen;
+ sc->actlen += actlen;
- if (xfer->actlen < xfer->sumlen) {
+ if (actlen < sumlen) {
/* short transfer */
sc->data_rem = 0;
}
@@ -360,15 +378,13 @@ bbb_data_write_callback(struct usb_xfer *xfer)
if (max_bulk > sc->data_rem) {
max_bulk = sc->data_rem;
}
- xfer->timeout = sc->data_timeout;
- xfer->frlengths[0] = max_bulk;
-
- usbd_set_frame_data(xfer, sc->data_ptr, 0);
+ usbd_xfer_set_timeout(xfer, sc->data_timeout);
+ usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
usbd_transfer_submit(xfer);
return;
default: /* Error */
- if (xfer->error == USB_ERR_CANCELLED) {
+ if (error == USB_ERR_CANCELLED) {
bbb_done(sc, 1);
} else {
bbb_transfer_start(sc, ST_DATA_WR_CS);
@@ -379,23 +395,26 @@ bbb_data_write_callback(struct usb_xfer *xfer)
}
static void
-bbb_data_wr_cs_callback(struct usb_xfer *xfer)
+bbb_data_wr_cs_callback(struct usb_xfer *xfer, usb_error_t error)
{
bbb_data_clear_stall_callback(xfer, ST_STATUS,
ST_DATA_WR);
}
static void
-bbb_status_callback(struct usb_xfer *xfer)
+bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct bbb_transfer *sc = xfer->priv_sc;
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
/* very simple status check */
- if (xfer->actlen < sizeof(sc->csw)) {
+ if (actlen < sizeof(sc->csw)) {
bbb_done(sc, 1);/* error */
} else if (sc->csw.bCSWStatus == CSWSTATUS_GOOD) {
bbb_done(sc, 0);/* success */
@@ -405,18 +424,15 @@ bbb_status_callback(struct usb_xfer *xfer)
break;
case USB_ST_SETUP:
- xfer->frlengths[0] = sizeof(sc->csw);
-
- usbd_set_frame_data(xfer, &sc->csw, 0);
+ usbd_xfer_set_frame_data(xfer, 0, &sc->csw, sizeof(sc->csw));
usbd_transfer_submit(xfer);
break;
default:
DPRINTFN(0, "Failed to read CSW: %s, try %d\n",
- usbd_errstr(xfer->error), sc->status_try);
+ usbd_errstr(error), sc->status_try);
- if ((xfer->error == USB_ERR_CANCELLED) ||
- (sc->status_try)) {
+ if (error == USB_ERR_CANCELLED || sc->status_try) {
bbb_done(sc, 1);
} else {
sc->status_try = 1;
diff --git a/sys/dev/usb/usb_parse.c b/sys/dev/usb/usb_parse.c
index aef7b140b823..884bd058648b 100644
--- a/sys/dev/usb/usb_parse.c
+++ b/sys/dev/usb/usb_parse.c
@@ -24,11 +24,30 @@
* SUCH DAMAGE.
*/
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
-#include <dev/usb/usb_mfunc.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_parse.h>
/*------------------------------------------------------------------------*
* usb_desc_foreach
diff --git a/sys/dev/usb/usb_parse.h b/sys/dev/usb/usb_parse.h
deleted file mode 100644
index 2ed1329d5f76..000000000000
--- a/sys/dev/usb/usb_parse.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_PARSE_H_
-#define _USB_PARSE_H_
-
-/* structures */
-
-struct usb_idesc_parse_state {
- struct usb_descriptor *desc;
- uint8_t iface_index; /* current interface index */
- uint8_t iface_no_last;
- uint8_t iface_index_alt; /* current alternate setting */
-};
-
-/* prototypes */
-
-struct usb_descriptor *usb_desc_foreach(struct usb_config_descriptor *cd,
- struct usb_descriptor *desc);
-struct usb_interface_descriptor *usb_idesc_foreach(
- struct usb_config_descriptor *cd,
- struct usb_idesc_parse_state *ps);
-struct usb_endpoint_descriptor *usb_edesc_foreach(
- struct usb_config_descriptor *cd,
- struct usb_endpoint_descriptor *ped);
-uint8_t usbd_get_no_descriptors(struct usb_config_descriptor *cd,
- uint8_t type);
-uint8_t usbd_get_no_alts(struct usb_config_descriptor *cd,
- struct usb_interface_descriptor *id);
-
-#endif /* _USB_PARSE_H_ */
diff --git a/sys/dev/usb/usb_process.c b/sys/dev/usb/usb_process.c
index 0732ee051355..eb79f1665081 100644
--- a/sys/dev/usb/usb_process.c
+++ b/sys/dev/usb/usb_process.c
@@ -26,7 +26,29 @@
#define USB_DEBUG_VAR usb_proc_debug
-#include <dev/usb/usb_core.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_util.h>
@@ -52,7 +74,7 @@
#define USB_THREAD_EXIT(err) kthread_exit(err)
#endif
-#if USB_DEBUG
+#ifdef USB_DEBUG
static int usb_proc_debug;
SYSCTL_NODE(_hw_usb, OID_AUTO, proc, CTLFLAG_RW, 0, "USB process");
diff --git a/sys/dev/usb/usb_process.h b/sys/dev/usb/usb_process.h
index d3cdd333c746..c717dc1522bc 100644
--- a/sys/dev/usb/usb_process.h
+++ b/sys/dev/usb/usb_process.h
@@ -41,19 +41,6 @@
struct usb_proc_msg;
-/* typedefs */
-
-typedef void (usb_proc_callback_t)(struct usb_proc_msg *hdr);
-
-/*
- * The following structure defines the USB process message header.
- */
-struct usb_proc_msg {
- TAILQ_ENTRY(usb_proc_msg) pm_qentry;
- usb_proc_callback_t *pm_callback;
- usb_size_t pm_num;
-};
-
/*
* The following structure defines the USB process.
*/
diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c
index da93b7b6de2b..de7101ad8216 100644
--- a/sys/dev/usb/usb_request.c
+++ b/sys/dev/usb/usb_request.c
@@ -26,9 +26,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_ioctl.h>
#include <dev/usb/usbhid.h>
@@ -68,7 +88,7 @@ SYSCTL_INT(_hw_usb, OID_AUTO, ss_delay, CTLFLAG_RW,
* transfers.
*------------------------------------------------------------------------*/
void
-usbd_do_request_callback(struct usb_xfer *xfer)
+usbd_do_request_callback(struct usb_xfer *xfer, usb_error_t error)
{
; /* workaround for a bug in "indent" */
@@ -90,7 +110,7 @@ usbd_do_request_callback(struct usb_xfer *xfer)
* This function is the USB callback for generic clear stall requests.
*------------------------------------------------------------------------*/
void
-usb_do_clear_stall_callback(struct usb_xfer *xfer)
+usb_do_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error)
{
struct usb_device_request req;
struct usb_device *udev;
@@ -147,7 +167,7 @@ tr_setup:
usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
/* set length */
- xfer->frlengths[0] = sizeof(req);
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
xfer->nframes = 1;
USB_BUS_UNLOCK(udev->bus);
@@ -382,15 +402,15 @@ usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
usbd_copy_in(xfer->frbuffers, 0, req, sizeof(*req));
- xfer->frlengths[0] = sizeof(*req);
+ usbd_xfer_set_frame_len(xfer, 0, sizeof(*req));
xfer->nframes = 2;
while (1) {
temp = length;
if (temp > xfer->max_data_length) {
- temp = xfer->max_data_length;
+ temp = usbd_xfer_max_len(xfer);
}
- xfer->frlengths[1] = temp;
+ usbd_xfer_set_frame_len(xfer, 1, temp);
if (temp > 0) {
if (!(req->bmRequestType & UT_READ)) {
@@ -482,7 +502,7 @@ usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
* Clear "frlengths[0]" so that we don't send the setup
* packet again:
*/
- xfer->frlengths[0] = 0;
+ usbd_xfer_set_frame_len(xfer, 0, 0);
/* update length and data pointer */
length -= temp;
diff --git a/sys/dev/usb/usb_request.h b/sys/dev/usb/usb_request.h
index f4021e57158c..21585651c19f 100644
--- a/sys/dev/usb/usb_request.h
+++ b/sys/dev/usb/usb_request.h
@@ -29,12 +29,6 @@
struct usb_process;
-usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
- struct usb_device_request *req, void *data, uint16_t flags,
- uint16_t *actlen, usb_timeout_t timeout);
-usb_error_t usbd_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
- struct usb_device_request *req, void *data, uint16_t flags,
- uint16_t *actlen, usb_timeout_t timeout);
usb_error_t usbd_req_clear_hub_feature(struct usb_device *udev,
struct mtx *mtx, uint16_t sel);
usb_error_t usbd_req_clear_port_feature(struct usb_device *udev,
@@ -66,41 +60,16 @@ usb_error_t usbd_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
struct usb_hub_status *st);
usb_error_t usbd_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
struct usb_port_status *ps, uint8_t port);
-usb_error_t usbd_req_get_report(struct usb_device *udev, struct mtx *mtx,
- void *data, uint16_t len, uint8_t iface_index, uint8_t type,
- uint8_t id);
-usb_error_t usbd_req_get_report_descriptor(struct usb_device *udev,
- struct mtx *mtx, void *d, uint16_t size,
- uint8_t iface_index);
-usb_error_t usbd_req_get_string_any(struct usb_device *udev, struct mtx *mtx,
- char *buf, uint16_t len, uint8_t string_index);
-usb_error_t usbd_req_get_string_desc(struct usb_device *udev, struct mtx *mtx,
- void *sdesc, uint16_t max_len, uint16_t lang_id,
- uint8_t string_index);
usb_error_t usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx,
uint8_t port);
usb_error_t usbd_req_set_address(struct usb_device *udev, struct mtx *mtx,
uint16_t addr);
-usb_error_t usbd_req_set_alt_interface_no(struct usb_device *udev,
- struct mtx *mtx, uint8_t iface_index, uint8_t alt_no);
-usb_error_t usbd_req_set_config(struct usb_device *udev, struct mtx *mtx,
- uint8_t conf);
usb_error_t usbd_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
uint16_t sel);
-usb_error_t usbd_req_set_idle(struct usb_device *udev, struct mtx *mtx,
- uint8_t iface_index, uint8_t duration, uint8_t id);
usb_error_t usbd_req_set_port_feature(struct usb_device *udev,
struct mtx *mtx, uint8_t port, uint16_t sel);
-usb_error_t usbd_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
- uint8_t iface_index, uint16_t report);
-usb_error_t usbd_req_set_report(struct usb_device *udev, struct mtx *mtx,
- void *data, uint16_t len, uint8_t iface_index,
- uint8_t type, uint8_t id);
usb_error_t usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx);
usb_error_t usbd_req_clear_device_feature(struct usb_device *udev, struct mtx *mtx, uint16_t sel);
usb_error_t usbd_req_set_device_feature(struct usb_device *udev, struct mtx *mtx, uint16_t sel);
-#define usbd_do_request(u,m,r,d) \
- usbd_do_request_flags(u,m,r,d,0,NULL,USB_DEFAULT_TIMEOUT)
-
#endif /* _USB_REQUEST_H_ */
diff --git a/sys/dev/usb/usb_revision.h b/sys/dev/usb/usb_revision.h
deleted file mode 100644
index 6e6914e463cd..000000000000
--- a/sys/dev/usb/usb_revision.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_REVISION_H_
-#define _USB_REVISION_H_
-
-/*
- * The "USB_SPEED" macros defines all the supported USB speeds.
- */
-enum usb_dev_speed {
- USB_SPEED_VARIABLE,
- USB_SPEED_LOW,
- USB_SPEED_FULL,
- USB_SPEED_HIGH,
- USB_SPEED_SUPER,
-};
-#define USB_SPEED_MAX (USB_SPEED_SUPER+1)
-
-/*
- * The "USB_REV" macros defines all the supported USB revisions.
- */
-enum usb_revision {
- USB_REV_UNKNOWN,
- USB_REV_PRE_1_0,
- USB_REV_1_0,
- USB_REV_1_1,
- USB_REV_2_0,
- USB_REV_2_5,
- USB_REV_3_0
-};
-#define USB_REV_MAX (USB_REV_3_0+1)
-
-/*
- * Supported host contoller modes.
- */
-enum usb_hc_mode {
- USB_MODE_HOST, /* initiates transfers */
- USB_MODE_DEVICE, /* bus transfer target */
- USB_MODE_DUAL /* can be host or device */
-};
-#define USB_MODE_MAX (USB_MODE_DUAL+1)
-
-/*
- * The "USB_MODE" macros defines all the supported device states.
- */
-enum usb_dev_state {
- USB_STATE_DETACHED,
- USB_STATE_ATTACHED,
- USB_STATE_POWERED,
- USB_STATE_ADDRESSED,
- USB_STATE_CONFIGURED,
-};
-#define USB_STATE_MAX (USB_STATE_CONFIGURED+1)
-#endif /* _USB_REVISION_H_ */
diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c
index bad72d4ee617..ae705396554b 100644
--- a/sys/dev/usb/usb_transfer.c
+++ b/sys/dev/usb/usb_transfer.c
@@ -24,9 +24,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#define USB_DEBUG_VAR usb_debug
@@ -85,7 +105,7 @@ static const struct usb_config usb_control_ep_cfg[USB_DEFAULT_XFER_MAX] = {
static void usbd_update_max_frame_size(struct usb_xfer *);
static void usbd_transfer_unsetup_sub(struct usb_xfer_root *, uint8_t);
static void usbd_control_transfer_init(struct usb_xfer *);
-static uint8_t usbd_start_hardware_sub(struct usb_xfer *);
+static int usbd_setup_ctrl_transfer(struct usb_xfer *);
static void usb_callback_proc(struct usb_proc_msg *);
static void usbd_callback_ss_done_defer(struct usb_xfer *);
static void usbd_callback_wrapper(struct usb_xfer_queue *);
@@ -99,12 +119,12 @@ static void usbd_get_std_packet_size(struct usb_std_packet_size *ptr,
* usb_request_callback
*------------------------------------------------------------------------*/
static void
-usb_request_callback(struct usb_xfer *xfer)
+usb_request_callback(struct usb_xfer *xfer, usb_error_t error)
{
if (xfer->flags_int.usb_mode == USB_MODE_DEVICE)
- usb_handle_request_callback(xfer);
+ usb_handle_request_callback(xfer, error);
else
- usbd_do_request_callback(xfer);
+ usbd_do_request_callback(xfer, error);
}
/*------------------------------------------------------------------------*
@@ -575,17 +595,16 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
xfer->max_data_length -= REQ_SIZE;
}
/* setup "frlengths" */
-
xfer->frlengths = parm->xfer_length_ptr;
-
parm->xfer_length_ptr += n_frlengths;
/* setup "frbuffers" */
-
xfer->frbuffers = parm->xfer_page_cache_ptr;
-
parm->xfer_page_cache_ptr += n_frbuffers;
+ /* initialize max frame count */
+ xfer->max_frame_count = xfer->nframes;
+
/*
* check if we need to setup
* a local buffer:
@@ -601,10 +620,10 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
xfer->local_buffer =
USB_ADD_BYTES(parm->buf, parm->size[0]);
- usbd_set_frame_offset(xfer, 0, 0);
+ usbd_xfer_set_frame_offset(xfer, 0, 0);
if ((type == UE_CONTROL) && (n_frbuffers > 1)) {
- usbd_set_frame_offset(xfer, REQ_SIZE, 1);
+ usbd_xfer_set_frame_offset(xfer, REQ_SIZE, 1);
}
}
parm->size[0] += parm->bufsize;
@@ -662,9 +681,6 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
parm->err = USB_ERR_INVAL;
goto done;
}
- /* initialize max frame count */
-
- xfer->max_frame_count = xfer->nframes;
/* initialize frame buffers */
@@ -1209,7 +1225,7 @@ usbd_control_transfer_init(struct usb_xfer *xfer)
}
/*------------------------------------------------------------------------*
- * usbd_start_hardware_sub
+ * usbd_setup_ctrl_transfer
*
* This function handles initialisation of control transfers. Control
* transfers are special in that regard that they can both transmit
@@ -1219,8 +1235,8 @@ usbd_control_transfer_init(struct usb_xfer *xfer)
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
-static uint8_t
-usbd_start_hardware_sub(struct usb_xfer *xfer)
+static int
+usbd_setup_ctrl_transfer(struct usb_xfer *xfer)
{
usb_frlength_t len;
@@ -1495,7 +1511,7 @@ usbd_transfer_submit(struct usb_xfer *xfer)
if (xfer->flags_int.control_xfr) {
- if (usbd_start_hardware_sub(xfer)) {
+ if (usbd_setup_ctrl_transfer(xfer)) {
USB_BUS_LOCK(bus);
usbd_transfer_done(xfer, USB_ERR_STALLED);
USB_BUS_UNLOCK(bus);
@@ -1780,8 +1796,24 @@ usbd_transfer_drain(struct usb_xfer *xfer)
USB_XFER_UNLOCK(xfer);
}
+struct usb_page_cache *
+usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
+{
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
+ return (&xfer->frbuffers[frindex]);
+}
+
+usb_frlength_t
+usbd_xfer_get_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex)
+{
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
+ return (xfer->frlengths[frindex]);
+}
+
/*------------------------------------------------------------------------*
- * usbd_set_frame_data
+ * usbd_xfer_set_frame_data
*
* This function sets the pointer of the buffer that should
* loaded directly into DMA for the given USB frame. Passing "ptr"
@@ -1789,30 +1821,106 @@ usbd_transfer_drain(struct usb_xfer *xfer)
* than zero gives undefined results!
*------------------------------------------------------------------------*/
void
-usbd_set_frame_data(struct usb_xfer *xfer, void *ptr, usb_frcount_t frindex)
+usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex,
+ void *ptr, usb_frlength_t len)
{
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
/* set virtual address to load and length */
xfer->frbuffers[frindex].buffer = ptr;
+ usbd_xfer_set_frame_len(xfer, frindex, len);
+}
+
+void
+usbd_xfer_get_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex,
+ void **ptr, int *len)
+{
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
+ if (ptr != NULL)
+ *ptr = xfer->frbuffers[frindex].buffer;
+ if (len != NULL)
+ *len = xfer->frlengths[frindex];
+}
+
+void
+usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes,
+ int *nframes)
+{
+ if (actlen != NULL)
+ *actlen = xfer->actlen;
+ if (sumlen != NULL)
+ *sumlen = xfer->sumlen;
+ if (aframes != NULL)
+ *aframes = xfer->aframes;
+ if (nframes != NULL)
+ *nframes = xfer->nframes;
}
/*------------------------------------------------------------------------*
- * usbd_set_frame_offset
+ * usbd_xfer_set_frame_offset
*
* This function sets the frame data buffer offset relative to the beginning
* of the USB DMA buffer allocated for this USB transfer.
*------------------------------------------------------------------------*/
void
-usbd_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset,
+usbd_xfer_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset,
usb_frcount_t frindex)
{
- USB_ASSERT(!xfer->flags.ext_buffer, ("Cannot offset data frame "
+ KASSERT(!xfer->flags.ext_buffer, ("Cannot offset data frame "
"when the USB buffer is external!\n"));
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
/* set virtual address to load */
xfer->frbuffers[frindex].buffer =
USB_ADD_BYTES(xfer->local_buffer, offset);
}
+void
+usbd_xfer_set_interval(struct usb_xfer *xfer, int i)
+{
+ xfer->interval = i;
+}
+
+void
+usbd_xfer_set_timeout(struct usb_xfer *xfer, int t)
+{
+ xfer->timeout = t;
+}
+
+void
+usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
+{
+ xfer->nframes = n;
+}
+
+usb_frcount_t
+usbd_xfer_max_frames(struct usb_xfer *xfer)
+{
+ return (xfer->max_frame_count);
+}
+
+usb_frlength_t
+usbd_xfer_max_len(struct usb_xfer *xfer)
+{
+ return (xfer->max_data_length);
+}
+
+usb_frlength_t
+usbd_xfer_max_framelen(struct usb_xfer *xfer)
+{
+ return (xfer->max_frame_size);
+}
+
+void
+usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex,
+ usb_frlength_t len)
+{
+ KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
+ xfer->frlengths[frindex] = len;
+}
+
/*------------------------------------------------------------------------*
* usb_callback_proc - factored out code
*
@@ -1963,7 +2071,7 @@ usbd_callback_wrapper(struct usb_xfer_queue *pq)
}
/* call processing routine */
- (xfer->callback) (xfer);
+ (xfer->callback) (xfer, xfer->error);
/* pickup the USB mutex again */
USB_BUS_LOCK(info->bus);
@@ -2157,13 +2265,13 @@ usbd_transfer_start_cb(void *arg)
}
/*------------------------------------------------------------------------*
- * usbd_transfer_set_stall
+ * usbd_xfer_set_stall
*
* This function is used to set the stall flag outside the
* callback. This function is NULL safe.
*------------------------------------------------------------------------*/
void
-usbd_transfer_set_stall(struct usb_xfer *xfer)
+usbd_xfer_set_stall(struct usb_xfer *xfer)
{
if (xfer == NULL) {
/* tearing down */
@@ -2173,12 +2281,16 @@ usbd_transfer_set_stall(struct usb_xfer *xfer)
/* avoid any races by locking the USB mutex */
USB_BUS_LOCK(xfer->xroot->bus);
-
xfer->flags.stall_pipe = 1;
-
USB_BUS_UNLOCK(xfer->xroot->bus);
}
+int
+usbd_xfer_is_stalled(struct usb_xfer *xfer)
+{
+ return (xfer->endpoint->is_stalled);
+}
+
/*------------------------------------------------------------------------*
* usbd_transfer_clear_stall
*
@@ -2411,7 +2523,7 @@ usbd_callback_wrapper_sub(struct usb_xfer *xfer)
* of frames transferred, "xfer->aframes":
*/
for (; x < xfer->nframes; x++) {
- xfer->frlengths[x] = 0;
+ usbd_xfer_set_frame_len(xfer, x, 0);
}
/* check actual length */
@@ -2425,7 +2537,7 @@ usbd_callback_wrapper_sub(struct usb_xfer *xfer)
xfer->actlen = xfer->sumlen;
}
}
- DPRINTFN(6, "xfer=%p endpoint=%p sts=%d alen=%d, slen=%d, afrm=%d, nfrm=%d\n",
+ DPRINTFN(1, "xfer=%p endpoint=%p sts=%d alen=%d, slen=%d, afrm=%d, nfrm=%d\n",
xfer, xfer->endpoint, xfer->error, xfer->actlen, xfer->sumlen,
xfer->aframes, xfer->nframes);
@@ -2734,13 +2846,13 @@ usbd_clear_stall_callback(struct usb_xfer *xfer1,
}
void
-usbd_do_poll(struct usb_xfer **ppxfer, uint16_t max)
+usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
{
static uint8_t once = 0;
/* polling is currently not supported */
if (!once) {
once = 1;
- printf("usbd_do_poll: USB polling is "
+ printf("usbd_transfer_poll: USB polling is "
"not supported!\n");
}
}
@@ -2819,3 +2931,53 @@ usbd_get_std_packet_size(struct usb_std_packet_size *ptr,
break;
}
}
+
+void *
+usbd_xfer_softc(struct usb_xfer *xfer)
+{
+ return (xfer->priv_sc);
+}
+
+void *
+usbd_xfer_get_priv(struct usb_xfer *xfer)
+{
+ return (xfer->priv_fifo);
+}
+
+void
+usbd_xfer_set_priv(struct usb_xfer *xfer, void *ptr)
+{
+ xfer->priv_fifo = ptr;
+}
+
+uint8_t
+usbd_xfer_state(struct usb_xfer *xfer)
+{
+ return (xfer->usb_state);
+}
+
+void
+usbd_xfer_set_flag(struct usb_xfer *xfer, int flag)
+{
+ switch (flag) {
+ case USB_FORCE_SHORT_XFER:
+ xfer->flags.force_short_xfer = 1;
+ break;
+ case USB_SHORT_XFER_OK:
+ xfer->flags.short_xfer_ok = 1;
+ break;
+ }
+}
+
+void
+usbd_xfer_clr_flag(struct usb_xfer *xfer, int flag)
+{
+ switch (flag) {
+ case USB_FORCE_SHORT_XFER:
+ xfer->flags.force_short_xfer = 0;
+ break;
+ case USB_SHORT_XFER_OK:
+ xfer->flags.short_xfer_ok = 0;
+ break;
+ }
+}
diff --git a/sys/dev/usb/usb_transfer.h b/sys/dev/usb/usb_transfer.h
index 89ca8c1f285e..27f3afffa638 100644
--- a/sys/dev/usb/usb_transfer.h
+++ b/sys/dev/usb/usb_transfer.h
@@ -126,7 +126,6 @@ void usbd_transfer_setup_sub(struct usb_setup_params *parm);
void usbd_default_transfer_setup(struct usb_device *udev);
void usbd_clear_data_toggle(struct usb_device *udev,
struct usb_endpoint *ep);
-void usbd_do_poll(struct usb_xfer **ppxfer, uint16_t max);
usb_callback_t usbd_do_request_callback;
usb_callback_t usb_handle_request_callback;
usb_callback_t usb_do_clear_stall_callback;
diff --git a/sys/dev/usb/usb_util.c b/sys/dev/usb/usb_util.c
index 8b16531fcf6f..a43ceeef6426 100644
--- a/sys/dev/usb/usb_util.c
+++ b/sys/dev/usb/usb_util.c
@@ -24,9 +24,29 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb_error.h>
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_util.h>
@@ -38,7 +58,6 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
-
/*------------------------------------------------------------------------*
* device_delete_all_children - delete all children of a device
*------------------------------------------------------------------------*/
diff --git a/sys/dev/usb/usb_util.h b/sys/dev/usb/usb_util.h
index b4fdd60ece05..35abeddddb3b 100644
--- a/sys/dev/usb/usb_util.h
+++ b/sys/dev/usb/usb_util.h
@@ -29,8 +29,6 @@
int device_delete_all_children(device_t dev);
uint8_t usb_make_str_desc(void *ptr, uint16_t max_len, const char *s);
-void device_set_usb_desc(device_t dev);
-void usb_pause_mtx(struct mtx *mtx, int _ticks);
void usb_printbcd(char *p, uint16_t p_len, uint16_t bcd);
void usb_trim_spaces(char *p);
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
new file mode 100644
index 000000000000..25f9ec08fa90
--- /dev/null
+++ b/sys/dev/usb/usbdi.h
@@ -0,0 +1,532 @@
+/*-
+ * Copyright (c) 2009 Andrew Thompson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _USB_USBDI_H_
+#define _USB_USBDI_H_
+
+struct usb_fifo;
+struct usb_xfer;
+struct usb_device;
+struct usb_interface;
+struct usb_endpoint;
+struct usb_page_cache;
+struct usb_page_search;
+struct usb_process;
+struct usb_proc_msg;
+struct usb_mbuf;
+struct mbuf;
+
+typedef enum { /* keep in sync with usb_errstr_table */
+ USB_ERR_NORMAL_COMPLETION = 0,
+ USB_ERR_PENDING_REQUESTS, /* 1 */
+ USB_ERR_NOT_STARTED, /* 2 */
+ USB_ERR_INVAL, /* 3 */
+ USB_ERR_NOMEM, /* 4 */
+ USB_ERR_CANCELLED, /* 5 */
+ USB_ERR_BAD_ADDRESS, /* 6 */
+ USB_ERR_BAD_BUFSIZE, /* 7 */
+ USB_ERR_BAD_FLAG, /* 8 */
+ USB_ERR_NO_CALLBACK, /* 9 */
+ USB_ERR_IN_USE, /* 10 */
+ USB_ERR_NO_ADDR, /* 11 */
+ USB_ERR_NO_PIPE, /* 12 */
+ USB_ERR_ZERO_NFRAMES, /* 13 */
+ USB_ERR_ZERO_MAXP, /* 14 */
+ USB_ERR_SET_ADDR_FAILED, /* 15 */
+ USB_ERR_NO_POWER, /* 16 */
+ USB_ERR_TOO_DEEP, /* 17 */
+ USB_ERR_IOERROR, /* 18 */
+ USB_ERR_NOT_CONFIGURED, /* 19 */
+ USB_ERR_TIMEOUT, /* 20 */
+ USB_ERR_SHORT_XFER, /* 21 */
+ USB_ERR_STALLED, /* 22 */
+ USB_ERR_INTERRUPTED, /* 23 */
+ USB_ERR_DMA_LOAD_FAILED, /* 24 */
+ USB_ERR_BAD_CONTEXT, /* 25 */
+ USB_ERR_NO_ROOT_HUB, /* 26 */
+ USB_ERR_NO_INTR_THREAD, /* 27 */
+ USB_ERR_NOT_LOCKED, /* 28 */
+ USB_ERR_MAX
+} usb_error_t;
+
+/*
+ * Flags for transfers
+ */
+#define USB_FORCE_SHORT_XFER 0x0001 /* force a short transmit last */
+#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */
+#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */
+#define USB_USER_DATA_PTR 0x0020 /* internal flag */
+
+#define USB_NO_TIMEOUT 0
+#define USB_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */
+
+#if defined(_KERNEL)
+/* typedefs */
+
+typedef void (usb_callback_t)(struct usb_xfer *, usb_error_t);
+typedef void (usb_proc_callback_t)(struct usb_proc_msg *);
+typedef usb_error_t (usb_handle_req_t)(struct usb_device *,
+ struct usb_device_request *, const void **, uint16_t *);
+
+typedef int (usb_fifo_open_t)(struct usb_fifo *fifo, int fflags);
+typedef void (usb_fifo_close_t)(struct usb_fifo *fifo, int fflags);
+typedef int (usb_fifo_ioctl_t)(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags);
+typedef void (usb_fifo_cmd_t)(struct usb_fifo *fifo);
+typedef void (usb_fifo_filter_t)(struct usb_fifo *fifo, struct usb_mbuf *m);
+
+/*
+ * The following macros are used used to convert milliseconds into
+ * HZ. We use 1024 instead of 1000 milliseconds per second to save a
+ * full division.
+ */
+#define USB_MS_HZ 1024
+
+#define USB_MS_TO_TICKS(ms) \
+ (((uint32_t)((((uint32_t)(ms)) * ((uint32_t)(hz))) + USB_MS_HZ - 1)) / USB_MS_HZ)
+
+/*
+ * Common queue structure for USB transfers.
+ */
+struct usb_xfer_queue {
+ TAILQ_HEAD(, usb_xfer) head;
+ struct usb_xfer *curr; /* current USB transfer processed */
+ void (*command) (struct usb_xfer_queue *pq);
+ uint8_t recurse_1:1;
+ uint8_t recurse_2:1;
+};
+
+/*
+ * The following structure defines an USB endpoint
+ * USB endpoint.
+ */
+struct usb_endpoint {
+ struct usb_xfer_queue endpoint_q; /* queue of USB transfers */
+
+ struct usb_endpoint_descriptor *edesc;
+ struct usb_pipe_methods *methods; /* set by HC driver */
+
+ uint16_t isoc_next;
+ uint16_t refcount;
+
+ uint8_t toggle_next:1; /* next data toggle value */
+ uint8_t is_stalled:1; /* set if endpoint is stalled */
+ uint8_t is_synced:1; /* set if we a synchronised */
+ uint8_t unused:5;
+ uint8_t iface_index; /* not used by "default endpoint" */
+};
+
+/*
+ * The following structure defines an USB interface.
+ */
+struct usb_interface {
+ struct usb_interface_descriptor *idesc;
+ device_t subdev;
+ uint8_t alt_index;
+ uint8_t parent_iface_index;
+
+ /* Linux compat */
+ struct usb_host_interface *altsetting;
+ struct usb_host_interface *cur_altsetting;
+ struct usb_device *linux_udev;
+ void *bsd_priv_sc; /* device specific information */
+ uint8_t num_altsetting; /* number of alternate settings */
+ uint8_t bsd_iface_index;
+};
+
+/*
+ * The following structure defines a set of USB transfer flags.
+ */
+struct usb_xfer_flags {
+ uint8_t force_short_xfer:1; /* force a short transmit transfer
+ * last */
+ uint8_t short_xfer_ok:1; /* allow short receive transfers */
+ uint8_t short_frames_ok:1; /* allow short frames */
+ uint8_t pipe_bof:1; /* block pipe on failure */
+ uint8_t proxy_buffer:1; /* makes buffer size a factor of
+ * "max_frame_size" */
+ uint8_t ext_buffer:1; /* uses external DMA buffer */
+ uint8_t manual_status:1; /* non automatic status stage on
+ * control transfers */
+ uint8_t no_pipe_ok:1; /* set if "USB_ERR_NO_PIPE" error can
+ * be ignored */
+ uint8_t stall_pipe:1; /* set if the endpoint belonging to
+ * this USB transfer should be stalled
+ * before starting this transfer! */
+};
+
+/*
+ * The following structure define an USB configuration, that basically
+ * is used when setting up an USB transfer.
+ */
+struct usb_config {
+ usb_callback_t *callback; /* USB transfer callback */
+ usb_frlength_t bufsize; /* total pipe buffer size in bytes */
+ usb_frcount_t frames; /* maximum number of USB frames */
+ usb_timeout_t interval; /* interval in milliseconds */
+#define USB_DEFAULT_INTERVAL 0
+ usb_timeout_t timeout; /* transfer timeout in milliseconds */
+ struct usb_xfer_flags flags; /* transfer flags */
+ enum usb_hc_mode usb_mode; /* host or device mode */
+ uint8_t type; /* pipe type */
+ uint8_t endpoint; /* pipe number */
+ uint8_t direction; /* pipe direction */
+ uint8_t ep_index; /* pipe index match to use */
+ uint8_t if_index; /* "ifaces" index to use */
+};
+
+/*
+ * The following structure is used when looking up an USB driver for
+ * an USB device. It is inspired by the Linux structure called
+ * "usb_device_id".
+ */
+struct usb_device_id {
+
+ /* Hook for driver specific information */
+ unsigned long driver_info;
+
+ /* Used for product specific matches; the BCD range is inclusive */
+ uint16_t idVendor;
+ uint16_t idProduct;
+ uint16_t bcdDevice_lo;
+ uint16_t bcdDevice_hi;
+
+ /* Used for device class matches */
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+
+ /* Used for interface class matches */
+ uint8_t bInterfaceClass;
+ uint8_t bInterfaceSubClass;
+ uint8_t bInterfaceProtocol;
+
+ /* Select which fields to match against */
+ uint8_t match_flag_vendor:1;
+ uint8_t match_flag_product:1;
+ uint8_t match_flag_dev_lo:1;
+ uint8_t match_flag_dev_hi:1;
+ uint8_t match_flag_dev_class:1;
+ uint8_t match_flag_dev_subclass:1;
+ uint8_t match_flag_dev_protocol:1;
+ uint8_t match_flag_int_class:1;
+ uint8_t match_flag_int_subclass:1;
+ uint8_t match_flag_int_protocol:1;
+
+#if USB_HAVE_COMPAT_LINUX
+ /* which fields to match against */
+ uint16_t match_flags;
+#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
+#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
+#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
+#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
+#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
+#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
+#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
+#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
+#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
+#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
+#endif
+};
+
+#define USB_VENDOR(vend) \
+ .match_flag_vendor = 1, .idVendor = (vend)
+
+#define USB_PRODUCT(prod) \
+ .match_flag_product = 1, .idProduct = (prod)
+
+#define USB_VP(vend,prod) \
+ USB_VENDOR(vend), USB_PRODUCT(prod)
+
+#define USB_VPI(vend,prod,info) \
+ USB_VENDOR(vend), USB_PRODUCT(prod), USB_DRIVER_INFO(info)
+
+#define USB_DEV_BCD_GTEQ(lo) /* greater than or equal */ \
+ .match_flag_dev_lo = 1, .bcdDevice_lo = (lo)
+
+#define USB_DEV_BCD_LTEQ(hi) /* less than or equal */ \
+ .match_flag_dev_hi = 1, .bcdDevice_hi = (hi)
+
+#define USB_DEV_CLASS(dc) \
+ .match_flag_dev_class = 1, .bDeviceClass = (dc)
+
+#define USB_DEV_SUBCLASS(dsc) \
+ .match_flag_dev_subclass = 1, .bDeviceSubClass = (dsc)
+
+#define USB_DEV_PROTOCOL(dp) \
+ .match_flag_dev_protocol = 1, .bDeviceProtocol = (dp)
+
+#define USB_IFACE_CLASS(ic) \
+ .match_flag_int_class = 1, .bInterfaceClass = (ic)
+
+#define USB_IFACE_SUBCLASS(isc) \
+ .match_flag_int_subclass = 1, .bInterfaceSubClass = (isc)
+
+#define USB_IFACE_PROTOCOL(ip) \
+ .match_flag_int_protocol = 1, .bInterfaceProtocol = (ip)
+
+#define USB_IF_CSI(class,subclass,info) \
+ USB_IFACE_CLASS(class), USB_IFACE_SUBCLASS(subclass), USB_DRIVER_INFO(info)
+
+#define USB_DRIVER_INFO(n) \
+ .driver_info = (n)
+
+#define USB_GET_DRIVER_INFO(did) \
+ (did)->driver_info
+
+/*
+ * The following structure keeps information that is used to match
+ * against an array of "usb_device_id" elements.
+ */
+struct usbd_lookup_info {
+ uint16_t idVendor;
+ uint16_t idProduct;
+ uint16_t bcdDevice;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bInterfaceClass;
+ uint8_t bInterfaceSubClass;
+ uint8_t bInterfaceProtocol;
+ uint8_t bIfaceIndex;
+ uint8_t bIfaceNum;
+ uint8_t bConfigIndex;
+ uint8_t bConfigNum;
+};
+
+/* Structure used by probe and attach */
+
+struct usb_attach_arg {
+ struct usbd_lookup_info info;
+ device_t temp_dev; /* for internal use */
+ unsigned long driver_info; /* for internal use */
+ void *driver_ivar;
+ struct usb_device *device; /* current device */
+ struct usb_interface *iface; /* current interface */
+ enum usb_hc_mode usb_mode; /* host or device mode */
+ uint8_t port;
+ uint8_t use_generic; /* hint for generic drivers */
+};
+
+/*
+ * The following is a wrapper for the callout structure to ease
+ * porting the code to other platforms.
+ */
+struct usb_callout {
+ struct callout co;
+};
+#define usb_callout_init_mtx(c,m,f) callout_init_mtx(&(c)->co,m,f)
+#define usb_callout_reset(c,t,f,d) callout_reset(&(c)->co,t,f,d)
+#define usb_callout_stop(c) callout_stop(&(c)->co)
+#define usb_callout_drain(c) callout_drain(&(c)->co)
+#define usb_callout_pending(c) callout_pending(&(c)->co)
+
+/* USB transfer states */
+
+#define USB_ST_SETUP 0
+#define USB_ST_TRANSFERRED 1
+#define USB_ST_ERROR 2
+
+/* USB handle request states */
+#define USB_HR_NOT_COMPLETE 0
+#define USB_HR_COMPLETE_OK 1
+#define USB_HR_COMPLETE_ERR 2
+
+/*
+ * The following macro will return the current state of an USB
+ * transfer like defined by the "USB_ST_XXX" enums.
+ */
+#define USB_GET_STATE(xfer) (usbd_xfer_state(xfer))
+
+/*
+ * The following structure defines the USB process message header.
+ */
+struct usb_proc_msg {
+ TAILQ_ENTRY(usb_proc_msg) pm_qentry;
+ usb_proc_callback_t *pm_callback;
+ usb_size_t pm_num;
+};
+
+#define USB_FIFO_TX 0
+#define USB_FIFO_RX 1
+
+/*
+ * Locking note for the following functions. All the
+ * "usb_fifo_cmd_t" and "usb_fifo_filter_t" functions are called
+ * locked. The others are called unlocked.
+ */
+struct usb_fifo_methods {
+ usb_fifo_open_t *f_open;
+ usb_fifo_close_t *f_close;
+ usb_fifo_ioctl_t *f_ioctl;
+ /*
+ * NOTE: The post-ioctl callback is called after the USB reference
+ * gets locked in the IOCTL handler:
+ */
+ usb_fifo_ioctl_t *f_ioctl_post;
+ usb_fifo_cmd_t *f_start_read;
+ usb_fifo_cmd_t *f_stop_read;
+ usb_fifo_cmd_t *f_start_write;
+ usb_fifo_cmd_t *f_stop_write;
+ usb_fifo_filter_t *f_filter_read;
+ usb_fifo_filter_t *f_filter_write;
+ const char *basename[4];
+ const char *postfix[4];
+};
+
+struct usb_fifo_sc {
+ struct usb_fifo *fp[2];
+ struct cdev* dev;
+};
+
+const char *usbd_errstr(usb_error_t error);
+void *usbd_find_descriptor(struct usb_device *udev, void *id,
+ uint8_t iface_index, uint8_t type, uint8_t type_mask,
+ uint8_t subtype, uint8_t subtype_mask);
+struct usb_config_descriptor *usbd_get_config_descriptor(
+ struct usb_device *udev);
+struct usb_device_descriptor *usbd_get_device_descriptor(
+ struct usb_device *udev);
+struct usb_interface *usbd_get_iface(struct usb_device *udev,
+ uint8_t iface_index);
+struct usb_interface_descriptor *usbd_get_interface_descriptor(
+ struct usb_interface *iface);
+struct usb_endpoint *usbd_get_endpoint(struct usb_device *udev, uint8_t iface_index,
+ const struct usb_config *setup);
+struct usb_endpoint *usbd_get_ep_by_addr(struct usb_device *udev, uint8_t ea_val);
+usb_error_t usbd_interface_count(struct usb_device *udev, uint8_t *count);
+enum usb_hc_mode usbd_get_mode(struct usb_device *udev);
+enum usb_dev_speed usbd_get_speed(struct usb_device *udev);
+void device_set_usb_desc(device_t dev);
+void usb_pause_mtx(struct mtx *mtx, int _ticks);
+
+const struct usb_device_id *usbd_lookup_id_by_info(
+ const struct usb_device_id *id, usb_size_t sizeof_id,
+ const struct usbd_lookup_info *info);
+int usbd_lookup_id_by_uaa(const struct usb_device_id *id,
+ usb_size_t sizeof_id, struct usb_attach_arg *uaa);
+
+usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
+ struct usb_device_request *req, void *data, uint16_t flags,
+ uint16_t *actlen, usb_timeout_t timeout);
+#define usbd_do_request(u,m,r,d) \
+ usbd_do_request_flags(u,m,r,d,0,NULL,USB_DEFAULT_TIMEOUT)
+
+uint8_t usbd_clear_stall_callback(struct usb_xfer *xfer1,
+ struct usb_xfer *xfer2);
+uint8_t usbd_get_interface_altindex(struct usb_interface *iface);
+usb_error_t usbd_set_alt_interface_index(struct usb_device *udev,
+ uint8_t iface_index, uint8_t alt_index);
+uint32_t usbd_get_isoc_fps(struct usb_device *udev);
+usb_error_t usbd_transfer_setup(struct usb_device *udev,
+ const uint8_t *ifaces, struct usb_xfer **pxfer,
+ const struct usb_config *setup_start, uint16_t n_setup,
+ void *priv_sc, struct mtx *priv_mtx);
+void usbd_transfer_submit(struct usb_xfer *xfer);
+void usbd_transfer_clear_stall(struct usb_xfer *xfer);
+void usbd_transfer_drain(struct usb_xfer *xfer);
+uint8_t usbd_transfer_pending(struct usb_xfer *xfer);
+void usbd_transfer_start(struct usb_xfer *xfer);
+void usbd_transfer_stop(struct usb_xfer *xfer);
+void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup);
+void usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max);
+void usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index,
+ uint8_t parent_index);
+uint8_t usbd_get_bus_index(struct usb_device *udev);
+uint8_t usbd_get_device_index(struct usb_device *udev);
+void usbd_set_power_mode(struct usb_device *udev, uint8_t power_mode);
+uint8_t usbd_device_attached(struct usb_device *udev);
+
+void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen,
+ int *aframes, int *nframes);
+struct usb_page_cache *usbd_xfer_get_frame(struct usb_xfer *xfer,
+ usb_frcount_t frindex);
+void *usbd_xfer_softc(struct usb_xfer *xfer);
+void *usbd_xfer_get_priv(struct usb_xfer *xfer);
+void usbd_xfer_set_priv(struct usb_xfer *xfer, void *);
+void usbd_xfer_set_interval(struct usb_xfer *xfer, int);
+uint8_t usbd_xfer_state(struct usb_xfer *xfer);
+void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex,
+ void *ptr, usb_frlength_t len);
+void usbd_xfer_get_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex,
+ void **ptr, int *len);
+void usbd_xfer_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset,
+ usb_frcount_t frindex);
+usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer);
+usb_frlength_t usbd_xfer_max_framelen(struct usb_xfer *xfer);
+usb_frcount_t usbd_xfer_max_frames(struct usb_xfer *xfer);
+usb_frlength_t usbd_xfer_get_frame_len(struct usb_xfer *xfer,
+ usb_frcount_t frindex);
+void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex,
+ usb_frlength_t len);
+void usbd_xfer_set_timeout(struct usb_xfer *xfer, int timeout);
+void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n);
+void usbd_xfer_set_stall(struct usb_xfer *xfer);
+int usbd_xfer_is_stalled(struct usb_xfer *xfer);
+void usbd_xfer_set_flag(struct usb_xfer *xfer, int flag);
+void usbd_xfer_clr_flag(struct usb_xfer *xfer, int flag);
+
+void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset,
+ const void *ptr, usb_frlength_t len);
+int usbd_copy_in_user(struct usb_page_cache *cache, usb_frlength_t offset,
+ const void *ptr, usb_frlength_t len);
+void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset,
+ void *ptr, usb_frlength_t len);
+int usbd_copy_out_user(struct usb_page_cache *cache, usb_frlength_t offset,
+ void *ptr, usb_frlength_t len);
+void usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
+ struct usb_page_search *res);
+void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset,
+ struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len);
+void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset,
+ usb_frlength_t len);
+
+int usb_fifo_attach(struct usb_device *udev, void *priv_sc,
+ struct mtx *priv_mtx, struct usb_fifo_methods *pm,
+ struct usb_fifo_sc *f_sc, uint16_t unit, uint16_t subunit,
+ uint8_t iface_index, uid_t uid, gid_t gid, int mode);
+void usb_fifo_detach(struct usb_fifo_sc *f_sc);
+int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize,
+ uint16_t nbuf);
+void usb_fifo_free_buffer(struct usb_fifo *f);
+uint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo);
+void usb_fifo_put_data(struct usb_fifo *fifo, struct usb_page_cache *pc,
+ usb_frlength_t offset, usb_frlength_t len, uint8_t what);
+void usb_fifo_put_data_linear(struct usb_fifo *fifo, void *ptr,
+ usb_size_t len, uint8_t what);
+uint8_t usb_fifo_put_data_buffer(struct usb_fifo *f, void *ptr, usb_size_t len);
+void usb_fifo_put_data_error(struct usb_fifo *fifo);
+uint8_t usb_fifo_get_data(struct usb_fifo *fifo, struct usb_page_cache *pc,
+ usb_frlength_t offset, usb_frlength_t len, usb_frlength_t *actlen,
+ uint8_t what);
+uint8_t usb_fifo_get_data_linear(struct usb_fifo *fifo, void *ptr,
+ usb_size_t len, usb_size_t *actlen, uint8_t what);
+uint8_t usb_fifo_get_data_buffer(struct usb_fifo *f, void **pptr,
+ usb_size_t *plen);
+void usb_fifo_reset(struct usb_fifo *f);
+void usb_fifo_wakeup(struct usb_fifo *f);
+void usb_fifo_get_data_error(struct usb_fifo *fifo);
+void *usb_fifo_softc(struct usb_fifo *fifo);
+#endif /* _KERNEL */
+#endif /* _USB_USBDI_H_ */
diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h
new file mode 100644
index 000000000000..bb6e324ab97e
--- /dev/null
+++ b/sys/dev/usb/usbdi_util.h
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2009 Andrew Thompson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _USB_USBDI_UTIL_H_
+#define _USB_USBDI_UTIL_H_
+
+struct cv;
+
+/* structures */
+
+struct usb_idesc_parse_state {
+ struct usb_descriptor *desc;
+ uint8_t iface_index; /* current interface index */
+ uint8_t iface_no_last;
+ uint8_t iface_index_alt; /* current alternate setting */
+};
+
+/* prototypes */
+
+usb_error_t usbd_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
+ struct usb_device_request *req, void *data, uint16_t flags,
+ uint16_t *actlen, usb_timeout_t timeout);
+
+struct usb_descriptor *usb_desc_foreach(struct usb_config_descriptor *cd,
+ struct usb_descriptor *desc);
+struct usb_interface_descriptor *usb_idesc_foreach(
+ struct usb_config_descriptor *cd,
+ struct usb_idesc_parse_state *ps);
+struct usb_endpoint_descriptor *usb_edesc_foreach(
+ struct usb_config_descriptor *cd,
+ struct usb_endpoint_descriptor *ped);
+uint8_t usbd_get_no_descriptors(struct usb_config_descriptor *cd,
+ uint8_t type);
+uint8_t usbd_get_no_alts(struct usb_config_descriptor *cd,
+ struct usb_interface_descriptor *id);
+
+usb_error_t usbd_req_get_report(struct usb_device *udev, struct mtx *mtx,
+ void *data, uint16_t len, uint8_t iface_index, uint8_t type,
+ uint8_t id);
+usb_error_t usbd_req_get_report_descriptor(struct usb_device *udev,
+ struct mtx *mtx, void *d, uint16_t size,
+ uint8_t iface_index);
+usb_error_t usbd_req_get_string_any(struct usb_device *udev, struct mtx *mtx,
+ char *buf, uint16_t len, uint8_t string_index);
+usb_error_t usbd_req_get_string_desc(struct usb_device *udev, struct mtx *mtx,
+ void *sdesc, uint16_t max_len, uint16_t lang_id,
+ uint8_t string_index);
+usb_error_t usbd_req_set_config(struct usb_device *udev, struct mtx *mtx,
+ uint8_t conf);
+usb_error_t usbd_req_set_alt_interface_no(struct usb_device *udev,
+ struct mtx *mtx, uint8_t iface_index, uint8_t alt_no);
+usb_error_t usbd_req_set_idle(struct usb_device *udev, struct mtx *mtx,
+ uint8_t iface_index, uint8_t duration, uint8_t id);
+usb_error_t usbd_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
+ uint8_t iface_index, uint16_t report);
+usb_error_t usbd_req_set_report(struct usb_device *udev, struct mtx *mtx,
+ void *data, uint16_t len, uint8_t iface_index,
+ uint8_t type, uint8_t id);
+#endif /* _USB_USBDI_UTIL_H_ */
diff --git a/sys/dev/usb/usbhid.h b/sys/dev/usb/usbhid.h
index 591a3b2e8efa..4c5f3132b31e 100644
--- a/sys/dev/usb/usbhid.h
+++ b/sys/dev/usb/usbhid.h
@@ -173,4 +173,67 @@ struct usb_hid_descriptor {
#define HIO_VOLATILE 0x080
#define HIO_BUFBYTES 0x100
+#ifdef _KERNEL
+struct usb_config_descriptor;
+
+enum hid_kind {
+ hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
+};
+
+struct hid_location {
+ uint32_t size;
+ uint32_t count;
+ uint32_t pos;
+};
+
+struct hid_item {
+ /* Global */
+ int32_t _usage_page;
+ int32_t logical_minimum;
+ int32_t logical_maximum;
+ int32_t physical_minimum;
+ int32_t physical_maximum;
+ int32_t unit_exponent;
+ int32_t unit;
+ int32_t report_ID;
+ /* Local */
+ int32_t usage;
+ int32_t usage_minimum;
+ int32_t usage_maximum;
+ int32_t designator_index;
+ int32_t designator_minimum;
+ int32_t designator_maximum;
+ int32_t string_index;
+ int32_t string_minimum;
+ int32_t string_maximum;
+ int32_t set_delimiter;
+ /* Misc */
+ int32_t collection;
+ int collevel;
+ enum hid_kind kind;
+ uint32_t flags;
+ /* Location */
+ struct hid_location loc;
+};
+
+/* prototypes from "usb_hid.c" */
+
+struct hid_data *hid_start_parse(const void *d, usb_size_t len, int kindset);
+void hid_end_parse(struct hid_data *s);
+int hid_get_item(struct hid_data *s, struct hid_item *h);
+int hid_report_size(const void *buf, usb_size_t len, enum hid_kind k,
+ uint8_t *id);
+int hid_locate(const void *desc, usb_size_t size, uint32_t usage,
+ enum hid_kind kind, uint8_t index, struct hid_location *loc,
+ uint32_t *flags, uint8_t *id);
+uint32_t hid_get_data(const uint8_t *buf, usb_size_t len,
+ struct hid_location *loc);
+int hid_is_collection(const void *desc, usb_size_t size, uint32_t usage);
+struct usb_hid_descriptor *hid_get_descriptor_from_usb(
+ struct usb_config_descriptor *cd,
+ struct usb_interface_descriptor *id);
+usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx,
+ void **descp, uint16_t *sizep, struct malloc_type *mem,
+ uint8_t iface_index);
+#endif /* _KERNEL */
#endif /* _USB_HID_H_ */
diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c
index 799abebfa28f..7abd10473f5e 100644
--- a/sys/dev/usb/wlan/if_rum.c
+++ b/sys/dev/usb/wlan/if_rum.c
@@ -66,18 +66,13 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_amrr.h>
-#define USB_DEBUG_VAR rum_debug
-
#include <dev/usb/usb.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
+#define USB_DEBUG_VAR rum_debug
+#include <dev/usb/usb_debug.h>
+
#include <dev/usb/wlan/if_rumreg.h>
#include <dev/usb/wlan/if_rumvar.h>
#include <dev/usb/wlan/if_rumfw.h>
@@ -764,23 +759,27 @@ rum_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
}
static void
-rum_bulk_write_callback(struct usb_xfer *xfer)
+rum_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct rum_softc *sc = xfer->priv_sc;
+ struct rum_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211vap *vap;
struct rum_tx_data *data;
struct mbuf *m;
+ struct usb_page_cache *pc;
unsigned int len;
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(11, "transfer complete, %d bytes\n", xfer->actlen);
+ DPRINTFN(11, "transfer complete, %d bytes\n", actlen);
/* free resources */
- data = xfer->priv_fifo;
+ data = usbd_xfer_get_priv(xfer);
rum_tx_free(data, 0);
- xfer->priv_fifo = NULL;
+ usbd_xfer_set_priv(xfer, NULL);
ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
@@ -798,10 +797,10 @@ tr_setup:
m->m_pkthdr.len);
m->m_pkthdr.len = (MCLBYTES + RT2573_TX_DESC_SIZE);
}
- usbd_copy_in(xfer->frbuffers, 0, &data->desc,
- RT2573_TX_DESC_SIZE);
- usbd_m_copy_in(xfer->frbuffers, RT2573_TX_DESC_SIZE, m,
- 0, m->m_pkthdr.len);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &data->desc, RT2573_TX_DESC_SIZE);
+ usbd_m_copy_in(pc, RT2573_TX_DESC_SIZE, m, 0,
+ m->m_pkthdr.len);
vap = data->ni->ni_vap;
if (ieee80211_radiotap_active_vap(vap)) {
@@ -822,8 +821,8 @@ tr_setup:
DPRINTFN(11, "sending frame len=%u xferlen=%u\n",
m->m_pkthdr.len, len);
- xfer->frlengths[0] = len;
- xfer->priv_fifo = data;
+ usbd_xfer_set_frame_len(xfer, 0, len);
+ usbd_xfer_set_priv(xfer, data);
usbd_transfer_submit(xfer);
}
@@ -831,44 +830,46 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- data = xfer->priv_fifo;
+ data = usbd_xfer_get_priv(xfer);
if (data != NULL) {
- rum_tx_free(data, xfer->error);
- xfer->priv_fifo = NULL;
+ rum_tx_free(data, error);
+ usbd_xfer_set_priv(xfer, NULL);
}
- if (xfer->error == USB_ERR_STALLED) {
+ if (error == USB_ERR_STALLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
- if (xfer->error == USB_ERR_TIMEOUT)
+ if (error == USB_ERR_TIMEOUT)
device_printf(sc->sc_dev, "device timeout\n");
break;
}
}
static void
-rum_bulk_read_callback(struct usb_xfer *xfer)
+rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct rum_softc *sc = xfer->priv_sc;
+ struct rum_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_node *ni;
struct mbuf *m = NULL;
+ struct usb_page_cache *pc;
uint32_t flags;
uint8_t rssi = 0;
- unsigned int len;
+ int len;
+
+ usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(15, "rx done, actlen=%d\n", xfer->actlen);
+ DPRINTFN(15, "rx done, actlen=%d\n", len);
- len = xfer->actlen;
if (len < RT2573_RX_DESC_SIZE + IEEE80211_MIN_LEN) {
DPRINTF("%s: xfer too short %d\n",
device_get_nameunit(sc->sc_dev), len);
@@ -877,8 +878,8 @@ rum_bulk_read_callback(struct usb_xfer *xfer)
}
len -= RT2573_RX_DESC_SIZE;
- usbd_copy_out(xfer->frbuffers, 0, &sc->sc_rx_desc,
- RT2573_RX_DESC_SIZE);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, &sc->sc_rx_desc, RT2573_RX_DESC_SIZE);
rssi = rum_get_rssi(sc, sc->sc_rx_desc.rssi);
flags = le32toh(sc->sc_rx_desc.flags);
@@ -899,7 +900,7 @@ rum_bulk_read_callback(struct usb_xfer *xfer)
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, RT2573_RX_DESC_SIZE,
+ usbd_copy_out(pc, RT2573_RX_DESC_SIZE,
mtod(m, uint8_t *), len);
/* finalize mbuf */
@@ -921,7 +922,7 @@ rum_bulk_read_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -945,9 +946,9 @@ tr_setup:
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -2011,7 +2012,7 @@ rum_init_locked(struct rum_softc *sc)
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
ifp->if_drv_flags |= IFF_DRV_RUNNING;
- usbd_transfer_set_stall(sc->sc_xfer[RUM_BULK_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[RUM_BULK_WR]);
usbd_transfer_start(sc->sc_xfer[RUM_BULK_RD]);
return;
diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c
index bc1531f71751..b9d549639f82 100644
--- a/sys/dev/usb/wlan/if_uath.c
+++ b/sys/dev/usb/wlan/if_uath.c
@@ -105,12 +105,7 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_radiotap.h>
#include <dev/usb/usb.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
#include <dev/usb/wlan/if_uathreg.h>
@@ -2401,10 +2396,14 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd)
}
static void
-uath_intr_rx_callback(struct usb_xfer *xfer)
+uath_intr_rx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct uath_cmd *cmd;
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
UATH_ASSERT_LOCKED(sc);
@@ -2418,18 +2417,19 @@ uath_intr_rx_callback(struct usb_xfer *xfer)
STAILQ_INSERT_TAIL(&sc->sc_cmd_inactive, cmd, next);
UATH_STAT_INC(sc, st_cmd_inactive);
- KASSERT(xfer->actlen >= sizeof(struct uath_cmd_hdr),
+ KASSERT(actlen >= sizeof(struct uath_cmd_hdr),
("short xfer error"));
- usbd_copy_out(xfer->frbuffers, 0, cmd->buf, xfer->actlen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, cmd->buf, actlen);
uath_cmdeof(sc, cmd);
case USB_ST_SETUP:
setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
default:
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
goto setup;
}
break;
@@ -2437,9 +2437,9 @@ setup:
}
static void
-uath_intr_tx_callback(struct usb_xfer *xfer)
+uath_intr_tx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct uath_cmd *cmd;
UATH_ASSERT_LOCKED(sc);
@@ -2475,13 +2475,12 @@ setup:
else
UATH_STAT_INC(sc, st_cmd_active);
- usbd_set_frame_data(xfer, cmd->buf, 0);
- xfer->frlengths[0] = cmd->buflen;
+ usbd_xfer_set_frame_data(xfer, 0, cmd->buf, cmd->buflen);
usbd_transfer_submit(xfer);
break;
default:
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
goto setup;
}
break;
@@ -2526,17 +2525,20 @@ static struct mbuf *
uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
struct uath_rx_desc **pdesc)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct uath_chunk *chunk;
struct uath_rx_desc *desc;
struct mbuf *m = data->m, *mnew, *mp;
uint16_t chunklen;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
- if (xfer->actlen < UATH_MIN_RXBUFSZ) {
+ if (actlen < UATH_MIN_RXBUFSZ) {
DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
- "%s: wrong xfer size (len=%d)\n", __func__, xfer->actlen);
+ "%s: wrong xfer size (len=%d)\n", __func__, actlen);
ifp->if_ierrors++;
return (NULL);
}
@@ -2694,9 +2696,9 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
}
static void
-uath_bulk_rx_callback(struct usb_xfer *xfer)
+uath_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_frame *wh;
@@ -2728,8 +2730,8 @@ setup:
UATH_STAT_DEC(sc, st_rx_inactive);
STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
UATH_STAT_INC(sc, st_rx_active);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf,
+ usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -2770,8 +2772,8 @@ setup:
STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
UATH_STAT_INC(sc, st_rx_inactive);
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
ifp->if_ierrors++;
goto setup;
}
@@ -2782,7 +2784,7 @@ setup:
static void
uath_data_txeof(struct usb_xfer *xfer, struct uath_data *data)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
@@ -2813,9 +2815,9 @@ uath_data_txeof(struct usb_xfer *xfer, struct uath_data *data)
}
static void
-uath_bulk_tx_callback(struct usb_xfer *xfer)
+uath_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct uath_softc *sc = xfer->priv_sc;
+ struct uath_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct uath_data *data;
@@ -2845,8 +2847,7 @@ setup:
STAILQ_INSERT_TAIL(&sc->sc_tx_active, data, next);
UATH_STAT_INC(sc, st_tx_active);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = data->buflen;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
usbd_transfer_submit(xfer);
UATH_UNLOCK(sc);
@@ -2863,8 +2864,8 @@ setup:
data->ni = NULL;
ifp->if_oerrors++;
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
goto setup;
}
break;
diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c
index b7e697c21ea9..9ab02a731c04 100644
--- a/sys/dev/usb/wlan/if_upgt.c
+++ b/sys/dev/usb/wlan/if_upgt.c
@@ -48,12 +48,7 @@
#include <net/bpf.h>
#include <dev/usb/usb.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
#include <dev/usb/wlan/if_upgtvar.h>
@@ -393,7 +388,7 @@ fail1: mtx_destroy(&sc->sc_mtx);
static void
upgt_txeof(struct usb_xfer *xfer, struct upgt_data *data)
{
- struct upgt_softc *sc = xfer->priv_sc;
+ struct upgt_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
@@ -1386,15 +1381,18 @@ static struct mbuf *
upgt_rxeof(struct usb_xfer *xfer, struct upgt_data *data, int *rssi)
{
struct mbuf *m = NULL;
- struct upgt_softc *sc = xfer->priv_sc;
+ struct upgt_softc *sc = usbd_xfer_softc(xfer);
struct upgt_lmac_header *header;
struct upgt_lmac_eeprom *eeprom;
uint8_t h1_type;
uint16_t h2_type;
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
UPGT_ASSERT_LOCKED(sc);
- if (xfer->actlen < 1)
+ if (actlen < 1)
return (NULL);
/* Check only at the very beginning. */
@@ -1405,7 +1403,7 @@ upgt_rxeof(struct usb_xfer *xfer, struct upgt_data *data, int *rssi)
return (NULL);
}
- if (xfer->actlen < UPGT_RX_MINSZ)
+ if (actlen < UPGT_RX_MINSZ)
return (NULL);
/*
@@ -2244,9 +2242,9 @@ done:
}
static void
-upgt_bulk_rx_callback(struct usb_xfer *xfer)
+upgt_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct upgt_softc *sc = xfer->priv_sc;
+ struct upgt_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_frame *wh;
@@ -2274,8 +2272,8 @@ setup:
return;
STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next);
STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf,
+ usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -2306,8 +2304,8 @@ setup:
STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
ifp->if_ierrors++;
goto setup;
}
@@ -2316,9 +2314,9 @@ setup:
}
static void
-upgt_bulk_tx_callback(struct usb_xfer *xfer)
+upgt_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct upgt_softc *sc = xfer->priv_sc;
+ struct upgt_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct upgt_data *data;
@@ -2347,8 +2345,7 @@ setup:
STAILQ_INSERT_TAIL(&sc->sc_tx_active, data, next);
UPGT_STAT_INC(sc, st_tx_active);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = data->buflen;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
usbd_transfer_submit(xfer);
UPGT_UNLOCK(sc);
upgt_start(ifp);
@@ -2363,8 +2360,8 @@ setup:
data->ni = NULL;
ifp->if_oerrors++;
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
goto setup;
}
break;
diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c
index f450e31566ec..f9a90a2a7b77 100644
--- a/sys/dev/usb/wlan/if_ural.c
+++ b/sys/dev/usb/wlan/if_ural.c
@@ -68,18 +68,12 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_amrr.h>
-#define USB_DEBUG_VAR ural_debug
-
#include <dev/usb/usb.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
+#define USB_DEBUG_VAR ural_debug
+#include <dev/usb/usb_debug.h>
#include <dev/usb/wlan/if_uralreg.h>
#include <dev/usb/wlan/if_uralvar.h>
@@ -777,23 +771,26 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
static void
-ural_bulk_write_callback(struct usb_xfer *xfer)
+ural_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ural_softc *sc = xfer->priv_sc;
+ struct ural_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211vap *vap;
struct ural_tx_data *data;
struct mbuf *m;
- unsigned int len;
+ struct usb_page_cache *pc;
+ int len;
+
+ usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(11, "transfer complete, %d bytes\n", xfer->actlen);
+ DPRINTFN(11, "transfer complete, %d bytes\n", len);
/* free resources */
- data = xfer->priv_fifo;
+ data = usbd_xfer_get_priv(xfer);
ural_tx_free(data, 0);
- xfer->priv_fifo = NULL;
+ usbd_xfer_set_priv(xfer, NULL);
ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
@@ -811,9 +808,9 @@ tr_setup:
m->m_pkthdr.len);
m->m_pkthdr.len = (RAL_FRAME_SIZE + RAL_TX_DESC_SIZE);
}
- usbd_copy_in(xfer->frbuffers, 0, &data->desc,
- RAL_TX_DESC_SIZE);
- usbd_m_copy_in(xfer->frbuffers, RAL_TX_DESC_SIZE, m, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &data->desc, RAL_TX_DESC_SIZE);
+ usbd_m_copy_in(pc, RAL_TX_DESC_SIZE, m, 0,
m->m_pkthdr.len);
vap = data->ni->ni_vap;
@@ -835,8 +832,8 @@ tr_setup:
DPRINTFN(11, "sending frame len=%u xferlen=%u\n",
m->m_pkthdr.len, len);
- xfer->frlengths[0] = len;
- xfer->priv_fifo = data;
+ usbd_xfer_set_frame_len(xfer, 0, len);
+ usbd_xfer_set_priv(xfer, data);
usbd_transfer_submit(xfer);
}
@@ -844,44 +841,46 @@ tr_setup:
default: /* Error */
DPRINTFN(11, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- data = xfer->priv_fifo;
+ data = usbd_xfer_get_priv(xfer);
if (data != NULL) {
- ural_tx_free(data, xfer->error);
- xfer->priv_fifo = NULL;
+ ural_tx_free(data, error);
+ usbd_xfer_set_priv(xfer, NULL);
}
- if (xfer->error == USB_ERR_STALLED) {
+ if (error == USB_ERR_STALLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
- if (xfer->error == USB_ERR_TIMEOUT)
+ if (error == USB_ERR_TIMEOUT)
device_printf(sc->sc_dev, "device timeout\n");
break;
}
}
static void
-ural_bulk_read_callback(struct usb_xfer *xfer)
+ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct ural_softc *sc = xfer->priv_sc;
+ struct ural_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_node *ni;
struct mbuf *m = NULL;
+ struct usb_page_cache *pc;
uint32_t flags;
int8_t rssi = 0, nf = 0;
- unsigned int len;
+ int len;
+
+ usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTFN(15, "rx done, actlen=%d\n", xfer->actlen);
+ DPRINTFN(15, "rx done, actlen=%d\n", len);
- len = xfer->actlen;
if (len < RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN) {
DPRINTF("%s: xfer too short %d\n",
device_get_nameunit(sc->sc_dev), len);
@@ -891,8 +890,8 @@ ural_bulk_read_callback(struct usb_xfer *xfer)
len -= RAL_RX_DESC_SIZE;
/* rx descriptor is located at the end */
- usbd_copy_out(xfer->frbuffers, len, &sc->sc_rx_desc,
- RAL_RX_DESC_SIZE);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, len, &sc->sc_rx_desc, RAL_RX_DESC_SIZE);
rssi = URAL_RSSI(sc->sc_rx_desc.rssi);
nf = RAL_NOISE_FLOOR;
@@ -914,7 +913,7 @@ ural_bulk_read_callback(struct usb_xfer *xfer)
ifp->if_ierrors++;
goto tr_setup;
}
- usbd_copy_out(xfer->frbuffers, 0, mtod(m, uint8_t *), len);
+ usbd_copy_out(pc, 0, mtod(m, uint8_t *), len);
/* finalize mbuf */
m->m_pkthdr.rcvif = ifp;
@@ -938,7 +937,7 @@ ural_bulk_read_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -960,9 +959,9 @@ tr_setup:
return;
default: /* Error */
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
return;
@@ -2120,7 +2119,7 @@ ural_init_locked(struct ural_softc *sc)
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
ifp->if_drv_flags |= IFF_DRV_RUNNING;
- usbd_transfer_set_stall(sc->sc_xfer[URAL_BULK_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[URAL_BULK_WR]);
usbd_transfer_start(sc->sc_xfer[URAL_BULK_RD]);
return;
diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c
index 30b14d371dfb..0f8fe4434551 100644
--- a/sys/dev/usb/wlan/if_urtw.c
+++ b/sys/dev/usb/wlan/if_urtw.c
@@ -55,13 +55,7 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_radiotap.h>
#include <dev/usb/usb.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
#include "usbdevs.h"
#include <dev/usb/wlan/if_urtwreg.h>
@@ -3944,7 +3938,8 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
struct ieee80211com *ic = ifp->if_l2com;
uint8_t *desc, quality = 0, rate;
- actlen = xfer->actlen;
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
+
if (actlen < URTW_MIN_RXBUFSZ) {
ifp->if_ierrors++;
return (NULL);
@@ -4023,9 +4018,9 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
}
static void
-urtw_bulk_rx_callback(struct usb_xfer *xfer)
+urtw_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urtw_softc *sc = xfer->priv_sc;
+ struct urtw_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_frame *wh;
@@ -4055,8 +4050,8 @@ setup:
}
STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next);
STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf,
+ usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -4086,8 +4081,8 @@ setup:
STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
ifp->if_ierrors++;
goto setup;
}
@@ -4098,7 +4093,7 @@ setup:
static void
urtw_txeof(struct usb_xfer *xfer, struct urtw_data *data)
{
- struct urtw_softc *sc = xfer->priv_sc;
+ struct urtw_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
@@ -4127,9 +4122,9 @@ urtw_txeof(struct usb_xfer *xfer, struct urtw_data *data)
}
static void
-urtw_bulk_tx_callback(struct usb_xfer *xfer)
+urtw_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct urtw_softc *sc = xfer->priv_sc;
+ struct urtw_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct urtw_data *data;
@@ -4155,8 +4150,7 @@ setup:
STAILQ_REMOVE_HEAD(&sc->sc_tx_pending, next);
STAILQ_INSERT_TAIL(&sc->sc_tx_active, data, next);
- usbd_set_frame_data(xfer, data->buf, 0);
- xfer->frlengths[0] = data->buflen;
+ usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
usbd_transfer_submit(xfer);
URTW_UNLOCK(sc);
@@ -4172,8 +4166,8 @@ setup:
data->ni = NULL;
ifp->if_oerrors++;
}
- if (xfer->error != USB_ERR_CANCELLED) {
- xfer->flags.stall_pipe = 1;
+ if (error != USB_ERR_CANCELLED) {
+ usbd_xfer_set_stall(xfer);
goto setup;
}
break;
diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c
index 8627d8112ec2..bdc9b2d0e920 100644
--- a/sys/dev/usb/wlan/if_zyd.c
+++ b/sys/dev/usb/wlan/if_zyd.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/lock.h>
#include <sys/mutex.h>
+#include <sys/condvar.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
@@ -67,13 +68,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_amrr.h>
#include <dev/usb/usb.h>
-#include <dev/usb/usb_error.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_lookup.h>
-#include <dev/usb/usb_debug.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_util.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
#include <dev/usb/wlan/if_zydreg.h>
@@ -632,19 +628,24 @@ fail:
* Callback handler for interrupt transfer
*/
static void
-zyd_intr_read_callback(struct usb_xfer *xfer)
+zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct zyd_softc *sc = xfer->priv_sc;
+ struct zyd_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
struct ieee80211_node *ni;
struct zyd_cmd *cmd = &sc->sc_ibuf;
+ struct usb_page_cache *pc;
int datalen;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- usbd_copy_out(xfer->frbuffers, 0, cmd, sizeof(*cmd));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, 0, cmd, sizeof(*cmd));
switch (le16toh(cmd->code)) {
case ZYD_NOTIF_RETRYSTATUS:
@@ -680,7 +681,7 @@ zyd_intr_read_callback(struct usb_xfer *xfer)
if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT)
break; /* HMAC interrupt */
- datalen = xfer->actlen - sizeof(cmd->code);
+ datalen = actlen - sizeof(cmd->code);
datalen -= 2; /* XXX: padding? */
STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) {
@@ -719,17 +720,17 @@ zyd_intr_read_callback(struct usb_xfer *xfer)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
break;
default: /* Error */
DPRINTF(sc, ZYD_DEBUG_CMD, "error = %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -737,18 +738,19 @@ tr_setup:
}
static void
-zyd_intr_write_callback(struct usb_xfer *xfer)
+zyd_intr_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct zyd_softc *sc = xfer->priv_sc;
- struct zyd_rq *rqp;
+ struct zyd_softc *sc = usbd_xfer_softc(xfer);
+ struct zyd_rq *rqp, *cmd;
+ struct usb_page_cache *pc;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- DPRINTF(sc, ZYD_DEBUG_CMD, "command %p transferred\n",
- xfer->priv_fifo);
+ cmd = usbd_xfer_get_priv(xfer);
+ DPRINTF(sc, ZYD_DEBUG_CMD, "command %p transferred\n", cmd);
STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) {
/* Ensure the cached rq pointer is still valid */
- if (rqp == xfer->priv_fifo &&
+ if (rqp == cmd &&
(rqp->flags & ZYD_CMD_FLAG_READ) == 0)
wakeup(rqp); /* wakeup caller */
}
@@ -760,10 +762,11 @@ tr_setup:
if (rqp->flags & ZYD_CMD_FLAG_SENT)
continue;
- usbd_copy_in(xfer->frbuffers, 0, rqp->cmd, rqp->ilen);
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, rqp->cmd, rqp->ilen);
- xfer->frlengths[0] = rqp->ilen;
- xfer->priv_fifo = rqp;
+ usbd_xfer_set_frame_len(xfer, 0, rqp->ilen);
+ usbd_xfer_set_priv(xfer, rqp);
rqp->flags |= ZYD_CMD_FLAG_SENT;
usbd_transfer_submit(xfer);
break;
@@ -772,11 +775,11 @@ tr_setup:
default: /* Error */
DPRINTF(sc, ZYD_DEBUG_ANY, "error = %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -2165,11 +2168,12 @@ fail:
static void
zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
{
- struct zyd_softc *sc = xfer->priv_sc;
+ struct zyd_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct zyd_plcphdr plcp;
struct zyd_rx_stat stat;
+ struct usb_page_cache *pc;
struct mbuf *m;
int rlen, rssi;
@@ -2179,9 +2183,9 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
ifp->if_ierrors++;
return;
}
- usbd_copy_out(xfer->frbuffers, offset, &plcp, sizeof(plcp));
- usbd_copy_out(xfer->frbuffers, offset + len - sizeof(stat),
- &stat, sizeof(stat));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, offset, &plcp, sizeof(plcp));
+ usbd_copy_out(pc, offset + len - sizeof(stat), &stat, sizeof(stat));
if (stat.flags & ZYD_RX_ERROR) {
DPRINTF(sc, ZYD_DEBUG_RECV,
@@ -2213,8 +2217,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
}
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = rlen;
- usbd_copy_out(xfer->frbuffers, offset + sizeof(plcp),
- mtod(m, uint8_t *), rlen);
+ usbd_copy_out(pc, offset + sizeof(plcp), mtod(m, uint8_t *), rlen);
if (ieee80211_radiotap_active(ic)) {
struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap;
@@ -2239,24 +2242,28 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
}
static void
-zyd_bulk_read_callback(struct usb_xfer *xfer)
+zyd_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct zyd_softc *sc = xfer->priv_sc;
+ struct zyd_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211_node *ni;
struct zyd_rx_desc desc;
struct mbuf *m;
+ struct usb_page_cache *pc;
uint32_t offset;
uint8_t rssi;
int8_t nf;
int i;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
sc->sc_rx_count = 0;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
- usbd_copy_out(xfer->frbuffers, xfer->actlen - sizeof(desc),
- &desc, sizeof(desc));
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_out(pc, actlen - sizeof(desc), &desc, sizeof(desc));
offset = 0;
if (UGETW(desc.tag) == ZYD_TAG_MULTIFRAME) {
@@ -2266,7 +2273,7 @@ zyd_bulk_read_callback(struct usb_xfer *xfer)
for (i = 0; i < ZYD_MAX_RXFRAMECNT; i++) {
uint16_t len16 = UGETW(desc.len[i]);
- if (len16 == 0 || len16 > xfer->actlen)
+ if (len16 == 0 || len16 > actlen)
break;
zyd_rx_data(xfer, offset, len16);
@@ -2274,20 +2281,20 @@ zyd_bulk_read_callback(struct usb_xfer *xfer)
/* next frame is aligned on a 32-bit boundary */
len16 = (len16 + 3) & ~3;
offset += len16;
- if (len16 > xfer->actlen)
+ if (len16 > actlen)
break;
- xfer->actlen -= len16;
+ actlen -= len16;
}
} else {
DPRINTF(sc, ZYD_DEBUG_RECV,
"%s: received single-frame transfer\n", __func__);
- zyd_rx_data(xfer, 0, xfer->actlen);
+ zyd_rx_data(xfer, 0, actlen);
}
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
- xfer->frlengths[0] = xfer->max_data_length;
+ usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
usbd_transfer_submit(xfer);
/*
@@ -2315,11 +2322,11 @@ tr_setup:
break;
default: /* Error */
- DPRINTF(sc, ZYD_DEBUG_ANY, "frame error: %s\n", usbd_errstr(xfer->error));
+ DPRINTF(sc, ZYD_DEBUG_ANY, "frame error: %s\n", usbd_errstr(error));
- if (xfer->error != USB_ERR_CANCELLED) {
+ if (error != USB_ERR_CANCELLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
break;
@@ -2363,23 +2370,27 @@ zyd_plcp_signal(struct zyd_softc *sc, int rate)
}
static void
-zyd_bulk_write_callback(struct usb_xfer *xfer)
+zyd_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
- struct zyd_softc *sc = xfer->priv_sc;
+ struct zyd_softc *sc = usbd_xfer_softc(xfer);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211vap *vap;
struct zyd_tx_data *data;
struct mbuf *m;
+ struct usb_page_cache *pc;
+ int actlen;
+
+ usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
DPRINTF(sc, ZYD_DEBUG_ANY, "transfer complete, %u bytes\n",
- xfer->actlen);
+ actlen);
/* free resources */
- data = xfer->priv_fifo;
+ data = usbd_xfer_get_priv(xfer);
zyd_tx_free(data, 0);
- xfer->priv_fifo = NULL;
+ usbd_xfer_set_priv(xfer, NULL);
ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
@@ -2397,9 +2408,9 @@ tr_setup:
m->m_pkthdr.len);
m->m_pkthdr.len = ZYD_MAX_TXBUFSZ;
}
- usbd_copy_in(xfer->frbuffers, 0, &data->desc,
- ZYD_TX_DESC_SIZE);
- usbd_m_copy_in(xfer->frbuffers, ZYD_TX_DESC_SIZE, m, 0,
+ pc = usbd_xfer_get_frame(xfer, 0);
+ usbd_copy_in(pc, 0, &data->desc, ZYD_TX_DESC_SIZE);
+ usbd_m_copy_in(pc, ZYD_TX_DESC_SIZE, m, 0,
m->m_pkthdr.len);
vap = data->ni->ni_vap;
@@ -2412,28 +2423,28 @@ tr_setup:
ieee80211_radiotap_tx(vap, m);
}
- xfer->frlengths[0] = ZYD_TX_DESC_SIZE + m->m_pkthdr.len;
- xfer->priv_fifo = data;
+ usbd_xfer_set_frame_len(xfer, 0, ZYD_TX_DESC_SIZE + m->m_pkthdr.len);
+ usbd_xfer_set_priv(xfer, data);
usbd_transfer_submit(xfer);
}
break;
default: /* Error */
DPRINTF(sc, ZYD_DEBUG_ANY, "transfer error, %s\n",
- usbd_errstr(xfer->error));
+ usbd_errstr(error));
ifp->if_oerrors++;
- data = xfer->priv_fifo;
- xfer->priv_fifo = NULL;
+ data = usbd_xfer_get_priv(xfer);
+ usbd_xfer_set_priv(xfer, NULL);
if (data != NULL)
- zyd_tx_free(data, xfer->error);
+ zyd_tx_free(data, error);
- if (xfer->error == USB_ERR_STALLED) {
+ if (error == USB_ERR_STALLED) {
/* try to clear stall first */
- xfer->flags.stall_pipe = 1;
+ usbd_xfer_set_stall(xfer);
goto tr_setup;
}
- if (xfer->error == USB_ERR_TIMEOUT)
+ if (error == USB_ERR_TIMEOUT)
device_printf(sc->sc_dev, "device timeout\n");
break;
}
@@ -2761,7 +2772,7 @@ zyd_init_locked(struct zyd_softc *sc)
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
ifp->if_drv_flags |= IFF_DRV_RUNNING;
- usbd_transfer_set_stall(sc->sc_xfer[ZYD_BULK_WR]);
+ usbd_xfer_set_stall(sc->sc_xfer[ZYD_BULK_WR]);
usbd_transfer_start(sc->sc_xfer[ZYD_BULK_RD]);
usbd_transfer_start(sc->sc_xfer[ZYD_INTR_RD]);