Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 1995 19:47:30 +0400 (MSD)
From:      "Serge V.Vakulenko" <vak@cronyx.ru>
To:        hackers@freebsd.org
Cc:        paul@isl.cf.ac.uk
Subject:   [patch] if_lnc.c: support for PCI Lance Ethernet adapters added
Message-ID:  <Pine.BSF.3.91.950720194344.478A-100000@hanoi.net.kiae.su>

next in thread | raw e-mail | index | archive | help
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 <pci.h>
+#if NPCI > 0
+#include <sys/kernel.h>
+#include <pci/pcireg.h>
+#include <pci/pcivar.h>
+
+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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.950720194344.478A-100000>