if_fevar.h revision 139972
1188943Sthompsa/*- 2188943Sthompsa * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 3188943Sthompsa * 4188943Sthompsa * This software may be used, modified, copied, distributed, and sold, in 5188943Sthompsa * both source and binary form provided that the above copyright, these 6188943Sthompsa * terms and the following disclaimer are retained. The name of the author 7188943Sthompsa * and/or the contributor may not be used to endorse or promote products 8188943Sthompsa * derived from this software without specific prior written permission. 9188943Sthompsa * 10188943Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND 11188943Sthompsa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 12188943Sthompsa * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 13188943Sthompsa * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE 14188943Sthompsa * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 15188943Sthompsa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 16188943Sthompsa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION. 17188943Sthompsa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18188943Sthompsa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 19188943Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 20188943Sthompsa * SUCH DAMAGE. 21188943Sthompsa * 22188943Sthompsa * $FreeBSD: head/sys/dev/fe/if_fevar.h 139972 2005-01-10 09:29:48Z imp $ 23188943Sthompsa */ 24188943Sthompsa 25188943Sthompsa/* How many registers does an fe-supported adapter have at maximum? */ 26188943Sthompsa#define MAXREGISTERS 32 27188943Sthompsa 28188943Sthompsa/* Shouldn't these be defined somewhere else such as isa_device.h? */ 29188943Sthompsa#define NO_IRQ 0 30188943Sthompsa 31188943Sthompsa/* Flags for stability. */ 32188943Sthompsa#define UNSTABLE_IRQ 0x01 /* IRQ setting may be incorrect. */ 33188943Sthompsa#define UNSTABLE_MAC 0x02 /* Probed MAC address may be incorrect. */ 34188943Sthompsa#define UNSTABLE_TYPE 0x04 /* Probed vendor/model may be incorrect. */ 35188943Sthompsa 36188943Sthompsa/* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */ 37#define MB_HA 0x0001 38#define MB_HM 0x0002 39#define MB_HT 0x0004 40#define MB_H2 0x0008 41#define MB_H5 0x0010 42#define MB_HF 0x0020 43#define MB_FT 0x0040 44 45/* Card types. */ 46#define FE_TYPE_SSI 1 47#define FE_TYPE_JLI 2 48#define FE_TYPE_FMV 3 49#define FE_TYPE_LNX 4 50#define FE_TYPE_UBN 5 51#define FE_TYPE_GWY 6 52#define FE_TYPE_MBH 7 53#define FE_TYPE_TDK 8 54#define FE_TYPE_RE1000 9 55#define FE_TYPE_CNET9NE 10 56#define FE_TYPE_REX 11 57 58/* 59 * Data type for a multicast address filter on 8696x. 60 */ 61struct fe_filter { 62 u_char data [FE_FILTER_LEN]; 63}; 64 65/* 66 * fe_softc: per line info and status 67 */ 68struct fe_softc { 69 70 /* Used by "common" codes. */ 71 struct arpcom arpcom; /* Ethernet common */ 72 int sc_unit; 73 74 /* Used by config codes. */ 75 int type; 76 int port_used; 77 struct resource * port_res; 78 bus_space_tag_t iot; 79 bus_space_handle_t ioh; 80 struct resource * irq_res; 81 void * irq_handle; 82 83 /* Set by probe() and not modified in later phases. */ 84 char const * typestr; /* printable name of the interface. */ 85 u_short txb_size; /* size of TX buffer, in bytes */ 86 u_char proto_dlcr4; /* DLCR4 prototype. */ 87 u_char proto_dlcr5; /* DLCR5 prototype. */ 88 u_char proto_dlcr6; /* DLCR6 prototype. */ 89 u_char proto_dlcr7; /* DLCR7 prototype. */ 90 u_char proto_bmpr13; /* BMPR13 prototype. */ 91 u_char stability; /* How stable is this? */ 92 u_short priv_info; /* info specific to a vendor/model. */ 93 94 /* Vendor/model specific hooks. */ 95 void (*init)(struct fe_softc *); /* Just before fe_init(). */ 96 void (*stop)(struct fe_softc *); /* Just after fe_stop(). */ 97 98 /* Transmission buffer management. */ 99 u_short txb_free; /* free bytes in TX buffer */ 100 u_char txb_count; /* number of packets in TX buffer */ 101 u_char txb_sched; /* number of scheduled packets */ 102 103 /* Excessive collision counter (see fe_tint() for details.) */ 104 u_char tx_excolls; /* # of excessive collisions. */ 105 106 /* Multicast address filter management. */ 107 u_char filter_change; /* MARs must be changed ASAP. */ 108 struct fe_filter filter;/* new filter value. */ 109 110 /* Network management. */ 111 struct ifmib_iso_8802_3 mibdata; 112 113 /* Media information. */ 114 struct ifmedia media; /* used by if_media. */ 115 u_short mbitmap; /* bitmap for supported media; see bit2media */ 116 int defmedia; /* default media */ 117 void (* msel)(struct fe_softc *); /* media selector. */ 118 119}; 120 121#define sc_if arpcom.ac_if 122#define sc_xname arpcom.ac_if.if_xname 123#define sc_enaddr arpcom.ac_enaddr 124 125 126struct fe_simple_probe_struct { 127 u_char port; /* Offset from the base I/O address. */ 128 u_char mask; /* Bits to be checked. */ 129 u_char bits; /* Values to be compared against. */ 130}; 131 132 133extern devclass_t fe_devclass; 134 135int fe_attach(device_t); 136int fe_alloc_port(device_t, int); 137int fe_alloc_irq(device_t, int); 138void fe_release_resource(device_t); 139 140int fe_simple_probe(struct fe_softc const *, 141 struct fe_simple_probe_struct const *); 142int fe_valid_Ether_p(u_char const *, unsigned); 143void fe_softc_defaults(struct fe_softc *); 144void fe_stop(struct fe_softc *sc); 145void fe_irq_failure(char const *, int, int, char const *); 146void fe_msel_965(struct fe_softc *); 147void fe_read_eeprom_jli(struct fe_softc *, u_char *); 148void fe_init_jli(struct fe_softc *); 149void fe_read_eeprom_ssi(struct fe_softc *, u_char *); 150void fe_read_eeprom_lnx(struct fe_softc *, u_char *); 151void fe_init_lnx(struct fe_softc *); 152void fe_init_ubn(struct fe_softc *); 153 154 155#define fe_inb(sc, port) \ 156 bus_space_read_1((sc)->iot, (sc)->ioh, (port)) 157 158#define fe_outb(sc, port, value) \ 159 bus_space_write_1((sc)->iot, (sc)->ioh, (port), (value)) 160 161#define fe_inw(sc, port) \ 162 bus_space_read_2((sc)->iot, (sc)->ioh, (port)) 163 164#define fe_outw(sc, port, value) \ 165 bus_space_write_2((sc)->iot, (sc)->ioh, (port), (value)) 166 167#define fe_insb(sc, port, addr, count) \ 168 bus_space_read_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count)) 169 170#define fe_outsb(sc, port, addr, count) \ 171 bus_space_write_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count)) 172 173#define fe_insw(sc, port, addr, count) \ 174 bus_space_read_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count)) 175 176#define fe_outsw(sc, port, addr, count) \ 177 bus_space_write_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count)) 178 179#define fe_inblk(sc, port, addr, count) \ 180 bus_space_read_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count)) 181 182#define fe_outblk(sc, port, addr, count) \ 183 bus_space_write_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count)) 184