usb_pf.h revision 218165
1/*-
2 * Copyright (c) 1990, 1991, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from the Stanford/CMU enet packet filter,
6 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8 * Berkeley Laboratory.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 4. Neither the name of the University nor the names of its contributors
19 *    may be used to endorse or promote products derived from this software
20 *    without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD: head/sys/dev/usb/usb_pf.h 218165 2011-02-01 10:25:48Z hselasky $
35 */
36
37#ifndef _DEV_USB_PF_H
38#define	_DEV_USB_PF_H
39
40struct usbpf_pkthdr {
41	uint32_t	up_busunit;	/* Host controller unit number */
42	uint8_t		up_address;	/* USB device address */
43	uint8_t		up_endpoint;	/* USB endpoint */
44	uint8_t		up_type;	/* points SUBMIT / DONE */
45	uint8_t		up_xfertype;	/* Transfer type */
46	uint32_t	up_flags;	/* Transfer flags */
47#define	USBPF_FLAG_FORCE_SHORT_XFER	(1 << 0)
48#define	USBPF_FLAG_SHORT_XFER_OK	(1 << 1)
49#define	USBPF_FLAG_SHORT_FRAMES_OK	(1 << 2)
50#define	USBPF_FLAG_PIPE_BOF		(1 << 3)
51#define	USBPF_FLAG_PROXY_BUFFER		(1 << 4)
52#define	USBPF_FLAG_EXT_BUFFER		(1 << 5)
53#define	USBPF_FLAG_MANUAL_STATUS	(1 << 6)
54#define	USBPF_FLAG_NO_PIPE_OK		(1 << 7)
55#define	USBPF_FLAG_STALL_PIPE		(1 << 8)
56	uint32_t	up_status;	/* Transfer status */
57#define	USBPF_STATUS_OPEN		(1 << 0)
58#define	USBPF_STATUS_TRANSFERRING	(1 << 1)
59#define	USBPF_STATUS_DID_DMA_DELAY	(1 << 2)
60#define	USBPF_STATUS_DID_CLOSE		(1 << 3)
61#define	USBPF_STATUS_DRAINING		(1 << 4)
62#define	USBPF_STATUS_STARTED		(1 << 5)
63#define	USBPF_STATUS_BW_RECLAIMED	(1 << 6)
64#define	USBPF_STATUS_CONTROL_XFR	(1 << 7)
65#define	USBPF_STATUS_CONTROL_HDR	(1 << 8)
66#define	USBPF_STATUS_CONTROL_ACT	(1 << 9)
67#define	USBPF_STATUS_CONTROL_STALL	(1 << 10)
68#define	USBPF_STATUS_SHORT_FRAMES_OK	(1 << 11)
69#define	USBPF_STATUS_SHORT_XFER_OK	(1 << 12)
70#if USB_HAVE_BUSDMA
71#define	USBPF_STATUS_BDMA_ENABLE	(1 << 13)
72#define	USBPF_STATUS_BDMA_NO_POST_SYNC	(1 << 14)
73#define	USBPF_STATUS_BDMA_SETUP		(1 << 15)
74#endif
75#define	USBPF_STATUS_ISOCHRONOUS_XFR	(1 << 16)
76#define	USBPF_STATUS_CURR_DMA_SET	(1 << 17)
77#define	USBPF_STATUS_CAN_CANCEL_IMMED	(1 << 18)
78#define	USBPF_STATUS_DOING_CALLBACK	(1 << 19)
79	uint32_t	up_length;	/* Total data length (submit/actual) */
80	uint32_t	up_frames;	/* USB frame number (submit/actual) */
81	uint32_t	up_error;	/* usb_error_t */
82	uint32_t	up_interval;	/* for interrupt and isoc */
83	/* sizeof(struct usbpf_pkthdr) == 128 bytes */
84	uint8_t		up_reserved[96];
85};
86
87#define	USBPF_HDR_LEN		128
88
89#define	USBPF_XFERTAP_SUBMIT	0
90#define	USBPF_XFERTAP_DONE	1
91
92#ifdef _KERNEL
93void	usbpf_attach(struct usb_bus *);
94void	usbpf_detach(struct usb_bus *);
95void	usbpf_xfertap(struct usb_xfer *, int);
96#endif
97
98#endif
99