i82557var.h revision 1.1 1 1.1 thorpej /* $NetBSD: i82557var.h,v 1.1 1999/06/20 16:33:29 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.1 thorpej * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.1 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.1 thorpej * NASA Ames Research Center.
10 1.1 thorpej *
11 1.1 thorpej * Redistribution and use in source and binary forms, with or without
12 1.1 thorpej * modification, are permitted provided that the following conditions
13 1.1 thorpej * are met:
14 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.1 thorpej * notice, this list of conditions and the following disclaimer.
16 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.1 thorpej * documentation and/or other materials provided with the distribution.
19 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.1 thorpej * must display the following acknowledgement:
21 1.1 thorpej * This product includes software developed by the NetBSD
22 1.1 thorpej * Foundation, Inc. and its contributors.
23 1.1 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1 thorpej * contributors may be used to endorse or promote products derived
25 1.1 thorpej * from this software without specific prior written permission.
26 1.1 thorpej *
27 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.1 thorpej */
39 1.1 thorpej
40 1.1 thorpej /*
41 1.1 thorpej * Copyright (c) 1995, David Greenman
42 1.1 thorpej * All rights reserved.
43 1.1 thorpej *
44 1.1 thorpej * Redistribution and use in source and binary forms, with or without
45 1.1 thorpej * modification, are permitted provided that the following conditions
46 1.1 thorpej * are met:
47 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
48 1.1 thorpej * notice unmodified, this list of conditions, and the following
49 1.1 thorpej * disclaimer.
50 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
51 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
52 1.1 thorpej * documentation and/or other materials provided with the distribution.
53 1.1 thorpej *
54 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
55 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 1.1 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 1.1 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
58 1.1 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 1.1 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 1.1 thorpej * SUCH DAMAGE.
65 1.1 thorpej *
66 1.1 thorpej * Id: if_fxpvar.h,v 1.4 1997/11/29 08:11:01 davidg Exp
67 1.1 thorpej */
68 1.1 thorpej
69 1.1 thorpej /*
70 1.1 thorpej * Misc. defintions for the Intel i82557 fast Ethernet controller
71 1.1 thorpej * driver.
72 1.1 thorpej */
73 1.1 thorpej
74 1.1 thorpej /*
75 1.1 thorpej * Number of transmit control blocks. This determines the number
76 1.1 thorpej * of transmit buffers that can be chained in the CB list. This
77 1.1 thorpej * must be a power of two.
78 1.1 thorpej */
79 1.1 thorpej #define FXP_NTXCB 128
80 1.1 thorpej
81 1.1 thorpej /*
82 1.1 thorpej * TxCB list index mask. This is used to do list wrap-around.
83 1.1 thorpej */
84 1.1 thorpej #define FXP_TXCB_MASK (FXP_NTXCB - 1)
85 1.1 thorpej
86 1.1 thorpej /*
87 1.1 thorpej * Number of receive frame area buffers. These are large, so
88 1.1 thorpej * choose wisely.
89 1.1 thorpej */
90 1.1 thorpej #define FXP_NRFABUFS 64
91 1.1 thorpej
92 1.1 thorpej /*
93 1.1 thorpej * Maximum number of seconds that the reciever can be idle before we
94 1.1 thorpej * assume it's dead and attempt to reset it by reprogramming the
95 1.1 thorpej * multicast filter. This is part of a work-around for a bug in the
96 1.1 thorpej * NIC. See fxp_stats_update().
97 1.1 thorpej */
98 1.1 thorpej #define FXP_MAX_RX_IDLE 15
99 1.1 thorpej
100 1.1 thorpej /*
101 1.1 thorpej * Misc. DMA'd data structures are allocated in a single clump, that
102 1.1 thorpej * maps to a single DMA segment, to make several things easier (computing
103 1.1 thorpej * offsets, setting up DMA maps, etc.)
104 1.1 thorpej */
105 1.1 thorpej struct fxp_control_data {
106 1.1 thorpej /*
107 1.1 thorpej * The transmit control blocks. The first if these
108 1.1 thorpej * is also used as the config CB.
109 1.1 thorpej */
110 1.1 thorpej struct fxp_cb_tx fcd_txcbs[FXP_NTXCB];
111 1.1 thorpej
112 1.1 thorpej /*
113 1.1 thorpej * The multicast setup CB.
114 1.1 thorpej */
115 1.1 thorpej struct fxp_cb_mcs fcd_mcscb;
116 1.1 thorpej
117 1.1 thorpej /*
118 1.1 thorpej * The NIC statistics.
119 1.1 thorpej */
120 1.1 thorpej struct fxp_stats fcd_stats;
121 1.1 thorpej };
122 1.1 thorpej
123 1.1 thorpej #define FXP_CDOFF(x) offsetof(struct fxp_control_data, x)
124 1.1 thorpej
125 1.1 thorpej /*
126 1.1 thorpej * Receive buffer descriptor (software only). This is the analog of
127 1.1 thorpej * the software portion of the fxp_cb_tx.
128 1.1 thorpej */
129 1.1 thorpej struct fxp_rxdesc {
130 1.1 thorpej struct fxp_rxdesc *fr_next; /* next in the chain */
131 1.1 thorpej struct mbuf *fr_mbhead; /* pointer to mbuf chain */
132 1.1 thorpej bus_dmamap_t fr_dmamap; /* our DMA map */
133 1.1 thorpej };
134 1.1 thorpej
135 1.1 thorpej struct fxp_softc {
136 1.1 thorpej struct device sc_dev; /* generic device structures */
137 1.1 thorpej void *sc_ih; /* interrupt handler cookie */
138 1.1 thorpej void *sc_sdhook; /* shutdown hook */
139 1.1 thorpej bus_space_tag_t sc_st; /* bus space tag */
140 1.1 thorpej bus_space_handle_t sc_sh; /* bus space handle */
141 1.1 thorpej bus_dma_tag_t sc_dmat; /* bus dma tag */
142 1.1 thorpej struct ethercom sc_ethercom; /* ethernet common part */
143 1.1 thorpej #define sc_if sc_ethercom.ec_if
144 1.1 thorpej
145 1.1 thorpej /*
146 1.1 thorpej * We create a single DMA map that maps all data structure
147 1.1 thorpej * overhead, except for RFAs, which are mapped by the
148 1.1 thorpej * fxp_rxdesc DMA map on a per-mbuf basis.
149 1.1 thorpej */
150 1.1 thorpej bus_dmamap_t sc_dmamap;
151 1.1 thorpej #define sc_cddma sc_dmamap->dm_segs[0].ds_addr
152 1.1 thorpej
153 1.1 thorpej /*
154 1.1 thorpej * These DMA maps map transmit and recieve buffers.
155 1.1 thorpej */
156 1.1 thorpej bus_dmamap_t sc_tx_dmamaps[FXP_NTXCB];
157 1.1 thorpej bus_dmamap_t sc_rx_dmamaps[FXP_NRFABUFS];
158 1.1 thorpej
159 1.1 thorpej /*
160 1.1 thorpej * Control data - TxCBs, stats, etc.
161 1.1 thorpej */
162 1.1 thorpej struct fxp_control_data *control_data;
163 1.1 thorpej
164 1.1 thorpej /* receive buffer descriptors */
165 1.1 thorpej struct fxp_rxdesc sc_rxdescs[FXP_NRFABUFS];
166 1.1 thorpej struct mii_data sc_mii; /* MII media information */
167 1.1 thorpej struct fxp_cb_tx *cbl_first; /* first active TxCB in list */
168 1.1 thorpej struct fxp_cb_tx *cbl_last; /* last active TxCB in list */
169 1.1 thorpej int tx_queued; /* # of active TxCB's */
170 1.1 thorpej int need_mcsetup; /* multicast filter needs programming */
171 1.1 thorpej struct fxp_rxdesc *rfa_head; /* first mbuf in receive frame area */
172 1.1 thorpej struct fxp_rxdesc *rfa_tail; /* last mbuf in receive frame area */
173 1.1 thorpej int rx_idle_secs; /* # of seconds RX has been idle */
174 1.1 thorpej int all_mcasts; /* receive all multicasts */
175 1.1 thorpej int promisc_mode; /* promiscuous mode enabled */
176 1.1 thorpej int phy_primary_addr; /* address of primary PHY */
177 1.1 thorpej int phy_primary_device; /* device type of primary PHY */
178 1.1 thorpej int phy_10Mbps_only; /* PHY is 10Mbps-only device */
179 1.1 thorpej #if NRND > 0
180 1.1 thorpej rndsource_element_t rnd_source; /* random source */
181 1.1 thorpej #endif
182 1.1 thorpej };
183 1.1 thorpej
184 1.1 thorpej /* Macros to ease CSR access. */
185 1.1 thorpej #define CSR_READ_1(sc, reg) \
186 1.1 thorpej bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
187 1.1 thorpej #define CSR_READ_2(sc, reg) \
188 1.1 thorpej bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
189 1.1 thorpej #define CSR_READ_4(sc, reg) \
190 1.1 thorpej bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
191 1.1 thorpej #define CSR_WRITE_1(sc, reg, val) \
192 1.1 thorpej bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
193 1.1 thorpej #define CSR_WRITE_2(sc, reg, val) \
194 1.1 thorpej bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
195 1.1 thorpej #define CSR_WRITE_4(sc, reg, val) \
196 1.1 thorpej bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
197 1.1 thorpej
198 1.1 thorpej void fxp_attach __P((struct fxp_softc *));
199 1.1 thorpej int fxp_intr __P((void *));
200