Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic If the detected media is gigabit, change the gem ...
details: https://anonhg.NetBSD.org/src/rev/d3b3c8e87521
branches: trunk
changeset: 526672:d3b3c8e87521
user: matt <matt%NetBSD.org@localhost>
date: Wed May 08 02:12:55 2002 +0000
description:
If the detected media is gigabit, change the gem to use GMII mode otherwise
switch back to MII mode. Keep a sliding window for TX segments and when it
gets > 2/3 full, request a TX interrupt (window gets reset when the h/w TX
queue is empty). Add dv_xname to a few printfs. With the above changes,
the gem driver will now work on Macintoshes, even in GigE mode. On a 733
PowerMac G4 it gets ~355Mb/s TX and ~280Mb/s RX to/from an Alpha XP1000.
XXX mii autoselect is still flakey.
diffstat:
sys/dev/ic/gem.c | 39 ++++++++++++++++++++++++++++-----------
sys/dev/ic/gemreg.h | 4 ++--
sys/dev/ic/gemvar.h | 3 ++-
3 files changed, 32 insertions(+), 14 deletions(-)
diffs (150 lines):
diff -r dc96352805d4 -r d3b3c8e87521 sys/dev/ic/gem.c
--- a/sys/dev/ic/gem.c Tue May 07 18:23:23 2002 +0000
+++ b/sys/dev/ic/gem.c Wed May 08 02:12:55 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gem.c,v 1.13 2002/03/29 00:00:10 matt Exp $ */
+/* $NetBSD: gem.c,v 1.14 2002/05/08 02:12:55 matt Exp $ */
/*
*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.13 2002/03/29 00:00:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.14 2002/05/08 02:12:55 matt Exp $");
#include "bpfilter.h"
@@ -624,8 +624,9 @@
}
GEM_CDTXSYNC(sc, 0, GEM_NTXDESC,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
- sc->sc_txfree = GEM_NTXDESC;
+ sc->sc_txfree = GEM_NTXDESC-1;
sc->sc_txnext = 0;
+ sc->sc_txwin = 0;
/*
* Initialize the receive descriptor and receive job
@@ -1028,6 +1029,10 @@
flags = dmamap->dm_segs[seg].ds_len & GEM_TD_BUFSIZE;
if (nexttx == firsttx) {
flags |= GEM_TD_START_OF_PACKET;
+ if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) {
+ sc->sc_txwin = 0;
+ flags |= GEM_TD_INTERRUPT_ME;
+ }
}
if (seg == dmamap->dm_nsegs - 1) {
flags |= GEM_TD_END_OF_PACKET;
@@ -1120,6 +1125,7 @@
bus_space_handle_t mac = sc->sc_h;
struct gem_txsoft *txs;
int txlast;
+ int progress = 0;
DPRINTF(sc, ("%s: gem_tint\n", sc->sc_dev.dv_xname));
@@ -1209,6 +1215,7 @@
SIMPLEQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q);
ifp->if_opackets++;
+ progress = 1;
}
DPRINTF(sc, ("gem_tint: GEM_TX_STATE_MACHINE %x "
@@ -1221,10 +1228,16 @@
GEM_TX_DATA_PTR_LO),
bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_COMPLETION)));
- gem_start(ifp);
+ if (progress) {
+ if (sc->sc_txfree == GEM_NTXDESC - 1)
+ sc->sc_txwin = 0;
- if (SIMPLEQ_FIRST(&sc->sc_txdirtyq) == NULL)
- ifp->if_timer = 0;
+ ifp->if_flags &= ~IFF_OACTIVE;
+ gem_start(ifp);
+
+ if (SIMPLEQ_FIRST(&sc->sc_txdirtyq) == NULL)
+ ifp->if_timer = 0;
+ }
DPRINTF(sc, ("%s: gem_tint: watchdog %d\n",
sc->sc_dev.dv_xname, ifp->if_timer));
@@ -1430,9 +1443,7 @@
if ((status & (GEM_INTR_RX_TAG_ERR | GEM_INTR_BERR)) != 0)
r |= gem_eint(sc, status);
- if ((status &
- (GEM_INTR_TX_EMPTY | GEM_INTR_TX_INTME))
- != 0)
+ if ((status & (GEM_INTR_TX_EMPTY | GEM_INTR_TX_INTME)) != 0)
r |= gem_tint(sc);
if ((status & (GEM_INTR_RX_DONE | GEM_INTR_RX_NOBUF)) != 0)
@@ -1442,12 +1453,14 @@
if (status & GEM_INTR_TX_MAC) {
int txstat = bus_space_read_4(t, seb, GEM_MAC_TX_STATUS);
if (txstat & ~GEM_MAC_TX_XMIT_DONE)
- printf("MAC tx fault, status %x\n", txstat);
+ printf("%s: MAC tx fault, status %x\n",
+ sc->sc_dev.dv_xname, txstat);
}
if (status & GEM_INTR_RX_MAC) {
int rxstat = bus_space_read_4(t, seb, GEM_MAC_RX_STATUS);
if (rxstat & ~GEM_MAC_RX_DONE)
- printf("MAC rx fault, status %x\n", rxstat);
+ printf("%s: MAC rx fault, status %x\n",
+ sc->sc_dev.dv_xname, rxstat);
}
return (r);
}
@@ -1633,6 +1646,10 @@
else
/* half duplex -- disable echo */
v |= GEM_MAC_XIF_ECHO_DISABL;
+ if (sc->sc_ethercom.ec_if.if_baudrate == IF_Mbps(1000))
+ v |= GEM_MAC_XIF_GMII_MODE;
+ else
+ v &= ~GEM_MAC_XIF_GMII_MODE;
} else
/* Internal MII needs buf enable */
v |= GEM_MAC_XIF_MII_BUF_ENA;
diff -r dc96352805d4 -r d3b3c8e87521 sys/dev/ic/gemreg.h
--- a/sys/dev/ic/gemreg.h Tue May 07 18:23:23 2002 +0000
+++ b/sys/dev/ic/gemreg.h Wed May 08 02:12:55 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gemreg.h,v 1.2 2001/10/18 03:33:33 thorpej Exp $ */
+/* $NetBSD: gemreg.h,v 1.3 2002/05/08 02:12:55 matt Exp $ */
/*
*
@@ -323,7 +323,7 @@
#define GEM_MAC_XIF_TX_MII_ENA 0x00000001 /* Enable XIF output drivers */
#define GEM_MAC_XIF_MII_LOOPBK 0x00000002 /* Enable MII loopback mode */
#define GEM_MAC_XIF_ECHO_DISABL 0x00000004 /* Disable echo */
-#define GEM_MAC_XIF_MII_MODE 0x00000008 /* Select GMII/MII mode */
+#define GEM_MAC_XIF_GMII_MODE 0x00000008 /* Select GMII/MII mode */
#define GEM_MAC_XIF_MII_BUF_ENA 0x00000010 /* Enable MII recv buffers */
#define GEM_MAC_XIF_LINK_LED 0x00000020 /* force link LED active */
#define GEM_MAC_XIF_FDPLX_LED 0x00000040 /* force FDPLX LED active */
diff -r dc96352805d4 -r d3b3c8e87521 sys/dev/ic/gemvar.h
--- a/sys/dev/ic/gemvar.h Tue May 07 18:23:23 2002 +0000
+++ b/sys/dev/ic/gemvar.h Wed May 08 02:12:55 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gemvar.h,v 1.5 2001/10/18 15:19:22 thorpej Exp $ */
+/* $NetBSD: gemvar.h,v 1.6 2002/05/08 02:12:55 matt Exp $ */
/*
*
@@ -157,6 +157,7 @@
int sc_txfree; /* number of free Tx descriptors */
int sc_txnext; /* next ready Tx descriptor */
+ int sc_txwin; /* Tx descriptors since last Tx int */
struct gem_txsq sc_txfreeq; /* free Tx descsofts */
struct gem_txsq sc_txdirtyq; /* dirty Tx descsofts */
Home |
Main Index |
Thread Index |
Old Index