1995-12-05 13:01:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, David Greenman
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice unmodified, this list of conditions, and the following
|
|
|
|
* disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1995-12-05 13:01:33 +00:00
|
|
|
*/
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
|
1993-06-14 22:21:25 +00:00
|
|
|
* adapters. By David Greenman, 29-April-1993
|
|
|
|
*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Currently supports the Western Digital/SMC 8003 and 8013 series,
|
1994-01-03 17:17:19 +00:00
|
|
|
* the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
|
|
|
|
* and a variety of similar clones.
|
1993-09-29 22:15:53 +00:00
|
|
|
*
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#include "opt_ed.h"
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1997-03-24 11:33:46 +00:00
|
|
|
#include <sys/sockio.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/mbuf.h>
|
2001-03-03 08:31:37 +00:00
|
|
|
#include <sys/kernel.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/syslog.h>
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
1998-01-08 23:42:31 +00:00
|
|
|
#include <net/ethernet.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <net/if.h>
|
1998-01-08 23:42:31 +00:00
|
|
|
#include <net/if_arp.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <net/if_dl.h>
|
1996-10-11 15:19:23 +00:00
|
|
|
#include <net/if_mib.h>
|
2001-03-03 08:31:37 +00:00
|
|
|
#include <net/if_media.h>
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <net/bpf.h>
|
1999-03-17 16:44:53 +00:00
|
|
|
#include <net/bridge.h>
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1996-06-25 20:31:01 +00:00
|
|
|
#include <machine/md_var.h>
|
1995-03-16 18:17:34 +00:00
|
|
|
|
1999-09-20 05:48:16 +00:00
|
|
|
#include <dev/ed/if_edreg.h>
|
|
|
|
#include <dev/ed/if_edvar.h>
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-12-26 06:38:04 +00:00
|
|
|
devclass_t ed_devclass;
|
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static void ed_init (void *);
|
|
|
|
static int ed_ioctl (struct ifnet *, u_long, caddr_t);
|
|
|
|
static void ed_start (struct ifnet *);
|
|
|
|
static void ed_reset (struct ifnet *);
|
|
|
|
static void ed_watchdog (struct ifnet *);
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2002-03-20 02:08:01 +00:00
|
|
|
static void ed_tick (void *);
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1995-10-31 18:41:49 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static void ds_getmcaf (struct ed_softc *, u_int32_t *);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static void ed_get_packet (struct ed_softc *, char *, /* u_short */ int);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static __inline void ed_rint (struct ed_softc *);
|
|
|
|
static __inline void ed_xmit (struct ed_softc *);
|
|
|
|
static __inline char * ed_ring_copy(struct ed_softc *, char *, char *,
|
|
|
|
/* u_short */ int);
|
|
|
|
static void ed_hpp_set_physical_link(struct ed_softc *);
|
|
|
|
static void ed_hpp_readmem (struct ed_softc *, int, unsigned char *,
|
|
|
|
/* u_short */ int);
|
|
|
|
static void ed_hpp_writemem (struct ed_softc *, unsigned char *,
|
|
|
|
/* u_short */ int, /* u_short */ int);
|
|
|
|
static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, int);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static void ed_setrcr (struct ed_softc *);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static u_int32_t ds_crc (u_char *ep);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
1994-11-26 10:51:49 +00:00
|
|
|
* Interrupt conversion table for WD/SMC ASIC/83C584
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1999-09-03 19:10:56 +00:00
|
|
|
static unsigned short ed_intr_val[] = {
|
|
|
|
9,
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
7,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
15,
|
|
|
|
4
|
1993-06-14 22:21:25 +00:00
|
|
|
};
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-11-22 11:08:16 +00:00
|
|
|
/*
|
1994-11-26 10:51:49 +00:00
|
|
|
* Interrupt conversion table for 83C790
|
1993-11-22 11:08:16 +00:00
|
|
|
*/
|
1999-09-03 19:10:56 +00:00
|
|
|
static unsigned short ed_790_intr_val[] = {
|
1993-11-22 11:08:16 +00:00
|
|
|
0,
|
1999-09-03 19:10:56 +00:00
|
|
|
9,
|
|
|
|
3,
|
|
|
|
5,
|
|
|
|
7,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
15
|
1993-11-22 11:08:16 +00:00
|
|
|
};
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
/*
|
|
|
|
* Interrupt conversion table for the HP PC LAN+
|
|
|
|
*/
|
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
static unsigned short ed_hpp_intr_val[] = {
|
1996-08-07 11:18:23 +00:00
|
|
|
0, /* 0 */
|
|
|
|
0, /* 1 */
|
|
|
|
0, /* 2 */
|
1999-09-03 19:10:56 +00:00
|
|
|
3, /* 3 */
|
|
|
|
4, /* 4 */
|
|
|
|
5, /* 5 */
|
|
|
|
6, /* 6 */
|
|
|
|
7, /* 7 */
|
1996-08-07 11:18:23 +00:00
|
|
|
0, /* 8 */
|
1999-09-03 19:10:56 +00:00
|
|
|
9, /* 9 */
|
|
|
|
10, /* 10 */
|
|
|
|
11, /* 11 */
|
|
|
|
12, /* 12 */
|
1996-08-07 11:18:23 +00:00
|
|
|
0, /* 13 */
|
|
|
|
0, /* 14 */
|
1999-09-03 19:10:56 +00:00
|
|
|
15 /* 15 */
|
|
|
|
};
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* Generic probe routine for testing for the existance of a DS8390.
|
|
|
|
* Must be called after the NIC has just been reset. This routine
|
1995-02-25 15:56:00 +00:00
|
|
|
* works by looking at certain register values that are guaranteed
|
1993-09-29 20:30:26 +00:00
|
|
|
* to be initialized a certain way after power-up or reset. Seems
|
|
|
|
* not to currently work on the 83C690.
|
|
|
|
*
|
|
|
|
* Specifically:
|
|
|
|
*
|
|
|
|
* Register reset bits set bits
|
|
|
|
* Command Register (CR) TXP, STA RD2, STP
|
|
|
|
* Interrupt Status (ISR) RST
|
|
|
|
* Interrupt Mask (IMR) All bits
|
|
|
|
* Data Control (DCR) LAS
|
|
|
|
* Transmit Config. (TCR) LB1, LB0
|
|
|
|
*
|
|
|
|
* We only look at the CR and ISR registers, however, because looking at
|
|
|
|
* the others would require changing register pages (which would be
|
|
|
|
* intrusive if this isn't an 8390).
|
|
|
|
*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Return 1 if 8390 was found, 0 if not.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
1993-09-29 20:30:26 +00:00
|
|
|
ed_probe_generic8390(sc)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
{
|
2000-08-17 12:15:45 +00:00
|
|
|
if ((ed_nic_inb(sc, ED_P0_CR) &
|
1994-08-04 17:42:35 +00:00
|
|
|
(ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) !=
|
|
|
|
(ED_CR_RD2 | ED_CR_STP))
|
1994-01-03 17:17:19 +00:00
|
|
|
return (0);
|
2000-08-17 12:15:45 +00:00
|
|
|
if ((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
|
1993-09-29 20:30:26 +00:00
|
|
|
return (0);
|
|
|
|
|
1994-08-04 17:42:35 +00:00
|
|
|
return (1);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-09 07:01:23 +00:00
|
|
|
/*
|
|
|
|
* Probe and vendor-specific initialization routine for SMC/WD80x3 boards
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_probe_WD80x3_generic(dev, flags, intr_vals)
|
1999-09-03 19:10:56 +00:00
|
|
|
device_t dev;
|
2000-08-17 12:15:45 +00:00
|
|
|
int flags;
|
|
|
|
unsigned short *intr_vals[];
|
1993-09-09 07:01:23 +00:00
|
|
|
{
|
1999-09-03 19:10:56 +00:00
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
1994-08-04 17:42:35 +00:00
|
|
|
int i;
|
1997-09-08 20:00:21 +00:00
|
|
|
u_int memsize, maddr;
|
2000-07-23 15:15:43 +00:00
|
|
|
u_char iptr, isa16bit, sum, totalsum;
|
1999-09-03 19:10:56 +00:00
|
|
|
u_long conf_maddr, conf_msize, irq, junk;
|
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
sc->chip_type = ED_CHIP_TYPE_DP8390;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_TOSH_ETHER) {
|
|
|
|
totalsum = ED_WD_ROM_CHECKSUM_TOTAL_TOSH_ETHER;
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_POW);
|
2000-07-23 15:15:43 +00:00
|
|
|
DELAY(10000);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
totalsum = ED_WD_ROM_CHECKSUM_TOTAL;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Attempt to do a checksum over the station address PROM. If it
|
|
|
|
* fails, it's probably not a SMC/WD board. There is a problem with
|
|
|
|
* this, though: some clone WD boards don't pass the checksum test.
|
|
|
|
* Danpex boards for one.
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
|
|
|
for (sum = 0, i = 0; i < 8; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
sum += ed_asic_inb(sc, ED_WD_PROM + i);
|
1993-10-01 00:56:43 +00:00
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sum != totalsum) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-10-01 00:56:43 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Checksum is invalid. This often happens with cheap WD8003E
|
|
|
|
* clones. In this case, the checksum byte (the eighth byte)
|
|
|
|
* seems to always be zero.
|
1993-10-01 00:56:43 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
if (ed_asic_inb(sc, ED_WD_CARD_ID) != ED_TYPE_WD8003E ||
|
|
|
|
ed_asic_inb(sc, ED_WD_PROM + 7) != 0)
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1993-10-01 00:56:43 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
/* reset card to force it into a known state. */
|
2000-07-23 15:15:43 +00:00
|
|
|
if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_TOSH_ETHER)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW);
|
2000-07-23 15:15:43 +00:00
|
|
|
else
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_RST);
|
2000-07-23 15:15:43 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
DELAY(100);
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ed_asic_inb(sc, ED_WD_MSR) & ~ED_WD_MSR_RST);
|
1998-04-17 22:37:19 +00:00
|
|
|
/* wait in the case this card is reading its EEROM */
|
1993-06-14 22:21:25 +00:00
|
|
|
DELAY(5000);
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->vendor = ED_VENDOR_WD_SMC;
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->type = ed_asic_inb(sc, ED_WD_CARD_ID);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set initial values for width/size.
|
|
|
|
*/
|
1994-02-02 14:05:58 +00:00
|
|
|
memsize = 8192;
|
|
|
|
isa16bit = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
switch (sc->type) {
|
|
|
|
case ED_TYPE_WD8003S:
|
|
|
|
sc->type_str = "WD8003S";
|
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8003E:
|
|
|
|
sc->type_str = "WD8003E";
|
1994-02-02 14:05:58 +00:00
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8003EB:
|
|
|
|
sc->type_str = "WD8003EB";
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1994-02-02 02:24:42 +00:00
|
|
|
case ED_TYPE_WD8003W:
|
|
|
|
sc->type_str = "WD8003W";
|
|
|
|
break;
|
1993-06-14 22:21:25 +00:00
|
|
|
case ED_TYPE_WD8013EBT:
|
|
|
|
sc->type_str = "WD8013EBT";
|
|
|
|
memsize = 16384;
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1993-11-29 17:07:33 +00:00
|
|
|
case ED_TYPE_WD8013W:
|
|
|
|
sc->type_str = "WD8013W";
|
|
|
|
memsize = 16384;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
1994-08-04 17:42:35 +00:00
|
|
|
case ED_TYPE_WD8013EP: /* also WD8003EP */
|
2000-08-17 12:15:45 +00:00
|
|
|
if (ed_asic_inb(sc, ED_WD_ICR) & ED_WD_ICR_16BIT) {
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-06-14 22:21:25 +00:00
|
|
|
memsize = 16384;
|
1993-09-09 07:01:23 +00:00
|
|
|
sc->type_str = "WD8013EP";
|
1993-06-14 22:21:25 +00:00
|
|
|
} else {
|
1993-09-22 17:47:43 +00:00
|
|
|
sc->type_str = "WD8003EP";
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
break;
|
1993-09-09 07:01:23 +00:00
|
|
|
case ED_TYPE_WD8013WC:
|
|
|
|
sc->type_str = "WD8013WC";
|
|
|
|
memsize = 16384;
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-09-09 07:01:23 +00:00
|
|
|
break;
|
1993-06-14 22:21:25 +00:00
|
|
|
case ED_TYPE_WD8013EBP:
|
|
|
|
sc->type_str = "WD8013EBP";
|
|
|
|
memsize = 16384;
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8013EPC:
|
|
|
|
sc->type_str = "WD8013EPC";
|
|
|
|
memsize = 16384;
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1994-12-31 17:09:58 +00:00
|
|
|
case ED_TYPE_SMC8216C: /* 8216 has 16K shared mem -- 8416 has 8K */
|
1995-11-15 07:45:56 +00:00
|
|
|
case ED_TYPE_SMC8216T:
|
1995-12-05 13:01:33 +00:00
|
|
|
if (sc->type == ED_TYPE_SMC8216C) {
|
1994-12-31 17:09:58 +00:00
|
|
|
sc->type_str = "SMC8216/SMC8216C";
|
1995-11-15 07:45:56 +00:00
|
|
|
} else {
|
|
|
|
sc->type_str = "SMC8216T";
|
1994-12-31 17:09:58 +00:00
|
|
|
}
|
1995-01-23 19:06:08 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD790_HWR,
|
|
|
|
ed_asic_inb(sc, ED_WD790_HWR) | ED_WD790_HWR_SWH);
|
|
|
|
switch (ed_asic_inb(sc, ED_WD790_RAR) & ED_WD790_RAR_SZ64) {
|
1995-01-23 19:06:08 +00:00
|
|
|
case ED_WD790_RAR_SZ64:
|
|
|
|
memsize = 65536;
|
|
|
|
break;
|
|
|
|
case ED_WD790_RAR_SZ32:
|
|
|
|
memsize = 32768;
|
|
|
|
break;
|
|
|
|
case ED_WD790_RAR_SZ16:
|
|
|
|
memsize = 16384;
|
|
|
|
break;
|
|
|
|
case ED_WD790_RAR_SZ8:
|
1995-11-15 07:45:56 +00:00
|
|
|
/* 8216 has 16K shared mem -- 8416 has 8K */
|
1995-12-05 13:01:33 +00:00
|
|
|
if (sc->type == ED_TYPE_SMC8216C) {
|
1995-11-15 07:45:56 +00:00
|
|
|
sc->type_str = "SMC8416C/SMC8416BT";
|
|
|
|
} else {
|
|
|
|
sc->type_str = "SMC8416T";
|
|
|
|
}
|
1994-12-31 17:09:58 +00:00
|
|
|
memsize = 8192;
|
1995-01-23 19:06:08 +00:00
|
|
|
break;
|
1994-12-31 17:09:58 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD790_HWR,
|
|
|
|
ed_asic_inb(sc, ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
|
1995-01-23 19:06:08 +00:00
|
|
|
|
1993-11-22 11:08:16 +00:00
|
|
|
isa16bit = 1;
|
2000-07-23 15:15:43 +00:00
|
|
|
sc->chip_type = ED_CHIP_TYPE_WD790;
|
1993-11-22 11:08:16 +00:00
|
|
|
break;
|
1994-01-11 23:28:21 +00:00
|
|
|
case ED_TYPE_TOSHIBA1:
|
|
|
|
sc->type_str = "Toshiba1";
|
|
|
|
memsize = 32768;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
1994-01-25 22:52:09 +00:00
|
|
|
case ED_TYPE_TOSHIBA4:
|
|
|
|
sc->type_str = "Toshiba4";
|
1994-01-11 23:28:21 +00:00
|
|
|
memsize = 32768;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
1993-06-14 22:21:25 +00:00
|
|
|
default:
|
1993-09-22 17:47:43 +00:00
|
|
|
sc->type_str = "";
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Make some adjustments to initial values depending on what is found
|
|
|
|
* in the ICR.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-09-22 17:47:43 +00:00
|
|
|
if (isa16bit && (sc->type != ED_TYPE_WD8013EBT)
|
1994-08-04 17:42:35 +00:00
|
|
|
&& (sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4)
|
2000-08-17 12:15:45 +00:00
|
|
|
&& ((ed_asic_inb(sc, ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
memsize = 8192;
|
|
|
|
}
|
1995-01-23 19:06:08 +00:00
|
|
|
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&conf_maddr, &conf_msize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
#if ED_DEBUG
|
1994-01-11 23:28:21 +00:00
|
|
|
printf("type = %x type_str=%s isa16bit=%d memsize=%d id_msize=%d\n",
|
1999-09-03 19:10:56 +00:00
|
|
|
sc->type, sc->type_str, isa16bit, memsize, conf_msize);
|
1994-08-04 17:42:35 +00:00
|
|
|
for (i = 0; i < 8; i++)
|
2000-08-17 12:15:45 +00:00
|
|
|
printf("%x -> %x\n", i, ed_asic_inb(sc, i));
|
1993-06-14 22:21:25 +00:00
|
|
|
#endif
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-07-20 23:16:50 +00:00
|
|
|
/*
|
|
|
|
* Allow the user to override the autoconfiguration
|
|
|
|
*/
|
1999-09-03 19:10:56 +00:00
|
|
|
if (conf_msize > 1)
|
|
|
|
memsize = conf_msize;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
maddr = conf_maddr;
|
1997-09-10 00:17:39 +00:00
|
|
|
if (maddr < 0xa0000 || maddr + memsize > 0x1000000) {
|
1999-09-03 19:10:56 +00:00
|
|
|
device_printf(dev, "Invalid ISA memory address range configured: 0x%x - 0x%x\n",
|
|
|
|
maddr, maddr + memsize);
|
|
|
|
return (ENXIO);
|
1997-09-08 20:00:21 +00:00
|
|
|
}
|
|
|
|
|
1993-07-20 23:16:50 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* (note that if the user specifies both of the following flags that
|
|
|
|
* '8bit' mode intentionally has precedence)
|
1993-07-20 23:16:50 +00:00
|
|
|
*/
|
1999-09-03 19:10:56 +00:00
|
|
|
if (flags & ED_FLAGS_FORCE_16BIT_MODE)
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1999-09-03 19:10:56 +00:00
|
|
|
if (flags & ED_FLAGS_FORCE_8BIT_MODE)
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 0;
|
1993-07-20 01:39:24 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
1994-11-13 07:17:46 +00:00
|
|
|
* If possible, get the assigned interrupt number from the card and
|
|
|
|
* use it.
|
1993-06-23 16:22:04 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
if ((sc->type & ED_WD_SOFTCONFIG) &&
|
|
|
|
(sc->chip_type != ED_CHIP_TYPE_WD790)) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
|
|
|
* Assemble together the encoded interrupt number.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
iptr = (ed_asic_inb(sc, ED_WD_ICR) & ED_WD_ICR_IR2) |
|
|
|
|
((ed_asic_inb(sc, ED_WD_IRR) &
|
1994-08-04 17:42:35 +00:00
|
|
|
(ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
|
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
1995-05-12 22:39:40 +00:00
|
|
|
* If no interrupt specified (or "?"), use what the board tells us.
|
1993-06-23 16:22:04 +00:00
|
|
|
*/
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&irq, &junk);
|
2000-08-17 12:15:45 +00:00
|
|
|
if (error && intr_vals[0] != NULL) {
|
|
|
|
error = bus_set_resource(dev, SYS_RES_IRQ, 0,
|
|
|
|
intr_vals[0][iptr], 1);
|
1999-09-03 19:10:56 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
|
|
|
* Enable the interrupt.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_IRR,
|
|
|
|
ed_asic_inb(sc, ED_WD_IRR) | ED_WD_IRR_IEN);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD790_HWR,
|
|
|
|
ed_asic_inb(sc, ED_WD790_HWR) | ED_WD790_HWR_SWH);
|
|
|
|
iptr = (((ed_asic_inb(sc, ED_WD790_GCR) & ED_WD790_GCR_IR2) >> 4) |
|
|
|
|
(ed_asic_inb(sc, ED_WD790_GCR) &
|
1994-08-04 17:42:35 +00:00
|
|
|
(ED_WD790_GCR_IR1 | ED_WD790_GCR_IR0)) >> 2);
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD790_HWR,
|
|
|
|
ed_asic_inb(sc, ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
|
1993-11-22 11:08:16 +00:00
|
|
|
|
1994-11-13 07:17:46 +00:00
|
|
|
/*
|
1995-05-12 22:39:40 +00:00
|
|
|
* If no interrupt specified (or "?"), use what the board tells us.
|
1994-11-13 07:17:46 +00:00
|
|
|
*/
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&irq, &junk);
|
2000-08-17 12:15:45 +00:00
|
|
|
if (error && intr_vals[1] != NULL) {
|
|
|
|
error = bus_set_resource(dev, SYS_RES_IRQ, 0,
|
|
|
|
intr_vals[1][iptr], 1);
|
1999-09-03 19:10:56 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1994-04-10 20:06:28 +00:00
|
|
|
/*
|
|
|
|
* Enable interrupts.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD790_ICR,
|
|
|
|
ed_asic_inb(sc, ED_WD790_ICR) | ED_WD790_ICR_EIL);
|
1993-11-22 11:08:16 +00:00
|
|
|
}
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&irq, &junk);
|
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "%s cards don't support auto-detected/assigned interrupts.\n",
|
|
|
|
sc->type_str);
|
|
|
|
return (ENXIO);
|
1994-11-13 07:17:46 +00:00
|
|
|
}
|
1993-09-22 17:47:43 +00:00
|
|
|
sc->isa16bit = isa16bit;
|
1999-10-18 04:27:33 +00:00
|
|
|
sc->mem_shared = 1;
|
1999-09-03 19:10:56 +00:00
|
|
|
|
|
|
|
error = ed_alloc_memory(dev, 0, memsize);
|
1999-10-15 03:12:48 +00:00
|
|
|
if (error) {
|
|
|
|
printf("*** ed_alloc_memory() failed! (%d)\n", error);
|
1999-09-03 19:10:56 +00:00
|
|
|
return (error);
|
1999-10-15 03:12:48 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res);
|
1993-09-22 17:47:43 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* allocate one xmit buffer if < 16k, two buffers otherwise
|
|
|
|
*/
|
1995-10-10 09:52:55 +00:00
|
|
|
if ((memsize < 16384) ||
|
1999-09-03 19:10:56 +00:00
|
|
|
(flags & ED_FLAGS_NO_MULTI_BUFFERING)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
} else {
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
}
|
1995-10-10 09:52:55 +00:00
|
|
|
sc->tx_page_start = ED_WD_PAGE_OFFSET;
|
|
|
|
sc->rec_page_start = ED_WD_PAGE_OFFSET + ED_TXBUF_SIZE * sc->txb_cnt;
|
|
|
|
sc->rec_page_stop = ED_WD_PAGE_OFFSET + memsize / ED_PAGE_SIZE;
|
|
|
|
sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * sc->rec_page_start);
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get station address from on-board ROM
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, ED_WD_PROM + i);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
/*
|
1997-11-02 07:12:52 +00:00
|
|
|
* Set upper address bits and 8/16 bit access to shared memory.
|
1994-09-07 06:11:29 +00:00
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->wd_laar_proto = ed_asic_inb(sc, ED_WD_LAAR);
|
1994-08-04 17:42:35 +00:00
|
|
|
} else {
|
1997-11-02 07:12:52 +00:00
|
|
|
sc->wd_laar_proto = ED_WD_LAAR_L16EN |
|
2000-08-17 12:15:45 +00:00
|
|
|
((kvtop(sc->mem_start) >> 19) & ED_WD_LAAR_ADDRHI);
|
1994-09-07 06:11:29 +00:00
|
|
|
}
|
1997-09-08 10:27:09 +00:00
|
|
|
/*
|
|
|
|
* Enable 16bit access
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR, sc->wd_laar_proto |
|
1997-09-08 10:27:09 +00:00
|
|
|
ED_WD_LAAR_M16EN);
|
1994-09-07 06:11:29 +00:00
|
|
|
} else {
|
1994-10-22 17:52:22 +00:00
|
|
|
if (((sc->type & ED_WD_SOFTCONFIG) ||
|
2000-08-17 12:15:45 +00:00
|
|
|
(sc->type == ED_TYPE_TOSHIBA1) ||
|
|
|
|
(sc->type == ED_TYPE_TOSHIBA4) ||
|
|
|
|
(sc->type == ED_TYPE_WD8013EBT)) &&
|
|
|
|
(sc->chip_type != ED_CHIP_TYPE_WD790)) {
|
|
|
|
sc->wd_laar_proto = (kvtop(sc->mem_start) >> 19) &
|
1997-09-08 10:27:09 +00:00
|
|
|
ED_WD_LAAR_ADDRHI;
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR, sc->wd_laar_proto);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-09-07 06:11:29 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
/*
|
|
|
|
* Set address and enable interface shared memory.
|
|
|
|
*/
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type != ED_CHIP_TYPE_WD790) {
|
|
|
|
if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_TOSH_ETHER) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR + 1,
|
|
|
|
((kvtop(sc->mem_start) >> 8) & 0xe0) | 4);
|
|
|
|
ed_asic_outb(sc, ED_WD_MSR + 2,
|
|
|
|
((kvtop(sc->mem_start) >> 16) & 0x0f));
|
|
|
|
ed_asic_outb(sc, ED_WD_MSR,
|
|
|
|
ED_WD_MSR_MENB | ED_WD_MSR_POW);
|
2000-08-14 04:31:07 +00:00
|
|
|
} else {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR,
|
|
|
|
((kvtop(sc->mem_start) >> 13) &
|
|
|
|
ED_WD_MSR_ADDR) | ED_WD_MSR_MENB);
|
2000-07-23 15:15:43 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
1994-09-07 06:11:29 +00:00
|
|
|
} else {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_MENB);
|
|
|
|
ed_asic_outb(sc, ED_WD790_HWR, (ed_asic_inb(sc, ED_WD790_HWR) | ED_WD790_HWR_SWH));
|
|
|
|
ed_asic_outb(sc, ED_WD790_RAR, ((kvtop(sc->mem_start) >> 13) & 0x0f) |
|
|
|
|
((kvtop(sc->mem_start) >> 11) & 0x40) |
|
|
|
|
(ed_asic_inb(sc, ED_WD790_RAR) & 0xb0));
|
|
|
|
ed_asic_outb(sc, ED_WD790_HWR, (ed_asic_inb(sc, ED_WD790_HWR) & ~ED_WD790_HWR_SWH));
|
1994-09-07 06:11:29 +00:00
|
|
|
sc->cr_proto = 0;
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1994-11-13 07:17:46 +00:00
|
|
|
#if 0
|
|
|
|
printf("starting memory performance test at 0x%x, size %d...\n",
|
|
|
|
sc->mem_start, memsize*16384);
|
|
|
|
for (i = 0; i < 16384; i++)
|
2000-08-17 12:15:45 +00:00
|
|
|
bzero(sc->mem_start, memsize);
|
1994-11-13 07:17:46 +00:00
|
|
|
printf("***DONE***\n");
|
|
|
|
#endif
|
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
/*
|
|
|
|
* Now zero memory and verify that it is clear
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
bzero(sc->mem_start, memsize);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
for (i = 0; i < memsize; ++i) {
|
2000-08-17 12:15:45 +00:00
|
|
|
if (sc->mem_start[i]) {
|
2003-04-05 18:12:36 +00:00
|
|
|
device_printf(dev, "failed to clear shared memory at %jx - check configuration\n",
|
|
|
|
(uintmax_t)kvtop(sc->mem_start + i));
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
/*
|
|
|
|
* Disable 16 bit access to shared memory
|
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, 0x00);
|
1994-04-13 10:15:34 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR, sc->wd_laar_proto &
|
1997-09-08 10:27:09 +00:00
|
|
|
~ED_WD_LAAR_M16EN);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1994-09-07 06:11:29 +00:00
|
|
|
}
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1994-09-07 06:11:29 +00:00
|
|
|
/*
|
|
|
|
* Disable 16bit access to shared memory - we leave it
|
|
|
|
* disabled so that 1) machines reboot properly when the board
|
|
|
|
* is set 16 bit mode and there are conflicting 8bit
|
|
|
|
* devices/ROMS in the same 128k address space as this boards
|
|
|
|
* shared memory. and 2) so that other 8 bit devices with
|
|
|
|
* shared memory can be used in this 128k region, too.
|
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, 0x00);
|
1994-04-13 10:15:34 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR, sc->wd_laar_proto &
|
1997-09-08 10:27:09 +00:00
|
|
|
~ED_WD_LAAR_M16EN);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
1993-09-09 07:01:23 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
int
|
|
|
|
ed_probe_WD80x3(dev, port_rid, flags)
|
|
|
|
device_t dev;
|
|
|
|
int port_rid;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
|
|
|
static unsigned short *intr_vals[] = {ed_intr_val, ed_790_intr_val};
|
|
|
|
|
|
|
|
error = ed_alloc_port(dev, port_rid, ED_WD_IO_PORTS);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
sc->asic_offset = ED_WD_ASIC_OFFSET;
|
|
|
|
sc->nic_offset = ED_WD_NIC_OFFSET;
|
|
|
|
|
|
|
|
return ed_probe_WD80x3_generic(dev, flags, intr_vals);
|
|
|
|
}
|
|
|
|
|
1993-09-09 07:01:23 +00:00
|
|
|
/*
|
|
|
|
* Probe and vendor-specific initialization routine for 3Com 3c503 boards
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_probe_3Com(dev, port_rid, flags)
|
1999-09-03 19:10:56 +00:00
|
|
|
device_t dev;
|
2000-08-17 12:15:45 +00:00
|
|
|
int port_rid;
|
|
|
|
int flags;
|
1993-09-09 07:01:23 +00:00
|
|
|
{
|
1999-09-03 19:10:56 +00:00
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
1994-08-04 17:42:35 +00:00
|
|
|
int i;
|
|
|
|
u_int memsize;
|
1994-10-22 17:52:22 +00:00
|
|
|
u_char isa16bit;
|
1999-09-03 19:10:56 +00:00
|
|
|
u_long conf_maddr, conf_msize, irq, junk;
|
|
|
|
|
|
|
|
error = ed_alloc_port(dev, 0, ED_3COM_IO_PORTS);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->asic_offset = ED_3COM_ASIC_OFFSET;
|
|
|
|
sc->nic_offset = ED_3COM_NIC_OFFSET;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that the kernel configured I/O address matches the board
|
1994-08-04 17:42:35 +00:00
|
|
|
* configured address
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
switch (ed_asic_inb(sc, ED_3COM_BCFR)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
case ED_3COM_BCFR_300:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x300)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_310:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x310)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_330:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x330)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_350:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x350)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_250:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x250)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_280:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x280)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_2A0:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x2a0)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_BCFR_2E0:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (rman_get_start(sc->port_res) != 0x2e0)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1993-06-26 02:32:26 +00:00
|
|
|
default:
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&conf_maddr, &conf_msize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Verify that the kernel shared memory address matches the board
|
|
|
|
* configured address.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
switch (ed_asic_inb(sc, ED_3COM_PCFR)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
case ED_3COM_PCFR_DC000:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (conf_maddr != 0xdc000)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_PCFR_D8000:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (conf_maddr != 0xd8000)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_PCFR_CC000:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (conf_maddr != 0xcc000)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case ED_3COM_PCFR_C8000:
|
1999-09-03 19:10:56 +00:00
|
|
|
if (conf_maddr != 0xc8000)
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1993-06-26 02:32:26 +00:00
|
|
|
default:
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1993-09-22 17:47:43 +00:00
|
|
|
* Reset NIC and ASIC. Enable on-board transceiver throughout reset
|
1994-08-04 17:42:35 +00:00
|
|
|
* sequence because it'll lock up if the cable isn't connected if we
|
|
|
|
* don't.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL);
|
1993-09-09 07:01:23 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Wait for a while, then un-reset it
|
|
|
|
*/
|
1993-09-09 07:01:23 +00:00
|
|
|
DELAY(50);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-09 07:01:23 +00:00
|
|
|
/*
|
|
|
|
* The 3Com ASIC defaults to rather strange settings for the CR after
|
2000-08-17 12:15:45 +00:00
|
|
|
* a reset - it's important to set it again after the following outb
|
|
|
|
* (this is done when we map the PROM below).
|
1993-09-09 07:01:23 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-06-22 12:10:07 +00:00
|
|
|
* Wait a bit for the NIC to recover from the reset
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
DELAY(5000);
|
|
|
|
|
|
|
|
sc->vendor = ED_VENDOR_3COM;
|
|
|
|
sc->type_str = "3c503";
|
|
|
|
sc->mem_shared = 1;
|
1994-09-07 06:11:29 +00:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window
|
|
|
|
* to it.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
memsize = 8192;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-09-09 07:01:23 +00:00
|
|
|
* Get station address from on-board ROM
|
|
|
|
*/
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-09 07:01:23 +00:00
|
|
|
/*
|
|
|
|
* First, map ethernet address PROM over the top of where the NIC
|
1994-08-04 17:42:35 +00:00
|
|
|
* registers normally appear.
|
1993-09-09 07:01:23 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
|
1993-09-09 07:01:23 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->arpcom.ac_enaddr[i] = ed_nic_inb(sc, i);
|
1993-09-09 07:01:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Unmap PROM - select NIC registers. The proper setting of the
|
1994-08-04 17:42:35 +00:00
|
|
|
* tranceiver is set in ed_init so that the attach code is given a
|
|
|
|
* chance to set the default based on a compile-time config option
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if this is an 8bit or 16bit board
|
|
|
|
*/
|
1993-06-22 12:10:07 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* select page 0 registers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP);
|
1993-06-22 12:10:07 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Attempt to clear WTS bit. If it doesn't clear, then this is a 16bit
|
|
|
|
* board.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_DCR, 0);
|
1993-06-22 12:10:07 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* select page 2 registers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_PAGE_2 | ED_CR_RD2 | ED_CR_STP);
|
1993-06-22 12:10:07 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* The 3c503 forces the WTS bit to a one if this is a 16bit board
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
if (ed_nic_inb(sc, ED_P2_DCR) & ED_DCR_WTS)
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 1;
|
1993-06-14 22:21:25 +00:00
|
|
|
else
|
1993-09-22 17:47:43 +00:00
|
|
|
isa16bit = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* select page 0 registers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P2_CR, ED_CR_RD2 | ED_CR_STP);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
error = ed_alloc_memory(dev, 0, memsize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res);
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* We have an entire 8k window to put the transmit buffers on the
|
1994-08-04 17:42:35 +00:00
|
|
|
* 16bit boards. But since the 16bit 3c503's shared memory is only
|
|
|
|
* fast enough to overlap the loading of one full-size packet, trying
|
|
|
|
* to load more than 2 buffers can actually leave the transmitter idle
|
|
|
|
* during the load. So 2 seems the best value. (Although a mix of
|
|
|
|
* variable-sized packets might change this assumption. Nonetheless,
|
|
|
|
* we optimize for linear transfers of same-size packets.)
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
1999-09-03 19:10:56 +00:00
|
|
|
if (flags & ED_FLAGS_NO_MULTI_BUFFERING)
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
else
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
|
|
|
|
sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT;
|
|
|
|
sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT;
|
|
|
|
sc->rec_page_stop = memsize / ED_PAGE_SIZE +
|
1994-08-04 17:42:35 +00:00
|
|
|
ED_3COM_RX_PAGE_OFFSET_16BIT;
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->mem_ring = sc->mem_start;
|
|
|
|
} else {
|
|
|
|
sc->txb_cnt = 1;
|
|
|
|
sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT;
|
|
|
|
sc->rec_page_start = ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT;
|
|
|
|
sc->rec_page_stop = memsize / ED_PAGE_SIZE +
|
1994-08-04 17:42:35 +00:00
|
|
|
ED_3COM_TX_PAGE_OFFSET_8BIT;
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE);
|
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
sc->isa16bit = isa16bit;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Initialize GA page start/stop registers. Probably only needed if
|
|
|
|
* doing DMA, but what the hell.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_PSTR, sc->rec_page_start);
|
|
|
|
ed_asic_outb(sc, ED_3COM_PSPR, sc->rec_page_stop);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set IRQ. 3c503 only allows a choice of irq 2-5.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, &junk);
|
1999-09-03 19:10:56 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
switch (irq) {
|
|
|
|
case 2:
|
2000-07-18 18:50:24 +00:00
|
|
|
case 9:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1999-09-03 19:10:56 +00:00
|
|
|
case 3:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1999-09-03 19:10:56 +00:00
|
|
|
case 4:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1999-09-03 19:10:56 +00:00
|
|
|
case 5:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
1999-09-03 19:10:56 +00:00
|
|
|
device_printf(dev, "Invalid irq configuration (%ld) must be 3-5,9 for 3c503\n",
|
|
|
|
irq);
|
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Initialize GA configuration register. Set bank and enable shared
|
|
|
|
* mem.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_GACFR, ED_3COM_GACFR_RSEL |
|
1994-08-04 17:42:35 +00:00
|
|
|
ED_3COM_GACFR_MBS0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Initialize "Vector Pointer" registers. These gawd-awful things are
|
|
|
|
* compared to 20 bits of the address on ISA, and if they match, the
|
|
|
|
* shared memory is disabled. We set them to 0xffff0...allegedly the
|
|
|
|
* reset vector.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_VPTR2, 0xff);
|
|
|
|
ed_asic_outb(sc, ED_3COM_VPTR1, 0xff);
|
|
|
|
ed_asic_outb(sc, ED_3COM_VPTR0, 0x00);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-06-22 12:10:07 +00:00
|
|
|
/*
|
|
|
|
* Zero memory and verify that it is clear
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
bzero(sc->mem_start, memsize);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
for (i = 0; i < memsize; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
if (sc->mem_start[i]) {
|
2003-04-05 18:12:36 +00:00
|
|
|
device_printf(dev, "failed to clear shared memory at %jx - check configuration\n",
|
|
|
|
(uintmax_t)kvtop(sc->mem_start + i));
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe and vendor-specific initialization routine for NE1000/2000 boards
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_probe_Novell_generic(dev, flags)
|
1999-09-03 19:10:56 +00:00
|
|
|
device_t dev;
|
1996-05-18 17:56:42 +00:00
|
|
|
int flags;
|
1993-09-29 20:30:26 +00:00
|
|
|
{
|
1999-09-03 19:10:56 +00:00
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
1994-08-04 17:42:35 +00:00
|
|
|
u_int memsize, n;
|
1994-10-22 17:52:22 +00:00
|
|
|
u_char romdata[16], tmp;
|
1993-09-29 20:30:26 +00:00
|
|
|
static char test_pattern[32] = "THIS is A memory TEST pattern";
|
1994-08-04 17:42:35 +00:00
|
|
|
char test_buffer[32];
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* XXX - do Novell-specific probe here */
|
|
|
|
|
|
|
|
/* Reset the board */
|
2000-07-23 15:15:43 +00:00
|
|
|
if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_NOVELL_RESET, 0);
|
2000-07-23 15:15:43 +00:00
|
|
|
DELAY(200);
|
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
tmp = ed_asic_inb(sc, ED_NOVELL_RESET);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* I don't know if this is necessary; probably cruft leftover from
|
1994-08-04 17:42:35 +00:00
|
|
|
* Clarkson packet driver code. Doesn't do a thing on the boards I've
|
2003-01-01 18:49:04 +00:00
|
|
|
* tested. -DG [note that an outb(0x84, 0) seems to work here, and is
|
1994-08-04 17:42:35 +00:00
|
|
|
* non-invasive...but some boards don't seem to reset and I don't have
|
|
|
|
* complete documentation on what the 'right' thing to do is...so we
|
|
|
|
* do the invasive thing for now. Yuck.]
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_NOVELL_RESET, tmp);
|
1993-09-29 20:30:26 +00:00
|
|
|
DELAY(5000);
|
|
|
|
|
1993-09-30 05:27:55 +00:00
|
|
|
/*
|
|
|
|
* This is needed because some NE clones apparently don't reset the
|
1994-08-04 17:42:35 +00:00
|
|
|
* NIC properly (or the NIC chip doesn't reset fully on power-up) XXX
|
|
|
|
* - this makes the probe invasive! ...Done against my better
|
|
|
|
* judgement. -DLG
|
1993-09-30 05:27:55 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1993-10-23 04:52:41 +00:00
|
|
|
DELAY(5000);
|
|
|
|
|
|
|
|
/* Make sure that we really have an 8390 based board */
|
|
|
|
if (!ed_probe_generic8390(sc))
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENXIO);
|
1993-10-23 04:52:41 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->vendor = ED_VENDOR_NOVELL;
|
|
|
|
sc->mem_shared = 0;
|
1994-09-07 06:11:29 +00:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Test the ability to read and write to the NIC memory. This has the
|
|
|
|
* side affect of determining if this is an NE1000 or an NE2000.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* This prevents packets from being stored in the NIC memory when the
|
|
|
|
* readmem routine turns on the start bit in the CR.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RCR, ED_RCR_MON);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* Temporarily initialize DCR for byte operations */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_PSTART, 8192 / ED_PAGE_SIZE);
|
|
|
|
ed_nic_outb(sc, ED_P0_PSTOP, 16384 / ED_PAGE_SIZE);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
sc->isa16bit = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a test pattern in byte mode. If this fails, then there
|
1994-08-04 17:42:35 +00:00
|
|
|
* probably isn't any memory at 8k - which likely means that the board
|
|
|
|
* is an NE2000.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
|
|
|
|
ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
|
|
|
|
|
2000-06-29 07:31:37 +00:00
|
|
|
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
|
2000-06-18 05:50:16 +00:00
|
|
|
sc->type = ED_TYPE_NE1000;
|
|
|
|
sc->type_str = "NE1000";
|
1999-11-01 01:16:56 +00:00
|
|
|
} else {
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1999-11-01 01:16:56 +00:00
|
|
|
/* neither an NE1000 nor a Linksys - try NE2000 */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
|
|
|
|
ed_nic_outb(sc, ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
|
|
|
|
ed_nic_outb(sc, ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
sc->isa16bit = 1;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* Write a test pattern in word mode. If this also fails, then
|
1994-08-04 17:42:35 +00:00
|
|
|
* we don't know what this board is.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
|
|
|
|
ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
|
1999-11-01 01:16:56 +00:00
|
|
|
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
|
|
|
|
sc->type = ED_TYPE_NE2000;
|
|
|
|
sc->type_str = "NE2000";
|
|
|
|
} else {
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1999-11-01 01:16:56 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/* 8k of memory plus an additional 8k if 16bit */
|
|
|
|
memsize = 8192 + sc->isa16bit * 8192;
|
|
|
|
|
1994-08-04 17:42:35 +00:00
|
|
|
#if 0 /* probably not useful - NE boards only come two ways */
|
1993-09-29 20:30:26 +00:00
|
|
|
/* allow kernel config file overrides */
|
|
|
|
if (isa_dev->id_msize)
|
|
|
|
memsize = isa_dev->id_msize;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sc->mem_size = memsize;
|
|
|
|
|
|
|
|
/* NIC memory doesn't start at zero on an NE board */
|
|
|
|
/* The start address is tied to the bus width */
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->mem_start = (char *) 8192 + sc->isa16bit * 8192;
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
|
|
|
sc->tx_page_start = memsize / ED_PAGE_SIZE;
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) {
|
1994-08-04 17:42:35 +00:00
|
|
|
int x, i, mstart = 0, msize = 0;
|
|
|
|
char pbuf0[ED_PAGE_SIZE], pbuf[ED_PAGE_SIZE], tbuf[ED_PAGE_SIZE];
|
|
|
|
|
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf0[i] = 0;
|
|
|
|
|
|
|
|
/* Clear all the memory. */
|
|
|
|
for (x = 1; x < 256; x++)
|
|
|
|
ed_pio_writemem(sc, pbuf0, x * 256, ED_PAGE_SIZE);
|
|
|
|
|
|
|
|
/* Search for the start of RAM. */
|
|
|
|
for (x = 1; x < 256; x++) {
|
|
|
|
ed_pio_readmem(sc, x * 256, tbuf, ED_PAGE_SIZE);
|
1995-07-25 22:18:56 +00:00
|
|
|
if (bcmp(pbuf0, tbuf, ED_PAGE_SIZE) == 0) {
|
1994-08-04 17:42:35 +00:00
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf[i] = 255 - x;
|
|
|
|
ed_pio_writemem(sc, pbuf, x * 256, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x * 256, tbuf, ED_PAGE_SIZE);
|
1995-07-25 22:18:56 +00:00
|
|
|
if (bcmp(pbuf, tbuf, ED_PAGE_SIZE) == 0) {
|
1994-08-04 17:42:35 +00:00
|
|
|
mstart = x * ED_PAGE_SIZE;
|
|
|
|
msize = ED_PAGE_SIZE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mstart == 0) {
|
1999-09-03 19:10:56 +00:00
|
|
|
device_printf(dev, "Cannot find start of RAM.\n");
|
|
|
|
return (ENXIO);
|
1994-08-04 17:42:35 +00:00
|
|
|
}
|
|
|
|
/* Search for the start of RAM. */
|
|
|
|
for (x = (mstart / ED_PAGE_SIZE) + 1; x < 256; x++) {
|
|
|
|
ed_pio_readmem(sc, x * 256, tbuf, ED_PAGE_SIZE);
|
1995-07-25 22:18:56 +00:00
|
|
|
if (bcmp(pbuf0, tbuf, ED_PAGE_SIZE) == 0) {
|
1994-08-04 17:42:35 +00:00
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf[i] = 255 - x;
|
|
|
|
ed_pio_writemem(sc, pbuf, x * 256, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x * 256, tbuf, ED_PAGE_SIZE);
|
1995-07-25 22:18:56 +00:00
|
|
|
if (bcmp(pbuf, tbuf, ED_PAGE_SIZE) == 0)
|
1994-08-04 17:42:35 +00:00
|
|
|
msize += ED_PAGE_SIZE;
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msize == 0) {
|
1999-09-03 19:10:56 +00:00
|
|
|
device_printf(dev, "Cannot find any RAM, start : %d, x = %d.\n", mstart, x);
|
|
|
|
return (ENXIO);
|
1994-08-04 17:42:35 +00:00
|
|
|
}
|
1999-09-03 19:10:56 +00:00
|
|
|
device_printf(dev, "RAM start at %d, size : %d.\n", mstart, msize);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
sc->mem_size = msize;
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->mem_start = (caddr_t) mstart;
|
|
|
|
sc->mem_end = (caddr_t) (msize + mstart);
|
1994-08-04 17:42:35 +00:00
|
|
|
sc->tx_page_start = mstart / ED_PAGE_SIZE;
|
|
|
|
}
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* Use one xmit buffer if < 16k, two buffers otherwise (if not told
|
1994-08-04 17:42:35 +00:00
|
|
|
* otherwise).
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
1996-05-18 17:56:42 +00:00
|
|
|
if ((memsize < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING))
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
else
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
|
|
|
|
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
|
|
|
sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE;
|
|
|
|
|
|
|
|
sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
|
|
|
|
|
2000-06-29 07:31:37 +00:00
|
|
|
ed_pio_readmem(sc, 0, romdata, 16);
|
|
|
|
for (n = 0; n < ETHER_ADDR_LEN; n++)
|
|
|
|
sc->arpcom.ac_enaddr[n] = romdata[n * (sc->isa16bit + 1)];
|
1994-08-04 17:42:35 +00:00
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) &&
|
|
|
|
(sc->arpcom.ac_enaddr[2] == 0x86)) {
|
1994-08-04 17:42:35 +00:00
|
|
|
sc->type_str = "Gateway AT";
|
1995-01-15 00:18:17 +00:00
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* clear any pending interrupts that might have occurred above */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR, 0xff);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_probe_Novell(dev, port_rid, flags)
|
1999-09-03 19:10:56 +00:00
|
|
|
device_t dev;
|
2000-08-17 12:15:45 +00:00
|
|
|
int port_rid;
|
|
|
|
int flags;
|
1996-05-18 17:56:42 +00:00
|
|
|
{
|
2000-08-17 12:15:45 +00:00
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = ed_alloc_port(dev, port_rid, ED_NOVELL_IO_PORTS);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
sc->asic_offset = ED_NOVELL_ASIC_OFFSET;
|
|
|
|
sc->nic_offset = ED_NOVELL_NIC_OFFSET;
|
|
|
|
|
|
|
|
return ed_probe_Novell_generic(dev, flags);
|
1996-05-18 17:56:42 +00:00
|
|
|
}
|
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
#define ED_HPP_TEST_SIZE 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe and vendor specific initialization for the HP PC Lan+ Cards.
|
|
|
|
* (HP Part nos: 27247B and 27252A).
|
|
|
|
*
|
|
|
|
* The card has an asic wrapper around a DS8390 core. The asic handles
|
|
|
|
* host accesses and offers both standard register IO and memory mapped
|
|
|
|
* IO. Memory mapped I/O allows better performance at the expense of greater
|
|
|
|
* chance of an incompatibility with existing ISA cards.
|
|
|
|
*
|
|
|
|
* The card has a few caveats: it isn't tolerant of byte wide accesses, only
|
|
|
|
* short (16 bit) or word (32 bit) accesses are allowed. Some card revisions
|
|
|
|
* don't allow 32 bit accesses; these are indicated by a bit in the software
|
|
|
|
* ID register (see if_edreg.h).
|
|
|
|
*
|
|
|
|
* Other caveats are: we should read the MAC address only when the card
|
|
|
|
* is inactive.
|
|
|
|
*
|
|
|
|
* For more information; please consult the CRYNWR packet driver.
|
|
|
|
*
|
|
|
|
* The AUI port is turned on using the "link2" option on the ifconfig
|
|
|
|
* command line.
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_probe_HP_pclanp(dev, port_rid, flags)
|
1999-09-03 19:10:56 +00:00
|
|
|
device_t dev;
|
2000-08-17 12:15:45 +00:00
|
|
|
int port_rid;
|
|
|
|
int flags;
|
1996-08-07 11:18:23 +00:00
|
|
|
{
|
1999-09-03 19:10:56 +00:00
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
1996-08-07 11:18:23 +00:00
|
|
|
int n; /* temp var */
|
|
|
|
int memsize; /* mem on board */
|
|
|
|
u_char checksum; /* checksum of board address */
|
|
|
|
u_char irq; /* board configured IRQ */
|
|
|
|
char test_pattern[ED_HPP_TEST_SIZE]; /* read/write areas for */
|
|
|
|
char test_buffer[ED_HPP_TEST_SIZE]; /* probing card */
|
1999-09-03 19:10:56 +00:00
|
|
|
u_long conf_maddr, conf_msize, conf_irq, junk;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
error = ed_alloc_port(dev, 0, ED_HPP_IO_PORTS);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/* Fill in basic information */
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->asic_offset = ED_HPP_ASIC_OFFSET;
|
|
|
|
sc->nic_offset = ED_HPP_NIC_OFFSET;
|
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
sc->chip_type = ED_CHIP_TYPE_DP8390;
|
1996-08-07 11:18:23 +00:00
|
|
|
sc->isa16bit = 0; /* the 8390 core needs to be in byte mode */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for the HP PCLAN+ signature: "0x50,0x48,0x00,0x53"
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
if ((ed_asic_inb(sc, ED_HPP_ID) != 0x50) ||
|
|
|
|
(ed_asic_inb(sc, ED_HPP_ID + 1) != 0x48) ||
|
|
|
|
((ed_asic_inb(sc, ED_HPP_ID + 2) & 0xF0) != 0) ||
|
|
|
|
(ed_asic_inb(sc, ED_HPP_ID + 3) != 0x53))
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the MAC address and verify checksum on the address.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_MAC);
|
1996-08-07 11:18:23 +00:00
|
|
|
for (n = 0, checksum = 0; n < ETHER_ADDR_LEN; n++)
|
|
|
|
checksum += (sc->arpcom.ac_enaddr[n] =
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_inb(sc, ED_HPP_MAC_ADDR + n));
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
checksum += ed_asic_inb(sc, ED_HPP_MAC_ADDR + ETHER_ADDR_LEN);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
if (checksum != 0xFF)
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that the software model number is 0.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_ID);
|
|
|
|
if (((sc->hpp_id = ed_asic_inw(sc, ED_HPP_PAGE_4)) &
|
1996-08-07 11:18:23 +00:00
|
|
|
ED_HPP_ID_SOFT_MODEL_MASK) != 0x0000)
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read in and save the current options configured on card.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->hpp_options = ed_asic_inw(sc, ED_HPP_OPTION);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
sc->hpp_options |= (ED_HPP_OPTION_NIC_RESET |
|
|
|
|
ED_HPP_OPTION_CHIP_RESET |
|
|
|
|
ED_HPP_OPTION_ENABLE_IRQ);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the chip. This requires writing to the option register
|
|
|
|
* so take care to preserve the other bits.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION,
|
1996-08-07 11:18:23 +00:00
|
|
|
(sc->hpp_options & ~(ED_HPP_OPTION_NIC_RESET |
|
|
|
|
ED_HPP_OPTION_CHIP_RESET)));
|
|
|
|
|
|
|
|
DELAY(5000); /* wait for chip reset to complete */
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION,
|
1996-08-07 11:18:23 +00:00
|
|
|
(sc->hpp_options | (ED_HPP_OPTION_NIC_RESET |
|
|
|
|
ED_HPP_OPTION_CHIP_RESET |
|
|
|
|
ED_HPP_OPTION_ENABLE_IRQ)));
|
|
|
|
|
|
|
|
DELAY(5000);
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
if (!(ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RST))
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO; /* reset did not complete */
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read out configuration information.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_HW);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
irq = ed_asic_inb(sc, ED_HPP_HW_IRQ);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for impossible IRQ.
|
|
|
|
*/
|
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
if (irq >= (sizeof(ed_hpp_intr_val) / sizeof(ed_hpp_intr_val[0])))
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the kernel IRQ was specified with a '?' use the cards idea
|
|
|
|
* of the IRQ. If the kernel IRQ was explicitly specified, it
|
|
|
|
* should match that of the hardware.
|
|
|
|
*/
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&conf_irq, &junk);
|
|
|
|
if (error) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
ed_hpp_intr_val[irq], 1);
|
|
|
|
} else {
|
|
|
|
if (conf_irq != ed_hpp_intr_val[irq])
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in softconfig info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sc->vendor = ED_VENDOR_HP;
|
|
|
|
sc->type = ED_TYPE_HP_PCLANPLUS;
|
|
|
|
sc->type_str = "HP-PCLAN+";
|
|
|
|
|
|
|
|
sc->mem_shared = 0; /* we DON'T have dual ported RAM */
|
|
|
|
sc->mem_start = 0; /* we use offsets inside the card RAM */
|
|
|
|
|
|
|
|
sc->hpp_mem_start = NULL;/* no memory mapped I/O by default */
|
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
/*
|
|
|
|
* The board has 32KB of memory. Is there a way to determine
|
|
|
|
* this programmatically?
|
|
|
|
*/
|
|
|
|
|
|
|
|
memsize = 32768;
|
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
/*
|
|
|
|
* Check if memory mapping of the I/O registers possible.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (sc->hpp_options & ED_HPP_OPTION_MEM_ENABLE)
|
|
|
|
{
|
|
|
|
u_long mem_addr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* determine the memory address from the board.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_HW);
|
|
|
|
mem_addr = (ed_asic_inw(sc, ED_HPP_HW_MEM_MAP) << 8);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that the kernel specified start of memory and
|
|
|
|
* hardware's idea of it match.
|
|
|
|
*/
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
1999-09-03 19:10:56 +00:00
|
|
|
&conf_maddr, &conf_msize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
if (mem_addr != conf_maddr)
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
error = ed_alloc_memory(dev, 0, memsize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
sc->hpp_mem_start = rman_get_virtual(sc->mem_res);
|
1999-09-03 19:10:56 +00:00
|
|
|
}
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the rest of the soft config structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The transmit page index.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sc->tx_page_start = ED_HPP_TX_PAGE_OFFSET;
|
|
|
|
|
1999-09-07 08:42:49 +00:00
|
|
|
if (device_get_flags(dev) & ED_FLAGS_NO_MULTI_BUFFERING)
|
1996-08-07 11:18:23 +00:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
else
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory description
|
|
|
|
*/
|
|
|
|
|
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_ring = sc->mem_start +
|
|
|
|
(sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE);
|
|
|
|
sc->mem_end = sc->mem_start + sc->mem_size;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive area starts after the transmit area and
|
|
|
|
* continues till the end of memory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sc->rec_page_start = sc->tx_page_start +
|
|
|
|
(sc->txb_cnt * ED_TXBUF_SIZE);
|
|
|
|
sc->rec_page_stop = (sc->mem_size / ED_PAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
sc->cr_proto = 0; /* value works */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the wrap registers for string I/O reads.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_HW);
|
|
|
|
ed_asic_outw(sc, ED_HPP_HW_WRAP,
|
1996-08-07 11:18:23 +00:00
|
|
|
((sc->rec_page_start / ED_PAGE_SIZE) |
|
|
|
|
(((sc->rec_page_stop / ED_PAGE_SIZE) - 1) << 8)));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the register page to normal operation.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_PERF);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that we can read/write from adapter memory.
|
|
|
|
* Create test pattern.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (n = 0; n < ED_HPP_TEST_SIZE; n++)
|
|
|
|
{
|
|
|
|
test_pattern[n] = (n*n) ^ ~n;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ED_HPP_TEST_SIZE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that the memory is accessible thru the I/O ports.
|
|
|
|
* Write out the contents of "test_pattern", read back
|
|
|
|
* into "test_buffer" and compare the two for any
|
|
|
|
* mismatch.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (n = 0; n < (32768 / ED_PAGE_SIZE); n ++) {
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_hpp_writemem(sc, test_pattern, (n * ED_PAGE_SIZE),
|
1996-08-07 11:18:23 +00:00
|
|
|
sizeof(test_pattern));
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_hpp_readmem(sc, (n * ED_PAGE_SIZE),
|
1996-08-07 11:18:23 +00:00
|
|
|
test_buffer, sizeof(test_pattern));
|
|
|
|
|
|
|
|
if (bcmp(test_pattern, test_buffer,
|
|
|
|
sizeof(test_pattern)))
|
1999-09-13 19:14:43 +00:00
|
|
|
return ENXIO;
|
1996-08-07 11:18:23 +00:00
|
|
|
}
|
|
|
|
|
2001-10-31 19:43:33 +00:00
|
|
|
return (0);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HP PC Lan+ : Set the physical link to use AUI or TP/TL.
|
|
|
|
*/
|
|
|
|
|
2002-09-28 17:15:38 +00:00
|
|
|
static void
|
1996-08-07 11:18:23 +00:00
|
|
|
ed_hpp_set_physical_link(struct ed_softc *sc)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
|
|
|
int lan_page;
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_LAN);
|
|
|
|
lan_page = ed_asic_inw(sc, ED_HPP_PAGE_0);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
if (ifp->if_flags & IFF_ALTPHYS) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use the AUI port.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lan_page |= ED_HPP_LAN_AUI;
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_LAN);
|
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_0, lan_page);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use the ThinLan interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
lan_page &= ~ED_HPP_LAN_AUI;
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_LAN);
|
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_0, lan_page);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for the lan card to re-initialize itself
|
|
|
|
*/
|
|
|
|
|
|
|
|
DELAY(150000); /* wait 150 ms */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore normal pages.
|
|
|
|
*/
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_PERF);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
/*
|
|
|
|
* Allocate a port resource with the given resource id.
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
1999-09-03 19:10:56 +00:00
|
|
|
ed_alloc_port(dev, rid, size)
|
|
|
|
device_t dev;
|
|
|
|
int rid;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
|
|
0ul, ~0ul, size, RF_ACTIVE);
|
|
|
|
if (res) {
|
|
|
|
sc->port_rid = rid;
|
|
|
|
sc->port_res = res;
|
1999-11-18 14:18:19 +00:00
|
|
|
sc->port_used = size;
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
2000-08-17 12:15:45 +00:00
|
|
|
} else {
|
1999-09-03 19:10:56 +00:00
|
|
|
return (ENOENT);
|
2000-08-17 12:15:45 +00:00
|
|
|
}
|
1999-09-03 19:10:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a memory resource with the given resource id.
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
1999-09-03 19:10:56 +00:00
|
|
|
ed_alloc_memory(dev, rid, size)
|
|
|
|
device_t dev;
|
|
|
|
int rid;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
|
|
|
|
0ul, ~0ul, size, RF_ACTIVE);
|
|
|
|
if (res) {
|
|
|
|
sc->mem_rid = rid;
|
|
|
|
sc->mem_res = res;
|
1999-11-18 14:18:19 +00:00
|
|
|
sc->mem_used = size;
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate an irq resource with the given resource id.
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
1999-09-03 19:10:56 +00:00
|
|
|
ed_alloc_irq(dev, rid, flags)
|
|
|
|
device_t dev;
|
|
|
|
int rid;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
|
|
|
|
0ul, ~0ul, 1, (RF_ACTIVE | flags));
|
|
|
|
if (res) {
|
|
|
|
sc->irq_rid = rid;
|
|
|
|
sc->irq_res = res;
|
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release all resources
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
void
|
1999-09-03 19:10:56 +00:00
|
|
|
ed_release_resources(dev)
|
|
|
|
device_t dev;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (sc->port_res) {
|
2000-11-25 03:36:09 +00:00
|
|
|
bus_deactivate_resource(dev, SYS_RES_IOPORT,
|
|
|
|
sc->port_rid, sc->port_res);
|
1999-09-03 19:10:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
sc->port_rid, sc->port_res);
|
|
|
|
sc->port_res = 0;
|
|
|
|
}
|
|
|
|
if (sc->mem_res) {
|
2000-11-25 03:36:09 +00:00
|
|
|
bus_deactivate_resource(dev, SYS_RES_MEMORY,
|
|
|
|
sc->mem_rid, sc->mem_res);
|
1999-09-03 19:10:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY,
|
|
|
|
sc->mem_rid, sc->mem_res);
|
|
|
|
sc->mem_res = 0;
|
|
|
|
}
|
|
|
|
if (sc->irq_res) {
|
2000-11-25 03:36:09 +00:00
|
|
|
bus_deactivate_resource(dev, SYS_RES_IRQ,
|
|
|
|
sc->irq_rid, sc->irq_res);
|
1999-09-03 19:10:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IRQ,
|
|
|
|
sc->irq_rid, sc->irq_res);
|
|
|
|
sc->irq_res = 0;
|
|
|
|
}
|
|
|
|
}
|
1996-08-07 11:18:23 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Install interface into kernel networking data structures
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
int
|
1996-05-18 17:56:42 +00:00
|
|
|
ed_attach(sc, unit, flags)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
int unit;
|
|
|
|
int flags;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
2001-03-03 08:31:37 +00:00
|
|
|
callout_handle_init(&sc->tick_ch);
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set interface to stopped condition (reset)
|
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_stop(sc);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (!ifp->if_name) {
|
|
|
|
/*
|
|
|
|
* Initialize ifnet structure
|
|
|
|
*/
|
1996-02-06 18:51:28 +00:00
|
|
|
ifp->if_softc = sc;
|
1996-05-18 17:56:42 +00:00
|
|
|
ifp->if_unit = unit;
|
1995-10-10 09:52:55 +00:00
|
|
|
ifp->if_name = "ed";
|
|
|
|
ifp->if_output = ether_output;
|
|
|
|
ifp->if_start = ed_start;
|
|
|
|
ifp->if_ioctl = ed_ioctl;
|
|
|
|
ifp->if_watchdog = ed_watchdog;
|
1996-10-11 15:19:23 +00:00
|
|
|
ifp->if_init = ed_init;
|
1995-10-10 09:52:55 +00:00
|
|
|
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
1996-10-11 15:19:23 +00:00
|
|
|
ifp->if_linkmib = &sc->mibdata;
|
|
|
|
ifp->if_linkmiblen = sizeof sc->mibdata;
|
|
|
|
/*
|
|
|
|
* XXX - should do a better job.
|
|
|
|
*/
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790)
|
1996-10-11 15:19:23 +00:00
|
|
|
sc->mibdata.dot3StatsEtherChipSet =
|
|
|
|
DOT3CHIPSET(dot3VendorWesternDigital,
|
|
|
|
dot3ChipSetWesternDigital83C790);
|
|
|
|
else
|
|
|
|
sc->mibdata.dot3StatsEtherChipSet =
|
|
|
|
DOT3CHIPSET(dot3VendorNational,
|
|
|
|
dot3ChipSetNational8390);
|
|
|
|
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
/*
|
|
|
|
* Set default state for ALTPHYS flag (used to disable the
|
|
|
|
* tranceiver for AUI operation), based on compile-time
|
|
|
|
* config option.
|
|
|
|
*/
|
1996-05-18 17:56:42 +00:00
|
|
|
if (flags & ED_FLAGS_DISABLE_TRANCEIVER)
|
1995-10-10 09:52:55 +00:00
|
|
|
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
|
1995-10-13 19:48:06 +00:00
|
|
|
IFF_MULTICAST | IFF_ALTPHYS);
|
1995-10-10 09:52:55 +00:00
|
|
|
else
|
|
|
|
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
|
1995-10-13 19:48:06 +00:00
|
|
|
IFF_MULTICAST);
|
1993-06-22 12:10:07 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
/*
|
|
|
|
* Attach the interface
|
|
|
|
*/
|
2002-11-14 23:54:55 +00:00
|
|
|
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
|
1995-10-10 09:52:55 +00:00
|
|
|
}
|
1995-01-15 00:18:17 +00:00
|
|
|
/* device attach does transition from UNCONFIGURED to IDLE state */
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Print additional info when attached
|
|
|
|
*/
|
2002-10-01 00:49:28 +00:00
|
|
|
if_printf(ifp, "address %6D, ", sc->arpcom.ac_enaddr, ":");
|
1993-09-22 17:47:43 +00:00
|
|
|
|
|
|
|
if (sc->type_str && (*sc->type_str != 0))
|
|
|
|
printf("type %s ", sc->type_str);
|
|
|
|
else
|
|
|
|
printf("type unknown (0x%x) ", sc->type);
|
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
if (sc->vendor == ED_VENDOR_HP)
|
|
|
|
printf("(%s %s IO)", (sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS) ?
|
|
|
|
"16-bit" : "32-bit",
|
|
|
|
sc->hpp_mem_start ? "memory mapped" : "regular");
|
|
|
|
else
|
|
|
|
printf("%s ", sc->isa16bit ? "(16 bit)" : "(8 bit)");
|
1993-09-22 17:47:43 +00:00
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
printf("%s\n", (((sc->vendor == ED_VENDOR_3COM) ||
|
|
|
|
(sc->vendor == ED_VENDOR_HP)) &&
|
|
|
|
(ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : "");
|
1993-07-20 23:16:50 +00:00
|
|
|
|
1999-09-03 19:10:56 +00:00
|
|
|
return (0);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Reset interface.
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_reset(ifp)
|
|
|
|
struct ifnet *ifp;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ed_softc *sc = ifp->if_softc;
|
1994-08-04 17:42:35 +00:00
|
|
|
int s;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-12-05 02:01:59 +00:00
|
|
|
if (sc->gone)
|
1995-10-10 09:52:55 +00:00
|
|
|
return;
|
1993-11-22 11:08:16 +00:00
|
|
|
s = splimp();
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop interface and re-initialize.
|
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_stop(sc);
|
1996-08-04 10:57:29 +00:00
|
|
|
ed_init(sc);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-07-27 10:52:31 +00:00
|
|
|
(void) splx(s);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Take interface offline.
|
|
|
|
*/
|
1999-12-10 07:22:53 +00:00
|
|
|
void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_stop(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1994-08-04 17:42:35 +00:00
|
|
|
int n = 5000;
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
untimeout(ed_tick, sc, sc->tick_ch);
|
|
|
|
callout_handle_init(&sc->tick_ch);
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Stop everything on the interface, and select page 0 registers.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STP);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Wait for interface to enter stopped state, but limit # of checks to
|
|
|
|
* 'n' (about 5ms). It shouldn't even take 5us on modern DS8390's, but
|
|
|
|
* just in case it's an old one.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type != ED_CHIP_TYPE_AX88190)
|
2000-08-17 12:15:45 +00:00
|
|
|
while (((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
|
|
|
* Device timeout/watchdog routine. Entered if the device neglects to
|
|
|
|
* generate an interrupt after a transmit has been started on it.
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_watchdog(ifp)
|
|
|
|
struct ifnet *ifp;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ed_softc *sc = ifp->if_softc;
|
1993-10-23 04:52:41 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
1995-12-05 02:01:59 +00:00
|
|
|
log(LOG_ERR, "ed%d: device timeout\n", ifp->if_unit);
|
|
|
|
ifp->if_oerrors++;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_reset(ifp);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
static void
|
|
|
|
ed_tick(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc = arg;
|
|
|
|
struct mii_data *mii;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
if (sc->gone) {
|
|
|
|
callout_handle_init(&sc->tick_ch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s = splimp();
|
|
|
|
if (sc->miibus != NULL) {
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
mii_tick(mii);
|
|
|
|
}
|
|
|
|
sc->tick_ch = timeout(ed_tick, sc, hz);
|
|
|
|
splx(s);
|
|
|
|
}
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
2001-03-03 08:31:37 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Initialize device.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1996-10-11 15:19:23 +00:00
|
|
|
ed_init(xsc)
|
|
|
|
void *xsc;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1996-10-11 15:19:23 +00:00
|
|
|
struct ed_softc *sc = xsc;
|
1996-08-04 10:57:29 +00:00
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
1994-08-04 17:42:35 +00:00
|
|
|
int i, s;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/* address not known */
|
1996-12-13 21:29:07 +00:00
|
|
|
if (TAILQ_EMPTY(&ifp->if_addrhead)) /* unlikely? XXX */
|
1994-08-04 17:42:35 +00:00
|
|
|
return;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the NIC in the exact order outlined in the NS manual.
|
1994-08-04 17:42:35 +00:00
|
|
|
* This init procedure is "mandatory"...don't change what or when
|
|
|
|
* things happen.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-11-22 11:08:16 +00:00
|
|
|
s = splimp();
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/* reset transmitter flags */
|
|
|
|
sc->xmit_busy = 0;
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_timer = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->txb_inuse = 0;
|
|
|
|
sc->txb_new = 0;
|
|
|
|
sc->txb_next_tx = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/* This variable is used below - don't move this assignment */
|
|
|
|
sc->next_packet = sc->rec_page_start + 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set interface for page 0, Remote DMA complete, Stopped
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STP);
|
1994-09-07 06:11:29 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
if (sc->isa16bit) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Set FIFO threshold to 8, No auto-init Remote DMA, byte
|
|
|
|
* order=80x86, word-wide DMA xfers,
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
|
1993-06-14 22:21:25 +00:00
|
|
|
} else {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Same as above, but byte-wide DMA xfers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear Remote Byte Count Registers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RBCR0, 0);
|
|
|
|
ed_nic_outb(sc, ED_P0_RBCR1, 0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* For the moment, don't store incoming packets in memory.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RCR, ED_RCR_MON);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Place NIC in internal loopback mode
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_TCR, ED_TCR_LB0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize transmit/receive (ring-buffer) Page Start
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_TPSR, sc->tx_page_start);
|
|
|
|
ed_nic_outb(sc, ED_P0_PSTART, sc->rec_page_start);
|
1993-11-22 11:08:16 +00:00
|
|
|
/* Set lower bits of byte addressable framing to 0 */
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, 0x09, 0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize Receiver (ring-buffer) Page Stop and Boundry
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_PSTOP, sc->rec_page_stop);
|
|
|
|
ed_nic_outb(sc, ED_P0_BNRY, sc->rec_page_start);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear all interrupts. A '1' in each bit position clears the
|
1994-08-04 17:42:35 +00:00
|
|
|
* corresponding flag.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR, 0xff);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the following interrupts: receive/transmit complete,
|
1994-08-04 17:42:35 +00:00
|
|
|
* receive/transmit error, and Receiver OverWrite.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1993-06-14 22:21:25 +00:00
|
|
|
* Counter overflow and Remote DMA complete are *not* enabled.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_IMR,
|
1994-08-04 17:42:35 +00:00
|
|
|
ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE | ED_IMR_OVWE);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Program Command Register for page 1
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Copy out our station address
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P1_PAR(i), sc->arpcom.ac_enaddr[i]);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set Current Page pointer to next_packet (initialized above)
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P1_CURR, sc->next_packet);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Program Receiver Configuration Register and multicast filter. CR is
|
|
|
|
* set to page 0 on return.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_setrcr(sc);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Take interface out of loopback
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_TCR, 0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-06-22 12:10:07 +00:00
|
|
|
/*
|
|
|
|
* If this is a 3Com board, the tranceiver must be software enabled
|
1994-08-04 17:42:35 +00:00
|
|
|
* (there is no settable hardware default).
|
1993-06-22 12:10:07 +00:00
|
|
|
*/
|
1993-07-25 23:43:30 +00:00
|
|
|
if (sc->vendor == ED_VENDOR_3COM) {
|
1993-09-09 07:01:23 +00:00
|
|
|
if (ifp->if_flags & IFF_ALTPHYS) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, 0);
|
1993-07-25 23:43:30 +00:00
|
|
|
} else {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-07-25 23:43:30 +00:00
|
|
|
}
|
1993-06-22 12:10:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
if (sc->miibus != NULL) {
|
|
|
|
struct mii_data *mii;
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
mii_mediachg(mii);
|
|
|
|
}
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set 'running' flag, and clear output active flag.
|
|
|
|
*/
|
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ...and attempt to start output
|
|
|
|
*/
|
|
|
|
ed_start(ifp);
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
untimeout(ed_tick, sc, sc->tick_ch);
|
|
|
|
sc->tick_ch = timeout(ed_tick, sc, hz);
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1993-06-14 22:21:25 +00:00
|
|
|
(void) splx(s);
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
|
|
|
* This routine actually starts the transmission on the interface
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_xmit(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1995-12-05 02:01:59 +00:00
|
|
|
struct ifnet *ifp = (struct ifnet *)sc;
|
1993-09-29 20:30:26 +00:00
|
|
|
unsigned short len;
|
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
1993-09-29 20:30:26 +00:00
|
|
|
len = sc->txb_len[sc->txb_next_tx];
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set NIC for page 0 register access
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set TX buffer start page
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_TPSR, sc->tx_page_start +
|
|
|
|
sc->txb_next_tx * ED_TXBUF_SIZE);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set TX length
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_TBCR0, len);
|
|
|
|
ed_nic_outb(sc, ED_P0_TBCR1, len >> 8);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-06-23 16:22:04 +00:00
|
|
|
* Set page 0, Remote DMA complete, Transmit Packet, and *Start*
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_TXP | ED_CR_STA);
|
1993-06-14 22:21:25 +00:00
|
|
|
sc->xmit_busy = 1;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Point to next transmit buffer slot and wrap if necessary.
|
1993-06-23 16:22:04 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->txb_next_tx++;
|
|
|
|
if (sc->txb_next_tx == sc->txb_cnt)
|
|
|
|
sc->txb_next_tx = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a timer just in case we never hear from the board again
|
|
|
|
*/
|
|
|
|
ifp->if_timer = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start output on interface.
|
|
|
|
* We make two assumptions here:
|
1993-11-22 11:08:16 +00:00
|
|
|
* 1) that the current priority is set to splimp _before_ this code
|
1993-06-14 22:21:25 +00:00
|
|
|
* is called *and* is returned to the appropriate priority after
|
|
|
|
* return
|
|
|
|
* 2) that the IFF_OACTIVE flag is checked before this code is called
|
|
|
|
* (i.e. that the output part of the interface is idle)
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1993-06-14 22:21:25 +00:00
|
|
|
ed_start(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ed_softc *sc = ifp->if_softc;
|
1993-06-14 22:21:25 +00:00
|
|
|
struct mbuf *m0, *m;
|
2000-08-17 12:15:45 +00:00
|
|
|
caddr_t buffer;
|
1994-08-04 17:42:35 +00:00
|
|
|
int len;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone) {
|
|
|
|
printf("ed_start(%p) GONE\n",ifp);
|
|
|
|
return;
|
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
outloop:
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* First, see if there are buffered packets and an idle transmitter -
|
|
|
|
* should never happen at this point.
|
1993-06-23 16:22:04 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
if (sc->txb_inuse && (sc->xmit_busy == 0)) {
|
1994-08-22 08:21:51 +00:00
|
|
|
printf("ed: packets buffered, but transmitter idle\n");
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_xmit(sc);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if there is room to put another packet in the buffer.
|
|
|
|
*/
|
|
|
|
if (sc->txb_inuse == sc->txb_cnt) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* No room. Indicate this to the outside world and exit.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
return;
|
|
|
|
}
|
1995-12-05 02:01:59 +00:00
|
|
|
IF_DEQUEUE(&ifp->if_snd, m);
|
1993-06-14 22:21:25 +00:00
|
|
|
if (m == 0) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We are using the !OACTIVE flag to indicate to the outside
|
|
|
|
* world that we can accept an additional packet rather than
|
|
|
|
* that the transmitter is _actually_ active. Indeed, the
|
|
|
|
* transmitter may be active, but if we haven't filled all the
|
|
|
|
* buffers with data then we still want to accept more.
|
|
|
|
*/
|
1993-06-14 22:21:25 +00:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the mbuf chain into the transmit buffer
|
|
|
|
*/
|
|
|
|
|
1993-10-15 11:06:41 +00:00
|
|
|
m0 = m;
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/* txb_new points to next open buffer slot */
|
|
|
|
buffer = sc->mem_start + (sc->txb_new * ED_TXBUF_SIZE * ED_PAGE_SIZE);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
if (sc->mem_shared) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* Special case setup for 16 bit boards...
|
|
|
|
*/
|
|
|
|
if (sc->isa16bit) {
|
|
|
|
switch (sc->vendor) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For 16bit 3Com boards (which have 16k of
|
|
|
|
* memory), we have the xmit buffers in a
|
|
|
|
* different page of memory ('page 0') - so
|
|
|
|
* change pages.
|
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
case ED_VENDOR_3COM:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_GACFR,
|
|
|
|
ED_3COM_GACFR_RSEL);
|
1993-09-29 20:30:26 +00:00
|
|
|
break;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable 16bit access to shared memory on
|
1994-10-08 09:24:20 +00:00
|
|
|
* WD/SMC boards.
|
1994-08-04 17:42:35 +00:00
|
|
|
*/
|
2000-08-14 04:31:07 +00:00
|
|
|
case ED_VENDOR_WD_SMC:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
|
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
|
|
|
ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_MENB);
|
|
|
|
}
|
|
|
|
break;
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
1993-10-15 11:06:41 +00:00
|
|
|
for (len = 0; m != 0; m = m->m_next) {
|
2000-08-17 12:15:45 +00:00
|
|
|
bcopy(mtod(m, caddr_t), buffer, m->m_len);
|
1993-09-29 20:30:26 +00:00
|
|
|
buffer += m->m_len;
|
1994-08-04 17:42:35 +00:00
|
|
|
len += m->m_len;
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Restore previous shared memory access
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
if (sc->isa16bit) {
|
|
|
|
switch (sc->vendor) {
|
|
|
|
case ED_VENDOR_3COM:
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_GACFR,
|
|
|
|
ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
|
1993-09-29 20:30:26 +00:00
|
|
|
break;
|
2000-08-14 04:31:07 +00:00
|
|
|
case ED_VENDOR_WD_SMC:
|
2000-08-17 12:15:45 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
|
|
|
ed_asic_outb(sc, ED_WD_MSR, 0x00);
|
|
|
|
}
|
|
|
|
ed_asic_outb(sc, ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto & ~ED_WD_LAAR_M16EN);
|
|
|
|
break;
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
1995-12-15 07:31:40 +00:00
|
|
|
len = ed_pio_write_mbufs(sc, m, (int)buffer);
|
2002-09-30 00:18:12 +00:00
|
|
|
if (len == 0) {
|
|
|
|
m_freem(m0);
|
1995-01-04 21:10:17 +00:00
|
|
|
goto outloop;
|
2002-09-30 00:18:12 +00:00
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1996-08-06 21:14:36 +00:00
|
|
|
sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN));
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
sc->txb_inuse++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Point to next buffer slot and wrap if necessary.
|
|
|
|
*/
|
|
|
|
sc->txb_new++;
|
|
|
|
if (sc->txb_new == sc->txb_cnt)
|
|
|
|
sc->txb_new = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
if (sc->xmit_busy == 0)
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_xmit(sc);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-10-08 09:24:20 +00:00
|
|
|
* Tap off here if there is a bpf listener.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2002-11-14 23:54:55 +00:00
|
|
|
BPF_MTAP(ifp, m0);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
m_freem(m0);
|
|
|
|
|
1993-06-23 16:22:04 +00:00
|
|
|
/*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Loop back to the top to possibly buffer more packets
|
1993-06-23 16:22:04 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
goto outloop;
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Ethernet interface receiver interrupt.
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_rint(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
1994-10-22 17:52:22 +00:00
|
|
|
u_char boundry;
|
1993-06-14 22:21:25 +00:00
|
|
|
u_short len;
|
1993-09-29 20:30:26 +00:00
|
|
|
struct ed_ring packet_hdr;
|
1994-08-04 17:42:35 +00:00
|
|
|
char *packet_ptr;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set NIC to page 1 registers to get 'current' pointer
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* 'sc->next_packet' is the logical beginning of the ring-buffer -
|
|
|
|
* i.e. it points to where new data has been buffered. The 'CURR'
|
|
|
|
* (current) register points to the logical end of the ring-buffer -
|
|
|
|
* i.e. it points to where additional new data will be added. We loop
|
|
|
|
* here until the logical beginning equals the logical end (or in
|
|
|
|
* other words, until the ring-buffer is empty).
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
while (sc->next_packet != ed_nic_inb(sc, ED_P1_CURR)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/* get pointer to this buffer's header structure */
|
2000-08-17 12:15:45 +00:00
|
|
|
packet_ptr = sc->mem_ring +
|
1994-01-03 17:17:19 +00:00
|
|
|
(sc->next_packet - sc->rec_page_start) * ED_PAGE_SIZE;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* The byte count includes a 4 byte header that was added by
|
|
|
|
* the NIC.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
if (sc->mem_shared)
|
1994-08-04 17:42:35 +00:00
|
|
|
packet_hdr = *(struct ed_ring *) packet_ptr;
|
1993-09-29 20:30:26 +00:00
|
|
|
else
|
1995-12-15 07:31:40 +00:00
|
|
|
ed_pio_readmem(sc, (int)packet_ptr, (char *) &packet_hdr,
|
1994-08-04 17:42:35 +00:00
|
|
|
sizeof(packet_hdr));
|
1993-09-29 20:30:26 +00:00
|
|
|
len = packet_hdr.count;
|
1996-08-06 21:14:36 +00:00
|
|
|
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring)) ||
|
|
|
|
len < (ETHER_MIN_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring))) {
|
1994-10-08 09:24:20 +00:00
|
|
|
/*
|
|
|
|
* Length is a wild value. There's a good chance that
|
|
|
|
* this was caused by the NIC being old and buggy.
|
|
|
|
* The bug is that the length low byte is duplicated in
|
|
|
|
* the high byte. Try to recalculate the length based on
|
|
|
|
* the pointer to the next packet.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* NOTE: sc->next_packet is pointing at the current packet.
|
|
|
|
*/
|
|
|
|
len &= ED_PAGE_SIZE - 1; /* preserve offset into page */
|
|
|
|
if (packet_hdr.next_packet >= sc->next_packet) {
|
|
|
|
len += (packet_hdr.next_packet - sc->next_packet) * ED_PAGE_SIZE;
|
|
|
|
} else {
|
|
|
|
len += ((packet_hdr.next_packet - sc->rec_page_start) +
|
|
|
|
(sc->rec_page_stop - sc->next_packet)) * ED_PAGE_SIZE;
|
|
|
|
}
|
1999-03-17 16:44:53 +00:00
|
|
|
/*
|
|
|
|
* because buffers are aligned on 256-byte boundary,
|
|
|
|
* the length computed above is off by 256 in almost
|
|
|
|
* all cases. Fix it...
|
|
|
|
*/
|
|
|
|
if (len & 0xff)
|
|
|
|
len -= 256 ;
|
1996-10-11 15:19:23 +00:00
|
|
|
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN
|
|
|
|
+ sizeof(struct ed_ring)))
|
|
|
|
sc->mibdata.dot3StatsFrameTooLongs++;
|
1994-10-08 09:24:20 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Be fairly liberal about what we allow as a "reasonable" length
|
|
|
|
* so that a [crufty] packet will make it to BPF (and can thus
|
|
|
|
* be analyzed). Note that all that is really important is that
|
|
|
|
* we have a length that will fit into one mbuf cluster or less;
|
|
|
|
* the upper layer protocols can then figure out the length from
|
|
|
|
* their own length field(s).
|
2001-02-08 22:21:30 +00:00
|
|
|
* But make sure that we have at least a full ethernet header
|
|
|
|
* or we would be unable to call ether_input() later.
|
1994-10-08 09:24:20 +00:00
|
|
|
*/
|
2001-02-08 22:54:57 +00:00
|
|
|
if ((len >= sizeof(struct ed_ring) + ETHER_HDR_LEN) &&
|
1995-07-28 12:15:16 +00:00
|
|
|
(len <= MCLBYTES) &&
|
1994-10-08 09:24:20 +00:00
|
|
|
(packet_hdr.next_packet >= sc->rec_page_start) &&
|
|
|
|
(packet_hdr.next_packet < sc->rec_page_stop)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Go get packet.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring),
|
2000-05-14 02:18:43 +00:00
|
|
|
len - sizeof(struct ed_ring));
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_ipackets++;
|
1993-06-14 22:21:25 +00:00
|
|
|
} else {
|
|
|
|
/*
|
1994-10-08 09:24:20 +00:00
|
|
|
* Really BAD. The ring pointers are corrupted.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
|
|
|
log(LOG_ERR,
|
1994-01-03 17:17:19 +00:00
|
|
|
"ed%d: NIC memory corrupt - invalid packet length %d\n",
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_unit, len);
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
ed_reset(ifp);
|
1993-06-14 22:21:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update next packet pointer
|
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
sc->next_packet = packet_hdr.next_packet;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Update NIC boundry pointer - being careful to keep it one
|
|
|
|
* buffer behind. (as recommended by NS databook)
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
|
|
|
boundry = sc->next_packet - 1;
|
|
|
|
if (boundry < sc->rec_page_start)
|
|
|
|
boundry = sc->rec_page_stop - 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set NIC to page 0 registers to update boundry register
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1994-09-07 06:11:29 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_BNRY, boundry);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Set NIC to page 1 registers before looping to top (prepare
|
|
|
|
* to get 'CURR' current pointer)
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethernet interface interrupt processor
|
|
|
|
*/
|
1999-10-15 03:12:48 +00:00
|
|
|
void
|
1999-09-03 19:10:56 +00:00
|
|
|
edintr(arg)
|
|
|
|
void *arg;
|
1993-06-14 22:21:25 +00:00
|
|
|
{
|
1999-09-03 19:10:56 +00:00
|
|
|
struct ed_softc *sc = (struct ed_softc*) arg;
|
1995-12-05 02:01:59 +00:00
|
|
|
struct ifnet *ifp = (struct ifnet *)sc;
|
1994-08-04 17:42:35 +00:00
|
|
|
u_char isr;
|
2001-11-24 16:15:18 +00:00
|
|
|
int count;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-10-10 09:52:55 +00:00
|
|
|
if (sc->gone)
|
|
|
|
return;
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Set NIC to page 0 registers
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
2001-11-24 16:15:18 +00:00
|
|
|
* loop until there are no more new interrupts. When the card
|
|
|
|
* goes away, the hardware will read back 0xff. Looking at
|
|
|
|
* the interrupts, it would appear that 0xff is impossible,
|
|
|
|
* or at least extremely unlikely.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2001-11-24 16:15:18 +00:00
|
|
|
while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0 && isr != 0xff) {
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* reset all the bits that we are 'acknowledging' by writing a
|
|
|
|
* '1' to each bit position that was set (writing a '1'
|
|
|
|
* *clears* the bit)
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR, isr);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2001-11-24 16:15:18 +00:00
|
|
|
/*
|
|
|
|
* XXX workaround for AX88190
|
|
|
|
* We limit this to 5000 iterations. At 1us per inb/outb,
|
|
|
|
* this translates to about 15ms, which should be plenty
|
|
|
|
* of time, and also gives protection in the card eject
|
|
|
|
* case.
|
|
|
|
*/
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_AX88190) {
|
2001-11-24 16:15:18 +00:00
|
|
|
count = 5000; /* 15ms */
|
|
|
|
while (count-- && (ed_nic_inb(sc, ED_P0_ISR) & isr)) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR,0);
|
|
|
|
ed_nic_outb(sc, ED_P0_ISR,isr);
|
2000-07-23 15:15:43 +00:00
|
|
|
}
|
2001-11-24 16:15:18 +00:00
|
|
|
if (count == 0)
|
|
|
|
break;
|
2000-07-23 15:15:43 +00:00
|
|
|
}
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Handle transmitter interrupts. Handle these first because
|
|
|
|
* the receiver will reset the board under some conditions.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1994-08-04 17:42:35 +00:00
|
|
|
if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
|
2000-08-17 12:15:45 +00:00
|
|
|
u_char collisions = ed_nic_inb(sc, ED_P0_NCR) & 0x0f;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-09-22 17:47:43 +00:00
|
|
|
* Check for transmit error. If a TX completed with an
|
|
|
|
* error, we end up throwing the packet away. Really
|
|
|
|
* the only error that is possible is excessive
|
1994-08-04 17:42:35 +00:00
|
|
|
* collisions, and in this case it is best to allow
|
|
|
|
* the automatic mechanisms of TCP to backoff the
|
|
|
|
* flow. Of course, with UDP we're screwed, but this
|
|
|
|
* is expected when a network is heavily loaded.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
(void) ed_nic_inb(sc, ED_P0_TSR);
|
1993-09-22 17:47:43 +00:00
|
|
|
if (isr & ED_ISR_TXE) {
|
1996-10-11 15:19:23 +00:00
|
|
|
u_char tsr;
|
1993-09-22 17:47:43 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1993-09-22 17:47:43 +00:00
|
|
|
* Excessive collisions (16)
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
tsr = ed_nic_inb(sc, ED_P0_TSR);
|
1996-10-11 15:19:23 +00:00
|
|
|
if ((tsr & ED_TSR_ABT)
|
1994-01-03 17:17:19 +00:00
|
|
|
&& (collisions == 0)) {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* When collisions total 16, the
|
1993-09-22 17:47:43 +00:00
|
|
|
* P0_NCR will indicate 0, and the
|
|
|
|
* TSR_ABT is set.
|
|
|
|
*/
|
|
|
|
collisions = 16;
|
1996-10-11 15:19:23 +00:00
|
|
|
sc->mibdata.dot3StatsExcessiveCollisions++;
|
|
|
|
sc->mibdata.dot3StatsCollFrequencies[15]++;
|
1993-09-22 17:47:43 +00:00
|
|
|
}
|
1996-10-11 15:19:23 +00:00
|
|
|
if (tsr & ED_TSR_OWC)
|
|
|
|
sc->mibdata.dot3StatsLateCollisions++;
|
|
|
|
if (tsr & ED_TSR_CDH)
|
|
|
|
sc->mibdata.dot3StatsSQETestErrors++;
|
|
|
|
if (tsr & ED_TSR_CRS)
|
|
|
|
sc->mibdata.dot3StatsCarrierSenseErrors++;
|
|
|
|
if (tsr & ED_TSR_FU)
|
|
|
|
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
|
|
|
* update output errors counter
|
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_oerrors++;
|
1993-09-22 17:47:43 +00:00
|
|
|
} else {
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
|
|
|
* Update total number of successfully
|
1994-08-04 17:42:35 +00:00
|
|
|
* transmitted packets.
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_opackets++;
|
1993-09-22 17:47:43 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* reset tx busy and output active flags
|
|
|
|
*/
|
|
|
|
sc->xmit_busy = 0;
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-06-23 16:22:04 +00:00
|
|
|
* clear watchdog timer
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_timer = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1993-09-22 17:47:43 +00:00
|
|
|
* Add in total number of collisions on last
|
1994-08-04 17:42:35 +00:00
|
|
|
* transmission.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_collisions += collisions;
|
1996-10-11 15:19:23 +00:00
|
|
|
switch(collisions) {
|
|
|
|
case 0:
|
|
|
|
case 16:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
sc->mibdata.dot3StatsSingleCollisionFrames++;
|
|
|
|
sc->mibdata.dot3StatsCollFrequencies[0]++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sc->mibdata.dot3StatsMultipleCollisionFrames++;
|
|
|
|
sc->mibdata.
|
|
|
|
dot3StatsCollFrequencies[collisions-1]
|
|
|
|
++;
|
|
|
|
break;
|
|
|
|
}
|
1993-09-22 17:47:43 +00:00
|
|
|
|
|
|
|
/*
|
1993-09-29 20:30:26 +00:00
|
|
|
* Decrement buffer in-use count if not zero (can only
|
1994-08-04 17:42:35 +00:00
|
|
|
* be zero if a transmitter interrupt occured while
|
|
|
|
* not actually transmitting). If data is ready to
|
|
|
|
* transmit, start it transmitting, otherwise defer
|
|
|
|
* until after handling receiver
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
1993-09-29 20:30:26 +00:00
|
|
|
if (sc->txb_inuse && --sc->txb_inuse)
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_xmit(sc);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1993-09-22 17:47:43 +00:00
|
|
|
* Handle receiver interrupts
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1994-08-04 17:42:35 +00:00
|
|
|
if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Overwrite warning. In order to make sure that a
|
|
|
|
* lockup of the local DMA hasn't occurred, we reset
|
|
|
|
* and re-init the NIC. The NSC manual suggests only a
|
|
|
|
* partial reset/re-init is necessary - but some chips
|
|
|
|
* seem to want more. The DMA lockup has been seen
|
|
|
|
* only with early rev chips - Methinks this bug was
|
|
|
|
* fixed in later revs. -DG
|
|
|
|
*/
|
1993-09-22 17:47:43 +00:00
|
|
|
if (isr & ED_ISR_OVW) {
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_ierrors++;
|
1993-09-29 20:30:26 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
1993-09-22 17:47:43 +00:00
|
|
|
log(LOG_WARNING,
|
1994-08-04 17:42:35 +00:00
|
|
|
"ed%d: warning - receiver ring buffer overrun\n",
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_unit);
|
1993-09-29 20:30:26 +00:00
|
|
|
#endif
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
|
|
|
* Stop/reset/re-init NIC
|
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_reset(ifp);
|
1993-09-22 17:47:43 +00:00
|
|
|
} else {
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1994-08-04 17:42:35 +00:00
|
|
|
/*
|
|
|
|
* Receiver Error. One or more of: CRC error,
|
|
|
|
* frame alignment error FIFO overrun, or
|
|
|
|
* missed packet.
|
|
|
|
*/
|
1993-09-22 17:47:43 +00:00
|
|
|
if (isr & ED_ISR_RXE) {
|
1996-10-11 15:19:23 +00:00
|
|
|
u_char rsr;
|
2000-08-17 12:15:45 +00:00
|
|
|
rsr = ed_nic_inb(sc, ED_P0_RSR);
|
1996-10-11 15:19:23 +00:00
|
|
|
if (rsr & ED_RSR_CRC)
|
|
|
|
sc->mibdata.dot3StatsFCSErrors++;
|
|
|
|
if (rsr & ED_RSR_FAE)
|
|
|
|
sc->mibdata.dot3StatsAlignmentErrors++;
|
|
|
|
if (rsr & ED_RSR_FO)
|
|
|
|
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_ierrors++;
|
1993-09-22 17:47:43 +00:00
|
|
|
#ifdef ED_DEBUG
|
2002-10-01 00:49:28 +00:00
|
|
|
if_printf(ifp, "receive error %x\n",
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_inb(sc, ED_P0_RSR));
|
1993-09-22 17:47:43 +00:00
|
|
|
#endif
|
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* Go get the packet(s) XXX - Doing this on an
|
|
|
|
* error is dubious because there shouldn't be
|
|
|
|
* any data to get (we've configured the
|
|
|
|
* interface to not accept packets with
|
|
|
|
* errors).
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1993-09-22 17:47:43 +00:00
|
|
|
/*
|
|
|
|
* Enable 16bit access to shared memory first
|
1994-08-04 17:42:35 +00:00
|
|
|
* on WD/SMC boards.
|
1993-09-22 17:47:43 +00:00
|
|
|
*/
|
|
|
|
if (sc->isa16bit &&
|
1994-01-03 17:17:19 +00:00
|
|
|
(sc->vendor == ED_VENDOR_WD_SMC)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR,
|
|
|
|
ED_WD_MSR_MENB);
|
1994-04-13 10:15:34 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_rint(sc);
|
1993-09-22 17:47:43 +00:00
|
|
|
|
|
|
|
/* disable 16bit access */
|
|
|
|
if (sc->isa16bit &&
|
1994-08-04 17:42:35 +00:00
|
|
|
(sc->vendor == ED_VENDOR_WD_SMC)) {
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-07-23 15:15:43 +00:00
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_WD790) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_MSR, 0x00);
|
1994-04-13 10:15:34 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto & ~ED_WD_LAAR_M16EN);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1993-09-22 17:47:43 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If it looks like the transmitter can take more data,
|
1994-08-04 17:42:35 +00:00
|
|
|
* attempt to start output on the interface. This is done
|
|
|
|
* after handling the receiver to give the receiver priority.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
|
|
|
ed_start(ifp);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* return NIC CR to standard state: page 0, remote DMA
|
|
|
|
* complete, start (toggling the TXP bit off, even if was just
|
|
|
|
* set in the transmit routine, is *okay* - it is 'edge'
|
|
|
|
* triggered from low to high)
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-07-27 03:13:50 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* If the Network Talley Counters overflow, read them to reset
|
|
|
|
* them. It appears that old 8390's won't clear the ISR flag
|
|
|
|
* otherwise - resulting in an infinite loop.
|
1993-07-27 03:13:50 +00:00
|
|
|
*/
|
|
|
|
if (isr & ED_ISR_CNT) {
|
2000-08-17 12:15:45 +00:00
|
|
|
(void) ed_nic_inb(sc, ED_P0_CNTR0);
|
|
|
|
(void) ed_nic_inb(sc, ED_P0_CNTR1);
|
|
|
|
(void) ed_nic_inb(sc, ED_P0_CNTR2);
|
1993-07-27 03:13:50 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Process an ioctl request. This code needs some work - it looks
|
|
|
|
* pretty ugly.
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static int
|
1993-06-14 22:21:25 +00:00
|
|
|
ed_ioctl(ifp, command, data)
|
|
|
|
register struct ifnet *ifp;
|
1998-06-07 17:13:14 +00:00
|
|
|
u_long command;
|
1993-06-14 22:21:25 +00:00
|
|
|
caddr_t data;
|
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ed_softc *sc = ifp->if_softc;
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
struct mii_data *mii;
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
1994-08-04 17:42:35 +00:00
|
|
|
int s, error = 0;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2000-06-01 21:55:49 +00:00
|
|
|
if (sc == NULL || sc->gone) {
|
1995-10-21 00:55:36 +00:00
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
|
|
return ENXIO;
|
|
|
|
}
|
1993-11-22 11:08:16 +00:00
|
|
|
s = splimp();
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case SIOCSIFFLAGS:
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
1995-12-05 13:01:33 +00:00
|
|
|
* If the interface is marked up and stopped, then start it.
|
|
|
|
* If it is marked down and running, then stop it.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1995-12-05 13:01:33 +00:00
|
|
|
if (ifp->if_flags & IFF_UP) {
|
|
|
|
if ((ifp->if_flags & IFF_RUNNING) == 0)
|
1997-02-11 09:29:48 +00:00
|
|
|
ed_init(sc);
|
1995-12-05 13:01:33 +00:00
|
|
|
} else {
|
|
|
|
if (ifp->if_flags & IFF_RUNNING) {
|
|
|
|
ed_stop(sc);
|
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Promiscuous flag may have changed, so reprogram the RCR.
|
|
|
|
*/
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_setrcr(sc);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1993-06-22 12:10:07 +00:00
|
|
|
/*
|
1994-08-04 17:42:35 +00:00
|
|
|
* An unfortunate hack to provide the (required) software
|
|
|
|
* control of the tranceiver for 3Com boards. The ALTPHYS flag
|
|
|
|
* disables the tranceiver if set.
|
1993-06-22 12:10:07 +00:00
|
|
|
*/
|
1993-07-25 23:43:30 +00:00
|
|
|
if (sc->vendor == ED_VENDOR_3COM) {
|
1993-09-09 07:01:23 +00:00
|
|
|
if (ifp->if_flags & IFF_ALTPHYS) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, 0);
|
1993-07-25 23:43:30 +00:00
|
|
|
} else {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-07-25 23:43:30 +00:00
|
|
|
}
|
1996-08-07 11:18:23 +00:00
|
|
|
} else if (sc->vendor == ED_VENDOR_HP)
|
|
|
|
ed_hpp_set_physical_link(sc);
|
1993-06-14 22:21:25 +00:00
|
|
|
break;
|
1994-09-07 06:11:29 +00:00
|
|
|
|
1994-08-04 17:42:35 +00:00
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
|
|
|
/*
|
1997-01-13 21:26:53 +00:00
|
|
|
* Multicast list has changed; set the hardware filter
|
|
|
|
* accordingly.
|
1994-08-04 17:42:35 +00:00
|
|
|
*/
|
1997-01-13 21:26:53 +00:00
|
|
|
ed_setrcr(sc);
|
|
|
|
error = 0;
|
1994-08-04 17:42:35 +00:00
|
|
|
break;
|
1994-08-08 12:09:04 +00:00
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
case SIOCGIFMEDIA:
|
|
|
|
case SIOCSIFMEDIA:
|
|
|
|
if (sc->miibus == NULL) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
|
|
|
|
break;
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
2001-03-03 08:31:37 +00:00
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
default:
|
2002-11-14 23:54:55 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
(void) splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1995-12-05 13:01:33 +00:00
|
|
|
/*
|
|
|
|
* Given a source and destination address, copy 'amount' of a packet from
|
|
|
|
* the ring buffer into a linear destination buffer. Takes into account
|
|
|
|
* ring-wrap.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
static __inline char *
|
1995-12-05 13:01:33 +00:00
|
|
|
ed_ring_copy(sc, src, dst, amount)
|
|
|
|
struct ed_softc *sc;
|
2000-08-17 12:15:45 +00:00
|
|
|
char *src;
|
1995-12-05 13:01:33 +00:00
|
|
|
char *dst;
|
|
|
|
u_short amount;
|
|
|
|
{
|
|
|
|
u_short tmp_amount;
|
|
|
|
|
|
|
|
/* does copy wrap to lower addr in ring buffer? */
|
|
|
|
if (src + amount > sc->mem_end) {
|
|
|
|
tmp_amount = sc->mem_end - src;
|
|
|
|
|
|
|
|
/* copy amount up to end of NIC memory */
|
|
|
|
if (sc->mem_shared)
|
2000-08-17 12:15:45 +00:00
|
|
|
bcopy(src, dst, tmp_amount);
|
1995-12-05 13:01:33 +00:00
|
|
|
else
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_pio_readmem(sc, (int)src, dst, tmp_amount);
|
1995-12-05 13:01:33 +00:00
|
|
|
|
|
|
|
amount -= tmp_amount;
|
|
|
|
src = sc->mem_ring;
|
|
|
|
dst += tmp_amount;
|
|
|
|
}
|
|
|
|
if (sc->mem_shared)
|
2000-08-17 12:15:45 +00:00
|
|
|
bcopy(src, dst, amount);
|
1995-12-05 13:01:33 +00:00
|
|
|
else
|
1995-12-15 07:31:40 +00:00
|
|
|
ed_pio_readmem(sc, (int)src, dst, amount);
|
1995-12-05 13:01:33 +00:00
|
|
|
|
|
|
|
return (src + amount);
|
|
|
|
}
|
|
|
|
|
1993-06-14 22:21:25 +00:00
|
|
|
/*
|
|
|
|
* Retreive packet from shared memory and send to the next level up via
|
2000-05-14 02:18:43 +00:00
|
|
|
* ether_input().
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1993-11-25 01:38:01 +00:00
|
|
|
static void
|
2000-05-14 02:18:43 +00:00
|
|
|
ed_get_packet(sc, buf, len)
|
2000-08-17 12:15:45 +00:00
|
|
|
struct ed_softc *sc;
|
|
|
|
char *buf;
|
1993-06-14 22:21:25 +00:00
|
|
|
u_short len;
|
|
|
|
{
|
2002-11-14 23:54:55 +00:00
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
1993-06-14 22:21:25 +00:00
|
|
|
struct ether_header *eh;
|
1994-11-26 10:51:49 +00:00
|
|
|
struct mbuf *m;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/* Allocate a header mbuf */
|
2003-02-19 05:47:46 +00:00
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
1994-10-08 09:24:20 +00:00
|
|
|
if (m == NULL)
|
|
|
|
return;
|
2002-11-14 23:54:55 +00:00
|
|
|
m->m_pkthdr.rcvif = ifp;
|
1994-11-26 10:51:49 +00:00
|
|
|
m->m_pkthdr.len = m->m_len = len;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
1995-12-05 13:01:33 +00:00
|
|
|
/*
|
|
|
|
* We always put the received packet in a single buffer -
|
|
|
|
* either with just an mbuf header or in a cluster attached
|
|
|
|
* to the header. The +2 is to compensate for the alignment
|
|
|
|
* fixup below.
|
|
|
|
*/
|
|
|
|
if ((len + 2) > MHLEN) {
|
|
|
|
/* Attach an mbuf cluster */
|
2003-02-19 05:47:46 +00:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1994-11-26 10:51:49 +00:00
|
|
|
|
1995-12-05 13:01:33 +00:00
|
|
|
/* Insist on getting a cluster */
|
|
|
|
if ((m->m_flags & M_EXT) == 0) {
|
|
|
|
m_freem(m);
|
|
|
|
return;
|
|
|
|
}
|
1994-11-26 10:51:49 +00:00
|
|
|
}
|
1993-06-14 22:21:25 +00:00
|
|
|
|
|
|
|
/*
|
1994-11-26 10:51:49 +00:00
|
|
|
* The +2 is to longword align the start of the real packet.
|
|
|
|
* This is important for NFS.
|
1993-06-14 22:21:25 +00:00
|
|
|
*/
|
1994-11-26 10:51:49 +00:00
|
|
|
m->m_data += 2;
|
1994-10-08 09:24:20 +00:00
|
|
|
eh = mtod(m, struct ether_header *);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1999-03-17 16:44:53 +00:00
|
|
|
/*
|
2000-05-14 02:18:43 +00:00
|
|
|
* Don't read in the entire packet if we know we're going to drop it
|
2001-02-08 22:54:57 +00:00
|
|
|
* and no bpf is active.
|
1999-03-17 16:44:53 +00:00
|
|
|
*/
|
2002-11-14 23:54:55 +00:00
|
|
|
if (!ifp->if_bpf && BDG_ACTIVE( (ifp) ) ) {
|
2000-05-14 02:18:43 +00:00
|
|
|
struct ifnet *bif;
|
|
|
|
|
|
|
|
ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN);
|
2002-11-14 23:54:55 +00:00
|
|
|
bif = bridge_in_ptr(ifp, eh) ;
|
2001-02-08 22:54:57 +00:00
|
|
|
if (bif == BDG_DROP) {
|
1999-03-17 16:44:53 +00:00
|
|
|
m_freem(m);
|
2000-05-14 02:18:43 +00:00
|
|
|
return;
|
1999-03-17 16:44:53 +00:00
|
|
|
}
|
2001-02-08 22:54:57 +00:00
|
|
|
if (len > ETHER_HDR_LEN)
|
|
|
|
ed_ring_copy(sc, buf + ETHER_HDR_LEN,
|
|
|
|
(char *)(eh + 1), len - ETHER_HDR_LEN);
|
2000-05-14 02:18:43 +00:00
|
|
|
} else
|
2001-11-01 17:10:52 +00:00
|
|
|
/*
|
|
|
|
* Get packet, including link layer address, from interface.
|
|
|
|
*/
|
|
|
|
ed_ring_copy(sc, buf, (char *)eh, len);
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2002-11-14 23:54:55 +00:00
|
|
|
m->m_pkthdr.len = m->m_len = len;
|
1993-06-14 22:21:25 +00:00
|
|
|
|
2002-11-14 23:54:55 +00:00
|
|
|
(*ifp->if_input)(ifp, m);
|
1993-06-14 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Supporting routines
|
|
|
|
*/
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/*
|
|
|
|
* Given a NIC memory source address and a host memory destination
|
|
|
|
* address, copy 'amount' from NIC to host using Programmed I/O.
|
|
|
|
* The 'amount' is rounded up to a word - okay as long as mbufs
|
|
|
|
* are word sized.
|
|
|
|
* This routine is currently Novell-specific.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
void
|
1994-08-04 17:42:35 +00:00
|
|
|
ed_pio_readmem(sc, src, dst, amount)
|
|
|
|
struct ed_softc *sc;
|
1995-12-15 07:31:40 +00:00
|
|
|
int src;
|
1993-09-29 20:30:26 +00:00
|
|
|
unsigned char *dst;
|
|
|
|
unsigned short amount;
|
|
|
|
{
|
2000-08-17 12:15:45 +00:00
|
|
|
/* HP PC Lan+ cards need special handling */
|
1996-08-07 11:18:23 +00:00
|
|
|
if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) {
|
|
|
|
ed_hpp_readmem(sc, src, dst, amount);
|
|
|
|
return;
|
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
/* Regular Novell cards */
|
1993-09-29 20:30:26 +00:00
|
|
|
/* select page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* round up to a word */
|
1994-08-04 17:42:35 +00:00
|
|
|
if (amount & 1)
|
|
|
|
++amount;
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* set up DMA byte count */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RBCR0, amount);
|
|
|
|
ed_nic_outb(sc, ED_P0_RBCR1, amount >> 8);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* set up source address in NIC mem */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RSAR0, src);
|
|
|
|
ed_nic_outb(sc, ED_P0_RSAR1, src >> 8);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD0 | ED_CR_STA);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
if (sc->isa16bit) {
|
|
|
|
ed_asic_insw(sc, ED_NOVELL_DATA, dst, amount / 2);
|
|
|
|
} else {
|
|
|
|
ed_asic_insb(sc, ED_NOVELL_DATA, dst, amount);
|
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stripped down routine for writing a linear buffer to NIC memory.
|
|
|
|
* Only used in the probe routine to test the memory. 'len' must
|
|
|
|
* be even.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
void
|
1994-08-04 17:42:35 +00:00
|
|
|
ed_pio_writemem(sc, src, dst, len)
|
1993-09-29 20:30:26 +00:00
|
|
|
struct ed_softc *sc;
|
1994-08-04 17:42:35 +00:00
|
|
|
char *src;
|
1993-09-29 20:30:26 +00:00
|
|
|
unsigned short dst;
|
|
|
|
unsigned short len;
|
|
|
|
{
|
1995-02-26 20:03:53 +00:00
|
|
|
int maxwait = 200; /* about 240us */
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* select page 0 registers */
|
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* reset remote DMA complete flag */
|
|
|
|
ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* set up DMA byte count */
|
|
|
|
ed_nic_outb(sc, ED_P0_RBCR0, len);
|
|
|
|
ed_nic_outb(sc, ED_P0_RBCR1, len >> 8);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* set up destination address in NIC mem */
|
|
|
|
ed_nic_outb(sc, ED_P0_RSAR0, dst);
|
|
|
|
ed_nic_outb(sc, ED_P0_RSAR1, dst >> 8);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* set remote DMA write */
|
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_STA);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
if (sc->isa16bit) {
|
|
|
|
ed_asic_outsw(sc, ED_NOVELL_DATA, src, len / 2);
|
|
|
|
} else {
|
|
|
|
ed_asic_outsb(sc, ED_NOVELL_DATA, src, len);
|
1996-08-07 11:18:23 +00:00
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for remote DMA complete. This is necessary because on the
|
|
|
|
* transmit side, data is handled internally by the NIC in bursts and
|
|
|
|
* we can't start another remote DMA until this one completes. Not
|
|
|
|
* waiting causes really bad things to happen - like the NIC
|
|
|
|
* irrecoverably jamming the ISA bus.
|
|
|
|
*/
|
|
|
|
while (((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write an mbuf chain to the destination NIC memory address using
|
|
|
|
* programmed I/O.
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static u_short
|
1994-08-04 17:42:35 +00:00
|
|
|
ed_pio_write_mbufs(sc, m, dst)
|
1993-09-29 20:30:26 +00:00
|
|
|
struct ed_softc *sc;
|
|
|
|
struct mbuf *m;
|
1995-12-15 07:31:40 +00:00
|
|
|
int dst;
|
1993-09-29 20:30:26 +00:00
|
|
|
{
|
1995-12-05 02:01:59 +00:00
|
|
|
struct ifnet *ifp = (struct ifnet *)sc;
|
1995-01-04 21:10:17 +00:00
|
|
|
unsigned short total_len, dma_len;
|
1993-09-29 20:30:26 +00:00
|
|
|
struct mbuf *mp;
|
1995-02-26 20:03:53 +00:00
|
|
|
int maxwait = 200; /* about 240us */
|
1993-09-29 20:30:26 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* HP PC Lan+ cards need special handling */
|
|
|
|
if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) {
|
1996-08-07 11:18:23 +00:00
|
|
|
return ed_hpp_write_mbufs(sc, m, dst);
|
|
|
|
}
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
/* Regular Novell cards */
|
1993-09-29 20:30:26 +00:00
|
|
|
/* First, count up the total number of bytes to copy */
|
1995-01-04 21:10:17 +00:00
|
|
|
for (total_len = 0, mp = m; mp; mp = mp->m_next)
|
|
|
|
total_len += mp->m_len;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1995-01-04 21:10:17 +00:00
|
|
|
dma_len = total_len;
|
1995-01-01 06:38:14 +00:00
|
|
|
if (sc->isa16bit && (dma_len & 1))
|
|
|
|
dma_len++;
|
|
|
|
|
1993-09-29 20:30:26 +00:00
|
|
|
/* select page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* reset remote DMA complete flag */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* set up DMA byte count */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RBCR0, dma_len);
|
|
|
|
ed_nic_outb(sc, ED_P0_RBCR1, dma_len >> 8);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* set up destination address in NIC mem */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RSAR0, dst);
|
|
|
|
ed_nic_outb(sc, ED_P0_RSAR1, dst >> 8);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
/* set remote DMA write */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_STA);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
1994-10-14 11:56:36 +00:00
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Transfer the mbuf chain to the NIC memory.
|
1994-10-14 11:56:36 +00:00
|
|
|
* 16-bit cards require that data be transferred as words, and only words.
|
|
|
|
* So that case requires some extra code to patch over odd-length mbufs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!sc->isa16bit) {
|
|
|
|
/* NE1000s are easy */
|
|
|
|
while (m) {
|
2000-08-17 12:15:45 +00:00
|
|
|
if (m->m_len) {
|
|
|
|
ed_asic_outsb(sc, ED_NOVELL_DATA,
|
|
|
|
m->m_data, m->m_len);
|
|
|
|
}
|
1994-10-14 11:56:36 +00:00
|
|
|
m = m->m_next;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* NE2000s are a pain */
|
|
|
|
unsigned char *data;
|
|
|
|
int len, wantbyte;
|
|
|
|
unsigned char savebyte[2];
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-10-14 11:56:36 +00:00
|
|
|
wantbyte = 0;
|
|
|
|
|
|
|
|
while (m) {
|
|
|
|
len = m->m_len;
|
|
|
|
if (len) {
|
1995-01-04 21:10:17 +00:00
|
|
|
data = mtod(m, caddr_t);
|
1994-10-14 11:56:36 +00:00
|
|
|
/* finish the last word */
|
|
|
|
if (wantbyte) {
|
|
|
|
savebyte[1] = *data;
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_NOVELL_DATA,
|
|
|
|
*(u_short *)savebyte);
|
1994-10-14 11:56:36 +00:00
|
|
|
data++;
|
|
|
|
len--;
|
|
|
|
wantbyte = 0;
|
|
|
|
}
|
|
|
|
/* output contiguous words */
|
|
|
|
if (len > 1) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outsw(sc, ED_NOVELL_DATA,
|
|
|
|
data, len >> 1);
|
1994-10-14 11:56:36 +00:00
|
|
|
data += len & ~1;
|
|
|
|
len &= 1;
|
|
|
|
}
|
|
|
|
/* save last byte, if necessary */
|
|
|
|
if (len == 1) {
|
|
|
|
savebyte[0] = *data;
|
|
|
|
wantbyte = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m = m->m_next;
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-10-14 11:56:36 +00:00
|
|
|
/* spit last byte */
|
1995-01-04 21:10:17 +00:00
|
|
|
if (wantbyte) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_NOVELL_DATA, *(u_short *)savebyte);
|
1995-01-04 21:10:17 +00:00
|
|
|
}
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for remote DMA complete. This is necessary because on the
|
1994-08-04 17:42:35 +00:00
|
|
|
* transmit side, data is handled internally by the NIC in bursts and
|
|
|
|
* we can't start another remote DMA until this one completes. Not
|
|
|
|
* waiting causes really bad things to happen - like the NIC
|
|
|
|
* irrecoverably jamming the ISA bus.
|
1993-09-29 20:30:26 +00:00
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
while (((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
|
1993-09-29 20:30:26 +00:00
|
|
|
|
|
|
|
if (!maxwait) {
|
|
|
|
log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n",
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_unit);
|
|
|
|
ed_reset(ifp);
|
1995-01-04 21:10:17 +00:00
|
|
|
return(0);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1995-01-04 21:10:17 +00:00
|
|
|
return (total_len);
|
1993-09-29 20:30:26 +00:00
|
|
|
}
|
1994-08-04 17:42:35 +00:00
|
|
|
|
1996-08-07 11:18:23 +00:00
|
|
|
/*
|
|
|
|
* Support routines to handle the HP PC Lan+ card.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HP PC Lan+: Read from NIC memory, using either PIO or memory mapped
|
|
|
|
* IO.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ed_hpp_readmem(sc, src, dst, amount)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
unsigned short src;
|
|
|
|
unsigned char *dst;
|
|
|
|
unsigned short amount;
|
|
|
|
{
|
|
|
|
|
|
|
|
int use_32bit_access = !(sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS);
|
|
|
|
|
|
|
|
|
|
|
|
/* Program the source address in RAM */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_2, src);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The HP PC Lan+ card supports word reads as well as
|
|
|
|
* a memory mapped i/o port that is aliased to every
|
|
|
|
* even address on the board.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (sc->hpp_mem_start) {
|
|
|
|
|
|
|
|
/* Enable memory mapped access. */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options &
|
1996-08-07 11:18:23 +00:00
|
|
|
~(ED_HPP_OPTION_MEM_DISABLE |
|
|
|
|
ED_HPP_OPTION_BOOT_ROM_ENB));
|
|
|
|
|
|
|
|
if (use_32bit_access && (amount > 3)) {
|
2000-08-14 04:31:07 +00:00
|
|
|
u_int32_t *dl = (u_int32_t *) dst;
|
|
|
|
volatile u_int32_t *const sl =
|
|
|
|
(u_int32_t *) sc->hpp_mem_start;
|
|
|
|
u_int32_t *const fence = dl + (amount >> 2);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/* Copy out NIC data. We could probably write this
|
|
|
|
as a `movsl'. The currently generated code is lousy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (dl < fence)
|
|
|
|
*dl++ = *sl;
|
|
|
|
|
|
|
|
dst += (amount & ~3);
|
|
|
|
amount &= 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish off any words left, as a series of short reads */
|
|
|
|
if (amount > 1) {
|
|
|
|
u_short *d = (u_short *) dst;
|
|
|
|
volatile u_short *const s =
|
|
|
|
(u_short *) sc->hpp_mem_start;
|
|
|
|
u_short *const fence = d + (amount >> 1);
|
|
|
|
|
|
|
|
/* Copy out NIC data. */
|
|
|
|
|
|
|
|
while (d < fence)
|
|
|
|
*d++ = *s;
|
|
|
|
|
|
|
|
dst += (amount & ~1);
|
|
|
|
amount &= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* read in a byte; however we need to always read 16 bits
|
|
|
|
* at a time or the hardware gets into a funny state
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (amount == 1) {
|
|
|
|
/* need to read in a short and copy LSB */
|
|
|
|
volatile u_short *const s =
|
|
|
|
(volatile u_short *) sc->hpp_mem_start;
|
|
|
|
|
|
|
|
*dst = (*s) & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore Boot ROM access. */
|
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Read in data using the I/O port */
|
|
|
|
if (use_32bit_access && (amount > 3)) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_insl(sc, ED_HPP_PAGE_4, dst, amount >> 2);
|
1996-08-07 11:18:23 +00:00
|
|
|
dst += (amount & ~3);
|
|
|
|
amount &= 3;
|
|
|
|
}
|
|
|
|
if (amount > 1) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_insw(sc, ED_HPP_PAGE_4, dst, amount >> 1);
|
1996-08-07 11:18:23 +00:00
|
|
|
dst += (amount & ~1);
|
|
|
|
amount &= 1;
|
|
|
|
}
|
|
|
|
if (amount == 1) { /* read in a short and keep the LSB */
|
2000-08-17 12:15:45 +00:00
|
|
|
*dst = ed_asic_inw(sc, ED_HPP_PAGE_4) & 0xFF;
|
1996-08-07 11:18:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-08-17 12:15:45 +00:00
|
|
|
* HP PC Lan+: Write to NIC memory, using either PIO or memory mapped
|
|
|
|
* IO.
|
|
|
|
* Only used in the probe routine to test the memory. 'len' must
|
|
|
|
* be even.
|
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static void
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_hpp_writemem(sc, src, dst, len)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
unsigned char *src;
|
|
|
|
unsigned short dst;
|
|
|
|
unsigned short len;
|
|
|
|
{
|
|
|
|
/* reset remote DMA complete flag */
|
|
|
|
ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
|
|
|
|
|
|
|
|
/* program the write address in RAM */
|
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_0, dst);
|
|
|
|
|
|
|
|
if (sc->hpp_mem_start) {
|
|
|
|
u_short *s = (u_short *) src;
|
|
|
|
volatile u_short *d = (u_short *) sc->hpp_mem_start;
|
|
|
|
u_short *const fence = s + (len >> 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable memory mapped access.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options &
|
|
|
|
~(ED_HPP_OPTION_MEM_DISABLE |
|
|
|
|
ED_HPP_OPTION_BOOT_ROM_ENB));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy to NIC memory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (s < fence)
|
|
|
|
*d = *s++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore Boot ROM access.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* write data using I/O writes */
|
|
|
|
ed_asic_outsw(sc, ED_HPP_PAGE_4, src, len / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write to HP PC Lan+ NIC memory. Access to the NIC can be by using
|
|
|
|
* outsw() or via the memory mapped interface to the same register.
|
1996-08-07 11:18:23 +00:00
|
|
|
* Writes have to be in word units; byte accesses won't work and may cause
|
2001-02-06 09:25:10 +00:00
|
|
|
* the NIC to behave weirdly. Long word accesses are permitted if the ASIC
|
1996-08-07 11:18:23 +00:00
|
|
|
* allows it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static u_short
|
|
|
|
ed_hpp_write_mbufs(struct ed_softc *sc, struct mbuf *m, int dst)
|
|
|
|
{
|
|
|
|
int len, wantbyte;
|
|
|
|
unsigned short total_len;
|
|
|
|
unsigned char savebyte[2];
|
|
|
|
volatile u_short * const d =
|
|
|
|
(volatile u_short *) sc->hpp_mem_start;
|
|
|
|
int use_32bit_accesses = !(sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS);
|
|
|
|
|
|
|
|
/* select page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/* reset remote DMA complete flag */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
/* program the write address in RAM */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_0, dst);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
if (sc->hpp_mem_start) /* enable memory mapped I/O */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options &
|
1996-08-07 11:18:23 +00:00
|
|
|
~(ED_HPP_OPTION_MEM_DISABLE |
|
|
|
|
ED_HPP_OPTION_BOOT_ROM_ENB));
|
|
|
|
|
|
|
|
wantbyte = 0;
|
|
|
|
total_len = 0;
|
|
|
|
|
|
|
|
if (sc->hpp_mem_start) { /* Memory mapped I/O port */
|
|
|
|
while (m) {
|
|
|
|
total_len += (len = m->m_len);
|
|
|
|
if (len) {
|
|
|
|
caddr_t data = mtod(m, caddr_t);
|
|
|
|
/* finish the last word of the previous mbuf */
|
|
|
|
if (wantbyte) {
|
|
|
|
savebyte[1] = *data;
|
|
|
|
*d = *((ushort *) savebyte);
|
|
|
|
data++; len--; wantbyte = 0;
|
|
|
|
}
|
|
|
|
/* output contiguous words */
|
|
|
|
if ((len > 3) && (use_32bit_accesses)) {
|
2000-08-14 04:31:07 +00:00
|
|
|
volatile u_int32_t *const dl =
|
|
|
|
(volatile u_int32_t *) d;
|
|
|
|
u_int32_t *sl = (u_int32_t *) data;
|
|
|
|
u_int32_t *fence = sl + (len >> 2);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
while (sl < fence)
|
|
|
|
*dl = *sl++;
|
|
|
|
|
|
|
|
data += (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
/* finish off remain 16 bit writes */
|
|
|
|
if (len > 1) {
|
|
|
|
u_short *s = (u_short *) data;
|
|
|
|
u_short *fence = s + (len >> 1);
|
|
|
|
|
|
|
|
while (s < fence)
|
|
|
|
*d = *s++;
|
|
|
|
|
|
|
|
data += (len & ~1);
|
|
|
|
len &= 1;
|
|
|
|
}
|
|
|
|
/* save last byte if needed */
|
1999-01-28 01:59:53 +00:00
|
|
|
if ((wantbyte = (len == 1)) != 0)
|
1996-08-07 11:18:23 +00:00
|
|
|
savebyte[0] = *data;
|
|
|
|
}
|
|
|
|
m = m->m_next; /* to next mbuf */
|
|
|
|
}
|
|
|
|
if (wantbyte) /* write last byte */
|
|
|
|
*d = *((u_short *) savebyte);
|
|
|
|
} else {
|
|
|
|
/* use programmed I/O */
|
|
|
|
while (m) {
|
|
|
|
total_len += (len = m->m_len);
|
|
|
|
if (len) {
|
|
|
|
caddr_t data = mtod(m, caddr_t);
|
|
|
|
/* finish the last word of the previous mbuf */
|
|
|
|
if (wantbyte) {
|
|
|
|
savebyte[1] = *data;
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_4,
|
|
|
|
*((u_short *)savebyte));
|
1996-08-07 11:18:23 +00:00
|
|
|
data++;
|
|
|
|
len--;
|
|
|
|
wantbyte = 0;
|
|
|
|
}
|
|
|
|
/* output contiguous words */
|
|
|
|
if ((len > 3) && use_32bit_accesses) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outsl(sc, ED_HPP_PAGE_4,
|
|
|
|
data, len >> 2);
|
1996-08-07 11:18:23 +00:00
|
|
|
data += (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
/* finish off remaining 16 bit accesses */
|
|
|
|
if (len > 1) {
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outsw(sc, ED_HPP_PAGE_4,
|
|
|
|
data, len >> 1);
|
1996-08-07 11:18:23 +00:00
|
|
|
data += (len & ~1);
|
|
|
|
len &= 1;
|
|
|
|
}
|
1999-01-28 01:59:53 +00:00
|
|
|
if ((wantbyte = (len == 1)) != 0)
|
1996-08-07 11:18:23 +00:00
|
|
|
savebyte[0] = *data;
|
|
|
|
|
|
|
|
} /* if len != 0 */
|
|
|
|
m = m->m_next;
|
|
|
|
}
|
|
|
|
if (wantbyte) /* spit last byte */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_PAGE_4, *(u_short *)savebyte);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->hpp_mem_start) /* turn off memory mapped i/o */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_asic_outw(sc, ED_HPP_OPTION, sc->hpp_options);
|
1996-08-07 11:18:23 +00:00
|
|
|
|
|
|
|
return (total_len);
|
|
|
|
}
|
|
|
|
|
2001-09-29 22:32:03 +00:00
|
|
|
#ifndef ED_NO_MIIBUS
|
2001-03-03 08:31:37 +00:00
|
|
|
/*
|
|
|
|
* MII bus support routines.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ed_miibus_readreg(dev, phy, reg)
|
|
|
|
device_t dev;
|
|
|
|
int phy, reg;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc;
|
2001-07-22 21:39:54 +00:00
|
|
|
int failed, s, val;
|
2001-03-03 08:31:37 +00:00
|
|
|
|
2001-07-22 21:39:54 +00:00
|
|
|
s = splimp();
|
2001-03-03 08:31:37 +00:00
|
|
|
sc = device_get_softc(dev);
|
2001-07-22 21:39:54 +00:00
|
|
|
if (sc->gone) {
|
|
|
|
splx(s);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-03-03 08:31:37 +00:00
|
|
|
(*sc->mii_writebits)(sc, 0xffffffff, 32);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_READOP, ED_MII_OP_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, phy, ED_MII_PHY_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, reg, ED_MII_REG_BITS);
|
|
|
|
|
|
|
|
failed = (*sc->mii_readbits)(sc, ED_MII_ACK_BITS);
|
|
|
|
val = (*sc->mii_readbits)(sc, ED_MII_DATA_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_IDLE, ED_MII_IDLE_BITS);
|
|
|
|
|
2001-07-22 21:39:54 +00:00
|
|
|
splx(s);
|
2001-03-03 08:31:37 +00:00
|
|
|
return (failed ? 0 : val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ed_miibus_writereg(dev, phy, reg, data)
|
|
|
|
device_t dev;
|
|
|
|
int phy, reg, data;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc;
|
2001-07-22 21:39:54 +00:00
|
|
|
int s;
|
2001-03-03 08:31:37 +00:00
|
|
|
|
2001-07-22 21:39:54 +00:00
|
|
|
s = splimp();
|
2001-03-03 08:31:37 +00:00
|
|
|
sc = device_get_softc(dev);
|
2001-07-22 21:39:54 +00:00
|
|
|
if (sc->gone) {
|
|
|
|
splx(s);
|
2001-03-03 08:31:37 +00:00
|
|
|
return;
|
2001-07-22 21:39:54 +00:00
|
|
|
}
|
2001-03-03 08:31:37 +00:00
|
|
|
|
|
|
|
(*sc->mii_writebits)(sc, 0xffffffff, 32);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_WRITEOP, ED_MII_OP_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, phy, ED_MII_PHY_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, reg, ED_MII_REG_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_TURNAROUND, ED_MII_TURNAROUND_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, data, ED_MII_DATA_BITS);
|
|
|
|
(*sc->mii_writebits)(sc, ED_MII_IDLE, ED_MII_IDLE_BITS);
|
2001-07-22 21:39:54 +00:00
|
|
|
|
|
|
|
splx(s);
|
2001-03-03 08:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ed_ifmedia_upd(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc;
|
|
|
|
struct mii_data *mii;
|
|
|
|
|
|
|
|
sc = ifp->if_softc;
|
|
|
|
if (sc->gone || sc->miibus == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
return mii_mediachg(mii);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ed_ifmedia_sts(ifp, ifmr)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifmediareq *ifmr;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc;
|
|
|
|
struct mii_data *mii;
|
|
|
|
|
|
|
|
sc = ifp->if_softc;
|
|
|
|
if (sc->gone || sc->miibus == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
mii_pollstat(mii);
|
|
|
|
ifmr->ifm_active = mii->mii_media_active;
|
|
|
|
ifmr->ifm_status = mii->mii_media_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ed_child_detached(dev, child)
|
|
|
|
device_t dev;
|
|
|
|
device_t child;
|
|
|
|
{
|
|
|
|
struct ed_softc *sc;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
if (child == sc->miibus)
|
|
|
|
sc->miibus = NULL;
|
|
|
|
}
|
2001-09-29 22:32:03 +00:00
|
|
|
#endif
|
2001-03-03 08:31:37 +00:00
|
|
|
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1995-12-05 02:01:59 +00:00
|
|
|
ed_setrcr(sc)
|
1994-08-04 17:42:35 +00:00
|
|
|
struct ed_softc *sc;
|
|
|
|
{
|
1995-12-05 02:01:59 +00:00
|
|
|
struct ifnet *ifp = (struct ifnet *)sc;
|
1994-08-04 17:42:35 +00:00
|
|
|
int i;
|
2000-08-14 04:31:07 +00:00
|
|
|
u_char reg1;
|
2000-07-23 15:15:43 +00:00
|
|
|
|
|
|
|
/* Bit 6 in AX88190 RCR register must be set. */
|
|
|
|
if (sc->chip_type == ED_CHIP_TYPE_AX88190)
|
|
|
|
reg1 = ED_RCR_INTT;
|
|
|
|
else
|
|
|
|
reg1 = 0x00;
|
|
|
|
|
1994-08-04 17:42:35 +00:00
|
|
|
/* set page 1 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reconfigure the multicast filter.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 8; i++)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P1_MAR(i), 0xff);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* And turn on promiscuous mode. Also enable reception of
|
|
|
|
* runts and packets with CRC & alignment errors.
|
|
|
|
*/
|
|
|
|
/* Set page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STP);
|
1994-09-07 06:11:29 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RCR, ED_RCR_PRO | ED_RCR_AM |
|
|
|
|
ED_RCR_AB | ED_RCR_AR | ED_RCR_SEP | reg1);
|
1994-08-04 17:42:35 +00:00
|
|
|
} else {
|
|
|
|
/* set up multicast addresses and filter modes */
|
|
|
|
if (ifp->if_flags & IFF_MULTICAST) {
|
2000-08-14 04:31:07 +00:00
|
|
|
u_int32_t mcaf[2];
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
if (ifp->if_flags & IFF_ALLMULTI) {
|
|
|
|
mcaf[0] = 0xffffffff;
|
|
|
|
mcaf[1] = 0xffffffff;
|
|
|
|
} else
|
|
|
|
ds_getmcaf(sc, mcaf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set multicast filter on chip.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 8; i++)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P1_MAR(i), ((u_char *) mcaf)[i]);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/* Set page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STP);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RCR, ED_RCR_AM | ED_RCR_AB | reg1);
|
1994-08-04 17:42:35 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize multicast address hashing registers to
|
|
|
|
* not accept multicasts.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 8; ++i)
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P1_MAR(i), 0x00);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
/* Set page 0 registers */
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STP);
|
1994-08-04 17:42:35 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_RCR, ED_RCR_AB | reg1);
|
1994-08-04 17:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
1994-11-17 14:42:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start interface.
|
|
|
|
*/
|
2000-08-17 12:15:45 +00:00
|
|
|
ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA);
|
1994-08-04 17:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute crc for ethernet address
|
|
|
|
*/
|
2000-08-14 04:31:07 +00:00
|
|
|
static u_int32_t
|
1994-08-04 17:42:35 +00:00
|
|
|
ds_crc(ep)
|
|
|
|
u_char *ep;
|
|
|
|
{
|
|
|
|
#define POLYNOMIAL 0x04c11db6
|
2000-08-14 04:31:07 +00:00
|
|
|
register u_int32_t crc = 0xffffffff;
|
1994-08-04 17:42:35 +00:00
|
|
|
register int carry, i, j;
|
|
|
|
register u_char b;
|
|
|
|
|
|
|
|
for (i = 6; --i >= 0;) {
|
|
|
|
b = *ep++;
|
|
|
|
for (j = 8; --j >= 0;) {
|
2000-08-14 04:31:07 +00:00
|
|
|
carry = ((crc & 0x80000000) ? 1 : 0) ^ (b & 0x01);
|
1994-08-04 17:42:35 +00:00
|
|
|
crc <<= 1;
|
|
|
|
b >>= 1;
|
|
|
|
if (carry)
|
2000-08-14 04:31:07 +00:00
|
|
|
crc = (crc ^ POLYNOMIAL) | carry;
|
1994-08-04 17:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-17 12:15:45 +00:00
|
|
|
return crc;
|
1994-08-04 17:42:35 +00:00
|
|
|
#undef POLYNOMIAL
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute the multicast address filter from the
|
|
|
|
* list of multicast addresses we need to listen to.
|
|
|
|
*/
|
1995-11-18 08:29:04 +00:00
|
|
|
static void
|
1994-08-04 17:42:35 +00:00
|
|
|
ds_getmcaf(sc, mcaf)
|
|
|
|
struct ed_softc *sc;
|
2000-08-14 04:31:07 +00:00
|
|
|
u_int32_t *mcaf;
|
1994-08-04 17:42:35 +00:00
|
|
|
{
|
2000-08-14 04:31:07 +00:00
|
|
|
register u_int32_t index;
|
1994-08-04 17:42:35 +00:00
|
|
|
register u_char *af = (u_char *) mcaf;
|
1997-01-13 21:26:53 +00:00
|
|
|
struct ifmultiaddr *ifma;
|
1994-08-04 17:42:35 +00:00
|
|
|
|
|
|
|
mcaf[0] = 0;
|
|
|
|
mcaf[1] = 0;
|
|
|
|
|
2001-02-06 10:12:15 +00:00
|
|
|
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
|
1997-01-13 21:26:53 +00:00
|
|
|
if (ifma->ifma_addr->sa_family != AF_LINK)
|
|
|
|
continue;
|
|
|
|
index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr))
|
|
|
|
>> 26;
|
1994-08-04 17:42:35 +00:00
|
|
|
af[index >> 3] |= 1 << (index & 7);
|
|
|
|
}
|
|
|
|
}
|