From owner-freebsd-hackers Sun Aug 27 11:23:40 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.FreeBSD.org (8.6.11/8.6.6) id LAA29189 for hackers-outgoing; Sun, 27 Aug 1995 11:23:40 -0700 Received: from linux.csie.nctu.edu.tw (linux.csie.nctu.edu.tw [140.113.235.252]) by freefall.FreeBSD.org (8.6.11/8.6.6) with ESMTP id LAA29180 for ; Sun, 27 Aug 1995 11:23:32 -0700 Received: (from jdli@localhost) by linux.csie.nctu.edu.tw (8.6.9/8.6.9) id CAA32229 for freebsd-hackers@FreeBSD.ORG; Mon, 28 Aug 1995 02:20:25 +0800 From: Chien-Ta Lee Message-Id: <199508271820.CAA32229@linux.csie.nctu.edu.tw> Subject: [patch] AMD Lance PCnet-PCI NE2100/Am79C970 To: freebsd-hackers@FreeBSD.ORG Date: Mon, 28 Aug 1995 02:20:25 +0800 (CST) X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 4873 Sender: hackers-owner@FreeBSD.ORG Precedence: bulk Hi : Someone send this patch to hackers-mailing-list before, and now someone requests this patch from me, so I sent this patch again. I hope this patch can be merged into current source, since it works for me. (I am not the author, thanks to vak) ------------------------------------------------------------------------ From: vak@cronyx.ru ("Serge V.Vakulenko") Subject: [patch] if_lnc.c: support for PCI Lance Ethernet adapters added Date: 20 Jul 1995 23:44:35 +0800 This patch adds the support for PCI Ethernet cards, based on AMD 79C970 chip. Apply this patch, and add the following lines to the kernel config file: controller pci0 device lnc0 Enjoy! Some notes: 1. The Am79C970 chip has the same manufacturer id as the Am79C965 one. Probing for it was wrong in the original driver. 2. Loss of carrier message could happen too often on overloaded networks, it surely does not worth printing. 3. There was a question of unit number conflict with configured ISA/EISA/VLB cards, the PCI probe routine now skips all busy unit numbers. Serge Vakulenko, Cronyx Ltd. --- if_lnc205.h Mon Oct 3 00:14:36 1994 +++ if_lnc.h Thu Jul 20 18:45:55 1995 @@ -67,8 +67,7 @@ #define PART_MASK 0xffff #define Am79C960 0x0003 #define Am79C961 0x2260 -#define Am79C965 0x2430 -#define Am79C970 0x0242 +#define Am79C965 0x2430 /* the same as for Am79C970 */ /* Board types */ #define UNKNOWN 0 --- if_lnc205.c Tue May 30 12:02:24 1995 +++ if_lnc.c Thu Jul 20 18:44:16 1995 @@ -698,7 +698,7 @@ } if (next->md->md3 & LCAR) { LNCSTATS(lcar) - log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit); + /* log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit); */ } if (next->md->md3 & RTRY) { LNCSTATS(rtry) @@ -1017,8 +1017,6 @@ return (PCnet_ISAplus); case Am79C965: return (PCnet_32); - case Am79C970: - return (PCnet_PCI); default: break; } @@ -1032,6 +1030,11 @@ { struct lnc_softc *sc = &lnc_softc[isa_dev->id_unit]; int lnc_mem_size; + static char *board_name [] = { /* Board types */ + "UNKNOWN", "BICC", "NE2100", "DEPCA" }; + static char *chip_name [] = { /* Chip types */ + "UNKNOWN", "Am7990", "Am79C90", "Am79C960", + "Am79C961", "Am79C965", "Am79C970" }; /* * Allocate memory for use by the controller. @@ -1106,6 +1109,15 @@ isa_dev->id_unit, sc->kdc.kdc_description, ether_sprintf(sc->arpcom.ac_enaddr)); + printf("lnc%d: type %s", isa_dev->id_unit, board_name[sc->nic.ident]); + if (sc->nic.ic) + printf("/%s", chip_name[sc->nic.ic]); + switch (sc->nic.mem_mode) { + case DMA_FIXED: printf (", static DMA buffer mode"); break; + case DMA_MBUF: printf (", chained DMA buffers mode"); break; + case SHMEM: printf (", shared memory mode"); break; + } + printf("\n"); #if NBPFILTER > 0 bpfattach(&sc->bpf, &sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); @@ -1673,6 +1685,73 @@ ++lnc_softc[unit].arpcom.ac_if.if_oerrors; lnc_reset(unit); } + +/* + * PCI bus probe and attach routines for LANCE Ethernet controllers, + * by Serge V.Vakulenko, vak@cronyx.ru + */ +#include +#if NPCI > 0 +#include +#include +#include + +static char *lnc_pci_probe (pcici_t tag, pcidi_t type); +static void lnc_pci_attach (pcici_t config_id, int unit); + +static u_long lnc_pci_count; + +struct pci_device lnc_pci_device = { "lnc", + lnc_pci_probe, lnc_pci_attach, &lnc_pci_count, 0 }; + +DATA_SET (pcidevice_set, lnc_pci_device); + +static char *lnc_pci_probe (pcici_t tag, pcidi_t type) +{ + char *name = 0; + struct isa_device *d; + + if (type == 0x20001022) + name = "AMD Lance Ethernet"; + if (! name) + return (0); + + /* Look at configuration table and skip all ISA/EISA + * Lance unit numbers to avoid conflict. */ +again: + for (d=isa_devtab_net; d->id_driver; ++d) + if (d->id_driver == &lncdriver && d->id_unit == lnc_pci_count) { + ++lnc_pci_count; + goto again; + } + if (lnc_pci_count >= NLNC) + return (0); + return (name); +} + +void lnc_pci_attach (pcici_t config_id, int unit) +{ + struct isa_device dv; + + dv.id_unit = unit; + dv.id_iobase = pci_conf_read (config_id, PCI_MAP_REG_START); + if (! dv.id_iobase) + return; + dv.id_iobase &= ~1; + + if (! lnc_probe (&dv)) + return; + + if (! pci_map_int (config_id, (int(*)())lncintr, (void*)unit, &net_imask)) + return; + + if (lnc_softc[unit].nic.ic == PCnet_32) { + lnc_softc[unit].nic.ic = PCnet_PCI; + lnc_softc[unit].kdc.kdc_description = "PCnet-PCI Ethernet controller"; + } + lnc_attach (&dv); +} +#endif /* NPCI > 0 */ #ifdef DEBUG void -- 李 建 達 (Adonis) 交大資工 Mail: jdli@csie.nctu.edu.tw