if_skvar.h revision 1.3.4.5 1 1.3.4.5 skrll /* $NetBSD: if_skvar.h,v 1.3.4.5 2004/10/19 15:56:59 skrll Exp $ */
2 1.3.4.2 skrll
3 1.3.4.2 skrll /*-
4 1.3.4.2 skrll * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 1.3.4.2 skrll * All rights reserved.
6 1.3.4.2 skrll *
7 1.3.4.2 skrll * Redistribution and use in source and binary forms, with or without
8 1.3.4.2 skrll * modification, are permitted provided that the following conditions
9 1.3.4.2 skrll * are met:
10 1.3.4.2 skrll * 1. Redistributions of source code must retain the above copyright
11 1.3.4.2 skrll * notice, this list of conditions and the following disclaimer.
12 1.3.4.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
13 1.3.4.2 skrll * notice, this list of conditions and the following disclaimer in the
14 1.3.4.2 skrll * documentation and/or other materials provided with the distribution.
15 1.3.4.2 skrll * 3. All advertising materials mentioning features or use of this software
16 1.3.4.2 skrll * must display the following acknowledgement:
17 1.3.4.2 skrll * This product includes software developed by the NetBSD
18 1.3.4.2 skrll * Foundation, Inc. and its contributors.
19 1.3.4.2 skrll * 4. Neither the name of The NetBSD Foundation nor the names of its
20 1.3.4.2 skrll * contributors may be used to endorse or promote products derived
21 1.3.4.2 skrll * from this software without specific prior written permission.
22 1.3.4.2 skrll *
23 1.3.4.2 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 1.3.4.2 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 1.3.4.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 1.3.4.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 1.3.4.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 1.3.4.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.3.4.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.3.4.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.3.4.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.3.4.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 1.3.4.2 skrll * POSSIBILITY OF SUCH DAMAGE.
34 1.3.4.2 skrll */
35 1.3.4.2 skrll /* $OpenBSD: if_skreg.h,v 1.10 2003/08/12 05:23:06 nate Exp $ */
36 1.3.4.2 skrll
37 1.3.4.2 skrll /*
38 1.3.4.2 skrll * Copyright (c) 1997, 1998, 1999, 2000
39 1.3.4.2 skrll * Bill Paul <wpaul (at) ctr.columbia.edu>. All rights reserved.
40 1.3.4.2 skrll *
41 1.3.4.2 skrll * Redistribution and use in source and binary forms, with or without
42 1.3.4.2 skrll * modification, are permitted provided that the following conditions
43 1.3.4.2 skrll * are met:
44 1.3.4.2 skrll * 1. Redistributions of source code must retain the above copyright
45 1.3.4.2 skrll * notice, this list of conditions and the following disclaimer.
46 1.3.4.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
47 1.3.4.2 skrll * notice, this list of conditions and the following disclaimer in the
48 1.3.4.2 skrll * documentation and/or other materials provided with the distribution.
49 1.3.4.2 skrll * 3. All advertising materials mentioning features or use of this software
50 1.3.4.2 skrll * must display the following acknowledgement:
51 1.3.4.2 skrll * This product includes software developed by Bill Paul.
52 1.3.4.2 skrll * 4. Neither the name of the author nor the names of any co-contributors
53 1.3.4.2 skrll * may be used to endorse or promote products derived from this software
54 1.3.4.2 skrll * without specific prior written permission.
55 1.3.4.2 skrll *
56 1.3.4.2 skrll * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
57 1.3.4.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 1.3.4.2 skrll * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 1.3.4.2 skrll * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
60 1.3.4.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61 1.3.4.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62 1.3.4.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63 1.3.4.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64 1.3.4.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 1.3.4.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66 1.3.4.2 skrll * THE POSSIBILITY OF SUCH DAMAGE.
67 1.3.4.2 skrll *
68 1.3.4.2 skrll * $FreeBSD: /c/ncvs/src/sys/pci/if_skreg.h,v 1.9 2000/04/22 02:16:37 wpaul Exp $
69 1.3.4.2 skrll */
70 1.3.4.2 skrll
71 1.3.4.2 skrll /*
72 1.3.4.2 skrll * Copyright (c) 2003 Nathan L. Binkert <binkertn (at) umich.edu>
73 1.3.4.2 skrll *
74 1.3.4.2 skrll * Permission to use, copy, modify, and distribute this software for any
75 1.3.4.2 skrll * purpose with or without fee is hereby granted, provided that the above
76 1.3.4.2 skrll * copyright notice and this permission notice appear in all copies.
77 1.3.4.2 skrll *
78 1.3.4.2 skrll * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
79 1.3.4.2 skrll * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
80 1.3.4.2 skrll * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
81 1.3.4.2 skrll * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
82 1.3.4.2 skrll * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
83 1.3.4.2 skrll * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
84 1.3.4.2 skrll * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
85 1.3.4.2 skrll */
86 1.3.4.2 skrll
87 1.3.4.2 skrll #ifndef _DEV_PCI_IF_SKVAR_H_
88 1.3.4.2 skrll #define _DEV_PCI_IF_SKVAR_H_
89 1.3.4.2 skrll
90 1.3.4.2 skrll struct sk_jslot {
91 1.3.4.2 skrll caddr_t sk_buf;
92 1.3.4.2 skrll int sk_inuse;
93 1.3.4.2 skrll };
94 1.3.4.2 skrll
95 1.3.4.2 skrll struct sk_jpool_entry {
96 1.3.4.2 skrll int slot;
97 1.3.4.2 skrll LIST_ENTRY(sk_jpool_entry) jpool_entries;
98 1.3.4.2 skrll };
99 1.3.4.2 skrll
100 1.3.4.2 skrll struct sk_chain {
101 1.3.4.2 skrll void *sk_desc;
102 1.3.4.2 skrll struct mbuf *sk_mbuf;
103 1.3.4.2 skrll struct sk_chain *sk_next;
104 1.3.4.2 skrll };
105 1.3.4.2 skrll
106 1.3.4.2 skrll /*
107 1.3.4.2 skrll * Number of DMA segments in a TxCB. Note that this is carefully
108 1.3.4.2 skrll * chosen to make the total struct size an even power of two. It's
109 1.3.4.2 skrll * critical that no TxCB be split across a page boundary since
110 1.3.4.2 skrll * no attempt is made to allocate physically contiguous memory.
111 1.3.4.2 skrll *
112 1.3.4.2 skrll */
113 1.3.4.2 skrll #define SK_NTXSEG 30
114 1.3.4.2 skrll
115 1.3.4.2 skrll struct sk_txmap_entry {
116 1.3.4.2 skrll bus_dmamap_t dmamap;
117 1.3.4.5 skrll SIMPLEQ_ENTRY(sk_txmap_entry) link;
118 1.3.4.2 skrll };
119 1.3.4.2 skrll
120 1.3.4.2 skrll struct sk_chain_data {
121 1.3.4.2 skrll struct sk_chain sk_tx_chain[SK_TX_RING_CNT];
122 1.3.4.2 skrll struct sk_chain sk_rx_chain[SK_RX_RING_CNT];
123 1.3.4.2 skrll struct sk_txmap_entry *sk_tx_map[SK_TX_RING_CNT];
124 1.3.4.2 skrll bus_dmamap_t sk_rx_map[SK_RX_RING_CNT];
125 1.3.4.2 skrll int sk_tx_prod;
126 1.3.4.2 skrll int sk_tx_cons;
127 1.3.4.2 skrll int sk_tx_cnt;
128 1.3.4.2 skrll int sk_rx_prod;
129 1.3.4.2 skrll int sk_rx_cons;
130 1.3.4.2 skrll int sk_rx_cnt;
131 1.3.4.2 skrll /* Stick the jumbo mem management stuff here too. */
132 1.3.4.2 skrll struct sk_jslot sk_jslots[SK_JSLOTS];
133 1.3.4.2 skrll void *sk_jumbo_buf;
134 1.3.4.2 skrll
135 1.3.4.2 skrll };
136 1.3.4.2 skrll
137 1.3.4.2 skrll struct sk_ring_data {
138 1.3.4.2 skrll struct sk_tx_desc sk_tx_ring[SK_TX_RING_CNT];
139 1.3.4.2 skrll struct sk_rx_desc sk_rx_ring[SK_RX_RING_CNT];
140 1.3.4.2 skrll };
141 1.3.4.2 skrll
142 1.3.4.2 skrll #define SK_TX_RING_ADDR(sc, i) \
143 1.3.4.2 skrll ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
144 1.3.4.2 skrll offsetof(struct sk_ring_data, sk_tx_ring[(i)]))
145 1.3.4.2 skrll
146 1.3.4.2 skrll #define SK_RX_RING_ADDR(sc, i) \
147 1.3.4.2 skrll ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
148 1.3.4.2 skrll offsetof(struct sk_ring_data, sk_rx_ring[(i)]))
149 1.3.4.2 skrll
150 1.3.4.2 skrll #define SK_CDOFF(x) offsetof(struct sk_ring_data, x)
151 1.3.4.2 skrll #define SK_CDTXOFF(x) SK_CDOFF(sk_tx_ring[(x)])
152 1.3.4.2 skrll #define SK_CDRXOFF(x) SK_CDOFF(sk_rx_ring[(x)])
153 1.3.4.2 skrll
154 1.3.4.2 skrll #define SK_CDTXSYNC(sc, x, n, ops) \
155 1.3.4.2 skrll do { \
156 1.3.4.2 skrll int __x, __n; \
157 1.3.4.2 skrll \
158 1.3.4.2 skrll __x = (x); \
159 1.3.4.2 skrll __n = (n); \
160 1.3.4.2 skrll \
161 1.3.4.2 skrll /* If it will wrap around, sync to the end of the ring. */ \
162 1.3.4.2 skrll if ((__x + __n) > SK_TX_RING_CNT) { \
163 1.3.4.2 skrll bus_dmamap_sync((sc)->sk_softc->sc_dmatag, \
164 1.3.4.2 skrll (sc)->sk_ring_map, SK_CDTXOFF(__x), \
165 1.3.4.2 skrll sizeof(struct sk_tx_desc) * (SK_TX_RING_CNT - __x),\
166 1.3.4.2 skrll (ops)); \
167 1.3.4.2 skrll __n -= (SK_TX_RING_CNT - __x); \
168 1.3.4.2 skrll __x = 0; \
169 1.3.4.2 skrll } \
170 1.3.4.2 skrll \
171 1.3.4.2 skrll /* Now sync whatever is left. */ \
172 1.3.4.2 skrll bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map, \
173 1.3.4.2 skrll SK_CDTXOFF((__x)), sizeof(struct sk_tx_desc) * __n, (ops)); \
174 1.3.4.2 skrll } while (/*CONSTCOND*/0)
175 1.3.4.2 skrll
176 1.3.4.2 skrll #define SK_CDRXSYNC(sc, x, ops) \
177 1.3.4.2 skrll do { \
178 1.3.4.2 skrll bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map, \
179 1.3.4.2 skrll SK_CDRXOFF((x)), sizeof(struct sk_rx_desc), (ops)); \
180 1.3.4.2 skrll } while (/*CONSTCOND*/0)
181 1.3.4.2 skrll
182 1.3.4.2 skrll struct sk_bcom_hack {
183 1.3.4.2 skrll int reg;
184 1.3.4.2 skrll int val;
185 1.3.4.2 skrll };
186 1.3.4.2 skrll
187 1.3.4.2 skrll #define SK_INC(x, y) (x) = (x + 1) % y
188 1.3.4.2 skrll
189 1.3.4.2 skrll /* Forward decl. */
190 1.3.4.2 skrll struct sk_if_softc;
191 1.3.4.2 skrll
192 1.3.4.2 skrll /* Softc for the GEnesis controller. */
193 1.3.4.2 skrll struct sk_softc {
194 1.3.4.2 skrll struct device sk_dev; /* generic device */
195 1.3.4.2 skrll bus_space_handle_t sk_bhandle; /* bus space handle */
196 1.3.4.2 skrll bus_space_tag_t sk_btag; /* bus space tag */
197 1.3.4.2 skrll void *sk_intrhand; /* irq handler handle */
198 1.3.4.2 skrll struct resource *sk_irq; /* IRQ resource handle */
199 1.3.4.2 skrll struct resource *sk_res; /* I/O or shared mem handle */
200 1.3.4.2 skrll u_int8_t sk_type;
201 1.3.4.5 skrll u_int8_t sk_rev;
202 1.3.4.5 skrll char *sk_name;
203 1.3.4.2 skrll char *sk_vpd_prodname;
204 1.3.4.2 skrll char *sk_vpd_readonly;
205 1.3.4.2 skrll u_int32_t sk_rboff; /* RAMbuffer offset */
206 1.3.4.2 skrll u_int32_t sk_ramsize; /* amount of RAM on NIC */
207 1.3.4.2 skrll u_int32_t sk_pmd; /* physical media type */
208 1.3.4.2 skrll u_int32_t sk_intrmask;
209 1.3.4.2 skrll bus_dma_tag_t sc_dmatag;
210 1.3.4.2 skrll struct sk_if_softc *sk_if[2];
211 1.3.4.2 skrll };
212 1.3.4.2 skrll
213 1.3.4.2 skrll /* Softc for each logical interface */
214 1.3.4.2 skrll struct sk_if_softc {
215 1.3.4.2 skrll struct device sk_dev; /* generic device */
216 1.3.4.2 skrll struct ethercom sk_ethercom; /* interface info */
217 1.3.4.2 skrll struct mii_data sk_mii;
218 1.3.4.2 skrll u_int8_t sk_enaddr[ETHER_ADDR_LEN]; /* station addr */
219 1.3.4.2 skrll u_int8_t sk_port; /* port # on controller */
220 1.3.4.2 skrll u_int8_t sk_xmac_rev; /* XMAC chip rev (B2 or C1) */
221 1.3.4.2 skrll u_int32_t sk_rx_ramstart;
222 1.3.4.2 skrll u_int32_t sk_rx_ramend;
223 1.3.4.2 skrll u_int32_t sk_tx_ramstart;
224 1.3.4.2 skrll u_int32_t sk_tx_ramend;
225 1.3.4.2 skrll int sk_phytype;
226 1.3.4.2 skrll int sk_phyaddr;
227 1.3.4.2 skrll int sk_cnt;
228 1.3.4.2 skrll int sk_link;
229 1.3.4.2 skrll struct callout sk_tick_ch;
230 1.3.4.2 skrll struct sk_chain_data sk_cdata;
231 1.3.4.2 skrll struct sk_ring_data *sk_rdata;
232 1.3.4.2 skrll bus_dmamap_t sk_ring_map;
233 1.3.4.2 skrll struct sk_softc *sk_softc; /* parent controller */
234 1.3.4.2 skrll int sk_tx_bmu; /* TX BMU register */
235 1.3.4.2 skrll int sk_if_flags;
236 1.3.4.2 skrll LIST_HEAD(__sk_jfreehead, sk_jpool_entry) sk_jfree_listhead;
237 1.3.4.2 skrll LIST_HEAD(__sk_jinusehead, sk_jpool_entry) sk_jinuse_listhead;
238 1.3.4.5 skrll SIMPLEQ_HEAD(__sk_txmaphead, sk_txmap_entry) sk_txmap_head;
239 1.3.4.2 skrll };
240 1.3.4.2 skrll
241 1.3.4.2 skrll struct skc_attach_args {
242 1.3.4.2 skrll u_int16_t skc_port;
243 1.3.4.2 skrll };
244 1.3.4.2 skrll
245 1.3.4.2 skrll #endif /* _DEV_PCI_IF_SKVAR_H_ */
246