Deleted Added
sdiff udiff text old ( 13638 ) new ( 13937 )
full compact
1/*
2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
3 *
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.

--- 200 unchanged lines hidden (view full) ---

209 u_char proto_dlcr5; /* DLCR5 prototype. */
210 u_char proto_dlcr6; /* DLCR6 prototype. */
211 u_char proto_dlcr7; /* DLCR7 prototype. */
212
213 /* Vendor specific hooks. */
214 void ( * init )( struct fe_softc * ); /* Just before fe_init(). */
215 void ( * stop )( struct fe_softc * ); /* Just after fe_stop(). */
216
217 /* For BPF. */
218 caddr_t bpf; /* BPF "magic cookie" */
219
220 /* Transmission buffer management. */
221 u_short txb_free; /* free bytes in TX buffer */
222 u_char txb_count; /* number of packets in TX buffer */
223 u_char txb_sched; /* number of scheduled packets */
224 u_char txb_padding; /* number of delayed padding bytes */
225
226 /* Multicast address filter management. */
227 u_char filter_change; /* MARs must be changed ASAP. */
228 struct fe_filter filter;/* new filter value. */
229
230} fe_softc[NFE];
231
232/* Frequently accessed members in arpcom and kdc. */
233#define sc_if arpcom.ac_if
234#define sc_unit arpcom.ac_if.if_unit
235#define sc_enaddr arpcom.ac_enaddr
236#define sc_dcstate kdc.kdc_state
237#define sc_description kdc.kdc_description
238
239/*
240 * Some entry functions receive a "struct ifnet *" typed pointer as an
241 * argument. It points to arpcom.ac_if of our softc. Remember arpcom.ac_if
242 * is located at very first of the fe_softc struct. So, there is no
243 * difference between "struct fe_softc *" and "struct ifnet *" at the machine
244 * language level. We just cast to turn a "struct ifnet *" value into "struct
245 * fe_softc * value". If this were C++, we would need no such cast at all.
246 */
247#define IFNET2SOFTC(P) ( ( struct fe_softc * )(P) )
248
249/* Standard driver entry points. These can be static. */
250static int fe_probe ( struct isa_device * );
251static int fe_attach ( struct isa_device * );
252static void fe_init ( int );
253static int fe_ioctl ( struct ifnet *, int, caddr_t );
254static void fe_start ( struct ifnet * );
255static void fe_reset ( int );

--- 10 unchanged lines hidden (view full) ---

266static void fe_rint ( struct fe_softc *, u_char );
267static void fe_xmit ( struct fe_softc * );
268static void fe_write_mbufs ( struct fe_softc *, struct mbuf * );
269static struct fe_filter
270 fe_mcaf ( struct fe_softc * );
271static int fe_hash ( u_char * );
272static void fe_setmode ( struct fe_softc * );
273static void fe_loadmar ( struct fe_softc * );
274static void fe_setlinkaddr ( struct fe_softc * );
275#if FE_DEBUG >= 1
276static void fe_dump ( int, struct fe_softc *, char * );
277#endif
278
279/* Ethernet constants. To be defined in if_ehter.h? FIXME. */
280#define ETHER_MIN_LEN 60 /* with header, without CRC. */
281#define ETHER_MAX_LEN 1514 /* with header, without CRC. */
282#define ETHER_ADDR_LEN 6 /* number of bytes in an address. */

--- 773 unchanged lines hidden (view full) ---

1056static int
1057fe_attach ( struct isa_device *isa_dev )
1058{
1059 struct fe_softc *sc = &fe_softc[isa_dev->id_unit];
1060
1061 /*
1062 * Initialize ifnet structure
1063 */
1064 sc->sc_if.if_unit = sc->sc_unit;
1065 sc->sc_if.if_name = "fe";
1066 sc->sc_if.if_output = ether_output;
1067 sc->sc_if.if_start = fe_start;
1068 sc->sc_if.if_ioctl = fe_ioctl;
1069 sc->sc_if.if_watchdog = fe_watchdog;
1070
1071 /*

--- 45 unchanged lines hidden (view full) ---

1117 sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
1118 sc->txb_size = 2048;
1119 break;
1120 }
1121
1122 /* Attach and stop the interface. */
1123 if_attach( &sc->sc_if );
1124 fe_stop( sc->sc_unit ); /* This changes the state to IDLE. */
1125 fe_setlinkaddr( sc );
1126
1127 /* Print additional info when attached. */
1128 printf( "fe%d: address %6D, type %s\n", sc->sc_unit,
1129 sc->sc_enaddr, ":" , sc->typestr );
1130#if FE_DEBUG >= 3
1131 {
1132 int buf, txb, bbw, sbw, ram;
1133

--- 23 unchanged lines hidden (view full) ---

1157 }
1158 printf( "fe%d: SRAM %dKB %dbit %dns, TXB %dKBx2, %dbit I/O\n",
1159 sc->sc_unit, buf, bbw, ram, txb, sbw );
1160 }
1161#endif
1162
1163#if NBPFILTER > 0
1164 /* If BPF is in the kernel, call the attach for it. */
1165 bpfattach(&sc->bpf, &sc->sc_if, DLT_EN10MB,
1166 sizeof(struct ether_header));
1167#endif
1168 return 1;
1169}
1170
1171/*
1172 * Reset interface.
1173 */
1174static void

--- 920 unchanged lines hidden (view full) ---

2095 struct ifreq * ifr = ( struct ifreq * )data;
2096
2097 bcopy((caddr_t)sc->sc_enaddr,
2098 (caddr_t)&ifr->ifr_data, ETHER_ADDR_LEN);
2099 break;
2100 }
2101#endif
2102
2103#ifdef SIOCSIFPHYSADDR
2104 case SIOCSIFPHYSADDR:
2105 {
2106 /*
2107 * Set the physical (Ehternet) address of the interface.
2108 * When and by whom is this command used? FIXME.
2109 */
2110 struct ifreq * ifr = ( struct ifreq * )data;
2111
2112 bcopy((caddr_t)&ifr->ifr_data,
2113 (caddr_t)sc->sc_enaddr, ETHER_ADDR_LEN);
2114 fe_setlinkaddr( sc );
2115 break;
2116 }
2117#endif
2118
2119#ifdef SIOCSIFFLAGS
2120 case SIOCSIFFLAGS:
2121 {
2122 /*
2123 * Switch interface state between "running" and
2124 * "stopped", reflecting the UP flag.
2125 */

--- 147 unchanged lines hidden (view full) ---

2273
2274#define ETHER_ADDR_IS_MULTICAST(A) (*(char *)(A) & 1)
2275
2276#if NBPFILTER > 0
2277 /*
2278 * Check if there's a BPF listener on this interface.
2279 * If it is, hand off the raw packet to bpf.
2280 */
2281 if ( sc->bpf ) {
2282 bpf_mtap( sc->bpf, m );
2283 }
2284#endif
2285
2286 /*
2287 * Make sure this packet is (or may be) directed to us.
2288 * That is, the packet is either unicasted to our address,
2289 * or broad/multi-casted. If any other packets are
2290 * received, it is an indication of an error -- probably

--- 384 unchanged lines hidden (view full) ---

2675 /* We have just updated the filter. */
2676 sc->filter_change = 0;
2677
2678#if FE_DEBUG >= 3
2679 log( LOG_INFO, "fe%d: address filter changed\n", sc->sc_unit );
2680#endif
2681}
2682
2683/*
2684 * Copy the physical (Ethernet) address into the "data link" address
2685 * entry of the address list for an interface.
2686 * This is (said to be) useful for netstat(1) to keep track of which
2687 * interface is which.
2688 *
2689 * What I'm not sure on this function is, why this is a driver's function.
2690 * Probably this should be moved to somewhere independent to a specific
2691 * hardware, such as if_ehtersubr.c. FIXME.
2692 */
2693static void
2694fe_setlinkaddr ( struct fe_softc * sc )
2695{
2696 struct ifaddr *ifa;
2697 struct sockaddr_dl * sdl;
2698
2699 /*
2700 * Search down the ifa address list looking for the AF_LINK type entry.
2701 */
2702 for ( ifa = sc->sc_if.if_addrlist; ifa != NULL; ifa = ifa->ifa_next ) {
2703 if ( ifa->ifa_addr != NULL
2704 && ifa->ifa_addr->sa_family == AF_LINK ) {
2705
2706 /*
2707 * We have found an AF_LINK type entry.
2708 * Fill in the link-level address for this interface
2709 */
2710 sdl = (struct sockaddr_dl *) ifa->ifa_addr;
2711 sdl->sdl_type = IFT_ETHER;
2712 sdl->sdl_alen = ETHER_ADDR_LEN;
2713 sdl->sdl_slen = 0;
2714 bcopy(sc->sc_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
2715#if FE_DEBUG >= 3
2716 log( LOG_INFO, "fe%d: link address set\n",
2717 sc->sc_unit );
2718#endif
2719 return;
2720 }
2721 }
2722}
2723
2724#if FE_DEBUG >= 1
2725static void
2726fe_dump ( int level, struct fe_softc * sc, char * message )
2727{
2728 log( level, "fe%d: %s,"
2729 " DLCR = %02x %02x %02x %02x %02x %02x %02x %02x,"
2730 " BMPR = xx xx %02x %02x %02x %02x %02x %02x,"
2731 " asic = %02x %02x %02x %02x %02x %02x %02x %02x"

--- 19 unchanged lines hidden ---