2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
4 * This software may be used, modified, copied, distributed, and sold, in
5 * both source and binary form provided that the above copyright, these
6 * terms and the following disclaimer are retained. The name of the author
7 * and/or the contributor may not be used to endorse or promote products
8 * derived from this software without specific prior written permission.
10 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND
11 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE
14 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
16 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION.
17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 /* How many registers does an fe-supported adapter have at maximum? */
26 #define MAXREGISTERS 32
28 /* Shouldn't these be defined somewhere else such as isa_device.h? */
31 /* Flags for stability. */
32 #define UNSTABLE_IRQ 0x01 /* IRQ setting may be incorrect. */
33 #define UNSTABLE_MAC 0x02 /* Probed MAC address may be incorrect. */
34 #define UNSTABLE_TYPE 0x04 /* Probed vendor/model may be incorrect. */
36 /* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */
54 #define FE_TYPE_RE1000 9
55 #define FE_TYPE_CNET9NE 10
56 #define FE_TYPE_REX 11
59 * Data type for a multicast address filter on 8696x.
62 u_char data [FE_FILTER_LEN];
66 * fe_softc: per line info and status
70 /* Used by "common" codes. */
75 /* Used by config codes. */
78 struct resource * port_res;
80 bus_space_handle_t ioh;
81 struct resource * irq_res;
84 /* Set by probe() and not modified in later phases. */
85 char const * typestr; /* printable name of the interface. */
86 u_short txb_size; /* size of TX buffer, in bytes */
87 u_char proto_dlcr4; /* DLCR4 prototype. */
88 u_char proto_dlcr5; /* DLCR5 prototype. */
89 u_char proto_dlcr6; /* DLCR6 prototype. */
90 u_char proto_dlcr7; /* DLCR7 prototype. */
91 u_char proto_bmpr13; /* BMPR13 prototype. */
92 u_char stability; /* How stable is this? */
93 u_short priv_info; /* info specific to a vendor/model. */
95 /* Vendor/model specific hooks. */
96 void (*init)(struct fe_softc *); /* Just before fe_init(). */
97 void (*stop)(struct fe_softc *); /* Just after fe_stop(). */
99 /* Transmission buffer management. */
100 u_short txb_free; /* free bytes in TX buffer */
101 u_char txb_count; /* number of packets in TX buffer */
102 u_char txb_sched; /* number of scheduled packets */
104 /* Excessive collision counter (see fe_tint() for details.) */
105 u_char tx_excolls; /* # of excessive collisions. */
107 /* Multicast address filter management. */
108 u_char filter_change; /* MARs must be changed ASAP. */
109 struct fe_filter filter;/* new filter value. */
111 /* Network management. */
112 struct ifmib_iso_8802_3 mibdata;
114 /* Media information. */
115 struct ifmedia media; /* used by if_media. */
116 u_short mbitmap; /* bitmap for supported media; see bit2media */
117 int defmedia; /* default media */
118 void (* msel)(struct fe_softc *); /* media selector. */
122 struct fe_simple_probe_struct {
123 u_char port; /* Offset from the base I/O address. */
124 u_char mask; /* Bits to be checked. */
125 u_char bits; /* Values to be compared against. */
129 extern devclass_t fe_devclass;
131 int fe_attach(device_t);
132 int fe_alloc_port(device_t, int);
133 int fe_alloc_irq(device_t, int);
134 void fe_release_resource(device_t);
136 int fe_simple_probe(struct fe_softc const *,
137 struct fe_simple_probe_struct const *);
138 int fe_valid_Ether_p(u_char const *, unsigned);
139 void fe_softc_defaults(struct fe_softc *);
140 void fe_stop(struct fe_softc *sc);
141 void fe_irq_failure(char const *, int, int, char const *);
142 void fe_msel_965(struct fe_softc *);
143 void fe_read_eeprom_jli(struct fe_softc *, u_char *);
144 void fe_init_jli(struct fe_softc *);
145 void fe_read_eeprom_ssi(struct fe_softc *, u_char *);
146 void fe_read_eeprom_lnx(struct fe_softc *, u_char *);
147 void fe_init_lnx(struct fe_softc *);
148 void fe_init_ubn(struct fe_softc *);
151 #define fe_inb(sc, port) \
152 bus_space_read_1((sc)->iot, (sc)->ioh, (port))
154 #define fe_outb(sc, port, value) \
155 bus_space_write_1((sc)->iot, (sc)->ioh, (port), (value))
157 #define fe_inw(sc, port) \
158 bus_space_read_2((sc)->iot, (sc)->ioh, (port))
160 #define fe_outw(sc, port, value) \
161 bus_space_write_2((sc)->iot, (sc)->ioh, (port), (value))
163 #define fe_insb(sc, port, addr, count) \
164 bus_space_read_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
166 #define fe_outsb(sc, port, addr, count) \
167 bus_space_write_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
169 #define fe_insw(sc, port, addr, count) \
170 bus_space_read_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count))
172 #define fe_outsw(sc, port, addr, count) \
173 bus_space_write_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count))
175 #define fe_inblk(sc, port, addr, count) \
176 bus_space_read_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
178 #define fe_outblk(sc, port, addr, count) \
179 bus_space_write_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count))