Nuke device_ptr_t, USBBASEDEVICE, USBDEVNAME(), USBDEVUNIT(), USBGETSOFTC(),
[dragonfly/vkernel-mp.git] / sys / dev / netif / sk / if_skvar.h
blob8c90ca348f21a6b8524e28672de34029a1cb0665
1 /*-
2 * Copyright (c) 2003 The NetBSD Foundation, Inc.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the NetBSD
16 * Foundation, Inc. and its contributors.
17 * 4. Neither the name of The NetBSD Foundation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
35 * Copyright (c) 1997, 1998, 1999, 2000
36 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by Bill Paul.
49 * 4. Neither the name of the author nor the names of any co-contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
57 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
58 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
59 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
60 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
61 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
63 * THE POSSIBILITY OF SUCH DAMAGE.
66 * $FreeBSD: /c/ncvs/src/sys/pci/if_skreg.h,v 1.9 2000/04/22 02:16:37 wpaul Exp $
67 * $NetBSD: if_skvar.h,v 1.6 2005/05/30 04:35:22 christos Exp $
68 * $OpenBSD: if_skvar.h,v 1.2 2005/12/22 20:54:47 brad Exp $
69 * $DragonFly: src/sys/dev/netif/sk/if_skvar.h,v 1.3 2007/06/23 09:25:02 sephe Exp $
73 * Copyright (c) 2003 Nathan L. Binkert <binkertn@umich.edu>
75 * Permission to use, copy, modify, and distribute this software for any
76 * purpose with or without fee is hereby granted, provided that the above
77 * copyright notice and this permission notice appear in all copies.
79 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
80 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
81 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
82 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
83 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
84 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
85 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
88 #ifndef _IF_SKVAR_H_
89 #define _IF_SKVAR_H_
91 struct sk_jpool_entry {
92 struct sk_if_softc *sc_if;
93 int inuse;
94 int slot;
95 void *buf;
96 bus_addr_t paddr;
97 SLIST_ENTRY(sk_jpool_entry) entry_next;
101 * Number of DMA segments in a TxCB. Note that this is carefully
102 * chosen to make the total struct size an even power of two. It's
103 * critical that no TxCB be split across a page boundary since
104 * no attempt is made to allocate physically contiguous memory.
106 #define SK_NTXSEG 30
108 struct sk_chain_data {
109 struct mbuf *sk_tx_mbuf[SK_TX_RING_CNT];
110 bus_dma_tag_t sk_tx_dtag;
111 bus_dmamap_t sk_tx_dmap[SK_TX_RING_CNT];
112 int sk_tx_prod;
113 int sk_tx_cons;
114 int sk_tx_cnt;
116 struct mbuf *sk_rx_mbuf[SK_RX_RING_CNT];
117 bus_dma_tag_t sk_rx_dtag;
118 bus_dmamap_t sk_rx_dmap[SK_RX_RING_CNT];
119 bus_dmamap_t sk_rx_dmap_tmp;
120 int sk_rx_prod;
121 int sk_rx_cons;
122 int sk_rx_cnt;
124 struct lwkt_serialize sk_jpool_serializer;
125 bus_dma_tag_t sk_jpool_dtag;
126 bus_dmamap_t sk_jpool_dmap;
127 void *sk_jpool;
128 struct sk_jpool_entry sk_jpool_ent[SK_JSLOTS];
129 SLIST_HEAD(, sk_jpool_entry) sk_jpool_free_ent;
132 struct sk_ring_data {
133 struct sk_tx_desc sk_tx_ring[SK_TX_RING_CNT];
134 struct sk_rx_desc sk_rx_ring[SK_RX_RING_CNT];
137 #define SK_TX_RING_ADDR(sc, i) \
138 ((sc)->sk_rdata_paddr + offsetof(struct sk_ring_data, sk_tx_ring[(i)]))
140 #define SK_RX_RING_ADDR(sc, i) \
141 ((sc)->sk_rdata_paddr + offsetof(struct sk_ring_data, sk_rx_ring[(i)]))
143 struct sk_bcom_hack {
144 int reg;
145 int val;
148 #define SK_INC(x, y) (x) = (x + 1) % y
150 /* Forward decl. */
151 struct sk_if_softc;
153 /* Softc for the GEnesis controller. */
154 struct sk_softc {
155 int sk_res_rid;
156 struct resource *sk_res;
157 bus_space_handle_t sk_bhandle; /* bus space handle */
158 bus_space_tag_t sk_btag; /* bus space tag */
160 int sk_irq_rid;
161 struct resource *sk_irq;
162 void *sk_intrhand; /* irq handler handle */
164 uint8_t sk_coppertype;
165 uint8_t sk_pmd; /* physical media type */
166 uint8_t sk_type;
167 uint8_t sk_rev;
168 uint8_t sk_macs; /* # of MACs */
169 uint32_t sk_rboff; /* RAMbuffer offset */
170 uint32_t sk_ramsize; /* amount of RAM on NIC */
171 uint32_t sk_intrmask;
172 uint32_t sk_imtimer_ticks;
173 int sk_imtime;
174 struct sysctl_ctx_list sk_sysctl_ctx;
175 struct sysctl_oid *sk_sysctl_tree;
176 struct lwkt_serialize sk_serializer;
177 struct sk_if_softc *sk_if[2];
178 device_t sk_devs[2];
181 /* Softc for each logical interface */
182 struct sk_if_softc {
183 struct arpcom arpcom; /* interface info */
184 device_t sk_miibus;
185 uint8_t sk_port; /* port # on controller */
186 uint8_t sk_xmac_rev; /* XMAC chip rev (B2 or C1) */
187 uint32_t sk_rx_ramstart;
188 uint32_t sk_rx_ramend;
189 uint32_t sk_tx_ramstart;
190 uint32_t sk_tx_ramend;
191 uint8_t sk_phytype;
192 int sk_phyaddr;
193 int sk_cnt;
194 int sk_link;
195 struct callout sk_tick_timer;
196 struct sk_chain_data sk_cdata;
197 struct sk_ring_data *sk_rdata;
198 bus_dma_tag_t sk_rdata_dtag;
199 bus_dmamap_t sk_rdata_dmap;
200 bus_addr_t sk_rdata_paddr;
201 struct sk_softc *sk_softc; /* parent controller */
202 int sk_tx_bmu; /* TX BMU register */
203 int sk_if_flags;
204 int sk_use_jumbo;
207 struct sk_dma_ctx {
208 int nsegs;
209 bus_dma_segment_t *segs;
212 #endif /* !_IF_SKVAR_H_ */