summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-06-23 18:16:25 +0000
committerjhb <jhb@FreeBSD.org>2008-06-23 18:16:25 +0000
commita782d8500e19ecab39ad9882e20565831a2ed993 (patch)
tree9239e1f623e9a04cbebc23d0b2468da608753fc5 /sys/dev
parent5a33ff14915b72280b936bb995c6e1d76161354a (diff)
downloadFreeBSD-src-a782d8500e19ecab39ad9882e20565831a2ed993.zip
FreeBSD-src-a782d8500e19ecab39ad9882e20565831a2ed993.tar.gz
- Use bus_foo() rather than bus_space_foo() and retire the bus tag and handle
from the softc. - Rework the watchdog timer to match other NIC drivers: - Start a timer in fe_init() that runs once a second and checks a counter in the softc that is identical to the deprecated 'if_timer'. - Just adjust the softc tx timeout value when sending packets instead of scheduling the timer. - Use IFQ_SET_MAXLEN(). Tested by: WATANABE Kazuhiro
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/fe/if_fe.c42
-rw-r--r--sys/dev/fe/if_fe_cbus.c3
-rw-r--r--sys/dev/fe/if_fe_isa.c2
-rw-r--r--sys/dev/fe/if_fe_pccard.c1
-rw-r--r--sys/dev/fe/if_fevar.h23
5 files changed, 27 insertions, 44 deletions
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index 49fda90..ed50841 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
-#include <machine/resource.h>
#include <net/ethernet.h>
#include <net/if.h>
@@ -767,21 +766,7 @@ fe_attach (device_t dev)
* Set fixed interface flags.
*/
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-
-#if 1
- /*
- * Set maximum size of output queue, if it has not been set.
- * It is done here as this driver may be started after the
- * system initialization (i.e., the interface is PCMCIA.)
- *
- * I'm not sure this is really necessary, but, even if it is,
- * it should be done somewhere else, e.g., in if_attach(),
- * since it must be a common workaround for all network drivers.
- * FIXME.
- */
- if (ifp->if_snd.ifq_maxlen == 0)
- ifp->if_snd.ifq_maxlen = ifqmaxlen;
-#endif
+ IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
#if FE_SINGLE_TRANSMISSION
/* Override txb config to allocate minimum. */
@@ -899,8 +884,6 @@ fe_alloc_port(device_t dev, int size)
if (res) {
sc->port_used = size;
sc->port_res = res;
- sc->iot = rman_get_bustag(res);
- sc->ioh = rman_get_bushandle(res);
return (0);
}
@@ -987,6 +970,7 @@ fe_stop (struct fe_softc *sc)
/* Reset transmitter variables and interface flags. */
sc->ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE | IFF_DRV_RUNNING);
+ sc->tx_timeout = 0;
callout_stop(&sc->timer);
sc->txb_free = sc->txb_size;
sc->txb_count = 0;
@@ -1011,13 +995,16 @@ fe_watchdog (void *arg)
FE_ASSERT_LOCKED(sc);
- /* A "debug" message. */
- if_printf(sc->ifp, "transmission timeout (%d+%d)%s\n",
- sc->txb_sched, sc->txb_count,
- (sc->ifp->if_flags & IFF_UP) ? "" : " when down");
- if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0)
- if_printf(sc->ifp, "wrong IRQ setting in config?\n");
- fe_reset(sc);
+ if (sc->tx_timeout && --sc->tx_timeout == 0) {
+ /* A "debug" message. */
+ if_printf(sc->ifp, "transmission timeout (%d+%d)%s\n",
+ sc->txb_sched, sc->txb_count,
+ (sc->ifp->if_flags & IFF_UP) ? "" : " when down");
+ if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0)
+ if_printf(sc->ifp, "wrong IRQ setting in config?\n");
+ fe_reset(sc);
+ }
+ callout_reset(&sc->timer, hz, fe_watchdog, sc);
}
/*
@@ -1128,6 +1115,7 @@ fe_init_locked (struct fe_softc *sc)
/* Set 'running' flag, because we are now running. */
sc->ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ callout_reset(&sc->timer, hz, fe_watchdog, sc);
/*
* At this point, the interface is running properly,
@@ -1159,7 +1147,7 @@ fe_xmit (struct fe_softc *sc)
* We use longer timeout for multiple packet transmission.
* I'm not sure this timer value is appropriate. FIXME.
*/
- callout_reset(&sc->timer, (1 + sc->txb_count) * hz, fe_watchdog, sc);
+ sc->tx_timeout = 1 + sc->txb_count;
/* Update txb variables. */
sc->txb_sched = sc->txb_count;
@@ -1555,7 +1543,7 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* Reset output active flag and watchdog timer.
*/
sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
- callout_stop(&sc->timer);
+ sc->tx_timeout = 0;
/*
* If more data is ready to transmit in the buffer, start
diff --git a/sys/dev/fe/if_fe_cbus.c b/sys/dev/fe/if_fe_cbus.c
index 7076f42..171a390 100644
--- a/sys/dev/fe/if_fe_cbus.c
+++ b/sys/dev/fe/if_fe_cbus.c
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
-#include <machine/resource.h>
#include <net/ethernet.h>
#include <net/if.h>
@@ -269,8 +268,6 @@ fe98_alloc_port(device_t dev, int type)
sc->type = type;
sc->port_used = size;
sc->port_res = res;
- sc->iot = rman_get_bustag(res);
- sc->ioh = rman_get_bushandle(res);
return (0);
}
diff --git a/sys/dev/fe/if_fe_isa.c b/sys/dev/fe/if_fe_isa.c
index 3c37575..1770434 100644
--- a/sys/dev/fe/if_fe_isa.c
+++ b/sys/dev/fe/if_fe_isa.c
@@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <machine/bus.h>
-#include <machine/resource.h>
+#include <sys/rman.h>
#include <net/ethernet.h>
#include <net/if.h>
diff --git a/sys/dev/fe/if_fe_pccard.c b/sys/dev/fe/if_fe_pccard.c
index dab4611..fa2561b 100644
--- a/sys/dev/fe/if_fe_pccard.c
+++ b/sys/dev/fe/if_fe_pccard.c
@@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <machine/bus.h>
-#include <machine/resource.h>
#include <sys/rman.h>
#include <net/ethernet.h>
diff --git a/sys/dev/fe/if_fevar.h b/sys/dev/fe/if_fevar.h
index 1477e74..3ebfeb0 100644
--- a/sys/dev/fe/if_fevar.h
+++ b/sys/dev/fe/if_fevar.h
@@ -76,8 +76,6 @@ struct fe_softc {
int type;
int port_used;
struct resource * port_res;
- bus_space_tag_t iot;
- bus_space_handle_t ioh;
struct resource * irq_res;
void * irq_handle;
@@ -119,6 +117,7 @@ struct fe_softc {
struct mtx lock;
struct callout timer;
+ int tx_timeout;
};
struct fe_simple_probe_struct {
@@ -154,31 +153,31 @@ void fe_init_ubn(struct fe_softc *);
#define fe_inb(sc, port) \
- bus_space_read_1((sc)->iot, (sc)->ioh, (port))
+ bus_read_1((sc)->port_res, (port))
#define fe_outb(sc, port, value) \
- bus_space_write_1((sc)->iot, (sc)->ioh, (port), (value))
+ bus_write_1((sc)->port_res, (port), (value))
#define fe_inw(sc, port) \
- bus_space_read_2((sc)->iot, (sc)->ioh, (port))
+ bus_read_2((sc)->port_res, (port))
#define fe_outw(sc, port, value) \
- bus_space_write_2((sc)->iot, (sc)->ioh, (port), (value))
+ bus_write_2((sc)->port_res, (port), (value))
#define fe_insb(sc, port, addr, count) \
- bus_space_read_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_read_multi_1((sc)->port_res, (port), (addr), (count))
#define fe_outsb(sc, port, addr, count) \
- bus_space_write_multi_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_write_multi_1((sc)->port_res, (port), (addr), (count))
#define fe_insw(sc, port, addr, count) \
- bus_space_read_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_read_multi_2((sc)->port_res, (port), (addr), (count))
#define fe_outsw(sc, port, addr, count) \
- bus_space_write_multi_2((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_write_multi_2((sc)->port_res, (port), (addr), (count))
#define fe_inblk(sc, port, addr, count) \
- bus_space_read_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_read_region_1((sc)->port_res, (port), (addr), (count))
#define fe_outblk(sc, port, addr, count) \
- bus_space_write_region_1((sc)->iot, (sc)->ioh, (port), (addr), (count))
+ bus_write_region_1((sc)->port_res, (port), (addr), (count))
OpenPOWER on IntegriCloud