Deleted Added
full compact
if_sn.c (63090) if_sn.c (66058)
1/*
2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
1/*
2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $FreeBSD: head/sys/dev/sn/if_sn.c 63090 2000-07-13 22:54:34Z archie $
31 * $FreeBSD: head/sys/dev/sn/if_sn.c 66058 2000-09-19 04:39:20Z imp $
32 */
33
34/*
35 * This is a driver for SMC's 9000 series of Ethernet adapters.
36 *
37 * This FreeBSD driver is derived from the smc9194 Linux driver by
38 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
39 * This driver also shamelessly borrows from the FreeBSD ep driver

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

73 *
74 * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
75 * BSD-nomads, Tokyo, Japan.
76 */
77/*
78 * Multicast support by Kei TANAKA <kei@pal.xerox.com>
79 * Special thanks to itojun@itojun.org
80 */
32 */
33
34/*
35 * This is a driver for SMC's 9000 series of Ethernet adapters.
36 *
37 * This FreeBSD driver is derived from the smc9194 Linux driver by
38 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
39 * This driver also shamelessly borrows from the FreeBSD ep driver

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

73 *
74 * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
75 * BSD-nomads, Tokyo, Japan.
76 */
77/*
78 * Multicast support by Kei TANAKA <kei@pal.xerox.com>
79 * Special thanks to itojun@itojun.org
80 */
81#define SN_DEBUG
81
82
82#undef SN_DEBUG /* (by hosokawa) */
83
84#include <sys/param.h>
85#include <sys/systm.h>
86#include <sys/errno.h>
87#include <sys/sockio.h>
88#include <sys/mbuf.h>
89#include <sys/socket.h>
90#include <sys/syslog.h>
91

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

356 register struct mbuf *m;
357 struct mbuf *top;
358 int s, pad;
359 int mask;
360 u_short length;
361 u_short numPages;
362 u_char packet_no;
363 int time_out;
83#include <sys/param.h>
84#include <sys/systm.h>
85#include <sys/errno.h>
86#include <sys/sockio.h>
87#include <sys/mbuf.h>
88#include <sys/socket.h>
89#include <sys/syslog.h>
90

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

355 register struct mbuf *m;
356 struct mbuf *top;
357 int s, pad;
358 int mask;
359 u_short length;
360 u_short numPages;
361 u_char packet_no;
362 int time_out;
363 int junk = 0;
364
365 s = splimp();
366
367 if (sc->arpcom.ac_if.if_flags & IFF_OACTIVE) {
368 splx(s);
369 return;
370 }
371 if (sc->pages_wanted != -1) {

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

438 */
439
440 time_out = MEMORY_WAIT_TIME;
441 do {
442 if (inb(BASE + INTR_STAT_REG_B) & IM_ALLOC_INT)
443 break;
444 } while (--time_out);
445
364
365 s = splimp();
366
367 if (sc->arpcom.ac_if.if_flags & IFF_OACTIVE) {
368 splx(s);
369 return;
370 }
371 if (sc->pages_wanted != -1) {

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

438 */
439
440 time_out = MEMORY_WAIT_TIME;
441 do {
442 if (inb(BASE + INTR_STAT_REG_B) & IM_ALLOC_INT)
443 break;
444 } while (--time_out);
445
446 if (!time_out) {
446 if (!time_out || junk > 10) {
447
448 /*
449 * No memory now. Oh well, wait until the chip finds memory
450 * later. Remember how many pages we were asking for and
451 * enable the allocation completion interrupt. Also set a
452 * watchdog in case we miss the interrupt. We mark the
453 * interface active since there is no point in attempting an
454 * snstart() until after the memory is available.

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

464 splx(s);
465 return;
466 }
467 /*
468 * The memory allocation completed. Check the results.
469 */
470 packet_no = inb(BASE + ALLOC_RESULT_REG_B);
471 if (packet_no & ARR_FAILED) {
447
448 /*
449 * No memory now. Oh well, wait until the chip finds memory
450 * later. Remember how many pages we were asking for and
451 * enable the allocation completion interrupt. Also set a
452 * watchdog in case we miss the interrupt. We mark the
453 * interface active since there is no point in attempting an
454 * snstart() until after the memory is available.

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

464 splx(s);
465 return;
466 }
467 /*
468 * The memory allocation completed. Check the results.
469 */
470 packet_no = inb(BASE + ALLOC_RESULT_REG_B);
471 if (packet_no & ARR_FAILED) {
472 printf("sn%d: Memory allocation failed\n", ifp->if_unit);
472 if (junk++ > 10)
473 printf("sn%d: Memory allocation failed\n", ifp->if_unit);
473 goto startagain;
474 }
475 /*
476 * We have a packet number, so tell the card to use it.
477 */
478 outb(BASE + PACKET_NUM_REG_B, packet_no);
479
480 /*

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

1238{
1239 struct sn_softc *sc = device_get_softc(dev);
1240 int err;
1241
1242 sc->port_rid = 0;
1243 sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
1244 0, ~0, SMC_IO_EXTENT, RF_ACTIVE);
1245 if (!sc->port_res) {
474 goto startagain;
475 }
476 /*
477 * We have a packet number, so tell the card to use it.
478 */
479 outb(BASE + PACKET_NUM_REG_B, packet_no);
480
481 /*

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

1239{
1240 struct sn_softc *sc = device_get_softc(dev);
1241 int err;
1242
1243 sc->port_rid = 0;
1244 sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
1245 0, ~0, SMC_IO_EXTENT, RF_ACTIVE);
1246 if (!sc->port_res) {
1246#ifdef SN_DEBUG
1247 device_printf(dev, "Cannot allocate ioport\n");
1248#endif
1247 if (bootverbose)
1248 device_printf(dev, "Cannot allocate ioport\n");
1249 return ENOMEM;
1250 }
1251
1252 sc->irq_rid = 0;
1253 sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
1254 0, ~0, 1, RF_ACTIVE);
1255 if (!sc->irq_res) {
1249 return ENOMEM;
1250 }
1251
1252 sc->irq_rid = 0;
1253 sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
1254 0, ~0, 1, RF_ACTIVE);
1255 if (!sc->irq_res) {
1256#ifdef SN_DEBUG
1257 device_printf(dev, "Cannot allocate irq\n");
1258#endif
1256 if (bootverbose)
1257 device_printf(dev, "Cannot allocate irq\n");
1259 sn_deactivate(dev);
1260 return ENOMEM;
1261 }
1262 if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, sn_intr, sc,
1263 &sc->intrhand)) != 0) {
1264 sn_deactivate(dev);
1265 return err;
1266 }

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

1312 u_short base_address_register;
1313 u_short ioaddr;
1314 int err;
1315
1316 if ((err = sn_activate(dev)) != 0)
1317 return err;
1318
1319 ioaddr = sc->sn_io_addr;
1258 sn_deactivate(dev);
1259 return ENOMEM;
1260 }
1261 if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, sn_intr, sc,
1262 &sc->intrhand)) != 0) {
1263 sn_deactivate(dev);
1264 return err;
1265 }

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

1311 u_short base_address_register;
1312 u_short ioaddr;
1313 int err;
1314
1315 if ((err = sn_activate(dev)) != 0)
1316 return err;
1317
1318 ioaddr = sc->sn_io_addr;
1320
1319#ifdef SN_DEBUG
1320 device_printf(dev, "ioaddr is 0x%x\n", ioaddr);
1321#endif
1321 /*
1322 * First, see if the high byte is 0x33
1323 */
1324 bank = inw(ioaddr + BANK_SELECT_REG_W);
1325 if ((bank & BSR_DETECT_MASK) != BSR_DETECT_VALUE) {
1326#ifdef SN_DEBUG
1327 device_printf(dev, "test1 failed\n");
1328#endif

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

1356 * pccard == 1, skip this test. (hosokawa)
1357 */
1358 if (!pccard && (ioaddr != (base_address_register >> 3 & 0x3E0))) {
1359
1360 /*
1361 * Well, the base address register didn't match. Must not
1362 * have been a SMC chip after all.
1363 */
1322 /*
1323 * First, see if the high byte is 0x33
1324 */
1325 bank = inw(ioaddr + BANK_SELECT_REG_W);
1326 if ((bank & BSR_DETECT_MASK) != BSR_DETECT_VALUE) {
1327#ifdef SN_DEBUG
1328 device_printf(dev, "test1 failed\n");
1329#endif

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

1357 * pccard == 1, skip this test. (hosokawa)
1358 */
1359 if (!pccard && (ioaddr != (base_address_register >> 3 & 0x3E0))) {
1360
1361 /*
1362 * Well, the base address register didn't match. Must not
1363 * have been a SMC chip after all.
1364 */
1364 /*
1365 * printf("sn: ioaddr %x doesn't match card configuration
1366 * (%x)\n", ioaddr, base_address_register >> 3 & 0x3E0 );
1367 */
1368
1369#ifdef SN_DEBUG
1370 device_printf(dev, "test3 failed ioaddr = 0x%x, "
1371 "base_address_register = 0x%x\n", ioaddr,
1372 base_address_register >> 3 & 0x3E0);
1373#endif
1374 goto error;
1375 }
1365#ifdef SN_DEBUG
1366 device_printf(dev, "test3 failed ioaddr = 0x%x, "
1367 "base_address_register = 0x%x\n", ioaddr,
1368 base_address_register >> 3 & 0x3E0);
1369#endif
1370 goto error;
1371 }
1372
1376 /*
1377 * Check if the revision register is something that I recognize.
1378 * These might need to be added to later, as future revisions could
1379 * be added.
1380 */
1381 outw(ioaddr + BANK_SELECT_REG_W, 0x3);
1382 revision_register = inw(ioaddr + REVISION_REG_W);
1383 if (!chip_ids[(revision_register >> 4) & 0xF]) {
1384
1385 /*
1386 * I don't regonize this chip, so...
1387 */
1388#ifdef SN_DEBUG
1389 device_printf(dev, "test4 failed\n");
1390#endif
1391 goto error;
1392 }
1373 /*
1374 * Check if the revision register is something that I recognize.
1375 * These might need to be added to later, as future revisions could
1376 * be added.
1377 */
1378 outw(ioaddr + BANK_SELECT_REG_W, 0x3);
1379 revision_register = inw(ioaddr + REVISION_REG_W);
1380 if (!chip_ids[(revision_register >> 4) & 0xF]) {
1381
1382 /*
1383 * I don't regonize this chip, so...
1384 */
1385#ifdef SN_DEBUG
1386 device_printf(dev, "test4 failed\n");
1387#endif
1388 goto error;
1389 }
1390
1393 /*
1394 * at this point I'll assume that the chip is an SMC9xxx. It might be
1395 * prudent to check a listing of MAC addresses against the hardware
1396 * address, or do some other tests.
1397 */
1398 sn_deactivate(dev);
1399 return 0;
1400 error:

--- 88 unchanged lines hidden ---
1391 /*
1392 * at this point I'll assume that the chip is an SMC9xxx. It might be
1393 * prudent to check a listing of MAC addresses against the hardware
1394 * address, or do some other tests.
1395 */
1396 sn_deactivate(dev);
1397 return 0;
1398 error:

--- 88 unchanged lines hidden ---