Deleted Added
full compact
if_fe.c (21673) if_fe.c (21694)
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.

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

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
20 * SUCH DAMAGE.
21 */
22
23/*
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.

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

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
20 * SUCH DAMAGE.
21 */
22
23/*
24 * $FreeBSD: head/sys/dev/fe/if_fe.c 21673 1997-01-14 07:20:47Z jkh $
24 * $FreeBSD: head/sys/dev/fe/if_fe.c 21694 1997-01-14 18:24:59Z wollman $
25 *
26 * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
27 * To be used with FreeBSD 2.x
28 * Contributed by M. Sekiguchi. <seki@sysrap.cs.fujitsu.co.jp>
29 *
30 * This version is intended to be a generic template for various
31 * MB86960A/MB86965A based Ethernet cards. It currently supports
32 * Fujitsu FMV-180 series for ISA and Allied-Telesis AT1700/RE2000

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

375 return (ENODEV);
376 /*
377 * Probe the device. If a value is returned,
378 * the device was found at the location.
379 */
380#if FE_DEBUG >= 2
381 printf("Start Probe\n");
382#endif
25 *
26 * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
27 * To be used with FreeBSD 2.x
28 * Contributed by M. Sekiguchi. <seki@sysrap.cs.fujitsu.co.jp>
29 *
30 * This version is intended to be a generic template for various
31 * MB86960A/MB86965A based Ethernet cards. It currently supports
32 * Fujitsu FMV-180 series for ISA and Allied-Telesis AT1700/RE2000

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

375 return (ENODEV);
376 /*
377 * Probe the device. If a value is returned,
378 * the device was found at the location.
379 */
380#if FE_DEBUG >= 2
381 printf("Start Probe\n");
382#endif
383 /* Initialize "minimum" parts of our softc. */
383 sc = &fe_softc[dp->isahd.id_unit];
384 sc = &fe_softc[dp->isahd.id_unit];
384 memcpy( sc->sc_enaddr, dp->misc, ETHER_ADDR_LEN );
385 if (fe_probe(&dp->isahd) == 0)
385 sc->sc_unit = dp->isahd.id_unit;
386 sc->iobase = dp->isahd.id_iobase;
387
388 /* Use Ethernet address got from CIS, if one is available. */
389 if ((dp->misc[0] & 0x03) == 0x00
390 && (dp->misc[0] | dp->misc[1] | dp->misc[2]) != 0) {
391 /* Yes, it looks like a valid Ether address. */
392 bcopy(dp->misc, sc->sc_enaddr, ETHER_ADDR_LEN);
393 } else {
394 /* Indicate we have no Ether address in CIS. */
395 bzero(sc->sc_enaddr, ETHER_ADDR_LEN);
396 }
397
398 /* Probe supported PC card models. */
399 if (fe_probe_tdk(&dp->isahd, sc) == 0
400 && fe_probe_mbh(&dp->isahd, sc) == 0)
386 return (ENXIO);
387#if FE_DEBUG >= 2
388 printf("Start attach\n");
389#endif
390 if (fe_attach(&dp->isahd) == 0)
391 return (ENXIO);
392 }
393 /*

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

446 { 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x300, 0x340, 0 };
447static u_short const fe_ati_addr [] =
448 { 0x240, 0x260, 0x280, 0x2A0, 0x300, 0x320, 0x340, 0x380, 0 };
449
450static struct fe_probe_list const fe_probe_list [] =
451{
452 { fe_probe_fmv, fe_fmv_addr },
453 { fe_probe_ati, fe_ati_addr },
401 return (ENXIO);
402#if FE_DEBUG >= 2
403 printf("Start attach\n");
404#endif
405 if (fe_attach(&dp->isahd) == 0)
406 return (ENXIO);
407 }
408 /*

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

461 { 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x300, 0x340, 0 };
462static u_short const fe_ati_addr [] =
463 { 0x240, 0x260, 0x280, 0x2A0, 0x300, 0x320, 0x340, 0x380, 0 };
464
465static struct fe_probe_list const fe_probe_list [] =
466{
467 { fe_probe_fmv, fe_fmv_addr },
468 { fe_probe_ati, fe_ati_addr },
454#if NCRD > 0
455 { fe_probe_mbh, NULL }, /* PCMCIAs cannot be auto-detected. */
456 { fe_probe_tdk, NULL },
457#endif
469 { fe_probe_gwy, NULL }, /* GWYs cannot be auto detected. */
458 { NULL, NULL }
459};
460
461
462/*
463 * Determine if the device is present
464 *
465 * on entry:

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

1161fe_probe_gwy ( DEVICE * dev, struct fe_softc * sc )
1162{
1163 int i,type;
1164
1165 static struct fe_simple_probe_struct probe_table [] = {
1166 { FE_DLCR2, 0x70, 0x00 },
1167 { FE_DLCR4, 0x08, 0x00 },
1168 { FE_DLCR7, 0xC0, 0x00 },
470 { NULL, NULL }
471};
472
473
474/*
475 * Determine if the device is present
476 *
477 * on entry:

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

1173fe_probe_gwy ( DEVICE * dev, struct fe_softc * sc )
1174{
1175 int i,type;
1176
1177 static struct fe_simple_probe_struct probe_table [] = {
1178 { FE_DLCR2, 0x70, 0x00 },
1179 { FE_DLCR4, 0x08, 0x00 },
1180 { FE_DLCR7, 0xC0, 0x00 },
1169 /*
1181 /*
1170 * Test *vendor* part of the address for Gateway.
1171 * This test is essential to identify Gateway's cards.
1172 * We shuld define some symbolic names for the
1173 * following offsets. FIXME.
1174 */
1175 { 0x18, 0xFF, 0x00 },
1176 { 0x19, 0xFF, 0x00 },
1177 { 0x1A, 0xFF, 0x61 },

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

1231 outb( sc->ioaddr[ FE_DLCR2 ], 0 );
1232 outb( sc->ioaddr[ FE_DLCR3 ], 0 );
1233
1234 /* That's all. The card occupies 32 I/O addresses, as always. */
1235 return 32;
1236}
1237
1238#if NCRD > 0
1182 * Test *vendor* part of the address for Gateway.
1183 * This test is essential to identify Gateway's cards.
1184 * We shuld define some symbolic names for the
1185 * following offsets. FIXME.
1186 */
1187 { 0x18, 0xFF, 0x00 },
1188 { 0x19, 0xFF, 0x00 },
1189 { 0x1A, 0xFF, 0x61 },

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

1243 outb( sc->ioaddr[ FE_DLCR2 ], 0 );
1244 outb( sc->ioaddr[ FE_DLCR3 ], 0 );
1245
1246 /* That's all. The card occupies 32 I/O addresses, as always. */
1247 return 32;
1248}
1249
1250#if NCRD > 0
1239 /*
1251/*
1240 * Probe and initialization for Fujitsu MBH10302 PCMCIA Ethernet interface.
1241 * Note that this is for 10302 only; MBH10304 is handled by fe_probe_tdk().
1242 */
1243static int
1244fe_probe_mbh ( DEVICE * dev, struct fe_softc * sc )
1245{
1246 int i,type;
1247

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

1372#if NCRD > 0
1373/*
1374 * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface.
1375 * by MASUI Kenji <masui@cs.titech.ac.jp>
1376 *
1377 * (Contec uses TDK Ethenet chip -- hosokawa)
1378 *
1379 * This version of fe_probe_tdk has been rewrote to handle
1252 * Probe and initialization for Fujitsu MBH10302 PCMCIA Ethernet interface.
1253 * Note that this is for 10302 only; MBH10304 is handled by fe_probe_tdk().
1254 */
1255static int
1256fe_probe_mbh ( DEVICE * dev, struct fe_softc * sc )
1257{
1258 int i,type;
1259

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

1384#if NCRD > 0
1385/*
1386 * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface.
1387 * by MASUI Kenji <masui@cs.titech.ac.jp>
1388 *
1389 * (Contec uses TDK Ethenet chip -- hosokawa)
1390 *
1391 * This version of fe_probe_tdk has been rewrote to handle
1380 * *generic* PC card implementation of Fujitsu MB8696x family. The
1381 * name _tdk is just for a historical reason. :-)
1392 * *generic* PC card implementation of Fujitsu MB8696x and compatibles.
1393 * The name _tdk is just for a historical reason. <seki> :-)
1382 */
1383static int
1384fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc )
1385{
1386 int i;
1387
1388 static struct fe_simple_probe_struct probe_table [] = {
1389 { FE_DLCR2, 0x70, 0x00 },
1390 { FE_DLCR4, 0x08, 0x00 },
1391 /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */
1392 { 0 }
1393 };
1394
1394 */
1395static int
1396fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc )
1397{
1398 int i;
1399
1400 static struct fe_simple_probe_struct probe_table [] = {
1401 { FE_DLCR2, 0x70, 0x00 },
1402 { FE_DLCR4, 0x08, 0x00 },
1403 /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */
1404 { 0 }
1405 };
1406
1407 /* We need an IRQ. */
1395 if ( dev->id_irq == NO_IRQ ) {
1396 return ( 0 );
1397 }
1398
1408 if ( dev->id_irq == NO_IRQ ) {
1409 return ( 0 );
1410 }
1411
1399 /* Setup an I/O address mapping table. */
1400 for ( i = 0; i < MAXREGISTERS; i++ ) {
1401 sc->ioaddr[ i ] = sc->iobase + i;
1412 /* Generic driver needs Ethernet address taken from CIS. */
1413 if (sc->arpcom.ac_enaddr[0] == 0
1414 && sc->arpcom.ac_enaddr[1] == 0
1415 && sc->arpcom.ac_enaddr[2] == 0) {
1416 return 0;
1417 }
1418
1419 /* Setup an I/O address mapping table; we need only 16 ports. */
1420 for (i = 0; i < 16; i++) {
1421 sc->ioaddr[i] = sc->iobase + i;
1402 }
1422 }
1423 /* Fill unused slots with a safe address. */
1424 for (i = 16; i < MAXREGISTERS; i++) {
1425 sc->ioaddr[i] = sc->iobase;
1426 }
1403
1404 /*
1405 * See if C-NET(PC)C is on its address.
1406 */
1407
1408 if ( !fe_simple_probe( sc, probe_table ) ) return 0;
1409
1410 /* Determine the card type. */

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

1442 DELAY( 200 );
1443
1444 /* Disable all interrupts. */
1445 outb( sc->ioaddr[ FE_DLCR2 ], 0 );
1446 outb( sc->ioaddr[ FE_DLCR3 ], 0 );
1447
1448 /*
1449 * That's all. C-NET(PC)C occupies 16 I/O addresses.
1427
1428 /*
1429 * See if C-NET(PC)C is on its address.
1430 */
1431
1432 if ( !fe_simple_probe( sc, probe_table ) ) return 0;
1433
1434 /* Determine the card type. */

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

1466 DELAY( 200 );
1467
1468 /* Disable all interrupts. */
1469 outb( sc->ioaddr[ FE_DLCR2 ], 0 );
1470 outb( sc->ioaddr[ FE_DLCR3 ], 0 );
1471
1472 /*
1473 * That's all. C-NET(PC)C occupies 16 I/O addresses.
1450 * XXX: Are there any card with 32 I/O addresses? FIXME.
1451 */
1474 *
1475 * Some PC cards (e.g., TDK and Contec) have 16 I/O addresses,
1476 * while some others (e.g., Fujitsu) have 32. Fortunately,
1477 * this generic driver never accesses latter 16 ports in 32
1478 * ports cards. So, we can assume the *generic* PC cards
1479 * always have 16 ports.
1480 *
1481 * Moreover, PC card probe is isolated from ISA probe, and PC
1482 * card probe routine doesn't use "# of ports" returned by this
1483 * function. 16 v.s. 32 is not important now.
1484 */
1452 return 16;
1453}
1454#endif
1455
1456/*
1457 * Install interface into kernel networking data structures
1458 */
1459static int

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

2073 * Empty receiving buffer.
2074 */
2075static void
2076fe_emptybuffer ( struct fe_softc * sc )
2077{
2078 int i;
2079 u_char saved_dlcr5;
2080
1485 return 16;
1486}
1487#endif
1488
1489/*
1490 * Install interface into kernel networking data structures
1491 */
1492static int

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

2106 * Empty receiving buffer.
2107 */
2108static void
2109fe_emptybuffer ( struct fe_softc * sc )
2110{
2111 int i;
2112 u_char saved_dlcr5;
2113
2081#if FE_DEBUG >= 1
2114#if FE_DEBUG >= 2
2082 log( LOG_WARNING, "fe%d: emptying receive buffer", sc->sc_unit );
2083#endif
2084 /*
2085 * Stop receiving packets, temporarily.
2086 */
2087 saved_dlcr5 = inb( sc->ioaddr[ FE_DLCR5 ] );
2088 outb( sc->ioaddr[ FE_DLCR5 ], sc->proto_dlcr5 );
2115 log( LOG_WARNING, "fe%d: emptying receive buffer", sc->sc_unit );
2116#endif
2117 /*
2118 * Stop receiving packets, temporarily.
2119 */
2120 saved_dlcr5 = inb( sc->ioaddr[ FE_DLCR5 ] );
2121 outb( sc->ioaddr[ FE_DLCR5 ], sc->proto_dlcr5 );
2122 DELAY(1300);
2089
2090 /*
2091 * When we come here, the receive buffer management should
2092 * have been broken. So, we cannot use skip operation.
2123
2124 /*
2125 * When we come here, the receive buffer management should
2126 * have been broken. So, we cannot use skip operation.
2127 * Just discard everything in the buffer.
2093 */
2128 */
2094 for ( i = 0; i < sc->txb_size; i += 2 ) {
2129 for (i = 0; i < 32768; i++) {
2095 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
2096 ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
2097 }
2098
2099 /*
2100 * Double check.
2101 */
2102 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) {

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

2254 u_char status;
2255 int i;
2256
2257 /*
2258 * Update statistics if this interrupt is caused by an error.
2259 */
2260 if ( rstat & ( FE_D1_OVRFLO | FE_D1_CRCERR
2261 | FE_D1_ALGERR | FE_D1_SRTPKT ) ) {
2130 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
2131 ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
2132 }
2133
2134 /*
2135 * Double check.
2136 */
2137 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) {

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

2289 u_char status;
2290 int i;
2291
2292 /*
2293 * Update statistics if this interrupt is caused by an error.
2294 */
2295 if ( rstat & ( FE_D1_OVRFLO | FE_D1_CRCERR
2296 | FE_D1_ALGERR | FE_D1_SRTPKT ) ) {
2262#if FE_DEBUG >= 3
2297#if FE_DEBUG >= 2
2263 log( LOG_WARNING,
2264 "fe%d: receive error: %s%s%s%s(%02x)\n",
2265 sc->sc_unit,
2266 rstat & FE_D1_OVRFLO ? "OVR " : "",
2267 rstat & FE_D1_CRCERR ? "CRC " : "",
2268 rstat & FE_D1_ALGERR ? "ALG " : "",
2269 rstat & FE_D1_SRTPKT ? "LEN " : "",
2270 rstat );
2271#endif
2272 sc->sc_if.if_ierrors++;
2273 }
2274
2275 /*
2276 * MB86960 has a flag indicating "receive queue empty."
2277 * We just loop, checking the flag, to pull out all received
2278 * packets.
2279 *
2280 * We limit the number of iterations to avoid infinite-loop.
2298 log( LOG_WARNING,
2299 "fe%d: receive error: %s%s%s%s(%02x)\n",
2300 sc->sc_unit,
2301 rstat & FE_D1_OVRFLO ? "OVR " : "",
2302 rstat & FE_D1_CRCERR ? "CRC " : "",
2303 rstat & FE_D1_ALGERR ? "ALG " : "",
2304 rstat & FE_D1_SRTPKT ? "LEN " : "",
2305 rstat );
2306#endif
2307 sc->sc_if.if_ierrors++;
2308 }
2309
2310 /*
2311 * MB86960 has a flag indicating "receive queue empty."
2312 * We just loop, checking the flag, to pull out all received
2313 * packets.
2314 *
2315 * We limit the number of iterations to avoid infinite-loop.
2281 * It can be caused by a very slow CPU (some broken
2282 * peripheral may insert incredible number of wait cycles)
2283 * or, worse, by a broken MB86960 chip.
2316 * The upper bound is set to unrealistic high value.
2284 */
2317 */
2285 for ( i = 0; i < FE_MAX_RECV_COUNT; i++ ) {
2318 for (i = 0; i < FE_MAX_RECV_COUNT * 2; i++) {
2286
2287 /* Stop the iteration if 86960 indicates no packets. */
2288 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
2289
2290 /*
2291 * Extract A receive status byte.
2292 * As our 86960 is in 16 bit bus access mode, we have to
2293 * use inw() to get the status byte. The significant

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

2301
2302 /*
2303 * Extract the packet length.
2304 * It is a sum of a header (14 bytes) and a payload.
2305 * CRC has been stripped off by the 86960.
2306 */
2307 len = inw( sc->ioaddr[ FE_BMPR8 ] );
2308
2319
2320 /* Stop the iteration if 86960 indicates no packets. */
2321 if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
2322
2323 /*
2324 * Extract A receive status byte.
2325 * As our 86960 is in 16 bit bus access mode, we have to
2326 * use inw() to get the status byte. The significant

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

2334
2335 /*
2336 * Extract the packet length.
2337 * It is a sum of a header (14 bytes) and a payload.
2338 * CRC has been stripped off by the 86960.
2339 */
2340 len = inw( sc->ioaddr[ FE_BMPR8 ] );
2341
2342#if FE_DEBUG >= 1
2309 /*
2343 /*
2310 * If there was an error, update statistics and drop
2311 * the packet, unless the interface is in promiscuous
2312 * mode.
2344 * If there was an error with the received packet, it
2345 * must be an indication of out-of-sync on receive
2346 * buffer, because we have programmed the 8696x to
2347 * to discard errored packets, even when the interface
2348 * is in promiscuous mode. We have to re-synchronize.
2313 */
2349 */
2314 if ( ( status & 0xF0 ) != 0x20 ) {
2315 if ( !( sc->sc_if.if_flags & IFF_PROMISC ) ) {
2316 sc->sc_if.if_ierrors++;
2317 fe_droppacket( sc, len );
2318 continue;
2319 }
2350 if (!(status & FE_RPH_GOOD)) {
2351 log(LOG_ERR,
2352 "fe%d: corrupted receive status byte (%02x)\n",
2353 sc->arpcom.ac_if.if_unit, status);
2354 sc->arpcom.ac_if.if_ierrors++;
2355 fe_emptybuffer( sc );
2356 break;
2320 }
2357 }
2358#endif
2321
2359
2360#if FE_DEBUG >= 1
2322 /*
2323 * MB86960 checks the packet length and drop big packet
2324 * before passing it to us. There are no chance we can
2325 * get big packets through it, even if they are actually
2326 * sent over a line. Hence, if the length exceeds
2327 * the specified limit, it means some serious failure,
2328 * such as out-of-sync on receive buffer management.
2329 *
2330 * Same for short packets, since we have programmed
2331 * 86960 to drop short packets.
2332 */
2333 if ( len > ETHER_MAX_LEN - ETHER_CRC_LEN
2334 || len < ETHER_MIN_LEN - ETHER_CRC_LEN ) {
2361 /*
2362 * MB86960 checks the packet length and drop big packet
2363 * before passing it to us. There are no chance we can
2364 * get big packets through it, even if they are actually
2365 * sent over a line. Hence, if the length exceeds
2366 * the specified limit, it means some serious failure,
2367 * such as out-of-sync on receive buffer management.
2368 *
2369 * Same for short packets, since we have programmed
2370 * 86960 to drop short packets.
2371 */
2372 if ( len > ETHER_MAX_LEN - ETHER_CRC_LEN
2373 || len < ETHER_MIN_LEN - ETHER_CRC_LEN ) {
2335#if FE_DEBUG >= 1
2336 log( LOG_WARNING,
2337 "fe%d: received a %s packet? (%u bytes)\n",
2338 sc->sc_unit,
2339 len < ETHER_MIN_LEN - ETHER_CRC_LEN
2340 ? "partial" : "big",
2341 len );
2374 log( LOG_WARNING,
2375 "fe%d: received a %s packet? (%u bytes)\n",
2376 sc->sc_unit,
2377 len < ETHER_MIN_LEN - ETHER_CRC_LEN
2378 ? "partial" : "big",
2379 len );
2342#endif
2343 sc->sc_if.if_ierrors++;
2344 fe_emptybuffer( sc );
2380 sc->sc_if.if_ierrors++;
2381 fe_emptybuffer( sc );
2345 continue;
2382 break;
2346 }
2383 }
2384#endif
2347
2348 /*
2349 * Go get a packet.
2350 */
2351 if ( fe_get_packet( sc, len ) < 0 ) {
2385
2386 /*
2387 * Go get a packet.
2388 */
2389 if ( fe_get_packet( sc, len ) < 0 ) {
2352 /* Skip a packet, updating statistics. */
2390
2353#if FE_DEBUG >= 2
2354 log( LOG_WARNING, "%s%d: out of mbuf;"
2355 " dropping a packet (%u bytes)\n",
2356 sc->sc_unit, len );
2357#endif
2391#if FE_DEBUG >= 2
2392 log( LOG_WARNING, "%s%d: out of mbuf;"
2393 " dropping a packet (%u bytes)\n",
2394 sc->sc_unit, len );
2395#endif
2396
2397 /* Skip a packet, updating statistics. */
2358 sc->sc_if.if_ierrors++;
2359 fe_droppacket( sc, len );
2360
2361 /*
2398 sc->sc_if.if_ierrors++;
2399 fe_droppacket( sc, len );
2400
2401 /*
2362 * We stop receiving packets, even if there are
2363 * more in the buffer. We hope we can get more
2364 * mbuf next time.
2402 * Try extracting other packets, although they will
2403 * cause out-of-mbuf error again. This is required
2404 * to keep receiver interrupt comming.
2405 * (Earlier versions had a bug on this point.)
2365 */
2406 */
2366 return;
2407 continue;
2367 }
2368
2369 /* Successfully received a packet. Update stat. */
2370 sc->sc_if.if_ipackets++;
2371 }
2372}
2373
2374/*

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

2389 fe_dump( LOG_INFO, sc, "intr()" );
2390#endif
2391
2392 /*
2393 * Get interrupt conditions, masking unneeded flags.
2394 */
2395 tstat = inb( sc->ioaddr[ FE_DLCR0 ] ) & FE_TMASK;
2396 rstat = inb( sc->ioaddr[ FE_DLCR1 ] ) & FE_RMASK;
2408 }
2409
2410 /* Successfully received a packet. Update stat. */
2411 sc->sc_if.if_ipackets++;
2412 }
2413}
2414
2415/*

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

2430 fe_dump( LOG_INFO, sc, "intr()" );
2431#endif
2432
2433 /*
2434 * Get interrupt conditions, masking unneeded flags.
2435 */
2436 tstat = inb( sc->ioaddr[ FE_DLCR0 ] ) & FE_TMASK;
2437 rstat = inb( sc->ioaddr[ FE_DLCR1 ] ) & FE_RMASK;
2438
2439#if FE_DEBUG >= 1
2440 /* Test for a "dead-lock" condition. */
2441 if ((rstat & FE_D1_PKTRDY) == 0
2442 && (inb(sc->ioaddr[FE_DLCR5]) & FE_D5_BUFEMP) == 0
2443 && (inb(sc->ioaddr[FE_DLCR1]) & FE_D1_PKTRDY) == 0) {
2444 /*
2445 * PKTRDY is off, while receive buffer is not empty.
2446 * We did a double check to avoid a race condition...
2447 * So, we should have missed an interrupt.
2448 */
2449 log(LOG_WARNING,
2450 "fe%d: missed a receiver interrupt?\n",
2451 sc->arpcom.ac_if.if_unit);
2452 /* Simulate the missed interrupt condition. */
2453 rstat |= FE_D1_PKTRDY;
2454 }
2455#endif
2456
2457 /* Stop processing if there are no interrupts to handle. */
2397 if ( tstat == 0 && rstat == 0 ) break;
2398
2399 /*
2400 * Reset the conditions we are acknowledging.
2401 */
2402 outb( sc->ioaddr[ FE_DLCR0 ], tstat );
2403 outb( sc->ioaddr[ FE_DLCR1 ], rstat );
2404

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

2804 u_short length, len;
2805 struct mbuf *mp;
2806 u_char *data;
2807 u_short savebyte; /* WARNING: Architecture dependent! */
2808#define NO_PENDING_BYTE 0xFFFF
2809
2810 static u_char padding [ ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_HDR_LEN ];
2811
2458 if ( tstat == 0 && rstat == 0 ) break;
2459
2460 /*
2461 * Reset the conditions we are acknowledging.
2462 */
2463 outb( sc->ioaddr[ FE_DLCR0 ], tstat );
2464 outb( sc->ioaddr[ FE_DLCR1 ], rstat );
2465

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

2865 u_short length, len;
2866 struct mbuf *mp;
2867 u_char *data;
2868 u_short savebyte; /* WARNING: Architecture dependent! */
2869#define NO_PENDING_BYTE 0xFFFF
2870
2871 static u_char padding [ ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_HDR_LEN ];
2872
2812#if FE_DEBUG >= 2
2873#if FE_DEBUG >= 1
2813 /* First, count up the total number of bytes to copy */
2814 length = 0;
2815 for ( mp = m; mp != NULL; mp = mp->m_next ) {
2816 length += mp->m_len;
2817 }
2874 /* First, count up the total number of bytes to copy */
2875 length = 0;
2876 for ( mp = m; mp != NULL; mp = mp->m_next ) {
2877 length += mp->m_len;
2878 }
2879#else
2880 /* Just use the length value in the packet header. */
2881 length = m->m_pkthdr.len;
2882#endif
2883
2884#if FE_DEBUG >= 2
2818 /* Check if this matches the one in the packet header. */
2819 if ( length != m->m_pkthdr.len ) {
2820 log( LOG_WARNING, "fe%d: packet length mismatch? (%d/%d)\n",
2821 sc->sc_unit, length, m->m_pkthdr.len );
2822 }
2885 /* Check if this matches the one in the packet header. */
2886 if ( length != m->m_pkthdr.len ) {
2887 log( LOG_WARNING, "fe%d: packet length mismatch? (%d/%d)\n",
2888 sc->sc_unit, length, m->m_pkthdr.len );
2889 }
2823#else
2824 /* Just use the length value in the packet header. */
2825 length = m->m_pkthdr.len;
2826#endif
2827
2828#if FE_DEBUG >= 1
2829 /*
2830 * Should never send big packets. If such a packet is passed,
2831 * it should be a bug of upper layer. We just ignore it.
2832 * ... Partial (too short) packets, neither.
2833 */

--- 298 unchanged lines hidden ---
2890#endif
2891
2892#if FE_DEBUG >= 1
2893 /*
2894 * Should never send big packets. If such a packet is passed,
2895 * it should be a bug of upper layer. We just ignore it.
2896 * ... Partial (too short) packets, neither.
2897 */

--- 298 unchanged lines hidden ---