NetBSD Problem Report #10194
Received: (qmail 20160 invoked from network); 24 May 2000 16:12:01 -0000
Message-Id: <200005241611.BAA00769@miyuki.my.domain>
Date: Thu, 25 May 2000 01:11:19 +0900 (JST)
From: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
Reply-To: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
To: gnats-bugs@gnats.netbsd.org
Subject: tlp doesn't handle Davicom DM9102
X-Send-Pr-Version: 3.95
>Number: 10194
>Category: kern
>Synopsis: tlp doesn't handle Davicom DM9102
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: thorpej
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed May 24 16:13:00 +0000 2000
>Closed-Date: Sun Jan 06 22:23:03 +0000 2002
>Last-Modified: Sun Jan 06 22:23:03 +0000 2002
>Originator: IWAMOTO Toshihiro
>Release: a week ago -current
>Organization:
>Environment:
System: NetBSD kiku.my.domain 1.4Y NetBSD 1.4Y (KIKU) #8: Wed May 24 22:31:22 JST 2000 toshii@miyuki.my.domain:/usr/src/syssrc/sys/arch/i386/compile/KIKU i386
>Description:
Davicom's DM9102 is a tulip clone Ethernet chip.
This PR adds support for DM9102 as a patch to the tlp driver.
>How-To-Repeat:
Buy a PC with DM9102 but without a PCI slot, and be at a loss.
>Fix:
Apply the following patch.
Although this is basically a trivial patch, it should be noted
that DM9102 can't handle a setup packet if TDCTL_Tx_FS and
TDCTL_Tx_LS bits are set. Intel's 21143 hardware reference
manual says that these bits should be 0 for setup packets.
As this patch unconditionally clears these bits, this patch
should fail with a variant of tulip which requires these bits
to be set (if such tulip clone ever exists).
As a further notice, FreeBSD's "dc" driver (for tulip clones)
unconditionally sets these bits 0.
Index: ic/tulip.c
===================================================================
RCS file: /export/NetBSD-CVS/syssrc/sys/dev/ic/tulip.c,v
retrieving revision 1.64
diff -u -r1.64 tulip.c
--- ic/tulip.c 2000/05/18 03:02:45 1.64
+++ ic/tulip.c 2000/05/24 15:02:24
@@ -146,6 +146,7 @@
void tlp_2114x_preinit __P((struct tulip_softc *));
void tlp_2114x_mii_preinit __P((struct tulip_softc *));
void tlp_pnic_preinit __P((struct tulip_softc *));
+void tlp_dm9102_preinit __P((struct tulip_softc *));
void tlp_21140_reset __P((struct tulip_softc *));
void tlp_21142_reset __P((struct tulip_softc *));
@@ -316,6 +317,11 @@
sc->sc_flags |= TULIPF_IC_FS;
break;
+ case TULIP_CHIP_DM9102:
+ sc->sc_preinit = tlp_dm9102_preinit;
+ sc->sc_tdctl_ch = TDCTL_CH;
+ sc->sc_tdctl_er = 0;
+ break;
default:
/*
* Default to running in ring mode.
@@ -382,9 +388,13 @@
* 4-byte aligned. We're almost guaranteed to have to copy
* the packet in that case, so we just limit ourselves to
* one segment.
+ *
+ * For DM9102, an mbuf chain should be a single mbuf
+ * cluster buffer.
*/
switch (sc->sc_chip) {
case TULIP_CHIP_X3201_3:
+ case TULIP_CHIP_DM9102:
sc->sc_ntxsegs = 1;
break;
@@ -617,6 +627,7 @@
tlp_stop(sc, 1);
}
+
/*
* tlp_start: [ifnet interface function]
*
@@ -777,7 +788,7 @@
#ifdef TLP_DEBUG
if (ifp->if_flags & IFF_DEBUG) {
- printf(" txsoft %p trainsmit chain:\n", txs);
+ printf(" txsoft %p transmit chain:\n", txs);
for (seg = sc->sc_txnext;; seg = TULIP_NEXTTX(seg)) {
printf(" descriptor %d:\n", seg);
printf(" td_status: 0x%08x\n",
@@ -1397,7 +1408,7 @@
#ifdef TLP_DEBUG
if (ifp->if_flags & IFF_DEBUG) {
int i;
- printf(" txsoft %p trainsmit chain:\n", txs);
+ printf(" txsoft %p transmit chain:\n", txs);
for (i = txs->txs_firstdesc;; i = TULIP_NEXTTX(i)) {
printf(" descriptor %d:\n", i);
printf(" td_status: 0x%08x\n",
@@ -1618,6 +1629,9 @@
* Note: We must *always* set these bits; a cache
* alignment of 0 is RESERVED.
*/
+ case 0:
+ sc->sc_busmode |= BUSMODE_CAL_NONE;
+ break;
case 8:
sc->sc_busmode |= BUSMODE_CAL_8LW;
break;
@@ -2643,10 +2657,11 @@
sc->sc_txdescs[sc->sc_txnext].td_bufaddr1 =
htole32(TULIP_CDSPADDR(sc));
+ /* 21143's document says that FS and LS should be cleared */
sc->sc_txdescs[sc->sc_txnext].td_ctl =
htole32((TULIP_SETUP_PACKET_LEN << TDCTL_SIZE1_SHIFT) |
- sc->sc_filtmode | TDCTL_Tx_SET | TDCTL_Tx_FS |
- TDCTL_Tx_LS | TDCTL_Tx_IC | sc->sc_tdctl_ch |
+ sc->sc_filtmode | TDCTL_Tx_SET |
+ TDCTL_Tx_IC | sc->sc_tdctl_ch |
(sc->sc_txnext == (TULIP_NTXDESC - 1) ? sc->sc_tdctl_er : 0));
sc->sc_txdescs[sc->sc_txnext].td_status = htole32(TDSTAT_OWN);
TULIP_CDTXSYNC(sc, sc->sc_txnext, txs->txs_ndescs,
@@ -3308,6 +3323,14 @@
*/
sc->sc_opmode |= OPMODE_PNIC_TBEN;
}
+}
+
+void
+tlp_dm9102_preinit(sc)
+ struct tulip_softc *sc;
+{
+ sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD;
+ TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
}
/*
Index: ic/tulipreg.h
===================================================================
RCS file: /export/NetBSD-CVS/syssrc/sys/dev/ic/tulipreg.h,v
retrieving revision 1.18
diff -u -r1.18 tulipreg.h
--- ic/tulipreg.h 2000/04/04 19:22:52 1.18
+++ ic/tulipreg.h 2000/05/24 15:05:39
@@ -547,12 +547,12 @@
#define OPMODE_CA 0x00020000 /* capture effect enable */
#define OPMODE_PNIC_TBEN 0x00020000 /* Tx backoff offset enable */
/*
- * On Davicom DM9102, OPMODE_PS and OPMODE_HBD must
- * always be set.
+ * On Davicom DM9102, OPMODE_HBD must always be set.
*/
#define OPMODE_PS 0x00040000 /* port select:
1 = MII/SYM, 0 = SRL
- (21140) */
+ (21140)
+ 1 = HomePNA (DM9102A) */
#define OPMODE_HBD 0x00080000 /* heartbeat disable:
set in MII/SYM 100mbps,
set according to PHY
Index: pci/if_tlp_pci.c
===================================================================
RCS file: /export/NetBSD-CVS/syssrc/sys/dev/pci/if_tlp_pci.c,v
retrieving revision 1.37
diff -u -r1.37 if_tlp_pci.c
--- pci/if_tlp_pci.c 2000/04/04 19:22:51 1.37
+++ pci/if_tlp_pci.c 2000/05/24 15:05:50
@@ -176,10 +176,8 @@
{ PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100ATX,
TULIP_CHIP_WB89C840F },
-#if 0
{ PCI_VENDOR_DAVICOM, PCI_PRODUCT_DAVICOM_DM9102,
TULIP_CHIP_DM9102 },
-#endif
{ PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AL981,
TULIP_CHIP_AL981 },
@@ -526,8 +524,11 @@
/*
* Get the cacheline size.
*/
- sc->sc_cacheline = PCI_CACHELINE(pci_conf_read(pc, pa->pa_tag,
- PCI_BHLC_REG));
+ if (sc->sc_chip == TULIP_CHIP_DM9102)
+ sc->sc_cacheline = 0;
+ else
+ sc->sc_cacheline = PCI_CACHELINE(pci_conf_read(pc, pa->pa_tag,
+ PCI_BHLC_REG));
/*
* Get PCI data moving command info.
@@ -798,6 +799,16 @@
/*
* Winbond 89C840F has an MII attached to the SIO.
*/
+ sc->sc_mediasw = &tlp_sio_mii_mediasw;
+ break;
+
+ case TULIP_CHIP_DM9102:
+ /*
+ * DM9102's Ethernet address is located
+ * at offset 20 of its EEPROM.
+ */
+ memcpy(enaddr, &sc->sc_srom[20], ETHER_ADDR_LEN);
+
sc->sc_mediasw = &tlp_sio_mii_mediasw;
break;
>Release-Note:
>Audit-Trail:
From: Matthew Orgass <darkstar@pgh.net>
To: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/10194: tlp doesn't handle Davicom DM9102
Date: Thu, 25 May 2000 08:45:59 -0400 (EDT)
On Thu, 25 May 2000, IWAMOTO Toshihiro wrote:
> Although this is basically a trivial patch, it should be noted
> that DM9102 can't handle a setup packet if TDCTL_Tx_FS and
> TDCTL_Tx_LS bits are set.
Doh! I have more comprehensive patches that work once these bits are
removed from the setup packet. I use the SROM info to configure the MII,
which needs a hack in mii.c since the 21140 MII setup code assumes that
phynos are sequential starting at 0 (the 9102 PHY is 1), even though there
is no reason to assume this from the MII probe code. I think the MII
probe should be changed to just probe for the desired PHY. Also, there is
a strange bit of code where SROM GPR entries are explicitly set to be 4
bytes, even though they are actually longer. This looks completely bogus
(since it then goes on to read more then 4 bytes), but I just skipped it
for the 9102 (whose GPR entries are themselves bogus and need to be
skipped).
Also, the receive process does not want to stop in tlp_idle while
waiting for a packet. This doesn't seem to be a big problem since
switching between auto (at 100baseTX) and 10baseT still works while it is
running (but between 10baseT and 100baseTX does not).
It also seems to switch over to store & forward mode fairly quickly (it
doesn't have a 160/1024 mode, which I'm sure is part of the problem) so it
may be worth either allowing a few more underruns or just putting it in
S&F mode to begin with.
Matthew Orgass
darkstar@pgh.net
Index: sys/dev/ic/tulip.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/tulip.c,v
retrieving revision 1.64
diff -u -r1.64 tulip.c
--- tulip.c 2000/05/18 03:02:45 1.64
+++ tulip.c 2000/05/25 11:24:55
@@ -98,6 +98,9 @@
const struct tulip_txthresh_tab tlp_10_100_txthresh_tab[] =
TLP_TXTHRESH_TAB_10_100;
+const struct tulip_txthresh_tab tlp_dm_txthresh_tab[] =
+ TLP_TXTHRESH_TAB_DM;
+
const struct tulip_txthresh_tab tlp_winb_txthresh_tab[] =
TLP_TXTHRESH_TAB_WINB;
@@ -129,6 +132,7 @@
void tlp_mii_tick __P((void *));
void tlp_mii_statchg __P((struct device *));
+void tlp_dm_mii_statchg __P((struct device *));
void tlp_winb_mii_statchg __P((struct device *));
void tlp_mii_getmedia __P((struct tulip_softc *, struct ifmediareq *));
@@ -146,6 +150,7 @@
void tlp_2114x_preinit __P((struct tulip_softc *));
void tlp_2114x_mii_preinit __P((struct tulip_softc *));
void tlp_pnic_preinit __P((struct tulip_softc *));
+void tlp_dm_preinit __P((struct tulip_softc *));
void tlp_21140_reset __P((struct tulip_softc *));
void tlp_21142_reset __P((struct tulip_softc *));
@@ -219,6 +224,10 @@
sc->sc_txth = tlp_10_txthresh_tab;
break;
+ case TULIP_CHIP_DM9102: /* no 160/1024 threshold */
+ sc->sc_txth = tlp_dm_txthresh_tab;
+ break;
+
default:
sc->sc_txth = tlp_10_100_txthresh_tab;
break;
@@ -249,6 +258,10 @@
sc->sc_statchg = tlp_winb_mii_statchg;
break;
+ case TULIP_CHIP_DM9102:
+ sc->sc_statchg = tlp_dm_mii_statchg;
+ break;
+
default:
/*
* We may override this if we have special media
@@ -316,6 +329,12 @@
sc->sc_flags |= TULIPF_IC_FS;
break;
+ case TULIP_CHIP_DM9102:
+ sc->sc_tdctl_ch = TDCTL_CH;
+ sc->sc_tdctl_er = 0;
+ sc->sc_preinit = tlp_dm_preinit;
+ break;
+
default:
/*
* Default to running in ring mode.
@@ -382,9 +401,13 @@
* 4-byte aligned. We're almost guaranteed to have to copy
* the packet in that case, so we just limit ourselves to
* one segment.
+ *
+ * For DM9102, a mbuf chain should be a single mbuf cluster
+ * buffer.
*/
switch (sc->sc_chip) {
case TULIP_CHIP_X3201_3:
+ case TULIP_CHIP_DM9102:
sc->sc_ntxsegs = 1;
break;
@@ -684,6 +707,7 @@
* likely we'll trip the alignment test than the
* more-than-one-segment test.
*/
+
if ((sc->sc_ntxsegs == 1 && (mtod(m0, bus_addr_t) & 3) != 0) ||
bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0,
BUS_DMA_NOWAIT) != 0) {
@@ -777,7 +801,7 @@
#ifdef TLP_DEBUG
if (ifp->if_flags & IFF_DEBUG) {
- printf(" txsoft %p trainsmit chain:\n", txs);
+ printf(" txsoft %p transmit chain:\n", txs);
for (seg = sc->sc_txnext;; seg = TULIP_NEXTTX(seg)) {
printf(" descriptor %d:\n", seg);
printf(" td_status: 0x%08x\n",
@@ -1061,6 +1085,10 @@
(sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
return (0);
+ /* disable interrupts for DM9102 (interrupt edge bug) */
+ if (sc->sc_chip == TULIP_CHIP_DM9102)
+ TULIP_WRITE(sc, CSR_INTEN, 0);
+
for (;;) {
status = TULIP_READ(sc, CSR_STATUS);
if (status)
@@ -1120,6 +1148,7 @@
sc->sc_opmode &= ~(OPMODE_TR|OPMODE_SF);
sc->sc_opmode |=
sc->sc_txth[txthresh].txth_opmode;
+
printf("%s: transmit underrun; new "
"threshold: %s\n",
sc->sc_dev.dv_xname,
@@ -1191,6 +1220,10 @@
*/
}
+ /* enable interrupts for DM9102 */
+ if (sc->sc_chip == TULIP_CHIP_DM9102)
+ TULIP_WRITE(sc, CSR_INTEN, sc->sc_inten);
+
/* Try to get more packets going. */
tlp_start(ifp);
@@ -1397,7 +1430,7 @@
#ifdef TLP_DEBUG
if (ifp->if_flags & IFF_DEBUG) {
int i;
- printf(" txsoft %p trainsmit chain:\n", txs);
+ printf(" txsoft %p transmit chain:\n", txs);
for (i = txs->txs_firstdesc;; i = TULIP_NEXTTX(i)) {
printf(" descriptor %d:\n", i);
printf(" td_status: 0x%08x\n",
@@ -1644,6 +1677,10 @@
* always work.
*/
#endif
+
+ /* DM9102 chips are broken and must have busmode set to 0 */
+ if (sc->sc_chip == TULIP_CHIP_DM9102)
+ sc->sc_busmode = 0;
TULIP_WRITE(sc, CSR_BUSMODE, sc->sc_busmode);
/*
@@ -2643,10 +2680,11 @@
sc->sc_txdescs[sc->sc_txnext].td_bufaddr1 =
htole32(TULIP_CDSPADDR(sc));
+ /* 21143's document says that FS and LS should be cleared
+ * The DM9102 fails badly if they are set. */
sc->sc_txdescs[sc->sc_txnext].td_ctl =
htole32((TULIP_SETUP_PACKET_LEN << TDCTL_SIZE1_SHIFT) |
- sc->sc_filtmode | TDCTL_Tx_SET | TDCTL_Tx_FS |
- TDCTL_Tx_LS | TDCTL_Tx_IC | sc->sc_tdctl_ch |
+ sc->sc_filtmode | TDCTL_Tx_SET | TDCTL_Tx_IC | sc->sc_tdctl_ch |
(sc->sc_txnext == (TULIP_NTXDESC - 1) ? sc->sc_tdctl_er : 0));
sc->sc_txdescs[sc->sc_txnext].td_status = htole32(TDSTAT_OWN);
TULIP_CDTXSYNC(sc, sc->sc_txnext, txs->txs_ndescs,
@@ -2844,6 +2882,27 @@
"RUNNING - FLUSH",
"RUNNING - QUEUE",
};
+ /* Grrr... the DM9102 has different state bits */
+ static const char *dm_tx_state_names[] = {
+ "STOPPED",
+ "RUNNING - FETCH",
+ "RUNNING - SETUP",
+ "RUNNING - READING",
+ "RUNNING - CLOSE - CLEAR OWNER",
+ "RUNNING - WAIT",
+ "RUNNING - CLOSE - WRITE STATUS",
+ "SUSPENDED",
+ };
+ static const char *dm_rx_state_names[] = {
+ "STOPPED",
+ "RUNNING - FETCH",
+ "RUNNING - WAIT",
+ "RUNNING - QUEUE",
+ "RUNNING - CLOSE - CLEAR OWNER",
+ "RUNNING - CLOSE - WRITE STATUS",
+ "SUSPENDED",
+ "RUNNING - FLUSH",
+ };
u_int32_t csr, ackmask = 0;
int i;
@@ -2867,12 +2926,16 @@
(csr & STATUS_TS) != STATUS_TS_STOPPED)
printf("%s: transmit process failed to idle: "
"state %s\n", sc->sc_dev.dv_xname,
- tx_state_names[(csr & STATUS_TS) >> 20]);
+ (sc->sc_chip == TULIP_CHIP_DM9102 ?
+ dm_tx_state_names[(csr & STATUS_TS) >> 20] :
+ tx_state_names[(csr & STATUS_TS) >> 20]));
if ((bits & OPMODE_SR) != 0 && (csr & STATUS_RPS) == 0 &&
(csr & STATUS_RS) != STATUS_RS_STOPPED)
printf("%s: receive process failed to idle: "
"state %s\n", sc->sc_dev.dv_xname,
- rx_state_names[(csr & STATUS_RS) >> 17]);
+ (sc->sc_chip == TULIP_CHIP_DM9102 ?
+ dm_rx_state_names[(csr & STATUS_RS) >> 17] :
+ rx_state_names[(csr & STATUS_RS) >> 17]));
}
TULIP_WRITE(sc, CSR_STATUS, ackmask);
}
@@ -2974,6 +3037,38 @@
}
/*
+ * tlp_dm_mii_statchg: [mii interface function]
+ *
+ * Callback from PHY when media changes. This version is
+ * for the Davicom DM9102, which only needs to worry about
+ * OPMODE_TTM and OPMODE_FD.
+ */
+void
+tlp_dm_mii_statchg(self)
+ struct device *self;
+{
+ struct tulip_softc *sc = (struct tulip_softc *)self;
+
+ tlp_idle(sc, OPMODE_ST|OPMODE_SR);
+
+ sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD);
+
+ if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T)
+ sc->sc_opmode |= OPMODE_TTM;
+
+ if (sc->sc_mii.mii_media_active & IFM_FDX)
+ sc->sc_opmode |= OPMODE_FD;
+
+ /*
+ * Write new OPMODE bits. This also restarts the transmit
+ * and receive processes.
+ */
+ TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
+
+ /* XXX Update ifp->if_baudrate */
+}
+
+/*
* tlp_winb_mii_statchg: [mii interface function]
*
* Callback from PHY when media changes. This version is
@@ -3311,6 +3406,23 @@
}
/*
+ * tlp_dm_preinit:
+ *
+ * Pre-init function for Davicom DM9102.
+ */
+void
+tlp_dm_preinit(sc)
+ struct tulip_softc *sc;
+{
+ if (sc->sc_rev >= 0x30) /* DM9102A */
+ sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD;
+ else
+ sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD|OPMODE_PS;
+
+ TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
+}
+
+/*
* tlp_21140_reset:
*
* Issue a reset sequence on the 21140 via the GPIO facility.
@@ -4312,6 +4424,7 @@
case TULIP_CHIP_MX98713:
case TULIP_CHIP_AX88140:
case TULIP_CHIP_AX88141:
+ case TULIP_CHIP_DM9102:
sc->sc_gp_dir = *cp++;
break;
@@ -4326,7 +4439,8 @@
/*
* Determine the type and length of this media block.
*/
- if ((*cp & 0x80) == 0) {
+ if (((*cp & 0x80) == 0) && /* XXX ? */
+ sc->sc_chip != TULIP_CHIP_DM9102) {
length = 4;
type = TULIP_ROM_MB_21140_GPR;
} else {
@@ -4340,6 +4454,10 @@
/* Now, parse the block. */
switch (type) {
case TULIP_ROM_MB_21140_GPR:
+ /* Ignore bogus GPR data in the DM9102. */
+ if (sc->sc_chip == TULIP_CHIP_DM9102)
+ continue; /* Ignore GPR data */
+
tlp_get_minst(sc);
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21140_GPR;
@@ -4768,7 +4886,9 @@
if (tm == NULL) {
#ifdef DIAGNOSTIC
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- panic("tlp_2114x_isv_tmsw_get");
+ panic("tlp_2114x_isv_tmsw_get: not IFM_AUTO");
+ if (sc->sc_nway_active == NULL)
+ panic("tlp_2114x_isv_tmsw_get: nway_active NULL");
#endif
tm = sc->sc_nway_active->ifm_aux;
}
@@ -4789,7 +4909,9 @@
if (tm == NULL) {
#ifdef DIAGNOSTIC
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- panic("tlp_2114x_isv_tmsw_set");
+ panic("tlp_2114x_isv_tmsw_set: not IFM_AUTO");
+ if (sc->sc_nway_active == NULL)
+ panic("tlp_2114x_isv_tmsw_set: nway_active NULL");
#endif
/* XXX XXX XXX */
}
Index: sys/dev/ic/tulipreg.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/tulipreg.h,v
retrieving revision 1.18
diff -u -r1.18 tulipreg.h
--- tulipreg.h 2000/04/04 19:22:52 1.18
+++ tulipreg.h 2000/05/25 11:25:09
@@ -75,6 +75,23 @@
* - Boards that lack PHYs use the internal NWay block
* and transciever.
*
+ * - Davicom DM9102 (DM):
+ *
+ * A 21140 plus and minus a few features and a gratutitus
+ * incompatibility or two:
+ *
+ * - Highly integrated chip includes PHY and PCI controller
+ * - Wake-on-LAN support (not supported yet)
+ * - Fails badly if FS and LS bits are set on setup packet
+ * - Some different status bit (including state)
+ * - Many required operation mode settings (including media
+ * status bits)
+ * - Only three System Bus Errors are defined
+ * - Has the full range of polling times
+ * - Little-endian only
+ * - Registers that are not the same as the 21140 or have a
+ * designated setting are noted below
+ *
* - Winbond 89C840F
*
* Less similar, but still roughly compatible (enough so
@@ -116,7 +133,7 @@
*
* Some of the clone chips have different registers, and some have
* different bits in the same registers. These will be denoted by
- * PMAC, PNICII, PNIC, WINB, and ADM in the register/bit names.
+ * PMAC, PNICII, PNIC, DM, WINB, and ADM in the register/bit names.
*/
/*
@@ -387,9 +404,11 @@
#define CSR_BUSMODE TULIP_CSR0
#define BUSMODE_SWR 0x00000001 /* software reset */
#define BUSMODE_BAR 0x00000002 /* bus arbitration */
+ /* DM reserved must be 0 */
#define BUSMODE_DSL 0x0000007c /* descriptor skip length */
#define BUSMODE_BLE 0x00000080 /* big endian */
/* programmable burst length */
+ /* DM reserved must be 0 */
#define BUSMODE_PBL_DEFAULT 0x00000000 /* default value */
#define BUSMODE_PBL_1LW 0x00000100 /* 1 longword */
#define BUSMODE_PBL_2LW 0x00000200 /* 2 longwords */
@@ -414,15 +433,18 @@
#define BUSMODE_TAP_200us 0x00020000 /* 200 uS */
#define BUSMODE_TAP_800us 0x00040000 /* 400 uS */
#define BUSMODE_TAP_1_6ms 0x00060000 /* 1.6 mS */
-#define BUSMODE_TAP_12_8us 0x00080000 /* 12.8 uS (21041+) */
-#define BUSMODE_TAP_25_6us 0x000a0000 /* 25.6 uS (21041+) */
-#define BUSMODE_TAP_51_2us 0x000c0000 /* 51.2 uS (21041+) */
-#define BUSMODE_TAP_102_4us 0x000e0000 /* 102.4 uS (21041+) */
+#define BUSMODE_TAP_12_8us 0x00080000 /* 12.8 uS (21041+/DM) */
+#define BUSMODE_TAP_25_6us 0x000a0000 /* 25.6 uS (21041+/DM) */
+#define BUSMODE_TAP_51_2us 0x000c0000 /* 51.2 uS (21041+/DM) */
+#define BUSMODE_TAP_102_4us 0x000e0000 /* 102.4 uS (21041+/DM) */
#define BUSMODE_DBO 0x00100000 /* desc-only b/e (21041+) */
+ /* DM reserved must be 0 */
#define BUSMODE_RME 0x00200000 /* rd/mult enab (21140+) */
#define BUSMODE_WINB_WAIT 0x00200000 /* wait state insertion */
#define BUSMODE_RLE 0x00800000 /* rd/line enab (21140+) */
+ /* DM not implemented */
#define BUSMODE_WLE 0x01000000 /* wt/line enab (21140+) */
+ /* DM not implemented */
#define BUSMODE_PNIC_MBO 0x04000000 /* magic `must be one' bit */
/* on Lite-On PNIC */
@@ -460,13 +482,14 @@
#define STATUS_AT 0x00000400 /* SIA AUI/TP pin changed
(21040) */
#define STATUS_ETI 0x00000400 /* early transmit interrupt
- (21142/PMAC/Winbond) */
+ (21142/PMAC/Winbond/DM) */
#define STATUS_FD 0x00000800 /* full duplex short frame
received (21040) */
-#define STATUS_TM 0x00000800 /* timer expired (21041) */
+#define STATUS_TM 0x00000800 /* timer expired (21041/DM) */
#define STATUS_LNF 0x00001000 /* link fail (21040) */
#define STATUS_SE 0x00002000 /* system error */
#define STATUS_ER 0x00004000 /* early receive (21041) */
+ /* DM not implemented */
#define STATUS_AIS 0x00008000 /* abnormal interrupt summary */
#define STATUS_NIS 0x00010000 /* normal interrupt summary */
#define STATUS_RS 0x000e0000 /* receive process state */
@@ -475,29 +498,48 @@
descriptor */
#define STATUS_RS_CHECK 0x00040000 /* Running - check for end
of receive */
+#define STATUS_RS_DM_WAIT 0x00040000 /* Running - wait for packet */
#define STATUS_RS_WAIT 0x00060000 /* Running - wait for packet */
+#define STATUS_RS_DM_QUEUE 0x00060000 /* Running - queue current
+ frame from FIFO into
+ buffer */
#define STATUS_RS_SUSPENDED 0x00080000 /* Suspended */
+#define STATUS_RS_DM_CLOSEC 0x00080000 /* Running - close receive
+ descriptor by clearing
+ owner bit */
#define STATUS_RS_CLOSE 0x000a0000 /* Running - close receive
- descriptor */
+ descriptor (DM: by
+ writing status) */
#define STATUS_RS_FLUSH 0x000c0000 /* Running - flush current
frame from FIFO */
+#define STATUS_RS_DM_SUSPENDED 0x000c0000 /* Suspended */
#define STATUS_RS_QUEUE 0x000e0000 /* Running - queue current
frame from FIFO into
buffer */
+#define STATUS_RS_DM_FLUSH 0x000e0000 /* Running - flush current
+ frame from FIFO */
#define STATUS_TS 0x00700000 /* transmit process state */
#define STATUS_TS_STOPPED 0x00000000 /* Stopped */
#define STATUS_TS_FETCH 0x00100000 /* Running - fetch transmit
descriptor */
#define STATUS_TS_WAIT 0x00200000 /* Running - wait for end
of transmission */
+#define STATUS_TS_DM_SETUP 0x00200000 /* Running - Setup packet */
#define STATUS_TS_READING 0x00300000 /* Running - read buffer from
memory and queue into
FIFO */
#define STATUS_TS_RESERVED 0x00400000 /* RESERVED */
+#define STATUS_TS_DM_CLOSEC 0x00400000 /* Running - close transmit
+ descriptor by clearing
+ owner bit */
#define STATUS_TS_SETUP 0x00500000 /* Running - Setup packet */
+#define STATUS_TS_DM_WAIT 0x00500000 /* Running - wait for end
+ of transmission */
#define STATUS_TS_SUSPENDED 0x00600000 /* Suspended */
#define STATUS_TS_CLOSE 0x00700000 /* Running - close transmit
- descriptor */
+ descriptor (DM: by
+ writing status) */
+#define STATUS_TS_DM_SUSPENDED 0x00700000 /* Suspended */
#define STATUS_EB 0x03800000 /* error bits */
#define STATUS_EB_PARITY 0x00000000 /* parity errror */
#define STATUS_EB_MABT 0x00800000 /* master abort */
@@ -524,6 +566,7 @@
#define OPMODE_WINB_AMP 0x00000010 /* accept multicast packet */
#define OPMODE_SB 0x00000020 /* start backoff counter */
#define OPMODE_WINB_ABP 0x00000020 /* accept broadcast packet */
+ /* DM reserved must be 0 */
#define OPMODE_PR 0x00000040 /* promiscuous mode */
#define OPMODE_WINB_ARP 0x00000040 /* accept runt packet */
#define OPMODE_PM 0x00000080 /* pass all multicast */
@@ -541,23 +584,25 @@
#define OPMODE_TR_96 0x00004000 /* 96 bytes */
#define OPMODE_TR_128 0x00008000 /* 128 bytes */
#define OPMODE_TR_160 0x0000c000 /* 160 bytes */
+ /* DM reserved */
#define OPMODE_WINB_TTH 0x001fc000 /* transmit threshold */
#define OPMODE_WINB_TTH_SHIFT 14
#define OPMODE_BP 0x00010000 /* backpressure enable */
+ /* DM reserved must be 0 */
#define OPMODE_CA 0x00020000 /* capture effect enable */
#define OPMODE_PNIC_TBEN 0x00020000 /* Tx backoff offset enable */
- /*
- * On Davicom DM9102, OPMODE_PS and OPMODE_HBD must
- * always be set.
- */
+ /* DM reserved must be 0 */
#define OPMODE_PS 0x00040000 /* port select:
1 = MII/SYM, 0 = SRL
- (21140) */
+ (21140/DM9102A) */
+ /* DM9102 must be 1 */
#define OPMODE_HBD 0x00080000 /* heartbeat disable:
set in MII/SYM 100mbps,
set according to PHY
in MII 10mbps mode
(21140) */
+ /* DM must be 1 */
+#define OPMODE_DM_MBO 0x020c0000 /* DM must be one bits */
#define OPMODE_PNIC_IT 0x00100000 /* immediate transmit */
#define OPMODE_SF 0x00200000 /* store and forward mode
(21140) */
@@ -567,9 +612,11 @@
1 = 10mbps, 0 = 100mbps
(21140) */
#define OPMODE_PCS 0x00800000 /* PCS function (21140) */
+ /* DM reserved must be 0 */
#define OPMODE_SCR 0x01000000 /* scrambler mode (21140) */
-#define OPMODE_MBO 0x02000000 /* must be one (21140,
- DM9102) */
+ /* DM reserved must be 0 */
+#define OPMODE_MBO 0x02000000 /* must be one (21140) */
+ /* DM use DM_MBO */
#define OPMODE_IDAMSB 0x04000000 /* ignore dest addr MSB
(21142) */
#define OPMODE_PNIC_DRC 0x20000000 /* don't include CRC in Rx
@@ -833,6 +880,20 @@
#define GPP_PNIC_PIN_BNC_XMER 2
#define GPP_PNIC_PIN_LNK100X 3
+/*
+ * On the Davicom DM9102, the GPP is used for initialization and PHY
+ * status only.
+ *
+ * The status bits are:
+ * 0 10Mbps link
+ * 1 100Mbps link
+ * 2 Full-duplex
+ * 3 Link status
+ * 4 RX-lock
+ * 5 Signal Detection
+ * 6 UTP-SIG
+ *
+ */
/*
* Digital Semiconductor 21040 registers.
@@ -939,6 +1000,16 @@
#define SIATXRX_21142_BNC 0x00004705
#define SIAGEN_21142_BNC 0x00000006
+/*
+ * Davicom DM9102 registers. CSR12 is a little different but is with the
+ * 21140 CSR12.
+ * XXX CSR13 CSR14 CSR15 need to be here
+ */
+
+/* CSR15 is the Watchdog and Jabber Timer Register. See CSR_SIAGEN above.
+ * SIAGEN_TSCK must be 0 */
+#define DM_SIAGEN_MASK (SIAGEN_JBD|SIAGEN_HUJ|SIAGEN_JCK| \
+ SIAGEN_RWD|SIAGEN_RWR)
/*
* Lite-On 82C168/82C169 registers.
Index: sys/dev/ic/tulipvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/tulipvar.h,v
retrieving revision 1.33
diff -u -r1.33 tulipvar.h
--- tulipvar.h 2000/04/04 19:22:52 1.33
+++ tulipvar.h 2000/05/25 11:25:17
@@ -216,6 +216,15 @@
#define TXTH_160 3
#define TXTH_SF 4
+/* The DM9102 does not have 160/1024 mode */
+#define TLP_TXTHRESH_TAB_DM { \
+ { OPMODE_TR_72, "72/128 bytes" }, \
+ { OPMODE_TR_96, "96/256 bytes" }, \
+ { OPMODE_TR_128, "128/512 bytes" }, \
+ { OPMODE_SF, "store and forward mode" }, \
+ { 0, NULL }, \
+}
+
/*
* The Winbond 89C840F does transmit threshold control totally
* differently. It simply has a 7-bit field which indicates
Index: sys/dev/pci/if_tlp_pci.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/if_tlp_pci.c,v
retrieving revision 1.37
diff -u -r1.37 if_tlp_pci.c
--- if_tlp_pci.c 2000/04/04 19:22:51 1.37
+++ if_tlp_pci.c 2000/05/25 11:25:38
@@ -176,10 +176,8 @@
{ PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100ATX,
TULIP_CHIP_WB89C840F },
-#if 0
{ PCI_VENDOR_DAVICOM, PCI_PRODUCT_DAVICOM_DM9102,
TULIP_CHIP_DM9102 },
-#endif
{ PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AL981,
TULIP_CHIP_AL981 },
@@ -462,6 +460,7 @@
case TULIP_CHIP_MX98715:
case TULIP_CHIP_MX98715A:
case TULIP_CHIP_MX98725:
+ case TULIP_CHIP_DM9102:
/*
* Clear the "sleep mode" bit in the CFDA register.
*/
@@ -663,6 +662,12 @@
*/
tlp_pci_get_quirks(psc, enaddr, tlp_pci_21041_quirks);
break;
+
+ case TULIP_CHIP_DM9102:
+ /*
+ * Should always have ISV format SROM.
+ */
+ /* FALLTHROUGH */
case TULIP_CHIP_21140:
case TULIP_CHIP_21140A:
Index: sys/dev/mii/mii.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/mii/mii.c,v
retrieving revision 1.20
diff -u -r1.20 mii.c
--- mii.c 2000/03/23 07:01:36 1.20
+++ mii.c 2000/05/25 11:25:46
@@ -122,6 +122,10 @@
*/
if (offloc != MII_OFFSET_ANY && offloc != offset) {
offset++;
+ /* XXX Try the same phyno again. Needed for the
+ * XXX tlp driver that assumes that PHYs are
+ * XXX numbered sequentially from 0. */
+ ma.mii_phyno--;
continue;
}
Responsible-Changed-From-To: kern-bug-people->thorpej
Responsible-Changed-By: thorpej
Responsible-Changed-When: Thu May 25 09:34:10 PDT 2000
Responsible-Changed-Why:
The tulip driver is my fault.
From: Jason R Thorpe <thorpej@zembu.com>
To: Matthew Orgass <darkstar@pgh.net>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org
Subject: Re: kern/10194: tlp doesn't handle Davicom DM9102
Date: Thu, 25 May 2000 14:52:04 -0700
On Thu, May 25, 2000 at 12:47:01PM -0000, Matthew Orgass wrote:
> removed from the setup packet. I use the SROM info to configure the MII,
> which needs a hack in mii.c since the 21140 MII setup code assumes that
> phynos are sequential starting at 0 (the 9102 PHY is 1), even though there
> is no reason to assume this from the MII probe code. I think the MII
> probe should be changed to just probe for the desired PHY. Also, there is
> a strange bit of code where SROM GPR entries are explicitly set to be 4
> bytes, even though they are actually longer. This looks completely bogus
> (since it then goes on to read more then 4 bytes), but I just skipped it
> for the 9102 (whose GPR entries are themselves bogus and need to be
> skipped).
Is that really true about the `first' PHY being at offset 1?
The DM9102A has both HomePNA and 10/100 interfaces. You select the
HomePNA PHY by clearing OPMODE_PS, and the 10/100 interface by setting
OPMODE_PS (on older DM9102 chips, you must always set OPMODE_PS).
So, it's quite likely that some of those bogus GPR bits are actually
a description of the HomePNA portion, and that the HomePNA PHY is
actually offset 0.
I planned on handling this board by punting on the ISV SROM parsing
(since there is no GPIO stuff to deal with, and you always have MII),
and special casing the DM9102A HomePNA PHY.
> Also, the receive process does not want to stop in tlp_idle while
> waiting for a packet. This doesn't seem to be a big problem since
> switching between auto (at 100baseTX) and 10baseT still works while it is
> running (but between 10baseT and 100baseTX does not).
Hm. Interesting. I wonder why the halt fails. That's kind of annoying,
since you're supposed to halt the receive process to load a new receive
filter. Oh well. I guess I could suppress the warning on the DM9102.
> It also seems to switch over to store & forward mode fairly quickly (it
> doesn't have a 160/1024 mode, which I'm sure is part of the problem) so it
> may be worth either allowing a few more underruns or just putting it in
> S&F mode to begin with.
Just doing S/F mode at the beginning seems reasonable, esp. since we
can't use MRL/MRM on that chip.
--
-- Jason R. Thorpe <thorpej@zembu.com>
From: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
To: thorpej@zembu.com, darkstar@pgh.net, gnats-bugs@netbsd.org,
tech-net@netbsd.org
Cc:
Subject: Re: kern/10194: tlp doesn't handle Davicom DM9102
Date: Fri, 26 May 2000 10:53:25 +0900
At Thu, 25 May 2000 14:52:04 -0700,
Jason R Thorpe <thorpej@zembu.com> wrote:
> The DM9102A has both HomePNA and 10/100 interfaces. You select the
> HomePNA PHY by clearing OPMODE_PS, and the 10/100 interface by setting
> OPMODE_PS (on older DM9102 chips, you must always set OPMODE_PS).
Is this true? I guessed the meaning of OPMODE_PS the opposite from
FreeBSD's code below (/sys/pci/if_dc.c).
Also, my DM9102 (pass 1.0 as the kernel reports) seems fine with this
bit cleared.
/*
* If this is a Davicom DM9102A card with a DM9801 HomePNA
* PHY and we want HomePNA mode, set the portsel bit to turn
* on the external MII port.
*/
if (DC_IS_DAVICOM(sc)) {
if (IFM_SUBTYPE(media) == IFM_homePNA) {
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
sc->dc_link = 1;
} else {
DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
}
}
> > Also, the receive process does not want to stop in tlp_idle while
> > waiting for a packet. This doesn't seem to be a big problem since
> > switching between auto (at 100baseTX) and 10baseT still works while it is
> > running (but between 10baseT and 100baseTX does not).
>
> Hm. Interesting. I wonder why the halt fails. That's kind of annoying,
> since you're supposed to halt the receive process to load a new receive
> filter. Oh well. I guess I could suppress the warning on the DM9102.
I get several tlp_idle warnings (the below) at the boot time and when
expicitly switching to auto. As I didn't get these warnings when I
first replaced tlp_idle with FreeBSD's code, the idle state check code
in tlp_idle might be suspicious.
tlp0: receive process failed to idle: state RUNNING - CHECK
--
IWAMOTO Toshihiro
From: Matthew Orgass <darkstar@pgh.net>
To: Jason R Thorpe <thorpej@zembu.com>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org
Subject: Re: kern/10194: tlp doesn't handle Davicom DM9102
Date: Fri, 26 May 2000 00:21:38 -0400 (EDT)
On Thu, 25 May 2000, Jason R Thorpe wrote:
> Is that really true about the `first' PHY being at offset 1?
Yep. In any case, the code should not assume that PHYs begin at 0
unless they must do so, which is not currently the case. In earlier
versions of the code it caused a null pointer dereference due to the PHY
data structure being only partially set up and later code not being
paranoid enough.
How about allowing mii_attach to be called with both phyloc and offloc
specified? This should allow the driver to DTRT.
> The DM9102A has both HomePNA and 10/100 interfaces. You select the
> HomePNA PHY by clearing OPMODE_PS, and the 10/100 interface by setting
> OPMODE_PS (on older DM9102 chips, you must always set OPMODE_PS).
>
> So, it's quite likely that some of those bogus GPR bits are actually
> a description of the HomePNA portion, and that the HomePNA PHY is
> actually offset 0.
Sounds like a good theory. I guess the GPR data should only be skipped
on major version < 3 (the manual for the 9102A says it has major version
3. I guess 2 was never used).
> I planned on handling this board by punting on the ISV SROM parsing
> (since there is no GPIO stuff to deal with, and you always have MII),
> and special casing the DM9102A HomePNA PHY.
The docs say that it wants the usual GPIO reset sequence anyway.
> > Also, the receive process does not want to stop in tlp_idle while
> > waiting for a packet. This doesn't seem to be a big problem since
> > switching between auto (at 100baseTX) and 10baseT still works while it is
> > running (but between 10baseT and 100baseTX does not).
>
> Hm. Interesting. I wonder why the halt fails. That's kind of annoying,
> since you're supposed to halt the receive process to load a new receive
> filter. Oh well. I guess I could suppress the warning on the DM9102.
I guess the filter should be set to reinit instead of idle, which should
take care of that. Maybe the same thing should be done for the media
switch. The docs do say that the receive process only stops when there is
no receive buffer available.
Note that the status bits on the 9102 are different from the standard
tulip status bits, which is why the current code reports CHECK (it is
actually WAITING). The FreeBSD code seems to only check that the transmit
OR receive processes stopped, which is why it works (the transmit process
does stop). Probably a thinko in the FreeBSD code. Also, if you happen
to receive something while trying to get it to stop, it will idle
correctly.
> Just doing S/F mode at the beginning seems reasonable, esp. since we
> can't use MRL/MRM on that chip.
Ok.
Matthew Orgass
darkstar@pgh.net
State-Changed-From-To: open->feedback
State-Changed-By: thorpej
State-Changed-When: Fri May 26 09:38:37 PDT 2000
State-Changed-Why:
Support for the chip committed. Please verify that it works on your
DM9102.
Thanks for the help in implementing this!
State-Changed-From-To: feedback->closed
State-Changed-By: fair
State-Changed-When: Sun Jan 6 14:21:36 PST 2002
State-Changed-Why:
No feedback in a year and a half - we presume this issue is resolved.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.