xref: /netbsd-src/sys/dev/usb/if_urevar.h (revision f344de3effc4695d74387b8fc70009fd45bd6a6a)
1 /*	$NetBSD: if_urevar.h,v 1.5 2019/08/09 06:46:35 mrg Exp $	*/
2 
3 /*	$OpenBSD: if_urereg.h,v 1.5 2018/11/02 21:32:30 jcs Exp $	*/
4 /*-
5  * Copyright (c) 2015-2016 Kevin Lo <kevlo@FreeBSD.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 
32 struct ure_intrpkt {
33 	uint8_t	ure_tsr;
34 	uint8_t	ure_rsr;
35 	uint8_t	ure_gep_msr;
36 	uint8_t	ure_waksr;
37 	uint8_t	ure_txok_cnt;
38 	uint8_t	ure_rxlost_cnt;
39 	uint8_t	ure_crcerr_cnt;
40 	uint8_t	ure_col_cnt;
41 } __packed;
42 
43 struct ure_rxpkt {
44 	uint32_t ure_pktlen;
45 #define	URE_RXPKT_LEN_MASK	0x7fff
46 	uint32_t ure_csum;
47 #define URE_RXPKT_IPV4_CS	__BIT(19)
48 #define URE_RXPKT_IPV6_CS	__BIT(20)
49 #define URE_RXPKT_TCP_CS	__BIT(22)
50 #define URE_RXPKT_UDP_CS	__BIT(23)
51 	uint32_t ure_misc;
52 #define URE_RXPKT_RX_VLAN_TAG	__BIT(16)
53 #define URE_RXPKT_TCP_F		__BIT(21)
54 #define URE_RXPKT_UDP_F		__BIT(22)
55 #define URE_RXPKT_IP_F		__BIT(23)
56 	uint32_t ure_rsvd2;
57 	uint32_t ure_rsvd3;
58 	uint32_t ure_rsvd4;
59 } __packed;
60 
61 struct ure_txpkt {
62 	uint32_t ure_pktlen;
63 #define	URE_TXPKT_TX_FS		__BIT(31)
64 #define	URE_TXPKT_TX_LS		__BIT(30)
65 #define	URE_TXPKT_LEN_MASK	0xffff
66 	uint32_t ure_csum;
67 #define URE_L4_OFFSET_MAX	0x7ff
68 #define URE_L4_OFFSET_SHIFT	17
69 #define URE_TXPKT_IPV6_CS	__BIT(28)
70 #define URE_TXPKT_IPV4_CS	__BIT(29)
71 #define URE_TXPKT_TCP_CS	__BIT(30)
72 #define URE_TXPKT_UDP_CS	__BIT(31)
73 } __packed;
74 
75 #ifndef URE_TX_LIST_CNT
76 #define URE_TX_LIST_CNT		4
77 #endif
78 #ifndef URE_RX_LIST_CNT
79 #define URE_RX_LIST_CNT		4
80 #endif
81 
82 /* usbnet::un_flags values */
83 #define	URE_FLAG_VER_4C00	0x0001
84 #define	URE_FLAG_VER_4C10	0x0002
85 #define	URE_FLAG_VER_5C00	0x0004
86 #define	URE_FLAG_VER_5C10	0x0008
87 #define	URE_FLAG_VER_5C20	0x0010
88 #define	URE_FLAG_VER_5C30	0x0020
89 #define	URE_FLAG_8152		0x1000	/* RTL8152 */
90