PERFORCE change 109539 for review
Sam Leffler
sam at FreeBSD.org
Wed Nov 8 18:44:31 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=109539
Change 109539 by sam at sam_ebb on 2006/11/08 18:44:03
Misc cleanups:
o add mii statchng method so we can force full/half duplex
mac state on mii change
o call mii_tick from npe_tick to poll for mii state changes
o add hw.npe mib tree
o add hw.npe.tickinterval knob for controlling the frequency
of npe_tick; change the default from 1 sec to 3 secs
o move debug mib knobs from debug to hw.npe
o parameterize the # tx/rx buffers; knobs are under hw.npe
o add carrier sense errors back into oerrors now that we have
full duplex done right
o remove miscounting of carrier sense errors as
mibdata.dot3StatsSQETestErrors
Affected files ...
.. //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#17 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#17 (text+ko) ====
@@ -68,9 +68,6 @@
#include "miibus_if.h"
-#define NPE_MAX_TX_BUFFERS 64
-#define NPE_MAX_RX_BUFFERS 128
-
struct npedma {
const char* name;
int nbuf; /* # npebuf's allocated */
@@ -92,7 +89,8 @@
bus_space_handle_t sc_miih; /* MII register window */
struct ixpnpe_softc *sc_npe; /* NPE support */
int sc_portid; /* NPE port identification */
- int debug; /* DPRINTF* control */
+ int sc_debug; /* DPRINTF* control */
+ int sc_tickinterval;
struct callout tick_ch; /* Tick callout */
struct npedma txdma;
struct npebuf *tx_free; /* list of free tx buffers */
@@ -204,17 +202,32 @@
static int tx_doneqid = -1;
static int rx_qid = -1;
+SYSCTL_NODE(_hw, OID_AUTO, npe, CTLFLAG_RD, 0, "IXP425 NPE driver parameters");
+
static int npe_debug = 0;
-SYSCTL_INT(_debug, OID_AUTO, npe, CTLFLAG_RW, &npe_debug,
+SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RW, &npe_debug,
0, "IXP425 NPE network interface debug msgs");
-TUNABLE_INT("debug.npe", &npe_debug);
+TUNABLE_INT("hw.npe.npe", &npe_debug);
#define DPRINTF(sc, fmt, ...) do { \
- if (sc->debug) device_printf(sc->sc_dev, fmt, __VA_ARGS__); \
+ if (sc->sc_debug) device_printf(sc->sc_dev, fmt, __VA_ARGS__); \
} while (0)
#define DPRINTFn(n, sc, fmt, ...) do { \
- if (sc->debug >= n) device_printf(sc->sc_dev, fmt, __VA_ARGS__);\
+ if (sc->sc_debug >= n) device_printf(sc->sc_dev, fmt, __VA_ARGS__);\
} while (0)
+static int npe_tickinterval = 3; /* npe_tick frequency (secs) */
+SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RD, &npe_tickinterval,
+ 0, "periodic work interval (secs)");
+TUNABLE_INT("hw.npe.tickinterval", &npe_tickinterval);
+static int npe_rxbuf = 64; /* # rx buffers to allocate */
+SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RD, &npe_rxbuf,
+ 0, "rx buffers allocated");
+TUNABLE_INT("hw.npe.rxbuf", &npe_rxbuf);
+static int npe_txbuf = 128; /* # tx buffers to allocate */
+SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RD, &npe_txbuf,
+ 0, "tx buffers allocated");
+TUNABLE_INT("hw.npe.txbuf", &npe_txbuf);
+
static int
npe_probe(device_t dev)
{
@@ -236,6 +249,8 @@
{
struct npe_softc *sc = device_get_softc(dev);
struct ixp425_softc *sa = device_get_softc(device_get_parent(dev));
+ struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
+ struct sysctl_oid *tree = device_get_sysctl_tree(dev);
struct ifnet *ifp = NULL;
int error;
u_char eaddr[6];
@@ -244,7 +259,8 @@
sc->sc_iot = sa->sc_iot;
NPE_LOCK_INIT(sc);
callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0);
- sc->debug = npe_debug;
+ sc->sc_debug = npe_debug;
+ sc->sc_tickinterval = npe_tickinterval;
sc->sc_npe = ixpnpe_attach(dev);
if (sc->sc_npe == NULL) {
@@ -274,7 +290,6 @@
ifp->if_ioctl = npeioctl;
ifp->if_watchdog = npewatchdog;
ifp->if_init = npeinit;
- ifp->if_baudrate = 100*1000*1000; /* XXX */
IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
@@ -283,9 +298,10 @@
ifp->if_linkmiblen = sizeof(sc->mibdata);
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_STATS;
- SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->sc_dev),
- SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)), OID_AUTO,
- "debug", CTLFLAG_RW, &sc->debug, 0, "control debugging printfs");
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "debug",
+ CTLFLAG_RW, &sc->sc_debug, 0, "control debugging printfs");
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tickinterval",
+ CTLFLAG_RW, &sc->sc_tickinterval, 0, "periodic work frequency");
ether_ifattach(ifp, eaddr);
return 0;
@@ -508,11 +524,10 @@
}
} else
sc->sc_miih = sc->sc_ioh;
- error = npe_dma_setup(sc, &sc->txdma, "tx", NPE_MAX_TX_BUFFERS,
- NPE_MAXSEG);
+ error = npe_dma_setup(sc, &sc->txdma, "tx", npe_txbuf, NPE_MAXSEG);
if (error != 0)
return error;
- error = npe_dma_setup(sc, &sc->rxdma, "rx", NPE_MAX_RX_BUFFERS, 1);
+ error = npe_dma_setup(sc, &sc->rxdma, "rx", npe_rxbuf, 1);
if (error != 0)
return error;
@@ -563,22 +578,20 @@
sc->rx_qid = npeconfig[unit].rx_qid;
sc->rx_freeqid = npeconfig[unit].rx_freeqid;
if (rx_qid == -1) {
- ixpqmgr_qconfig(sc->rx_qid, NPE_MAX_RX_BUFFERS, 0, 1,
+ ixpqmgr_qconfig(sc->rx_qid, npe_rxbuf, 0, 1,
IX_QMGR_Q_SOURCE_ID_NOT_E, npe_rxdone, sc);
rx_qid = sc->rx_qid;
}
- ixpqmgr_qconfig(sc->rx_freeqid, NPE_MAX_RX_BUFFERS, 0,
- NPE_MAX_RX_BUFFERS/2, 0, NULL, sc);
+ ixpqmgr_qconfig(sc->rx_freeqid, npe_rxbuf, 0, npe_rxbuf/2, 0, NULL, sc);
/* tell the NPE to direct all traffic to rx_qid */
for (i = 0; i < 8; i++)
npe_setrxqosentry(sc, i, 0, sc->rx_qid);
sc->tx_qid = npeconfig[unit].tx_qid;
sc->tx_doneqid = npeconfig[unit].tx_doneqid;
- ixpqmgr_qconfig(sc->tx_qid, NPE_MAX_TX_BUFFERS, 0,
- NPE_MAX_TX_BUFFERS, 0, NULL, sc);
+ ixpqmgr_qconfig(sc->tx_qid, npe_txbuf, 0, npe_txbuf, 0, NULL, sc);
if (tx_doneqid == -1) {
- ixpqmgr_qconfig(sc->tx_doneqid, NPE_MAX_TX_BUFFERS, 0, 2,
+ ixpqmgr_qconfig(sc->tx_doneqid, npe_txbuf, 0, 2,
IX_QMGR_Q_SOURCE_ID_NOT_E, npe_txdone, sc);
tx_doneqid = sc->tx_doneqid;
}
@@ -661,9 +674,6 @@
MIBADD(dot3StatsFCSErrors);
MIBADD(dot3StatsSingleCollisionFrames);
MIBADD(dot3StatsMultipleCollisionFrames);
- /* XXX? */
- sc->mibdata.dot3StatsSQETestErrors +=
- be32toh(ns->dot3StatsCarrierSenseErrors);
MIBADD(dot3StatsDeferredTransmissions);
MIBADD(dot3StatsLateCollisions);
MIBADD(dot3StatsExcessiveCollisions);
@@ -679,6 +689,7 @@
ifp->if_oerrors +=
be32toh(ns->dot3StatsInternalMacTransmitErrors)
+ + be32toh(ns->dot3StatsCarrierSenseErrors)
+ be32toh(ns->TxVLANIdFilterDiscards)
;
ifp->if_ierrors += be32toh(ns->dot3StatsFCSErrors)
@@ -698,6 +709,7 @@
{
#define ACK (NPE_RESETSTATS << NPE_MAC_MSGID_SHL)
struct npe_softc *sc = xsc;
+ struct mii_data *mii = device_get_softc(sc->sc_mii);
uint32_t msg[2];
NPE_ASSERT_LOCKED(sc);
@@ -708,8 +720,10 @@
npe_addstats(sc);
}
npe_updatestats(sc);
+ mii_tick(mii);
+
/* schedule next poll */
- callout_reset(&sc->tick_ch, hz, npe_tick, sc);
+ callout_reset(&sc->tick_ch, sc->sc_tickinterval * hz, npe_tick, sc);
#undef ACK
}
@@ -976,7 +990,7 @@
WR4(sc, NPE_MAC_TX_CNTRL1,
RD4(sc, NPE_MAC_TX_CNTRL1) | NPE_TX_CNTRL1_TX_EN);
- callout_reset(&sc->tick_ch, hz, npe_tick, sc);
+ callout_reset(&sc->tick_ch, sc->sc_tickinterval * hz, npe_tick, sc);
}
static void
@@ -1456,6 +1470,27 @@
(void) npe_mii_mdio_wait(sc);
}
+static void
+npe_miibus_statchg(device_t dev)
+{
+ struct npe_softc *sc = device_get_softc(dev);
+ struct mii_data *mii = device_get_softc(sc->sc_mii);
+ uint32_t tx1, rx1;
+
+ /* sync MAC duplex state */
+ tx1 = RD4(sc, NPE_MAC_TX_CNTRL1);
+ rx1 = RD4(sc, NPE_MAC_RX_CNTRL1);
+ if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
+ tx1 &= ~NPE_TX_CNTRL1_DUPLEX;
+ rx1 |= NPE_RX_CNTRL1_PAUSE_EN;
+ } else {
+ tx1 |= NPE_TX_CNTRL1_DUPLEX;
+ rx1 &= ~NPE_RX_CNTRL1_PAUSE_EN;
+ }
+ WR4(sc, NPE_MAC_RX_CNTRL1, rx1);
+ WR4(sc, NPE_MAC_TX_CNTRL1, tx1);
+}
+
static device_method_t npe_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, npe_probe),
@@ -1468,6 +1503,7 @@
/* MII interface */
DEVMETHOD(miibus_readreg, npe_miibus_readreg),
DEVMETHOD(miibus_writereg, npe_miibus_writereg),
+ DEVMETHOD(miibus_statchg, npe_miibus_statchg),
{ 0, 0 }
};
More information about the p4-projects
mailing list