Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Back out new "hme" driver because it causes a per...
details: https://anonhg.NetBSD.org/src/rev/f9c05da25e76
branches: trunk
changeset: 518210:f9c05da25e76
user: tron <tron%NetBSD.org@localhost>
date: Mon Nov 26 10:39:29 2001 +0000
description:
Back out new "hme" driver because it causes a performance regression on
"netio" on an U5.
diffstat:
sys/dev/ic/hme.c | 760 +++++++++++++++++++++++++++------------------------
sys/dev/ic/hmereg.h | 30 +-
sys/dev/ic/hmevar.h | 32 +-
3 files changed, 440 insertions(+), 382 deletions(-)
diffs (truncated from 1241 to 300 lines):
diff -r 5c459a6b2d04 -r f9c05da25e76 sys/dev/ic/hme.c
--- a/sys/dev/ic/hme.c Mon Nov 26 10:38:59 2001 +0000
+++ b/sys/dev/ic/hme.c Mon Nov 26 10:39:29 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hme.c,v 1.27 2001/11/26 06:51:12 tron Exp $ */
+/* $NetBSD: hme.c,v 1.28 2001/11/26 10:39:29 tron Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -41,9 +41,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.27 2001/11/26 06:51:12 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.28 2001/11/26 10:39:29 tron Exp $");
-#undef HMEDEBUG
+#define HMEDEBUG
#include "opt_inet.h"
#include "opt_ns.h"
@@ -95,8 +95,6 @@
#include <dev/ic/hmereg.h>
#include <dev/ic/hmevar.h>
-#define HME_RX_OFFSET 2
-
void hme_start __P((struct ifnet *));
void hme_stop __P((struct hme_softc *));
int hme_ioctl __P((struct ifnet *, u_long, caddr_t));
@@ -108,8 +106,6 @@
void hme_mifinit __P((struct hme_softc *));
void hme_reset __P((struct hme_softc *));
void hme_setladrf __P((struct hme_softc *));
-int hme_newbuf __P((struct hme_softc *, struct hme_sxd *, int));
-int hme_encap __P((struct hme_softc *, struct mbuf *, int *));
/* MII methods & callbacks */
static int hme_mii_readreg __P((struct device *, int, int));
@@ -119,10 +115,21 @@
int hme_mediachange __P((struct ifnet *));
void hme_mediastatus __P((struct ifnet *, struct ifmediareq *));
+struct mbuf *hme_get __P((struct hme_softc *, int, int));
+int hme_put __P((struct hme_softc *, int, struct mbuf *));
+void hme_read __P((struct hme_softc *, int, int));
int hme_eint __P((struct hme_softc *, u_int));
int hme_rint __P((struct hme_softc *));
int hme_tint __P((struct hme_softc *));
+static int ether_cmp __P((u_char *, u_char *));
+
+/* Default buffer copy routines */
+void hme_copytobuf_contig __P((struct hme_softc *, void *, int, int));
+void hme_copyfrombuf_contig __P((struct hme_softc *, void *, int, int));
+void hme_zerobuf_contig __P((struct hme_softc *, int, int));
+
+
void
hme_config(sc)
struct hme_softc *sc;
@@ -133,7 +140,7 @@
bus_dma_tag_t dmatag = sc->sc_dmatag;
bus_dma_segment_t seg;
bus_size_t size;
- int rseg, error, i;
+ int rseg, error;
/*
* HME common initialization.
@@ -156,6 +163,9 @@
* the maximum bus burst size:
* sc_burst
*
+ * (notyet:DMA capable memory for the ring descriptors & packet buffers:
+ * rb_membase, rb_dmabase)
+ *
* the local Ethernet address:
* sc_enaddr
*
@@ -165,60 +175,60 @@
hme_stop(sc);
- for (i = 0; i < HME_TX_RING_SIZE; i++) {
- if (bus_dmamap_create(sc->sc_dmatag, MCLBYTES, 1,
- MCLBYTES, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
- &sc->sc_txd[i].sd_map) != 0) {
- sc->sc_txd[i].sd_map = NULL;
- goto fail;
- }
- }
- for (i = 0; i < HME_RX_RING_SIZE; i++) {
- if (bus_dmamap_create(sc->sc_dmatag, MCLBYTES, 1,
- MCLBYTES, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
- &sc->sc_rxd[i].sd_map) != 0) {
- sc->sc_rxd[i].sd_map = NULL;
- goto fail;
- }
- }
- if (bus_dmamap_create(sc->sc_dmatag, MCLBYTES, 1, MCLBYTES, 0,
- BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &sc->sc_rxmap_spare) != 0) {
- sc->sc_rxmap_spare = NULL;
- goto fail;
- }
+ /*
+ * Allocate descriptors and buffers
+ * XXX - do all this differently.. and more configurably,
+ * eg. use things as `dma_load_mbuf()' on transmit,
+ * and a pool of `EXTMEM' mbufs (with buffers DMA-mapped
+ * all the time) on the reveiver side.
+ *
+ * Note: receive buffers must be 64-byte aligned.
+ * Also, apparently, the buffers must extend to a DMA burst
+ * boundary beyond the maximum packet size.
+ */
+#define _HME_NDESC 128
+#define _HME_BUFSZ 1600
+
+ /* Note: the # of descriptors must be a multiple of 16 */
+ sc->sc_rb.rb_ntbuf = _HME_NDESC;
+ sc->sc_rb.rb_nrbuf = _HME_NDESC;
/*
* Allocate DMA capable memory
* Buffer descriptors must be aligned on a 2048 byte boundary;
* take this into account when calculating the size. Note that
* the maximum number of descriptors (256) occupies 2048 bytes,
- * so we allocate that much regardless of the number of descriptors.
+ * so we allocate that much regardless of _HME_NDESC.
*/
- size = (HME_XD_SIZE * HME_RX_RING_MAX) + /* RX descriptors */
- (HME_XD_SIZE * HME_TX_RING_MAX); /* TX descriptors */
+ size = 2048 + /* TX descriptors */
+ 2048 + /* RX descriptors */
+ sc->sc_rb.rb_ntbuf * _HME_BUFSZ + /* TX buffers */
+ sc->sc_rb.rb_nrbuf * _HME_BUFSZ; /* TX buffers */
/* Allocate DMA buffer */
- if ((error = bus_dmamem_alloc(dmatag, size, 2048, 0, &seg, 1, &rseg,
- BUS_DMA_NOWAIT)) != 0) {
+ if ((error = bus_dmamem_alloc(dmatag, size,
+ 2048, 0,
+ &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer alloc error %d\n",
- sc->sc_dev.dv_xname, error);
+ sc->sc_dev.dv_xname, error);
return;
}
/* Map DMA memory in CPU addressable space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, size,
- &sc->sc_rb.rb_membase, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ &sc->sc_rb.rb_membase,
+ BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
- sc->sc_dev.dv_xname, error);
+ sc->sc_dev.dv_xname, error);
bus_dmamap_unload(dmatag, sc->sc_dmamap);
bus_dmamem_free(dmatag, &seg, rseg);
return;
}
if ((error = bus_dmamap_create(dmatag, size, 1, size, 0,
- BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n",
- sc->sc_dev.dv_xname, error);
+ sc->sc_dev.dv_xname, error);
return;
}
@@ -227,7 +237,7 @@
sc->sc_rb.rb_membase, size, NULL,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map load error %d\n",
- sc->sc_dev.dv_xname, error);
+ sc->sc_dev.dv_xname, error);
bus_dmamem_free(dmatag, &seg, rseg);
return;
}
@@ -257,7 +267,7 @@
hme_mifinit(sc);
mii_attach(&sc->sc_dev, mii, 0xffffffff,
- MII_PHY_ANY, MII_OFFSET_ANY, 0);
+ MII_PHY_ANY, MII_OFFSET_ANY, 0);
child = LIST_FIRST(&mii->mii_phys);
if (child == NULL) {
@@ -280,10 +290,10 @@
*/
if (child->mii_phy > 1 || child->mii_inst > 1) {
printf("%s: cannot accomodate MII device %s"
- " at phy %d, instance %d\n",
- sc->sc_dev.dv_xname,
- child->mii_dev.dv_xname,
- child->mii_phy, child->mii_inst);
+ " at phy %d, instance %d\n",
+ sc->sc_dev.dv_xname,
+ child->mii_dev.dv_xname,
+ child->mii_phy, child->mii_inst);
continue;
}
@@ -297,7 +307,7 @@
ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_AUTO);
}
- /* We can support 802.1Q VLAN-sized frames. */
+ /* claim 802.1q capability */
sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
/* Attach the interface. */
@@ -308,23 +318,21 @@
if (sc->sc_sh == NULL)
panic("hme_config: can't establish shutdownhook");
+#if 0
+ printf("%s: %d receive buffers, %d transmit buffers\n",
+ sc->sc_dev.dv_xname, sc->sc_nrbuf, sc->sc_ntbuf);
+ sc->sc_rbufaddr = malloc(sc->sc_nrbuf * sizeof(int), M_DEVBUF,
+ M_WAITOK);
+ sc->sc_tbufaddr = malloc(sc->sc_ntbuf * sizeof(int), M_DEVBUF,
+ M_WAITOK);
+#endif
+
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
callout_init(&sc->sc_tick_ch);
- return;
-
-fail:
- if (sc->sc_rxmap_spare != NULL)
- bus_dmamap_destroy(sc->sc_dmatag, sc->sc_rxmap_spare);
- for (i = 0; i < HME_TX_RING_SIZE; i++)
- if (sc->sc_txd[i].sd_map != NULL)
- bus_dmamap_destroy(sc->sc_dmatag, sc->sc_txd[i].sd_map);
- for (i = 0; i < HME_RX_RING_SIZE; i++)
- if (sc->sc_rxd[i].sd_map != NULL)
- bus_dmamap_destroy(sc->sc_dmatag, sc->sc_rxd[i].sd_map);
}
void
@@ -332,29 +340,9 @@
void *arg;
{
struct hme_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- bus_space_tag_t t = sc->sc_bustag;
- bus_space_handle_t mac = sc->sc_mac;
int s;
s = splnet();
- /*
- * Unload collision counters
- */
- ifp->if_collisions +=
- bus_space_read_4(t, mac, HME_MACI_NCCNT) +
- bus_space_read_4(t, mac, HME_MACI_FCCNT) +
- bus_space_read_4(t, mac, HME_MACI_EXCNT) +
- bus_space_read_4(t, mac, HME_MACI_LTCNT);
-
- /*
- * then clear the hardware counters.
- */
- bus_space_write_4(t, mac, HME_MACI_NCCNT, 0);
- bus_space_write_4(t, mac, HME_MACI_FCCNT, 0);
- bus_space_write_4(t, mac, HME_MACI_EXCNT, 0);
- bus_space_write_4(t, mac, HME_MACI_LTCNT, 0);
-
mii_tick(&sc->sc_mii);
splx(s);
@@ -385,7 +373,7 @@
/* Reset transmitter and receiver */
bus_space_write_4(t, seb, HME_SEBI_RESET,
- (HME_SEB_RESET_ETX | HME_SEB_RESET_ERX));
+ (HME_SEB_RESET_ETX | HME_SEB_RESET_ERX));
for (n = 0; n < 20; n++) {
u_int32_t v = bus_space_read_4(t, seb, HME_SEBI_RESET);
@@ -394,20 +382,6 @@
DELAY(20);
}
- for (n = 0; n < HME_TX_RING_SIZE; n++) {
- if (sc->sc_txd[n].sd_loaded) {
- bus_dmamap_sync(sc->sc_dmatag, sc->sc_txd[n].sd_map,
- 0, sc->sc_txd[n].sd_map->dm_mapsize,
- BUS_DMASYNC_POSTWRITE);
- bus_dmamap_unload(sc->sc_dmatag, sc->sc_txd[n].sd_map);
- sc->sc_txd[n].sd_loaded = 0;
- }
- if (sc->sc_txd[n].sd_mbuf != NULL) {
- m_freem(sc->sc_txd[n].sd_mbuf);
Home |
Main Index |
Thread Index |
Old Index