if_urevar.h revision 1.2.4.2 1 1.2.4.2 christos /* $NetBSD: if_urevar.h,v 1.2.4.2 2019/06/10 22:07:34 christos Exp $ */
2 1.2.4.2 christos /* $OpenBSD: if_urereg.h,v 1.5 2018/11/02 21:32:30 jcs Exp $ */
3 1.2.4.2 christos /*-
4 1.2.4.2 christos * Copyright (c) 2015-2016 Kevin Lo <kevlo (at) FreeBSD.org>
5 1.2.4.2 christos * All rights reserved.
6 1.2.4.2 christos *
7 1.2.4.2 christos * Redistribution and use in source and binary forms, with or without
8 1.2.4.2 christos * modification, are permitted provided that the following conditions
9 1.2.4.2 christos * are met:
10 1.2.4.2 christos * 1. Redistributions of source code must retain the above copyright
11 1.2.4.2 christos * notice, this list of conditions and the following disclaimer.
12 1.2.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.4.2 christos * notice, this list of conditions and the following disclaimer in the
14 1.2.4.2 christos * documentation and/or other materials provided with the distribution.
15 1.2.4.2 christos *
16 1.2.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.2.4.2 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.2.4.2 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.2.4.2 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.2.4.2 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.2.4.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.2.4.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.2.4.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.2.4.2 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.2.4.2 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.2.4.2 christos * SUCH DAMAGE.
27 1.2.4.2 christos *
28 1.2.4.2 christos * $FreeBSD$
29 1.2.4.2 christos */
30 1.2.4.2 christos
31 1.2.4.2 christos struct ure_intrpkt {
32 1.2.4.2 christos uint8_t ure_tsr;
33 1.2.4.2 christos uint8_t ure_rsr;
34 1.2.4.2 christos uint8_t ure_gep_msr;
35 1.2.4.2 christos uint8_t ure_waksr;
36 1.2.4.2 christos uint8_t ure_txok_cnt;
37 1.2.4.2 christos uint8_t ure_rxlost_cnt;
38 1.2.4.2 christos uint8_t ure_crcerr_cnt;
39 1.2.4.2 christos uint8_t ure_col_cnt;
40 1.2.4.2 christos } __packed;
41 1.2.4.2 christos
42 1.2.4.2 christos struct ure_rxpkt {
43 1.2.4.2 christos uint32_t ure_pktlen;
44 1.2.4.2 christos #define URE_RXPKT_LEN_MASK 0x7fff
45 1.2.4.2 christos uint32_t ure_csum;
46 1.2.4.2 christos #define URE_RXPKT_IPV4_CS __BIT(19)
47 1.2.4.2 christos #define URE_RXPKT_IPV6_CS __BIT(20)
48 1.2.4.2 christos #define URE_RXPKT_TCP_CS __BIT(22)
49 1.2.4.2 christos #define URE_RXPKT_UDP_CS __BIT(23)
50 1.2.4.2 christos uint32_t ure_misc;
51 1.2.4.2 christos #define URE_RXPKT_RX_VLAN_TAG __BIT(16)
52 1.2.4.2 christos #define URE_RXPKT_TCP_F __BIT(21)
53 1.2.4.2 christos #define URE_RXPKT_UDP_F __BIT(22)
54 1.2.4.2 christos #define URE_RXPKT_IP_F __BIT(23)
55 1.2.4.2 christos uint32_t ure_rsvd2;
56 1.2.4.2 christos uint32_t ure_rsvd3;
57 1.2.4.2 christos uint32_t ure_rsvd4;
58 1.2.4.2 christos } __packed;
59 1.2.4.2 christos
60 1.2.4.2 christos struct ure_txpkt {
61 1.2.4.2 christos uint32_t ure_pktlen;
62 1.2.4.2 christos #define URE_TXPKT_TX_FS __BIT(31)
63 1.2.4.2 christos #define URE_TXPKT_TX_LS __BIT(30)
64 1.2.4.2 christos #define URE_TXPKT_LEN_MASK 0xffff
65 1.2.4.2 christos uint32_t ure_csum;
66 1.2.4.2 christos #define URE_L4_OFFSET_MAX 0x7ff
67 1.2.4.2 christos #define URE_L4_OFFSET_SHIFT 17
68 1.2.4.2 christos #define URE_TXPKT_IPV6_CS __BIT(28)
69 1.2.4.2 christos #define URE_TXPKT_IPV4_CS __BIT(29)
70 1.2.4.2 christos #define URE_TXPKT_TCP_CS __BIT(30)
71 1.2.4.2 christos #define URE_TXPKT_UDP_CS __BIT(31)
72 1.2.4.2 christos } __packed;
73 1.2.4.2 christos
74 1.2.4.2 christos #define URE_ENDPT_RX 0
75 1.2.4.2 christos #define URE_ENDPT_TX 1
76 1.2.4.2 christos #define URE_ENDPT_MAX 2
77 1.2.4.2 christos
78 1.2.4.2 christos #ifndef URE_TX_LIST_CNT
79 1.2.4.2 christos #define URE_TX_LIST_CNT 4
80 1.2.4.2 christos #endif
81 1.2.4.2 christos #ifndef URE_RX_LIST_CNT
82 1.2.4.2 christos #define URE_RX_LIST_CNT 4
83 1.2.4.2 christos #endif
84 1.2.4.2 christos
85 1.2.4.2 christos struct ure_chain {
86 1.2.4.2 christos struct ure_softc *uc_sc;
87 1.2.4.2 christos struct usbd_xfer *uc_xfer;
88 1.2.4.2 christos char *uc_buf;
89 1.2.4.2 christos };
90 1.2.4.2 christos
91 1.2.4.2 christos struct ure_cdata {
92 1.2.4.2 christos struct ure_chain tx_chain[URE_TX_LIST_CNT];
93 1.2.4.2 christos struct ure_chain rx_chain[URE_RX_LIST_CNT];
94 1.2.4.2 christos int tx_prod;
95 1.2.4.2 christos int tx_cnt;
96 1.2.4.2 christos };
97 1.2.4.2 christos
98 1.2.4.2 christos struct ure_softc {
99 1.2.4.2 christos device_t ure_dev;
100 1.2.4.2 christos struct usbd_device *ure_udev;
101 1.2.4.2 christos
102 1.2.4.2 christos /* usb */
103 1.2.4.2 christos struct usbd_interface *ure_iface;
104 1.2.4.2 christos struct usb_task ure_tick_task;
105 1.2.4.2 christos int ure_ed[URE_ENDPT_MAX];
106 1.2.4.2 christos struct usbd_pipe *ure_ep[URE_ENDPT_MAX];
107 1.2.4.2 christos
108 1.2.4.2 christos /* ethernet */
109 1.2.4.2 christos struct ethercom ure_ec;
110 1.2.4.2 christos #define GET_IFP(sc) (&(sc)->ure_ec.ec_if)
111 1.2.4.2 christos struct mii_data ure_mii;
112 1.2.4.2 christos #define GET_MII(sc) (&(sc)->ure_mii)
113 1.2.4.2 christos kmutex_t ure_mii_lock;
114 1.2.4.2 christos int ure_refcnt;
115 1.2.4.2 christos
116 1.2.4.2 christos struct ure_cdata ure_cdata;
117 1.2.4.2 christos callout_t ure_stat_ch;
118 1.2.4.2 christos
119 1.2.4.2 christos struct timeval ure_rx_notice;
120 1.2.4.2 christos struct timeval ure_tx_notice;
121 1.2.4.2 christos u_int ure_bufsz;
122 1.2.4.2 christos
123 1.2.4.2 christos int ure_phyno;
124 1.2.4.2 christos
125 1.2.4.2 christos u_int ure_flags;
126 1.2.4.2 christos #define URE_FLAG_LINK 0x0001
127 1.2.4.2 christos #define URE_FLAG_8152 0x1000 /* RTL8152 */
128 1.2.4.2 christos
129 1.2.4.2 christos u_int ure_chip;
130 1.2.4.2 christos #define URE_CHIP_VER_4C00 0x01
131 1.2.4.2 christos #define URE_CHIP_VER_4C10 0x02
132 1.2.4.2 christos #define URE_CHIP_VER_5C00 0x04
133 1.2.4.2 christos #define URE_CHIP_VER_5C10 0x08
134 1.2.4.2 christos #define URE_CHIP_VER_5C20 0x10
135 1.2.4.2 christos #define URE_CHIP_VER_5C30 0x20
136 1.2.4.2 christos
137 1.2.4.2 christos krndsource_t ure_rnd_source;
138 1.2.4.2 christos bool ure_dying;
139 1.2.4.2 christos };
140