1215649Sweongyo/*-
2215649Sweongyo * Copyright (c) 1990, 1991, 1993
3215649Sweongyo *	The Regents of the University of California.  All rights reserved.
4215649Sweongyo *
5215649Sweongyo * This code is derived from the Stanford/CMU enet packet filter,
6215649Sweongyo * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7215649Sweongyo * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8215649Sweongyo * Berkeley Laboratory.
9215649Sweongyo *
10215649Sweongyo * Redistribution and use in source and binary forms, with or without
11215649Sweongyo * modification, are permitted provided that the following conditions
12215649Sweongyo * are met:
13215649Sweongyo * 1. Redistributions of source code must retain the above copyright
14215649Sweongyo *    notice, this list of conditions and the following disclaimer.
15215649Sweongyo * 2. Redistributions in binary form must reproduce the above copyright
16215649Sweongyo *    notice, this list of conditions and the following disclaimer in the
17215649Sweongyo *    documentation and/or other materials provided with the distribution.
18215649Sweongyo * 4. Neither the name of the University nor the names of its contributors
19215649Sweongyo *    may be used to endorse or promote products derived from this software
20215649Sweongyo *    without specific prior written permission.
21215649Sweongyo *
22215649Sweongyo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23215649Sweongyo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24215649Sweongyo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25215649Sweongyo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26215649Sweongyo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27215649Sweongyo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28215649Sweongyo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29215649Sweongyo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30215649Sweongyo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31215649Sweongyo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32215649Sweongyo * SUCH DAMAGE.
33215649Sweongyo *
34215649Sweongyo * $FreeBSD$
35215649Sweongyo */
36215649Sweongyo
37215649Sweongyo#ifndef _DEV_USB_PF_H
38215649Sweongyo#define	_DEV_USB_PF_H
39215649Sweongyo
40215649Sweongyostruct usbpf_pkthdr {
41220301Shselasky	uint32_t	up_totlen;	/* Total length including all headers */
42218165Shselasky	uint32_t	up_busunit;	/* Host controller unit number */
43220301Shselasky	uint8_t		up_address;	/* USB device index */
44220301Shselasky	uint8_t		up_mode;	/* Mode of transfer */
45220301Shselasky#define	USBPF_MODE_HOST		0
46220301Shselasky#define	USBPF_MODE_DEVICE	1
47218165Shselasky	uint8_t		up_type;	/* points SUBMIT / DONE */
48220301Shselasky	uint8_t		up_xfertype;	/* Transfer type, see USB2.0 spec. */
49218165Shselasky	uint32_t	up_flags;	/* Transfer flags */
50215649Sweongyo#define	USBPF_FLAG_FORCE_SHORT_XFER	(1 << 0)
51215649Sweongyo#define	USBPF_FLAG_SHORT_XFER_OK	(1 << 1)
52215649Sweongyo#define	USBPF_FLAG_SHORT_FRAMES_OK	(1 << 2)
53215649Sweongyo#define	USBPF_FLAG_PIPE_BOF		(1 << 3)
54215649Sweongyo#define	USBPF_FLAG_PROXY_BUFFER		(1 << 4)
55215649Sweongyo#define	USBPF_FLAG_EXT_BUFFER		(1 << 5)
56215649Sweongyo#define	USBPF_FLAG_MANUAL_STATUS	(1 << 6)
57215649Sweongyo#define	USBPF_FLAG_NO_PIPE_OK		(1 << 7)
58215649Sweongyo#define	USBPF_FLAG_STALL_PIPE		(1 << 8)
59218165Shselasky	uint32_t	up_status;	/* Transfer status */
60215649Sweongyo#define	USBPF_STATUS_OPEN		(1 << 0)
61215649Sweongyo#define	USBPF_STATUS_TRANSFERRING	(1 << 1)
62215649Sweongyo#define	USBPF_STATUS_DID_DMA_DELAY	(1 << 2)
63215649Sweongyo#define	USBPF_STATUS_DID_CLOSE		(1 << 3)
64215649Sweongyo#define	USBPF_STATUS_DRAINING		(1 << 4)
65215649Sweongyo#define	USBPF_STATUS_STARTED		(1 << 5)
66215649Sweongyo#define	USBPF_STATUS_BW_RECLAIMED	(1 << 6)
67215649Sweongyo#define	USBPF_STATUS_CONTROL_XFR	(1 << 7)
68215649Sweongyo#define	USBPF_STATUS_CONTROL_HDR	(1 << 8)
69215649Sweongyo#define	USBPF_STATUS_CONTROL_ACT	(1 << 9)
70215649Sweongyo#define	USBPF_STATUS_CONTROL_STALL	(1 << 10)
71215649Sweongyo#define	USBPF_STATUS_SHORT_FRAMES_OK	(1 << 11)
72215649Sweongyo#define	USBPF_STATUS_SHORT_XFER_OK	(1 << 12)
73215649Sweongyo#define	USBPF_STATUS_BDMA_ENABLE	(1 << 13)
74215649Sweongyo#define	USBPF_STATUS_BDMA_NO_POST_SYNC	(1 << 14)
75215649Sweongyo#define	USBPF_STATUS_BDMA_SETUP		(1 << 15)
76215649Sweongyo#define	USBPF_STATUS_ISOCHRONOUS_XFR	(1 << 16)
77215649Sweongyo#define	USBPF_STATUS_CURR_DMA_SET	(1 << 17)
78215649Sweongyo#define	USBPF_STATUS_CAN_CANCEL_IMMED	(1 << 18)
79215649Sweongyo#define	USBPF_STATUS_DOING_CALLBACK	(1 << 19)
80220301Shselasky	uint32_t	up_error;	/* USB error, see USB_ERR_XXX */
81220301Shselasky	uint32_t	up_interval;	/* For interrupt and isoc (ms) */
82220301Shselasky	uint32_t	up_frames;	/* Number of following frames */
83220301Shselasky	uint32_t	up_packet_size;	/* Packet size used */
84220301Shselasky	uint32_t	up_packet_count;	/* Packet count used */
85220301Shselasky	uint32_t	up_endpoint;	/* USB endpoint / stream ID */
86220301Shselasky	uint8_t		up_speed;	/* USB speed, see USB_SPEED_XXX */
87215649Sweongyo	/* sizeof(struct usbpf_pkthdr) == 128 bytes */
88220301Shselasky	uint8_t		up_reserved[83];
89215649Sweongyo};
90215649Sweongyo
91220301Shselaskystruct usbpf_framehdr {
92220301Shselasky	/*
93220301Shselasky	 * The frame length field excludes length of frame header and
94220301Shselasky	 * any alignment.
95220301Shselasky	 */
96220301Shselasky	uint32_t length;
97220301Shselasky#define	USBPF_FRAME_ALIGN(x)		(((x) + 3) & ~3)
98220301Shselasky	uint32_t flags;
99220301Shselasky#define	USBPF_FRAMEFLAG_READ		(1 << 0)
100220301Shselasky#define	USBPF_FRAMEFLAG_DATA_FOLLOWS	(1 << 1)
101220301Shselasky};
102215649Sweongyo
103220301Shselasky#define	USBPF_HDR_LEN		128	/* bytes */
104220301Shselasky#define	USBPF_FRAME_HDR_LEN	8	/* bytes */
105220301Shselasky
106220301Shselaskyextern uint8_t usbpf_pkthdr_size_ok[
107220301Shselasky    (sizeof(struct usbpf_pkthdr) == USBPF_HDR_LEN) ? 1 : -1];
108220301Shselaskyextern uint8_t usbpf_framehdr_size_ok[
109220301Shselasky    (sizeof(struct usbpf_framehdr) == USBPF_FRAME_HDR_LEN) ? 1 : -1];
110220301Shselasky
111215649Sweongyo#define	USBPF_XFERTAP_SUBMIT	0
112215649Sweongyo#define	USBPF_XFERTAP_DONE	1
113215649Sweongyo
114215649Sweongyo#ifdef _KERNEL
115215802Sweongyovoid	usbpf_attach(struct usb_bus *);
116215649Sweongyovoid	usbpf_detach(struct usb_bus *);
117215649Sweongyovoid	usbpf_xfertap(struct usb_xfer *, int);
118215649Sweongyo#endif
119215649Sweongyo
120215649Sweongyo#endif
121