Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev - More PNIC NWAY stuff. Still more work to do, here.
details: https://anonhg.NetBSD.org/src/rev/22ebc90e843b
branches: trunk
changeset: 476343:22ebc90e843b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Sep 14 00:55:38 1999 +0000
description:
- More PNIC NWAY stuff. Still more work to do, here.
- Fix the SROM checksum routine.
- Add code to parse the old DEC Address ROM SROM format.
- Rearrange the statchg routines a bit, to make them consistent with one
another.
- Add support for the DECchip 21040. XXX No support for media autosense
yet, and no support for any of the multi-port boards yet.
diffstat:
sys/dev/ic/tulip.c | 373 +++++++++++++++++++++++++++++++++++++++++++++-
sys/dev/ic/tulipreg.h | 65 +++++++-
sys/dev/ic/tulipvar.h | 20 ++-
sys/dev/pci/if_tlp_pci.c | 53 +++++-
4 files changed, 485 insertions(+), 26 deletions(-)
diffs (truncated from 735 to 300 lines):
diff -r 7c993deb03e6 -r 22ebc90e843b sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c Mon Sep 13 23:04:34 1999 +0000
+++ b/sys/dev/ic/tulip.c Tue Sep 14 00:55:38 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.6 1999/09/09 21:48:18 thorpej Exp $ */
+/* $NetBSD: tulip.c,v 1.7 1999/09/14 00:55:38 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -236,6 +236,12 @@
break;
default:
+ /*
+ * We may override this if we have special media
+ * handling requirements (e.g. flipping GPIO pins).
+ *
+ * The pure-MII statchg function covers the basics.
+ */
sc->sc_statchg = tlp_mii_statchg;
break;
}
@@ -1358,6 +1364,16 @@
sc->sc_opmode |= OPMODE_PS;
break;
}
+ } else {
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_82C168:
+ case TULIP_CHIP_82C169:
+ sc->sc_opmode |= OPMODE_PNIC_TBEN;
+ break;
+
+ default:
+ /* Nothing. */
+ }
}
/*
@@ -1795,13 +1811,98 @@
{
u_int32_t crc;
- crc = tlp_crc32(romdata, 126);
- if ((crc ^ 0xffff) == (romdata[126] | (romdata[127] << 8)))
+ crc = tlp_crc32(romdata, TULIP_ROM_CRC32_CHECKSUM);
+ crc = (crc & 0xffff) ^ 0xffff;
+ if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM))
return (1);
return (0);
}
/*
+ * tlp_parse_old_srom:
+ *
+ * Parse old-format SROMs.
+ *
+ * This routine is largely lifted from Matt Thomas's `de' driver.
+ */
+int
+tlp_parse_old_srom(sc, enaddr)
+ struct tulip_softc *sc;
+ u_int8_t *enaddr;
+{
+ static const u_int8_t testpat[] =
+ { 0xff, 0, 0x55, 0xaa, 0xff, 0, 0x55, 0xaa };
+ int i;
+ u_int32_t cksum;
+
+ if (memcmp(&sc->sc_srom[0], &sc->sc_srom[16], 8) != 0) {
+ /*
+ * Some vendors (e.g. ZNYX) don't use the standard
+ * DEC Address ROM format, but rather just have an
+ * Ethernet address in the first 6 bytes, maybe a
+ * 2 byte checksum, and then all 0xff's.
+ */
+ for (i = 8; i < 32; i++) {
+ if (sc->sc_srom[i] != 0xff)
+ return (0);
+ }
+
+ /*
+ * Sanity check the Ethernet address:
+ *
+ * - Make sure it's not multicast or locally
+ * assigned
+ * - Make sure it has a non-0 OUI
+ */
+ if (sc->sc_srom[0] & 3)
+ return (0);
+ if (sc->sc_srom[0] == 0 && sc->sc_srom[1] == 0 &&
+ sc->sc_srom[2] == 0)
+ return (0);
+
+ memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
+ return (1);
+ }
+
+ /*
+ * Standard DEC Address ROM test.
+ */
+
+ if (memcmp(&sc->sc_srom[24], testpat, 8) != 0)
+ return (0);
+
+ for (i = 0; i < 8; i++) {
+ if (sc->sc_srom[i] != sc->sc_srom[15 - i])
+ return (0);
+ }
+
+ memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
+
+ cksum = *(u_int16_t *) &enaddr[0];
+
+ cksum <<= 1;
+ if (cksum > 0xffff)
+ cksum -= 0xffff;
+
+ cksum += *(u_int16_t *) &enaddr[2];
+ if (cksum > 0xffff)
+ cksum -= 0xffff;
+
+ cksum <<= 1;
+ if (cksum > 0xffff)
+ cksum -= 0xffff;
+
+ cksum += *(u_int16_t *) &enaddr[4];
+ if (cksum >= 0xffff)
+ cksum -= 0xffff;
+
+ if (cksum != *(u_int16_t *) &sc->sc_srom[6])
+ return (0);
+
+ return (1);
+}
+
+/*
* tlp_filter_setup:
*
* Set the Tulip's receive filter.
@@ -2241,15 +2342,13 @@
* XXX by the PHY? I hope so...
*/
+ sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD);
+
if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T)
sc->sc_opmode |= OPMODE_TTM;
- else
- sc->sc_opmode &= ~OPMODE_TTM;
if (sc->sc_mii.mii_media_active & IFM_FDX)
sc->sc_opmode |= OPMODE_FD;
- else
- sc->sc_opmode &= ~OPMODE_FD;
/*
* Write new OPMODE bits. This also restarts the transmit
@@ -2280,15 +2379,13 @@
* XXX by the PHY? I hope so...
*/
+ sc->sc_opmode &= ~(OPMODE_WINB_FES|OPMODE_FD);
+
if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_100_TX)
sc->sc_opmode |= OPMODE_WINB_FES;
- else
- sc->sc_opmode &= ~OPMODE_WINB_FES;
if (sc->sc_mii.mii_media_active & IFM_FDX)
sc->sc_opmode |= OPMODE_FD;
- else
- sc->sc_opmode &= ~OPMODE_FD;
/*
* Write new OPMODE bits. This also restarts the transmit
@@ -2520,6 +2617,215 @@
*****************************************************************************/
/*
+ * 21040 and 21041 media switches.
+ */
+void tlp_21040_tmsw_init __P((struct tulip_softc *));
+void tlp_21040_tp_tmsw_init __P((struct tulip_softc *));
+void tlp_21040_auibnc_tmsw_init __P((struct tulip_softc *));
+void tlp_21040_21041_tmsw_get __P((struct tulip_softc *,
+ struct ifmediareq *));
+int tlp_21040_21041_tmsw_set __P((struct tulip_softc *));
+
+const struct tulip_mediasw tlp_21040_mediasw = {
+ tlp_21040_tmsw_init, tlp_21040_21041_tmsw_get, tlp_21040_21041_tmsw_set
+};
+
+const struct tulip_mediasw tlp_21040_tp_mediasw = {
+ tlp_21040_tp_tmsw_init, tlp_21040_21041_tmsw_get,
+ tlp_21040_21041_tmsw_set
+};
+
+const struct tulip_mediasw tlp_21040_auibnc_mediasw = {
+ tlp_21040_auibnc_tmsw_init, tlp_21040_21041_tmsw_get,
+ tlp_21040_21041_tmsw_set
+};
+
+#define ADD(m, t) ifmedia_add(&sc->sc_mii.mii_media, (m), 0, (t))
+#define PRINT(s) printf("%s%s", sep, s); sep = ", "
+
+void
+tlp_21040_tmsw_init(sc)
+ struct tulip_softc *sc;
+{
+ struct tulip_21040_21041_sia_media *tsm;
+ const char *sep = "";
+
+ ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+ tlp_mediastatus);
+
+ printf("%s: ", sc->sc_dev.dv_xname);
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_10BASET;
+ tsm->tsm_siatxrx = SIATXRX_21040_10BASET;
+ tsm->tsm_siagen = SIAGEN_21040_10BASET;
+ ADD(IFM_ETHER|IFM_10_T, tsm);
+ PRINT("10baseT");
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_10BASET_FDX;
+ tsm->tsm_siatxrx = SIATXRX_21040_10BASET_FDX;
+ tsm->tsm_siagen = SIAGEN_21040_10BASET_FDX;
+ ADD(IFM_ETHER|IFM_10_T|IFM_FDX, tsm);
+ PRINT("10baseT-FDX");
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_AUI;
+ tsm->tsm_siatxrx = SIATXRX_21040_AUI;
+ tsm->tsm_siagen = SIAGEN_21040_AUI;
+ ADD(IFM_ETHER|IFM_10_5, tsm);
+ PRINT("10base5");
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_EXTSIA;
+ tsm->tsm_siatxrx = SIATXRX_21040_EXTSIA;
+ tsm->tsm_siagen = SIAGEN_21040_EXTSIA;
+ ADD(IFM_ETHER|IFM_MANUAL, tsm);
+ PRINT("manual");
+
+ /*
+ * XXX Autosense not yet supported.
+ */
+
+ /* XXX This should be auto-sense. */
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
+ printf(", default 10baseT");
+
+ printf("\n");
+}
+
+void
+tlp_21040_tp_tmsw_init(sc)
+ struct tulip_softc *sc;
+{
+ struct tulip_21040_21041_sia_media *tsm;
+ const char *sep = "";
+
+ ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+ tlp_mediastatus);
+
+ printf("%s: ", sc->sc_dev.dv_xname);
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_10BASET;
+ tsm->tsm_siatxrx = SIATXRX_21040_10BASET;
+ tsm->tsm_siagen = SIAGEN_21040_10BASET;
+ ADD(IFM_ETHER|IFM_10_T, tsm);
+ PRINT("10baseT");
+
+ tsm = malloc(sizeof(struct tulip_21040_21041_sia_media), M_DEVBUF,
+ M_WAITOK);
+ tsm->tsm_siaconn = SIACONN_21040_10BASET_FDX;
+ tsm->tsm_siatxrx = SIATXRX_21040_10BASET_FDX;
+ tsm->tsm_siagen = SIAGEN_21040_10BASET_FDX;
+ ADD(IFM_ETHER|IFM_10_T|IFM_FDX, tsm);
+ PRINT("10baseT-FDX");
+
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
+ printf(", default 10baseT");
+
+ printf("\n");
+}
+
+void
+tlp_21040_auibnc_tmsw_init(sc)
+ struct tulip_softc *sc;
+{
+ struct tulip_21040_21041_sia_media *tsm;
Home |
Main Index |
Thread Index |
Old Index