mb86960var.h revision 1.22 1 /* $NetBSD: mb86960var.h,v 1.22 1998/11/17 20:25:01 thorpej Exp $ */
2
3 /*
4 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
5 *
6 * This software may be used, modified, copied, distributed, and sold, in
7 * both source and binary form provided that the above copyright, these
8 * terms and the following disclaimer are retained. The name of the author
9 * and/or the contributor may not be used to endorse or promote products
10 * derived from this software without specific prior written permission.
11 *
12 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND
13 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE
16 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION.
19 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22 * SUCH DAMAGE.
23 */
24
25 /*
26 * Portions copyright (C) 1993, David Greenman. This software may be used,
27 * modified, copied, distributed, and sold, in both source and binary form
28 * provided that the above copyright and these terms are retained. Under no
29 * circumstances is the author responsible for the proper functioning of this
30 * software, nor does the author assume any responsibility for damages
31 * incurred with its use.
32 */
33
34 #define FE_VERSION "if_fe.c ver. 0.8"
35
36 /*
37 * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
38 * Contributed by M.S. <seki (at) sysrap.cs.fujitsu.co.jp>
39 *
40 * This version is intended to be a generic template for various
41 * MB86960A/MB86965A based Ethernet cards. It currently supports
42 * Fujitsu FMV-180 series (i.e., FMV-181 and FMV-182) and Allied-
43 * Telesis AT1700 series and RE2000 series. There are some
44 * unnecessary hooks embedded, which are primarily intended to support
45 * other types of Ethernet cards, but the author is not sure whether
46 * they are useful.
47 */
48
49 #include "rnd.h"
50
51 #if NRND > 0
52 #include <sys/rnd.h>
53 #endif
54
55 /*
56 * Default settings for fe driver specific options.
57 * They can be set in config file by "options" statements.
58 */
59
60 /*
61 * Debug control.
62 * 0: No debug at all. All debug specific codes are stripped off.
63 * 1: Silent. No debug messages are logged except emergent ones.
64 * 2: Brief. Lair events and/or important information are logged.
65 * 3: Detailed. Logs all information which *may* be useful for debugging.
66 * 4: Trace. All actions in the driver is logged. Super verbose.
67 */
68 #ifndef FE_DEBUG
69 #define FE_DEBUG 1
70 #endif
71
72 /*
73 * Delay padding of short transmission packets to minimum Ethernet size.
74 * This may or may not gain performance. An EXPERIMENTAL option.
75 */
76 #ifndef FE_DELAYED_PADDING
77 #define FE_DELAYED_PADDING 0
78 #endif
79
80 /*
81 * Transmit just one packet per a "send" command to 86960.
82 * This option is intended for performance test. An EXPERIMENTAL option.
83 */
84 #ifndef FE_SINGLE_TRANSMISSION
85 #define FE_SINGLE_TRANSMISSION 0
86 #endif
87
88 /*
89 * Device configuration flags.
90 */
91
92 /* DLCR6 settings. */
93 #define FE_FLAGS_DLCR6_VALUE 0x007F
94
95 /* Force DLCR6 override. */
96 #define FE_FLAGS_OVERRIDE_DLCR6 0x0080
97
98 /* A cludge for PCMCIA support. */
99 #define FE_FLAGS_PCMCIA 0x8000
100
101 /*
102 * Supported hardware (Ethernet card) types
103 * This information is currently used only for debugging
104 */
105 enum fe_type {
106 /* For cards which are successfully probed but not identified. */
107 FE_TYPE_UNKNOWN = 0,
108
109 /* Fujitsu FMV-180 series. */
110 FE_TYPE_FMV181,
111 FE_TYPE_FMV182,
112
113 /* Allied-Telesis AT1700 series and RE2000 series. */
114 FE_TYPE_AT1700T,
115 FE_TYPE_AT1700BT,
116 FE_TYPE_AT1700FT,
117 FE_TYPE_AT1700AT,
118 FE_TYPE_RE2000,
119
120 /* PCMCIA by Fujitsu. */
121 FE_TYPE_MBH10302,
122 FE_TYPE_MBH10304,
123 };
124
125 enum mb86960_type {
126 MB86960_TYPE_86960,
127 MB86960_TYPE_86965
128 };
129
130 /*
131 * fe_softc: per line info and status
132 */
133 struct mb86960_softc {
134 struct device sc_dev;
135 struct ethercom sc_ec; /* ethernet common */
136 struct ifmedia sc_media; /* supported media information */
137
138 bus_space_tag_t sc_bst; /* bus space */
139 bus_space_handle_t sc_bsh;
140
141 /* Set by probe() and not modified in later phases. */
142 enum mb86960_type type; /* controller type */
143
144 u_char proto_dlcr4; /* DLCR4 prototype. */
145 u_char proto_dlcr5; /* DLCR5 prototype. */
146 u_char proto_dlcr6; /* DLCR6 prototype. */
147 u_char proto_dlcr7; /* DLCR7 prototype. */
148 u_char proto_bmpr13; /* BMPR13 prototype. */
149
150 /* Vendor specific hooks. */
151 void (*init_card) __P((struct mb86960_softc *));
152 void (*stop_card) __P((struct mb86960_softc *));
153
154 /* Transmission buffer management. */
155 u_short txb_size; /* total bytes in TX buffer */
156 u_short txb_free; /* free bytes in TX buffer */
157 u_char txb_count; /* number of packets in TX buffer */
158 u_char txb_sched; /* number of scheduled packets */
159 u_char txb_padding; /* number of delayed padding bytes */
160
161 /* Multicast address filter management. */
162 u_char filter_change; /* MARs must be changed ASAP. */
163 u_char filter[FE_FILTER_LEN]; /* new filter value. */
164
165 u_int8_t sc_enaddr[ETHER_ADDR_LEN];
166
167 #if NRND > 0
168 rndsource_element_t rnd_source;
169 #endif
170
171 int sc_enabled; /* boolean; power enabled on interface */
172
173 int (*sc_enable) __P((struct mb86960_softc *));
174 void (*sc_disable) __P((struct mb86960_softc *));
175
176 int (*sc_mediachange) __P((struct mb86960_softc *));
177 void (*sc_mediastatus) __P((struct mb86960_softc *,
178 struct ifmediareq *));
179 };
180
181 /* Ethernet constants. To be defined in if_ehter.h? FIXME. */
182 #define ETHER_MIN_LEN 60 /* with header, without CRC. */
183 #define ETHER_MAX_LEN 1514 /* with header, without CRC. */
184 #define ETHER_HDR_SIZE 14 /* src addr, dst addr, and data type. */
185
186 /*
187 * Fe driver specific constants which relate to 86960/86965.
188 */
189
190 /* Interrupt masks. */
191 #define FE_TMASK (FE_D2_COLL16 | FE_D2_TXDONE)
192 #define FE_RMASK (FE_D3_OVRFLO | FE_D3_CRCERR | \
193 FE_D3_ALGERR | FE_D3_SRTPKT | FE_D3_PKTRDY)
194
195 /* Maximum number of iterrations for a receive interrupt. */
196 #define FE_MAX_RECV_COUNT ((65536 - 2048 * 2) / 64)
197 /* Maximum size of SRAM is 65536,
198 * minimum size of transmission buffer in fe is 2x2KB,
199 * and minimum amount of received packet including headers
200 * added by the chip is 64 bytes.
201 * Hence FE_MAX_RECV_COUNT is the upper limit for number
202 * of packets in the receive buffer. */
203
204 void mb86960_attach __P((struct mb86960_softc *, enum mb86960_type,
205 u_int8_t *));
206 void mb86960_config __P((struct mb86960_softc *, int *, int, int));
207 int mb86960_intr __P((void *));
208 int mb86960_enable __P((struct mb86960_softc *));
209 void mb86960_disable __P((struct mb86960_softc *));
210