Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Make it possible for attachment to specify that the ...
details: https://anonhg.NetBSD.org/src/rev/d60ed807b09b
branches: trunk
changeset: 579960:d60ed807b09b
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sun Apr 03 10:56:59 2005 +0000
description:
Make it possible for attachment to specify that the 16bit access shouldn't
be toggled in WE_MEM_{ENABLE|DISABLE} when receiving or transmitting packets.
Use this to switch the toggle off for MCA cards, since it causes NIC resets
there.
Fixes PR kern/26895 by Dave Barnes.
diffstat:
sys/dev/ic/we.c | 58 ++++++++++++++++++++++++------------------------
sys/dev/ic/wevar.h | 6 +++-
sys/dev/isa/if_we_isa.c | 18 +++++++-------
sys/dev/mca/if_we_mca.c | 7 +++--
4 files changed, 46 insertions(+), 43 deletions(-)
diffs (260 lines):
diff -r 61f4ca088d28 -r d60ed807b09b sys/dev/ic/we.c
--- a/sys/dev/ic/we.c Sun Apr 03 06:56:39 2005 +0000
+++ b/sys/dev/ic/we.c Sun Apr 03 10:56:59 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: we.c,v 1.6 2005/02/04 02:10:37 perry Exp $ */
+/* $NetBSD: we.c,v 1.7 2005/04/03 10:56:59 jdolecek Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.6 2005/02/04 02:10:37 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.7 2005/04/03 10:56:59 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -115,27 +115,27 @@
* Enable card RAM, and 16-bit access.
*/
#define WE_MEM_ENABLE(wsc) \
-do { \
- if ((wsc)->sc_16bitp) \
- bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
- WE_LAAR, (wsc)->sc_laar_proto | WE_LAAR_M16EN); \
- bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
- WE_MSR, wsc->sc_msr_proto | WE_MSR_MENB); \
- WE_DELAY((wsc)); \
-} while (0)
+if (((wsc)->sc_flags & WE_16BIT_NOTOGGLE) == 0) { \
+ if ((wsc)->sc_flags & WE_16BIT_ENABLE) \
+ bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
+ WE_LAAR, (wsc)->sc_laar_proto | WE_LAAR_M16EN); \
+ bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
+ WE_MSR, wsc->sc_msr_proto | WE_MSR_MENB); \
+ WE_DELAY((wsc)); \
+}
/*
* Disable card RAM, and 16-bit access.
*/
#define WE_MEM_DISABLE(wsc) \
-do { \
- bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
- WE_MSR, (wsc)->sc_msr_proto); \
- if ((wsc)->sc_16bitp) \
- bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
- WE_LAAR, (wsc)->sc_laar_proto); \
- WE_DELAY((wsc)); \
-} while (0)
+if (((wsc)->sc_flags & WE_16BIT_NOTOGGLE) == 0) { \
+ bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
+ WE_MSR, (wsc)->sc_msr_proto); \
+ if ((wsc)->sc_flags & WE_16BIT_ENABLE) \
+ bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \
+ WE_LAAR, (wsc)->sc_laar_proto); \
+ WE_DELAY((wsc)); \
+}
int
we_config(self, wsc, typestr)
@@ -151,11 +151,11 @@
* Allow user to override 16-bit mode. 8-bit takes precedence.
*/
if (self->dv_cfdata->cf_flags & DP8390_FORCE_16BIT_MODE) {
- wsc->sc_16bitp = 1;
+ wsc->sc_flags |= WE_16BIT_ENABLE;
forced_16bit = 1;
}
if (self->dv_cfdata->cf_flags & DP8390_FORCE_8BIT_MODE)
- wsc->sc_16bitp = 0;
+ wsc->sc_flags &= ~WE_16BIT_ENABLE;
/* Registers are linear. */
for (i = 0; i < 16; i++)
@@ -164,7 +164,7 @@
/* Now we can use the NIC_{GET,PUT}() macros. */
printf("%s: %s Ethernet (%s-bit)\n", sc->sc_dev.dv_xname,
- typestr, wsc->sc_16bitp ? "16" : "8");
+ typestr, wsc->sc_flags & WE_16BIT_ENABLE ? "16" : "8");
/* Get station address from EEPROM. */
for (i = 0; i < ETHER_ADDR_LEN; i++)
@@ -179,7 +179,7 @@
bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR) &
~WE_LAAR_M16EN;
bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR,
- wsc->sc_laar_proto | (wsc->sc_16bitp ? WE_LAAR_M16EN : 0));
+ wsc->sc_laar_proto | (wsc->sc_flags & WE_16BIT_ENABLE ? WE_LAAR_M16EN : 0));
} else if ((wsc->sc_type & WE_SOFTCONFIG) ||
#ifdef TOSH_ETHER
(wsc->sc_type == WE_TYPE_TOSHIBA1) ||
@@ -188,10 +188,10 @@
(forced_16bit) ||
(wsc->sc_type == WE_TYPE_WD8013EBT)) {
wsc->sc_laar_proto = (wsc->sc_maddr >> 19) & WE_LAAR_ADDRHI;
- if (wsc->sc_16bitp)
+ if (wsc->sc_flags & WE_16BIT_ENABLE)
wsc->sc_laar_proto |= WE_LAAR_L16EN;
bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR,
- wsc->sc_laar_proto | (wsc->sc_16bitp ? WE_LAAR_M16EN : 0));
+ wsc->sc_laar_proto | (wsc->sc_flags & WE_16BIT_ENABLE ? WE_LAAR_M16EN : 0));
}
/*
@@ -240,7 +240,7 @@
* 16-bit cards also get word-wide DMA transfers.
*/
sc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS |
- (wsc->sc_16bitp ? ED_DCR_WTS : 0);
+ (wsc->sc_flags & WE_16BIT_ENABLE ? ED_DCR_WTS : 0);
sc->test_mem = we_test_mem;
sc->ring_copy = we_ring_copy;
@@ -294,12 +294,12 @@
bus_size_t memsize = sc->mem_size;
int i;
- if (wsc->sc_16bitp)
+ if (wsc->sc_flags & WE_16BIT_ENABLE)
bus_space_set_region_2(memt, memh, 0, 0, memsize >> 1);
else
bus_space_set_region_1(memt, memh, 0, 0, memsize);
- if (wsc->sc_16bitp) {
+ if (wsc->sc_flags & WE_16BIT_ENABLE) {
for (i = 0; i < memsize; i += 2) {
if (bus_space_read_2(memt, memh, i) != 0)
goto fail;
@@ -338,7 +338,7 @@
if (len & 1)
++len;
- if (wsc->sc_16bitp)
+ if (wsc->sc_flags & WE_16BIT_ENABLE)
bus_space_read_region_stream_2(memt, memh, from,
(u_int16_t *)to, len >> 1);
else
@@ -368,7 +368,7 @@
/*
* 8-bit boards are simple; no alignment tricks are necessary.
*/
- if (wsc->sc_16bitp == 0) {
+ if ((wsc->sc_flags & WE_16BIT_ENABLE) == 0) {
for (; m != NULL; buf += m->m_len, m = m->m_next)
bus_space_write_region_1(memt, memh,
buf, mtod(m, u_int8_t *), m->m_len);
diff -r 61f4ca088d28 -r d60ed807b09b sys/dev/ic/wevar.h
--- a/sys/dev/ic/wevar.h Sun Apr 03 06:56:39 2005 +0000
+++ b/sys/dev/ic/wevar.h Sun Apr 03 10:56:59 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wevar.h,v 1.2 2005/02/04 02:10:37 perry Exp $ */
+/* $NetBSD: wevar.h,v 1.3 2005/04/03 10:56:59 jdolecek Exp $ */
/*
* National Semiconductor DS8390 NIC register definitions.
@@ -21,7 +21,9 @@
u_int8_t sc_type; /* our type */
- int sc_16bitp; /* are we 16 bit? */
+ u_int8_t sc_flags; /* attachment flags */
+#define WE_16BIT_ENABLE 1 /* are we 16 bit? */
+#define WE_16BIT_NOTOGGLE 2 /* avoid explicit 16bit reset/enable? */
int sc_iobase; /* i/o address */
int sc_maddr; /* physical i/o mem addr */
diff -r 61f4ca088d28 -r d60ed807b09b sys/dev/isa/if_we_isa.c
--- a/sys/dev/isa/if_we_isa.c Sun Apr 03 06:56:39 2005 +0000
+++ b/sys/dev/isa/if_we_isa.c Sun Apr 03 10:56:59 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_we_isa.c,v 1.11 2005/02/27 00:27:17 perry Exp $ */
+/* $NetBSD: if_we_isa.c,v 1.12 2005/04/03 10:56:59 jdolecek Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_we_isa.c,v 1.11 2005/02/27 00:27:17 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_we_isa.c,v 1.12 2005/04/03 10:56:59 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -99,7 +99,7 @@
extern struct cfdriver we_cd;
static const char *we_params(bus_space_tag_t, bus_space_handle_t,
- u_int8_t *, bus_size_t *, int *, int *);
+ u_int8_t *, bus_size_t *, u_int8_t *, int *);
static const int we_584_irq[] = {
9, 3, 5, 7, 10, 11, 15, 4,
@@ -331,7 +331,7 @@
}
typestr = we_params(asict, asich, &wsc->sc_type, NULL,
- &wsc->sc_16bitp, &sc->is790);
+ &wsc->sc_flags, &sc->is790);
if (typestr == NULL) {
printf("%s: where did the card go?\n", sc->sc_dev.dv_xname);
return;
@@ -390,12 +390,12 @@
}
static const char *
-we_params(asict, asich, typep, memsizep, is16bitp, is790p)
+we_params(asict, asich, typep, memsizep, flagp, is790p)
bus_space_tag_t asict;
bus_space_handle_t asich;
- u_int8_t *typep;
+ u_int8_t *typep, *flagp;
bus_size_t *memsizep;
- int *is16bitp, *is790p;
+ int *is790p;
{
const char *typestr;
bus_size_t memsize;
@@ -533,8 +533,8 @@
*typep = type;
if (memsizep != NULL)
*memsizep = memsize;
- if (is16bitp != NULL)
- *is16bitp = is16bit;
+ if (flagp != NULL && is16bit)
+ *flagp |= WE_16BIT_ENABLE;
if (is790p != NULL)
*is790p = is790;
return (typestr);
diff -r 61f4ca088d28 -r d60ed807b09b sys/dev/mca/if_we_mca.c
--- a/sys/dev/mca/if_we_mca.c Sun Apr 03 06:56:39 2005 +0000
+++ b/sys/dev/mca/if_we_mca.c Sun Apr 03 10:56:59 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_we_mca.c,v 1.12 2005/02/04 02:10:43 perry Exp $ */
+/* $NetBSD: if_we_mca.c,v 1.13 2005/04/03 10:56:59 jdolecek Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_we_mca.c,v 1.12 2005/02/04 02:10:43 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_we_mca.c,v 1.13 2005/04/03 10:56:59 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -267,7 +267,8 @@
}
wsc->sc_type = wep->we_type;
- wsc->sc_16bitp = 1; /* all cards we support are 16bit */
+ /* all cards we support are 16bit native (no need for reset) */
+ wsc->sc_flags = WE_16BIT_ENABLE|WE_16BIT_NOTOGGLE;
sc->is790 = 0;
typestr = wep->we_typestr;
Home |
Main Index |
Thread Index |
Old Index