1994-10-01 20:16:47 +00:00
|
|
|
|
/*-
|
1995-04-09 04:46:15 +00:00
|
|
|
|
* Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
* 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, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software withough specific prior written permission
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
|
|
|
|
*
|
1995-06-11 19:33:05 +00:00
|
|
|
|
* $Id: if_de.c,v 1.28.2.1 1995/06/02 10:44:24 davidg Exp $
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* DEC DC21040 PCI Ethernet Controller
|
|
|
|
|
*
|
|
|
|
|
* Written by Matt Thomas
|
|
|
|
|
* BPF support code stolen directly from if_ec.c
|
|
|
|
|
*
|
|
|
|
|
* This driver supports the DEC DE435 or any other PCI
|
1995-05-05 20:09:51 +00:00
|
|
|
|
* board which support DC21040 or DC21140 (mostly).
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#include "de.h"
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if NDE > 0 || !defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
#include <sys/malloc.h>
|
1995-02-02 13:12:18 +00:00
|
|
|
|
#include <sys/kernel.h>
|
1995-03-16 17:41:20 +00:00
|
|
|
|
#include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1995-03-17 04:27:21 +00:00
|
|
|
|
#include <sys/devconf.h>
|
1995-02-02 13:12:18 +00:00
|
|
|
|
#include <machine/clock.h>
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#elif defined(__bsdi__) || defined(__NetBSD__)
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
|
#include <net/if_types.h>
|
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
|
#include <net/route.h>
|
|
|
|
|
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#include "bpfilter.h"
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef NS
|
|
|
|
|
#include <netns/ns.h>
|
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#include <pci.h>
|
|
|
|
|
#if NPCI > 0
|
1995-02-02 13:12:18 +00:00
|
|
|
|
#include <pci/pcivar.h>
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#include <pci/dc21040.h>
|
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#endif
|
1995-02-02 13:12:18 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
#include <i386/pci/pci.h>
|
|
|
|
|
#include <i386/pci/dc21040.h>
|
|
|
|
|
#include <i386/isa/isa.h>
|
|
|
|
|
#include <i386/isa/icu.h>
|
|
|
|
|
#include <i386/isa/dma.h>
|
|
|
|
|
#include <i386/isa/isavar.h>
|
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
#include <dev/ic/dc21040.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
/*
|
1995-04-09 04:46:15 +00:00
|
|
|
|
* This module supports
|
|
|
|
|
* the DEC DC21040 PCI Ethernet Controller.
|
|
|
|
|
* the DEC DC21140 PCI Fast Ethernet Controller.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
unsigned long addr;
|
|
|
|
|
unsigned long length;
|
|
|
|
|
} tulip_addrvec_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
tulip_desc_t *ri_first;
|
|
|
|
|
tulip_desc_t *ri_last;
|
|
|
|
|
tulip_desc_t *ri_nextin;
|
|
|
|
|
tulip_desc_t *ri_nextout;
|
|
|
|
|
int ri_max;
|
|
|
|
|
int ri_free;
|
|
|
|
|
} tulip_ringinfo_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
volatile tulip_uint32_t *csr_busmode; /* CSR0 */
|
|
|
|
|
volatile tulip_uint32_t *csr_txpoll; /* CSR1 */
|
|
|
|
|
volatile tulip_uint32_t *csr_rxpoll; /* CSR2 */
|
|
|
|
|
volatile tulip_uint32_t *csr_rxlist; /* CSR3 */
|
|
|
|
|
volatile tulip_uint32_t *csr_txlist; /* CSR4 */
|
|
|
|
|
volatile tulip_uint32_t *csr_status; /* CSR5 */
|
|
|
|
|
volatile tulip_uint32_t *csr_command; /* CSR6 */
|
|
|
|
|
volatile tulip_uint32_t *csr_intr; /* CSR7 */
|
|
|
|
|
volatile tulip_uint32_t *csr_missed_frame; /* CSR8 */
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
|
|
|
|
/* DC21040 specific registers */
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
volatile tulip_sint32_t *csr_enetrom; /* CSR9 */
|
|
|
|
|
volatile tulip_uint32_t *csr_reserved; /* CSR10 */
|
|
|
|
|
volatile tulip_uint32_t *csr_full_duplex; /* CSR11 */
|
|
|
|
|
volatile tulip_uint32_t *csr_sia_status; /* CSR12 */
|
|
|
|
|
volatile tulip_uint32_t *csr_sia_connectivity; /* CSR13 */
|
|
|
|
|
volatile tulip_uint32_t *csr_sia_tx_rx; /* CSR14 */
|
|
|
|
|
volatile tulip_uint32_t *csr_sia_general; /* CSR15 */
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
|
|
|
|
/* DC21140/DC21041 specific registers */
|
|
|
|
|
|
|
|
|
|
volatile tulip_uint32_t *csr_srom_mii; /* CSR9 */
|
|
|
|
|
volatile tulip_uint32_t *csr_gp_timer; /* CSR11 */
|
|
|
|
|
volatile tulip_uint32_t *csr_gp; /* CSR12 */
|
|
|
|
|
volatile tulip_uint32_t *csr_watchdog; /* CSR15 */
|
1994-10-01 20:16:47 +00:00
|
|
|
|
} tulip_regfile_t;
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* macros to read and write CSRs. Note that the "0 +" in
|
|
|
|
|
* READ_CSR is to prevent the macro from being an lvalue
|
|
|
|
|
* and WRITE_CSR shouldn't be assigned from.
|
|
|
|
|
*/
|
|
|
|
|
#define TULIP_READ_CSR(sc, csr) (0 + *(sc)->tulip_csrs.csr)
|
|
|
|
|
#ifndef __alpha__
|
|
|
|
|
#define TULIP_WRITE_CSR(sc, csr, val) \
|
|
|
|
|
((void)(*(sc)->tulip_csrs.csr = (val)))
|
|
|
|
|
#else
|
|
|
|
|
#define TULIP_WRITE_CSR(sc, csr, val) \
|
|
|
|
|
((void)(*(sc)->tulip_csrs.csr = (val), MB()))
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
/*
|
|
|
|
|
* The DC21040 has a stupid restriction in that the receive
|
|
|
|
|
* buffers must be longword aligned. But since Ethernet
|
|
|
|
|
* headers are not a multiple of longwords in size this forces
|
|
|
|
|
* the data to non-longword aligned. Since IP requires the
|
1994-11-22 09:47:31 +00:00
|
|
|
|
* data to be longword aligned, we need to copy it after it has
|
1994-10-01 20:16:47 +00:00
|
|
|
|
* been DMA'ed in our memory.
|
|
|
|
|
*
|
|
|
|
|
* Since we have to copy it anyways, we might as well as allocate
|
|
|
|
|
* dedicated receive space for the input. This allows to use a
|
|
|
|
|
* small receive buffer size and more ring entries to be able to
|
1994-11-22 09:47:31 +00:00
|
|
|
|
* better keep with a flood of tiny Ethernet packets.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*
|
|
|
|
|
* The receive space MUST ALWAYS be a multiple of the page size.
|
|
|
|
|
* And the number of receive descriptors multiplied by the size
|
|
|
|
|
* of the receive buffers must equal the recevive space. This
|
1994-11-22 09:47:31 +00:00
|
|
|
|
* is so that we can manipulate the page tables so that even if a
|
1995-05-30 08:16:23 +00:00
|
|
|
|
* packet wraps around the end of the receive space, we can
|
1994-10-01 20:16:47 +00:00
|
|
|
|
* treat it as virtually contiguous.
|
1995-04-09 04:46:15 +00:00
|
|
|
|
*
|
|
|
|
|
* The above used to be true (the stupid restriction is still true)
|
|
|
|
|
* but we gone to directly DMA'ing into MBUFs because with 100Mb
|
|
|
|
|
* cards the copying is just too much of a hit.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__alpha__)
|
|
|
|
|
#define TULIP_COPY_RXDATA 1
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
#define TULIP_RXDESCS 16
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#define TULIP_TXDESCS 128
|
1995-04-09 04:46:15 +00:00
|
|
|
|
#define TULIP_RXQ_TARGET 8
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
typedef enum {
|
|
|
|
|
TULIP_DC21040_GENERIC,
|
|
|
|
|
TULIP_DC21140_DEC_EB,
|
1995-05-05 20:09:51 +00:00
|
|
|
|
TULIP_DC21140_DEC_DE500,
|
|
|
|
|
TULIP_DC21140_COGENT_EM100
|
1995-04-13 04:46:40 +00:00
|
|
|
|
} tulip_board_t;
|
|
|
|
|
|
|
|
|
|
typedef struct _tulip_softc_t tulip_softc_t;
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
typedef struct {
|
1995-04-13 04:46:40 +00:00
|
|
|
|
tulip_board_t bd_type;
|
|
|
|
|
const char *bd_description;
|
|
|
|
|
int (*bd_media_probe)(tulip_softc_t *sc);
|
|
|
|
|
void (*bd_media_select)(tulip_softc_t *sc);
|
|
|
|
|
} tulip_boardsw_t;
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
typedef enum { TULIP_DC21040, TULIP_DC21140, TULIP_DC21041 } tulip_chipid_t;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
|
|
|
|
|
struct _tulip_softc_t {
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
struct device tulip_dev; /* base device */
|
|
|
|
|
struct isadev tulip_id; /* ISA device */
|
|
|
|
|
struct intrhand tulip_ih; /* intrrupt vectoring */
|
|
|
|
|
struct atshutdown tulip_ats; /* shutdown routine */
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
struct device tulip_dev; /* base device */
|
|
|
|
|
void *tulip_ih; /* intrrupt vectoring */
|
|
|
|
|
/* XXX no shutdown routine? */
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
struct arpcom tulip_ac;
|
|
|
|
|
tulip_regfile_t tulip_csrs;
|
|
|
|
|
unsigned tulip_flags;
|
|
|
|
|
#define TULIP_WANTSETUP 0x01
|
|
|
|
|
#define TULIP_WANTHASH 0x02
|
|
|
|
|
#define TULIP_DOINGSETUP 0x04
|
|
|
|
|
#define TULIP_ALTPHYS 0x08 /* use AUI */
|
1995-04-09 04:46:15 +00:00
|
|
|
|
unsigned char tulip_rombuf[128];
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_uint32_t tulip_setupbuf[192/sizeof(tulip_uint32_t)];
|
|
|
|
|
tulip_uint32_t tulip_setupdata[192/sizeof(tulip_uint32_t)];
|
|
|
|
|
tulip_uint32_t tulip_intrmask;
|
|
|
|
|
tulip_uint32_t tulip_cmdmode;
|
|
|
|
|
tulip_uint32_t tulip_revinfo;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
tulip_chipid_t tulip_chipid;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
const tulip_boardsw_t *tulip_boardsw;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
struct ifqueue tulip_txq;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
struct ifqueue tulip_rxq;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_ringinfo_t tulip_rxinfo;
|
|
|
|
|
tulip_ringinfo_t tulip_txinfo;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
};
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
#ifndef IFF_ALTPHYS
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#define IFF_ALTPHYS IFF_LINK0 /* In case it isn't defined */
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#endif
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static const char *tulip_chipdescs[] = {
|
1994-10-12 11:19:36 +00:00
|
|
|
|
"DC21040 [10Mb/s]",
|
1995-04-13 04:46:40 +00:00
|
|
|
|
"DC21140 [10-100Mb/s]",
|
1995-04-09 04:46:15 +00:00
|
|
|
|
"DC21041 [10Mb/s]"
|
1994-10-12 11:19:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
|
typedef void ifnet_ret_t;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
typedef int ioctl_cmd_t;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_softc_t *tulips[NDE];
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit])
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
typedef int ifnet_ret_t;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
typedef int ioctl_cmd_t;
|
|
|
|
|
extern struct cfdriver decd;
|
|
|
|
|
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
typedef void ifnet_ret_t;
|
|
|
|
|
typedef u_long ioctl_cmd_t;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
extern struct cfdriver decd;
|
|
|
|
|
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
|
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
#define tulip_if tulip_ac.ac_if
|
|
|
|
|
#define tulip_unit tulip_ac.ac_if.if_unit
|
|
|
|
|
#define tulip_name tulip_ac.ac_if.if_name
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#define tulip_bpf tulip_ac.ac_if.if_bpf
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#define tulip_hwaddr tulip_ac.ac_enaddr
|
|
|
|
|
|
|
|
|
|
#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */
|
|
|
|
|
#define TULIP_CHECK_RXCRC 0
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#define TULIP_MAX_TXSEG 30
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
#define TULIP_ADDREQUAL(a1, a2) \
|
|
|
|
|
(((u_short *)a1)[0] == ((u_short *)a2)[0] \
|
1994-11-22 09:47:31 +00:00
|
|
|
|
&& ((u_short *)a1)[1] == ((u_short *)a2)[1] \
|
|
|
|
|
&& ((u_short *)a1)[2] == ((u_short *)a2)[2])
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#define TULIP_ADDRBRDCST(a1) \
|
|
|
|
|
(((u_short *)a1)[0] == 0xFFFFU \
|
1994-11-22 09:47:31 +00:00
|
|
|
|
&& ((u_short *)a1)[1] == 0xFFFFU \
|
|
|
|
|
&& ((u_short *)a1)[2] == 0xFFFFU)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
static ifnet_ret_t tulip_start(struct ifnet *ifp);
|
1995-04-09 04:46:15 +00:00
|
|
|
|
static void tulip_rx_intr(tulip_softc_t *sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
static void tulip_addr_filter(tulip_softc_t *sc);
|
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_dc21040_media_probe(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
|
|
|
|
int cnt;
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_sia_connectivity, 0);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_10BASET);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
for (cnt = 0; cnt < 2400; cnt++) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
if ((TULIP_READ_CSR(sc, csr_sia_status) & TULIP_SIASTS_LINKFAIL) == 0)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
break;
|
|
|
|
|
DELAY(1000);
|
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
return (TULIP_READ_CSR(sc, csr_sia_status) & TULIP_SIASTS_LINKFAIL) != 0;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_dc21040_media_select(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
if (sc->tulip_if.if_flags & IFF_ALTPHYS) {
|
|
|
|
|
if ((sc->tulip_flags & TULIP_ALTPHYS) == 0)
|
|
|
|
|
printf("%s%d: enabling Thinwire/AUI port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_AUI);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
sc->tulip_flags |= TULIP_ALTPHYS;
|
|
|
|
|
} else {
|
|
|
|
|
if (sc->tulip_flags & TULIP_ALTPHYS)
|
|
|
|
|
printf("%s%d: enabling 10baseT/UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_10BASET);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
sc->tulip_flags &= ~TULIP_ALTPHYS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const tulip_boardsw_t tulip_dc21040_boardsw = {
|
|
|
|
|
TULIP_DC21040_GENERIC,
|
|
|
|
|
"",
|
|
|
|
|
tulip_dc21040_media_probe,
|
|
|
|
|
tulip_dc21040_media_select
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_dc21140_evalboard_media_probe(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EB_PINS);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EB_INIT);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) | TULIP_CMD_PORTSELECT |
|
|
|
|
|
TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
DELAY(1000000);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_EB_OK100) != 0;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_dc21140_evalboard_media_select(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_STOREFWD|TULIP_CMD_MUSTBEONE;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EB_PINS);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EB_INIT);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
if (sc->tulip_if.if_flags & IFF_ALTPHYS) {
|
|
|
|
|
if ((sc->tulip_flags & TULIP_ALTPHYS) == 0)
|
|
|
|
|
printf("%s%d: enabling 100baseTX UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT
|
|
|
|
|
|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER;
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
|
|
|
|
|
sc->tulip_flags |= TULIP_ALTPHYS;
|
|
|
|
|
} else {
|
|
|
|
|
if (sc->tulip_flags & TULIP_ALTPHYS)
|
|
|
|
|
printf("%s%d: enabling 10baseT UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
|
|
|
|
sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT
|
|
|
|
|
|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER);
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
|
|
|
|
|
sc->tulip_flags &= ~TULIP_ALTPHYS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const tulip_boardsw_t tulip_dc21140_eb_boardsw = {
|
|
|
|
|
TULIP_DC21140_DEC_EB,
|
|
|
|
|
"",
|
|
|
|
|
tulip_dc21140_evalboard_media_probe,
|
|
|
|
|
tulip_dc21140_evalboard_media_select
|
|
|
|
|
};
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_dc21140_cogent_em100_media_probe(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-05-05 20:09:51 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_PINS);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_INIT);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) | TULIP_CMD_PORTSELECT |
|
|
|
|
|
TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_dc21140_cogent_em100_media_select(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-05-05 20:09:51 +00:00
|
|
|
|
{
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_STOREFWD|TULIP_CMD_MUSTBEONE;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_PINS);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_INIT);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if ((sc->tulip_flags & TULIP_ALTPHYS) == 0)
|
|
|
|
|
printf("%s%d: enabling 100baseTX UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT
|
|
|
|
|
|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER;
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
|
|
|
|
|
sc->tulip_flags |= TULIP_ALTPHYS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const tulip_boardsw_t tulip_dc21140_cogent_em100_boardsw = {
|
|
|
|
|
TULIP_DC21140_COGENT_EM100,
|
|
|
|
|
"Cogent EM100",
|
|
|
|
|
tulip_dc21140_cogent_em100_media_probe,
|
|
|
|
|
tulip_dc21140_cogent_em100_media_select
|
|
|
|
|
};
|
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
static int
|
|
|
|
|
tulip_dc21140_de500_media_probe(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_DE500_PINS);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
DELAY(1000);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_DE500_HALFDUPLEX);
|
|
|
|
|
if ((TULIP_READ_CSR(sc, csr_gp) &
|
|
|
|
|
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10)) !=
|
|
|
|
|
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10))
|
|
|
|
|
return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp,
|
|
|
|
|
TULIP_GP_DE500_HALFDUPLEX|TULIP_GP_DE500_FORCE_100);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) | TULIP_CMD_PORTSELECT |
|
|
|
|
|
TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command,
|
|
|
|
|
TULIP_READ_CSR(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
DELAY(1000000);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
|
1995-04-13 04:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_dc21140_de500_media_select(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
{
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_STOREFWD|TULIP_CMD_MUSTBEONE;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_DE500_PINS);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
if (sc->tulip_if.if_flags & IFF_ALTPHYS) {
|
|
|
|
|
if ((sc->tulip_flags & TULIP_ALTPHYS) == 0)
|
|
|
|
|
printf("%s%d: enabling 100baseTX UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT
|
|
|
|
|
|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER;
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
|
|
|
|
|
sc->tulip_flags |= TULIP_ALTPHYS;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp,
|
|
|
|
|
TULIP_GP_DE500_HALFDUPLEX|TULIP_GP_DE500_FORCE_100);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (sc->tulip_flags & TULIP_ALTPHYS)
|
|
|
|
|
printf("%s%d: enabling 10baseT UTP port\n",
|
|
|
|
|
sc->tulip_if.if_name, sc->tulip_if.if_unit);
|
|
|
|
|
sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT
|
|
|
|
|
|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER);
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
|
|
|
|
|
sc->tulip_flags &= ~TULIP_ALTPHYS;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_DE500_HALFDUPLEX);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const tulip_boardsw_t tulip_dc21140_de500_boardsw = {
|
|
|
|
|
TULIP_DC21140_DEC_DE500, "Digital DE500 ",
|
|
|
|
|
tulip_dc21140_de500_media_probe,
|
|
|
|
|
tulip_dc21140_de500_media_select
|
|
|
|
|
};
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static void
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_reset(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
tulip_ringinfo_t *ri;
|
|
|
|
|
tulip_desc_t *di;
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at
|
1994-10-01 20:16:47 +00:00
|
|
|
|
33MHz that comes to two microseconds but wait a
|
|
|
|
|
bit longer anyways) */
|
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
(*sc->tulip_boardsw->bd_media_select)(sc);
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_txlist, vtophys(&sc->tulip_txinfo.ri_first[0]));
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_rxlist, vtophys(&sc->tulip_rxinfo.ri_first[0]));
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_intr, 0);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_busmode,
|
|
|
|
|
TULIP_BUSMODE_BURSTLEN_8LW|TULIP_BUSMODE_CACHE_ALIGN8
|
|
|
|
|
|(BYTE_ORDER != LITTLE_ENDIAN ? TULIP_BUSMODE_BIGENDIAN : 0));
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS;
|
|
|
|
|
/*
|
|
|
|
|
* Free all the mbufs that were on the transmit ring.
|
|
|
|
|
*/
|
|
|
|
|
for (;;) {
|
|
|
|
|
struct mbuf *m;
|
|
|
|
|
IF_DEQUEUE(&sc->tulip_txq, m);
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
break;
|
|
|
|
|
m_freem(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ri = &sc->tulip_txinfo;
|
|
|
|
|
ri->ri_nextin = ri->ri_nextout = ri->ri_first;
|
|
|
|
|
ri->ri_free = ri->ri_max;
|
|
|
|
|
for (di = ri->ri_first; di < ri->ri_last; di++)
|
|
|
|
|
di->d_status = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
|
* We need to collect all the mbufs were on the
|
1994-10-01 20:16:47 +00:00
|
|
|
|
* receive ring before we reinit it either to put
|
|
|
|
|
* them back on or to know if we have to allocate
|
|
|
|
|
* more.
|
|
|
|
|
*/
|
|
|
|
|
ri = &sc->tulip_rxinfo;
|
|
|
|
|
ri->ri_nextin = ri->ri_nextout = ri->ri_first;
|
|
|
|
|
ri->ri_free = ri->ri_max;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
for (di = ri->ri_first; di < ri->ri_last; di++) {
|
|
|
|
|
di->d_status = 0;
|
|
|
|
|
di->d_length1 = 0; di->d_addr1 = 0;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
di->d_length2 = 0; di->d_addr2 = 0;
|
|
|
|
|
}
|
1995-04-09 04:46:15 +00:00
|
|
|
|
for (;;) {
|
|
|
|
|
struct mbuf *m;
|
|
|
|
|
IF_DEQUEUE(&sc->tulip_rxq, m);
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
break;
|
|
|
|
|
m_freem(m);
|
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
sc->tulip_intrmask = TULIP_STS_NORMALINTR|TULIP_STS_RXINTR|TULIP_STS_TXINTR
|
|
|
|
|
|TULIP_STS_ABNRMLINTR|TULIP_STS_SYSERROR|TULIP_STS_TXSTOPPED
|
|
|
|
|
|TULIP_STS_TXBABBLE|TULIP_STS_LINKFAIL|TULIP_STS_RXSTOPPED;
|
|
|
|
|
sc->tulip_flags &= ~(TULIP_DOINGSETUP|TULIP_WANTSETUP);
|
|
|
|
|
tulip_addr_filter(sc);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static void
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_init(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (sc->tulip_if.if_flags & IFF_UP) {
|
|
|
|
|
sc->tulip_if.if_flags |= IFF_RUNNING;
|
|
|
|
|
if (sc->tulip_if.if_flags & IFF_PROMISC) {
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS;
|
|
|
|
|
} else {
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_PROMISCUOUS;
|
|
|
|
|
if (sc->tulip_if.if_flags & IFF_ALLMULTI) {
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_ALLMULTI;
|
|
|
|
|
} else {
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_ALLMULTI;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_TXRUN;
|
|
|
|
|
if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) {
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_rx_intr(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
|
|
|
|
|
sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
|
|
|
|
|
} else {
|
|
|
|
|
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
|
|
|
|
|
tulip_start(&sc->tulip_if);
|
|
|
|
|
}
|
1994-10-12 02:33:23 +00:00
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_THRSHLD160;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_intr, sc->tulip_intrmask);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command, sc->tulip_cmdmode);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
} else {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc->tulip_if.if_flags &= ~IFF_RUNNING;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if TULIP_CHECK_RXCRC
|
|
|
|
|
static unsigned
|
|
|
|
|
tulip_crc32(
|
|
|
|
|
u_char *addr,
|
|
|
|
|
int len)
|
|
|
|
|
{
|
|
|
|
|
unsigned int crc = 0xFFFFFFFF;
|
|
|
|
|
static unsigned int crctbl[256];
|
|
|
|
|
int idx;
|
|
|
|
|
static int done;
|
|
|
|
|
/*
|
|
|
|
|
* initialize the multicast address CRC table
|
|
|
|
|
*/
|
|
|
|
|
for (idx = 0; !done && idx < 256; idx++) {
|
|
|
|
|
unsigned int tmp = idx;
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */
|
|
|
|
|
crctbl[idx] = tmp;
|
|
|
|
|
}
|
|
|
|
|
done = 1;
|
|
|
|
|
|
|
|
|
|
while (len-- > 0)
|
|
|
|
|
crc = (crc >> 8) ^ crctbl[*addr++] ^ crctbl[crc & 0xFF];
|
|
|
|
|
|
|
|
|
|
return crc;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_rx_intr(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_ringinfo_t * const ri = &sc->tulip_rxinfo;
|
|
|
|
|
struct ifnet * const ifp = &sc->tulip_if;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1994-11-09 15:12:44 +00:00
|
|
|
|
for (;;) {
|
1995-04-09 04:46:15 +00:00
|
|
|
|
struct ether_header eh;
|
|
|
|
|
tulip_desc_t *eop = ri->ri_nextin;
|
|
|
|
|
int total_len = 0;
|
|
|
|
|
struct mbuf *m = NULL;
|
|
|
|
|
int accept = 0;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
if (sc->tulip_rxq.ifq_len < TULIP_RXQ_TARGET)
|
|
|
|
|
goto queue_mbuf;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
|
|
|
|
|
break;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
total_len = ((eop->d_status >> 16) & 0x7FF) - 4;
|
|
|
|
|
IF_DEQUEUE(&sc->tulip_rxq, m);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if ((eop->d_status & TULIP_DSTS_ERRSUM) == 0) {
|
|
|
|
|
|
|
|
|
|
#if TULIP_CHECK_RXCRC
|
1995-04-09 04:46:15 +00:00
|
|
|
|
unsigned crc = tulip_crc32(mtod(m, unsigned char *), total_len);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if (~crc != *((unsigned *) &bufaddr[total_len])) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
printf("%s%d: bad rx crc: %08x [rx] != %08x\n",
|
|
|
|
|
sc->tulip_name, sc->tulip_unit,
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*((unsigned *) &bufaddr[total_len]), ~crc);
|
|
|
|
|
goto next;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1995-04-09 04:46:15 +00:00
|
|
|
|
eh = *mtod(m, struct ether_header *);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#if NBPFILTER > 0
|
1995-05-26 02:02:44 +00:00
|
|
|
|
if (sc->tulip_bpf != NULL)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
bpf_tap(sc->tulip_bpf, mtod(m, caddr_t), total_len);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#endif
|
1995-05-26 02:02:44 +00:00
|
|
|
|
if ((sc->tulip_if.if_flags & IFF_PROMISC)
|
|
|
|
|
&& (eh.ether_dhost[0] & 1) == 0
|
|
|
|
|
&& !TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_ac.ac_enaddr))
|
|
|
|
|
goto next;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
accept = 1;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
total_len -= sizeof(struct ether_header);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
} else {
|
1994-11-09 15:12:44 +00:00
|
|
|
|
ifp->if_ierrors++;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
1995-04-09 04:46:15 +00:00
|
|
|
|
next:
|
1994-11-09 15:12:44 +00:00
|
|
|
|
ifp->if_ipackets++;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
if (++ri->ri_nextin == ri->ri_last)
|
|
|
|
|
ri->ri_nextin = ri->ri_first;
|
|
|
|
|
queue_mbuf:
|
|
|
|
|
/*
|
|
|
|
|
* Either we are priming the TULIP with mbufs (m == NULL)
|
|
|
|
|
* or we are about to accept an mbuf for the upper layers
|
|
|
|
|
* so we need to allocate an mbuf to replace it. If we
|
|
|
|
|
* can't replace, then count it as an input error and reuse
|
|
|
|
|
* the mbuf.
|
|
|
|
|
*/
|
|
|
|
|
if (accept || m == NULL) {
|
|
|
|
|
struct mbuf *m0;
|
|
|
|
|
MGETHDR(m0, M_DONTWAIT, MT_DATA);
|
|
|
|
|
if (m0 != NULL) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(TULIP_COPY_RXDATA)
|
|
|
|
|
if (!accept || total_len >= MHLEN) {
|
|
|
|
|
#endif
|
|
|
|
|
MCLGET(m0, M_DONTWAIT);
|
|
|
|
|
if ((m0->m_flags & M_EXT) == 0) {
|
|
|
|
|
m_freem(m0);
|
|
|
|
|
m0 = NULL;
|
|
|
|
|
}
|
|
|
|
|
#if defined(TULIP_COPY_RXDATA)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#endif
|
1995-04-09 04:46:15 +00:00
|
|
|
|
}
|
|
|
|
|
if (accept) {
|
|
|
|
|
if (m0 != NULL) {
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
eh.ether_type = ntohs(eh.ether_type);
|
|
|
|
|
#endif
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if !defined(TULIP_COPY_RXDATA)
|
|
|
|
|
m->m_data += sizeof(struct ether_header);
|
|
|
|
|
m->m_len = m->m_pkthdr.len = total_len;
|
|
|
|
|
m->m_pkthdr.rcvif = ifp;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
ether_input(ifp, &eh, m);
|
|
|
|
|
m = m0;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#else
|
|
|
|
|
bcopy(mtod(m, caddr_t) + sizeof(struct ether_header),
|
|
|
|
|
mtod(m0, caddr_t), total_len);
|
|
|
|
|
m0->m_len = m0->m_pkthdr.len = total_len;
|
|
|
|
|
m0->m_pkthdr.rcvif = ifp;
|
|
|
|
|
ether_input(ifp, &eh, m0);
|
|
|
|
|
#endif
|
1995-04-09 04:46:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
ifp->if_ierrors++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
m = m0;
|
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
1995-04-09 04:46:15 +00:00
|
|
|
|
if (m == NULL)
|
|
|
|
|
break;
|
|
|
|
|
/*
|
|
|
|
|
* Now give the buffer to the TULIP and save in our
|
|
|
|
|
* receive queue.
|
|
|
|
|
*/
|
|
|
|
|
ri->ri_nextout->d_length1 = MCLBYTES - 4;
|
|
|
|
|
ri->ri_nextout->d_addr1 = vtophys(mtod(m, caddr_t));
|
|
|
|
|
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
|
|
|
|
|
if (++ri->ri_nextout == ri->ri_last)
|
|
|
|
|
ri->ri_nextout = ri->ri_first;
|
|
|
|
|
IF_ENQUEUE(&sc->tulip_rxq, m);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_tx_intr(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_ringinfo_t * const ri = &sc->tulip_txinfo;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
struct mbuf *m;
|
|
|
|
|
int xmits = 0;
|
|
|
|
|
|
|
|
|
|
while (ri->ri_free < ri->ri_max) {
|
|
|
|
|
if (((volatile tulip_desc_t *) ri->ri_nextin)->d_status & TULIP_DSTS_OWNER)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxLASTSEG) {
|
|
|
|
|
if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxSETUPPKT) {
|
|
|
|
|
/*
|
|
|
|
|
* We've just finished processing a setup packet.
|
|
|
|
|
* Mark that we can finished it. If there's not
|
|
|
|
|
* another pending, startup the TULIP receiver.
|
1994-11-22 09:47:31 +00:00
|
|
|
|
* Make sure we ack the RXSTOPPED so we won't get
|
|
|
|
|
* an abormal interrupt indication.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
|
|
|
|
sc->tulip_flags &= ~TULIP_DOINGSETUP;
|
|
|
|
|
if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) {
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_rx_intr(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
|
|
|
|
|
sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_status, TULIP_STS_RXSTOPPED);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command, sc->tulip_cmdmode);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_intr, sc->tulip_intrmask);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
IF_DEQUEUE(&sc->tulip_txq, m);
|
|
|
|
|
m_freem(m);
|
|
|
|
|
sc->tulip_if.if_collisions +=
|
|
|
|
|
(ri->ri_nextin->d_status & TULIP_DSTS_TxCOLLMASK)
|
|
|
|
|
>> TULIP_DSTS_V_TxCOLLCNT;
|
|
|
|
|
if (ri->ri_nextin->d_status & TULIP_DSTS_ERRSUM)
|
|
|
|
|
sc->tulip_if.if_oerrors++;
|
|
|
|
|
xmits++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (++ri->ri_nextin == ri->ri_last)
|
|
|
|
|
ri->ri_nextin = ri->ri_first;
|
|
|
|
|
ri->ri_free++;
|
|
|
|
|
sc->tulip_if.if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
}
|
|
|
|
|
sc->tulip_if.if_opackets += xmits;
|
|
|
|
|
return xmits;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
static ifnet_ret_t
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_start(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
struct ifnet * const ifp)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit);
|
|
|
|
|
struct ifqueue * const ifq = &ifp->if_snd;
|
|
|
|
|
tulip_ringinfo_t * const ri = &sc->tulip_txinfo;
|
|
|
|
|
struct mbuf *m, *m0;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
if ((ifp->if_flags & IFF_RUNNING) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_desc_t *eop, *nextout;
|
|
|
|
|
int segcnt, free, recopy;
|
|
|
|
|
tulip_uint32_t d_status;
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if (sc->tulip_flags & TULIP_WANTSETUP) {
|
|
|
|
|
if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) {
|
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
|
|
|
|
|
sizeof(sc->tulip_setupbuf));
|
|
|
|
|
sc->tulip_flags &= ~TULIP_WANTSETUP;
|
|
|
|
|
sc->tulip_flags |= TULIP_DOINGSETUP;
|
|
|
|
|
ri->ri_free--;
|
|
|
|
|
ri->ri_nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
|
|
|
|
|
ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG
|
|
|
|
|
|TULIP_DFLAG_TxSETUPPKT|TULIP_DFLAG_TxWANTINTR;
|
|
|
|
|
if (sc->tulip_flags & TULIP_WANTHASH)
|
|
|
|
|
ri->ri_nextout->d_flag |= TULIP_DFLAG_TxHASHFILT;
|
|
|
|
|
ri->ri_nextout->d_length1 = sizeof(sc->tulip_setupbuf);
|
|
|
|
|
ri->ri_nextout->d_addr1 = vtophys(sc->tulip_setupbuf);
|
|
|
|
|
ri->ri_nextout->d_length2 = 0;
|
|
|
|
|
ri->ri_nextout->d_addr2 = 0;
|
|
|
|
|
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_txpoll, 1);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
/*
|
|
|
|
|
* Advance the ring for the next transmit packet.
|
|
|
|
|
*/
|
|
|
|
|
if (++ri->ri_nextout == ri->ri_last)
|
|
|
|
|
ri->ri_nextout = ri->ri_first;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* Make sure the next descriptor is owned by us since it
|
|
|
|
|
* may have been set up above if we ran out of room in the
|
|
|
|
|
* ring.
|
|
|
|
|
*/
|
|
|
|
|
ri->ri_nextout->d_status = 0;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
IF_DEQUEUE(ifq, m);
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/*
|
1995-05-26 02:02:44 +00:00
|
|
|
|
* Now we try to fill in our transmit descriptors. This is
|
|
|
|
|
* a bit reminiscent of going on the Ark two by two
|
|
|
|
|
* since each descriptor for the TULIP can describe
|
|
|
|
|
* two buffers. So we advance through packet filling
|
|
|
|
|
* each of the two entries at a time to to fill each
|
|
|
|
|
* descriptor. Clear the first and last segment bits
|
|
|
|
|
* in each descriptor (actually just clear everything
|
|
|
|
|
* but the end-of-ring or chain bits) to make sure
|
|
|
|
|
* we don't get messed up by previously sent packets.
|
|
|
|
|
*
|
|
|
|
|
* We may fail to put the entire packet on the ring if
|
|
|
|
|
* there is either not enough ring entries free or if the
|
|
|
|
|
* packet has more than MAX_TXSEG segments. In the former
|
|
|
|
|
* case we will just wait for the ring to empty. In the
|
|
|
|
|
* latter case we have to recopy.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
1995-05-26 02:02:44 +00:00
|
|
|
|
d_status = 0;
|
|
|
|
|
recopy = 0;
|
|
|
|
|
eop = nextout = ri->ri_nextout;
|
|
|
|
|
m0 = m;
|
|
|
|
|
segcnt = 0;
|
|
|
|
|
free = ri->ri_free;
|
|
|
|
|
do {
|
|
|
|
|
int len = m0->m_len;
|
|
|
|
|
caddr_t addr = mtod(m0, caddr_t);
|
|
|
|
|
unsigned clsize = CLBYTES - (((u_long) addr) & (CLBYTES-1));
|
|
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
|
unsigned slen = min(len, clsize);
|
|
|
|
|
|
|
|
|
|
segcnt++;
|
|
|
|
|
if (segcnt > TULIP_MAX_TXSEG) {
|
|
|
|
|
recopy = 1;
|
|
|
|
|
m0 = NULL; /* to break out of outside loop */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (segcnt & 1) {
|
|
|
|
|
if (--free == 0) {
|
|
|
|
|
/*
|
|
|
|
|
* There's no more room but since nothing
|
|
|
|
|
* has been committed at this point, just
|
|
|
|
|
* show output is active, put back the
|
|
|
|
|
* mbuf and return.
|
|
|
|
|
*/
|
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
|
IF_PREPEND(ifq, m);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
eop = nextout;
|
|
|
|
|
if (++nextout == ri->ri_last)
|
|
|
|
|
nextout = ri->ri_first;
|
|
|
|
|
eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
|
|
|
|
|
eop->d_status = d_status;
|
|
|
|
|
eop->d_addr1 = vtophys(addr); eop->d_length1 = slen;
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Fill in second half of descriptor
|
|
|
|
|
*/
|
|
|
|
|
eop->d_addr2 = vtophys(addr); eop->d_length2 = slen;
|
|
|
|
|
}
|
|
|
|
|
d_status = TULIP_DSTS_OWNER;
|
|
|
|
|
len -= slen;
|
|
|
|
|
addr += slen;
|
|
|
|
|
clsize = CLBYTES;
|
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
|
} while ((m0 != NULL) && ((m0 = m0->m_next) != NULL));
|
1995-05-26 02:02:44 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The packet exceeds the number of transmit buffer
|
|
|
|
|
* entries that we can use for one packet, so we have
|
|
|
|
|
* recopy it into one mbuf and then try again.
|
|
|
|
|
*/
|
|
|
|
|
if (recopy) {
|
1994-10-01 20:16:47 +00:00
|
|
|
|
MGETHDR(m0, M_DONTWAIT, MT_DATA);
|
|
|
|
|
if (m0 != NULL) {
|
|
|
|
|
if (m->m_pkthdr.len > MHLEN) {
|
|
|
|
|
MCLGET(m0, M_DONTWAIT);
|
|
|
|
|
if ((m0->m_flags & M_EXT) == 0) {
|
|
|
|
|
m_freem(m);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
m_freem(m0);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-05-05 20:09:51 +00:00
|
|
|
|
m_copydata(m, 0, m->m_pkthdr.len, mtod(m0, caddr_t));
|
1994-10-01 20:16:47 +00:00
|
|
|
|
m0->m_pkthdr.len = m0->m_len = m->m_pkthdr.len;
|
|
|
|
|
IF_PREPEND(ifq, m0);
|
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
m_freem(m);
|
|
|
|
|
continue;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
1995-05-26 02:02:44 +00:00
|
|
|
|
* The descriptors have been filled in. Now get ready
|
|
|
|
|
* to transmit.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#if NBPFILTER > 0
|
1995-05-26 02:02:44 +00:00
|
|
|
|
if (sc->tulip_bpf != NULL)
|
|
|
|
|
bpf_mtap(sc->tulip_bpf, m);
|
1994-11-22 09:47:31 +00:00
|
|
|
|
#endif
|
1995-05-26 02:02:44 +00:00
|
|
|
|
IF_ENQUEUE(&sc->tulip_txq, m);
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
/*
|
1995-05-26 02:02:44 +00:00
|
|
|
|
* Make sure the next descriptor after this packet is owned
|
|
|
|
|
* by us since it may have been set up above if we ran out
|
|
|
|
|
* of room in the ring.
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*/
|
1995-05-26 02:02:44 +00:00
|
|
|
|
nextout->d_status = 0;
|
1994-11-22 09:47:31 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* If we only used the first segment of the last descriptor,
|
|
|
|
|
* make sure the second segment will not be used.
|
|
|
|
|
*/
|
|
|
|
|
if (segcnt & 1) {
|
|
|
|
|
eop->d_addr2 = 0;
|
|
|
|
|
eop->d_length2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Mark the last and first segments, indicate we want a transmit
|
|
|
|
|
* complete interrupt, give the descriptors to the TULIP, and tell
|
|
|
|
|
* it to transmit!
|
|
|
|
|
*/
|
1994-10-01 20:16:47 +00:00
|
|
|
|
eop->d_flag |= TULIP_DFLAG_TxLASTSEG|TULIP_DFLAG_TxWANTINTR;
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* Note that ri->ri_nextout is still the start of the packet
|
|
|
|
|
* and until we set the OWNER bit, we can still back out of
|
|
|
|
|
* everything we have done.
|
|
|
|
|
*/
|
|
|
|
|
ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG;
|
|
|
|
|
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This advances the ring for us.
|
|
|
|
|
*/
|
|
|
|
|
ri->ri_nextout = nextout;
|
|
|
|
|
ri->ri_free = free;
|
|
|
|
|
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_txpoll, 1);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
if (m != NULL) {
|
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
|
IF_PREPEND(ifq, m);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_intr(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
void *arg)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = (tulip_softc_t *) arg;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_uint32_t csr;
|
1995-03-21 22:41:19 +00:00
|
|
|
|
int progress=0;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
while ((csr = TULIP_READ_CSR(sc, csr_status)) & (TULIP_STS_NORMALINTR|TULIP_STS_ABNRMLINTR)) {
|
1995-03-21 22:41:19 +00:00
|
|
|
|
progress = 1;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_status, csr & sc->tulip_intrmask);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
if (csr & TULIP_STS_SYSERROR) {
|
|
|
|
|
if ((csr & TULIP_STS_ERRORMASK) == TULIP_STS_ERR_PARITY) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
|
|
|
|
tulip_init(sc);
|
1995-03-21 22:41:19 +00:00
|
|
|
|
break;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-22 09:47:31 +00:00
|
|
|
|
if (csr & TULIP_STS_ABNRMLINTR) {
|
|
|
|
|
printf("%s%d: abnormal interrupt: 0x%05x [0x%05x]\n",
|
|
|
|
|
sc->tulip_name, sc->tulip_unit, csr, csr & sc->tulip_intrmask);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_command, sc->tulip_cmdmode);
|
1994-11-22 09:47:31 +00:00
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if (csr & TULIP_STS_RXINTR)
|
|
|
|
|
tulip_rx_intr(sc);
|
|
|
|
|
if (sc->tulip_txinfo.ri_free < sc->tulip_txinfo.ri_max) {
|
|
|
|
|
tulip_tx_intr(sc);
|
|
|
|
|
tulip_start(&sc->tulip_if);
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-03-21 22:41:19 +00:00
|
|
|
|
return (progress);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static void
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_delay_300ns(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
|
|
|
|
TULIP_READ_CSR(sc, csr_busmode); TULIP_READ_CSR(sc, csr_busmode);
|
1995-04-09 04:46:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#define EMIT do { TULIP_WRITE_CSR(sc, csr_srom_mii, csr); tulip_delay_300ns(sc); } while (0)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static void
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_idle_srom(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned bit, csr;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
|
|
|
|
csr = SROMSEL | SROMRD; EMIT;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
csr ^= SROMCS; EMIT;
|
|
|
|
|
csr ^= SROMCLKON; EMIT;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Write 25 cycles of 0 which will force the SROM to be idle.
|
|
|
|
|
*/
|
|
|
|
|
for (bit = 3 + SROM_BITWIDTH + 16; bit > 0; bit--) {
|
|
|
|
|
csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
|
|
|
|
|
csr ^= SROMCLKON; EMIT; /* clock high; data valid */
|
|
|
|
|
}
|
|
|
|
|
csr ^= SROMCLKOFF; EMIT;
|
|
|
|
|
csr ^= SROMCS; EMIT; EMIT;
|
|
|
|
|
csr = 0; EMIT;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static void
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_read_srom(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1995-05-30 08:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
int idx;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
const unsigned bitwidth = SROM_BITWIDTH;
|
|
|
|
|
const unsigned cmdmask = (SROMCMD_RD << bitwidth);
|
|
|
|
|
const unsigned msb = 1 << (bitwidth + 3 - 1);
|
|
|
|
|
unsigned lastidx = (1 << bitwidth) - 1;
|
|
|
|
|
|
|
|
|
|
tulip_idle_srom(sc);
|
|
|
|
|
|
|
|
|
|
for (idx = 0; idx <= lastidx; idx++) {
|
|
|
|
|
unsigned lastbit, data, bits, bit, csr;
|
|
|
|
|
csr = SROMSEL | SROMRD; EMIT;
|
|
|
|
|
csr ^= SROMCSON; EMIT;
|
|
|
|
|
csr ^= SROMCLKON; EMIT;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
lastbit = 0;
|
|
|
|
|
for (bits = idx|cmdmask, bit = bitwidth + 3; bit > 0; bit--, bits <<= 1) {
|
|
|
|
|
const unsigned thisbit = bits & msb;
|
|
|
|
|
csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
|
|
|
|
|
if (thisbit != lastbit) {
|
|
|
|
|
csr ^= SROMDOUT; EMIT; /* clock low; invert data */
|
|
|
|
|
}
|
|
|
|
|
csr ^= SROMCLKON; EMIT; /* clock high; data valid */
|
|
|
|
|
lastbit = thisbit;
|
|
|
|
|
}
|
|
|
|
|
csr ^= SROMCLKOFF; EMIT;
|
|
|
|
|
|
|
|
|
|
for (data = 0, bits = 0; bits < 16; bits++) {
|
|
|
|
|
data <<= 1;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
csr ^= SROMCLKON; EMIT; /* clock high; data valid */
|
1995-05-26 02:02:44 +00:00
|
|
|
|
data |= TULIP_READ_CSR(sc, csr_srom_mii) & SROMDIN ? 1 : 0;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
|
|
|
|
|
}
|
|
|
|
|
sc->tulip_rombuf[idx*2] = data & 0xFF;
|
|
|
|
|
sc->tulip_rombuf[idx*2+1] = data >> 8;
|
|
|
|
|
csr = SROMSEL | SROMRD; EMIT;
|
|
|
|
|
csr = 0; EMIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-04-13 04:46:40 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#define tulip_mchash(mca) (tulip_crc32(mca, 6) & 0x1FF)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
#define tulip_srom_crcok(databuf) ( \
|
|
|
|
|
(tulip_crc32(databuf, 126) & 0xFFFF) == \
|
|
|
|
|
((databuf)[126] | ((databuf)[127] << 8)))
|
|
|
|
|
|
|
|
|
|
static unsigned
|
|
|
|
|
tulip_crc32(
|
|
|
|
|
const unsigned char *databuf,
|
|
|
|
|
size_t datalen)
|
|
|
|
|
{
|
|
|
|
|
u_int idx, bit, data, crc = 0xFFFFFFFFUL;
|
|
|
|
|
|
|
|
|
|
for (idx = 0; idx < datalen; idx++)
|
|
|
|
|
for (data = *databuf++, bit = 0; bit < 8; bit++, data >>= 1)
|
|
|
|
|
crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0);
|
|
|
|
|
return crc;
|
|
|
|
|
}
|
|
|
|
|
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
/*
|
|
|
|
|
* This is the standard method of reading the DEC Address ROMS.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
tulip_read_macaddr(
|
|
|
|
|
tulip_softc_t *sc)
|
|
|
|
|
{
|
|
|
|
|
int cksum, rom_cksum, idx;
|
|
|
|
|
tulip_sint32_t csr;
|
|
|
|
|
unsigned char tmpbuf[8];
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static const u_char testpat[] = { 0xFF, 0, 0x55, 0xAA, 0xFF, 0, 0x55, 0xAA };
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (sc->tulip_chipid == TULIP_DC21040) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
TULIP_WRITE_CSR(sc, csr_enetrom, 1);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
sc->tulip_boardsw = &tulip_dc21040_boardsw;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
for (idx = 0; idx < 32; idx++) {
|
|
|
|
|
int cnt = 0;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
while ((csr = TULIP_READ_CSR(sc, csr_enetrom)) < 0 && cnt < 10000)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
cnt++;
|
|
|
|
|
sc->tulip_rombuf[idx] = csr & 0xFF;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
1995-04-13 04:46:40 +00:00
|
|
|
|
/*
|
|
|
|
|
* Assume all DC21140 board are compatible with the
|
|
|
|
|
* DEC 10/100 evaluation board. Not really valid but ...
|
|
|
|
|
*/
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (sc->tulip_chipid == TULIP_DC21140)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
sc->tulip_boardsw = &tulip_dc21140_eb_boardsw;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
tulip_read_srom(sc);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
if (tulip_srom_crcok(sc->tulip_rombuf)) {
|
|
|
|
|
/*
|
|
|
|
|
* New SROM format. Copy out the Ethernet address.
|
|
|
|
|
* If it contains a DE500-XA string, then it must be
|
|
|
|
|
* a DE500-XA.
|
|
|
|
|
*/
|
|
|
|
|
bcopy(sc->tulip_rombuf + 20, sc->tulip_hwaddr, 6);
|
|
|
|
|
if (bcmp(sc->tulip_rombuf + 29, "DE500-XA", 8) == 0)
|
|
|
|
|
sc->tulip_boardsw = &tulip_dc21140_de500_boardsw;
|
|
|
|
|
if (sc->tulip_boardsw == NULL)
|
|
|
|
|
return -6;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
|
1994-11-22 09:47:31 +00:00
|
|
|
|
if (bcmp(&sc->tulip_rombuf[0], &sc->tulip_rombuf[16], 8) != 0) {
|
|
|
|
|
/*
|
|
|
|
|
* Some folks don't use the standard ethernet rom format
|
|
|
|
|
* but instead just put the address in the first 6 bytes
|
|
|
|
|
* of the rom and let the rest be all 0xffs. (Can we say
|
|
|
|
|
* ZNYX???)
|
|
|
|
|
*/
|
|
|
|
|
for (idx = 6; idx < 32; idx++) {
|
|
|
|
|
if (sc->tulip_rombuf[idx] != 0xFF)
|
|
|
|
|
return -4;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Make sure the address is not multicast or locally assigned
|
|
|
|
|
* that the OUI is not 00-00-00.
|
|
|
|
|
*/
|
|
|
|
|
if ((sc->tulip_rombuf[0] & 3) != 0)
|
|
|
|
|
return -4;
|
|
|
|
|
if (sc->tulip_rombuf[0] == 0 && sc->tulip_rombuf[1] == 0
|
|
|
|
|
&& sc->tulip_rombuf[2] == 0)
|
|
|
|
|
return -4;
|
|
|
|
|
bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if (bcmp(&sc->tulip_rombuf[24], testpat, 8) != 0)
|
|
|
|
|
return -3;
|
|
|
|
|
|
|
|
|
|
tmpbuf[0] = sc->tulip_rombuf[15]; tmpbuf[1] = sc->tulip_rombuf[14];
|
|
|
|
|
tmpbuf[2] = sc->tulip_rombuf[13]; tmpbuf[3] = sc->tulip_rombuf[12];
|
|
|
|
|
tmpbuf[4] = sc->tulip_rombuf[11]; tmpbuf[5] = sc->tulip_rombuf[10];
|
|
|
|
|
tmpbuf[6] = sc->tulip_rombuf[9]; tmpbuf[7] = sc->tulip_rombuf[8];
|
|
|
|
|
if (bcmp(&sc->tulip_rombuf[0], tmpbuf, 8) != 0)
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6);
|
|
|
|
|
|
|
|
|
|
cksum = *(u_short *) &sc->tulip_hwaddr[0];
|
|
|
|
|
cksum *= 2;
|
|
|
|
|
if (cksum > 65535) cksum -= 65535;
|
|
|
|
|
cksum += *(u_short *) &sc->tulip_hwaddr[2];
|
|
|
|
|
if (cksum > 65535) cksum -= 65535;
|
|
|
|
|
cksum *= 2;
|
|
|
|
|
if (cksum > 65535) cksum -= 65535;
|
|
|
|
|
cksum += *(u_short *) &sc->tulip_hwaddr[4];
|
|
|
|
|
if (cksum >= 65535) cksum -= 65535;
|
|
|
|
|
|
|
|
|
|
rom_cksum = *(u_short *) &sc->tulip_rombuf[6];
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
if (cksum != rom_cksum)
|
|
|
|
|
return -1;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
|
|
|
|
if (sc->tulip_chipid == TULIP_DC21140) {
|
|
|
|
|
if (sc->tulip_hwaddr[0] == TULIP_OUI_COGENT_0
|
|
|
|
|
&& sc->tulip_hwaddr[1] == TULIP_OUI_COGENT_1
|
|
|
|
|
&& sc->tulip_hwaddr[2] == TULIP_OUI_COGENT_2) {
|
|
|
|
|
if (sc->tulip_rombuf[32] == TULIP_COGENT_EM100_ID)
|
|
|
|
|
sc->tulip_boardsw = &tulip_dc21140_cogent_em100_boardsw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_addr_filter(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
tulip_uint32_t *sp = sc->tulip_setupdata;
|
|
|
|
|
struct ether_multistep step;
|
|
|
|
|
struct ether_multi *enm;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
sc->tulip_flags &= ~TULIP_WANTHASH;
|
|
|
|
|
sc->tulip_flags |= TULIP_WANTSETUP;
|
|
|
|
|
sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
|
|
|
|
|
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
|
|
|
|
|
if (sc->tulip_ac.ac_multicnt > 14) {
|
|
|
|
|
unsigned hash;
|
|
|
|
|
/*
|
|
|
|
|
* If we have more than 14 multicasts, we have
|
|
|
|
|
* go into hash perfect mode (512 bit multicast
|
|
|
|
|
* hash and one perfect hardware).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
|
|
|
|
|
hash = tulip_mchash(etherbroadcastaddr);
|
|
|
|
|
sp[hash >> 4] |= 1 << (hash & 0xF);
|
|
|
|
|
ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm);
|
|
|
|
|
while (enm != NULL) {
|
|
|
|
|
hash = tulip_mchash(enm->enm_addrlo);
|
|
|
|
|
sp[hash >> 4] |= 1 << (hash & 0xF);
|
|
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
sc->tulip_flags |= TULIP_WANTHASH;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
sp[39] = ((u_short *) sc->tulip_ac.ac_enaddr)[0];
|
|
|
|
|
sp[40] = ((u_short *) sc->tulip_ac.ac_enaddr)[1];
|
1995-04-09 04:46:15 +00:00
|
|
|
|
sp[41] = ((u_short *) sc->tulip_ac.ac_enaddr)[2];
|
1994-10-01 20:16:47 +00:00
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Else can get perfect filtering for 16 addresses.
|
|
|
|
|
*/
|
|
|
|
|
i = 0;
|
|
|
|
|
ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm);
|
|
|
|
|
for (; enm != NULL; i++) {
|
1995-05-30 08:16:23 +00:00
|
|
|
|
*sp++ = ((u_short *) enm->enm_addrlo)[0];
|
|
|
|
|
*sp++ = ((u_short *) enm->enm_addrlo)[1];
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*sp++ = ((u_short *) enm->enm_addrlo)[2];
|
|
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* If an IP address is enabled, turn on broadcast
|
|
|
|
|
*/
|
|
|
|
|
if (sc->tulip_ac.ac_ipaddr.s_addr != 0) {
|
|
|
|
|
i++;
|
|
|
|
|
*sp++ = 0xFFFF;
|
|
|
|
|
*sp++ = 0xFFFF;
|
|
|
|
|
*sp++ = 0xFFFF;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Pad the rest with our hardware address
|
|
|
|
|
*/
|
|
|
|
|
for (; i < 16; i++) {
|
1995-05-30 08:16:23 +00:00
|
|
|
|
*sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[0];
|
|
|
|
|
*sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[1];
|
1994-10-01 20:16:47 +00:00
|
|
|
|
*sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[2];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-02 13:12:18 +00:00
|
|
|
|
/*extern void arp_ifinit(struct arpcom *, struct ifaddr*);*/
|
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
static int
|
|
|
|
|
tulip_ioctl(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
struct ifnet * const ifp,
|
|
|
|
|
ioctl_cmd_t cmd,
|
1994-10-01 20:16:47 +00:00
|
|
|
|
caddr_t data)
|
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit);
|
1994-11-13 12:39:38 +00:00
|
|
|
|
struct ifaddr *ifa = (struct ifaddr *)data;
|
|
|
|
|
struct ifreq *ifr = (struct ifreq *) data;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
int s, error = 0;
|
|
|
|
|
|
|
|
|
|
s = splimp();
|
|
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case SIOCSIFADDR: {
|
|
|
|
|
|
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
switch(ifa->ifa_addr->sa_family) {
|
|
|
|
|
#ifdef INET
|
|
|
|
|
case AF_INET: {
|
|
|
|
|
((struct arpcom *)ifp)->ac_ipaddr = IA_SIN(ifa)->sin_addr;
|
1994-11-22 09:47:31 +00:00
|
|
|
|
tulip_addr_filter(sc); /* reset multicast filtering */
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_init(sc);
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
1994-12-22 21:56:22 +00:00
|
|
|
|
arp_ifinit((struct arpcom *)ifp, ifa);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#elif defined(__bsdi__)
|
1995-05-05 20:09:51 +00:00
|
|
|
|
arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif /* INET */
|
|
|
|
|
|
|
|
|
|
#ifdef NS
|
1995-05-26 02:02:44 +00:00
|
|
|
|
/*
|
|
|
|
|
* This magic copied from if_is.c; I don't use XNS,
|
1994-10-01 20:16:47 +00:00
|
|
|
|
* so I have no way of telling if this actually
|
|
|
|
|
* works or not.
|
|
|
|
|
*/
|
|
|
|
|
case AF_NS: {
|
|
|
|
|
struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
|
|
|
|
|
if (ns_nullhost(*ina)) {
|
|
|
|
|
ina->x_host = *(union ns_host *)(sc->tulip_ac.ac_enaddr);
|
|
|
|
|
} else {
|
|
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
|
|
|
bcopy((caddr_t)ina->x_host.c_host,
|
|
|
|
|
(caddr_t)sc->tulip_ac.ac_enaddr,
|
|
|
|
|
sizeof sc->tulip_ac.ac_enaddr);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_init(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif /* NS */
|
|
|
|
|
|
|
|
|
|
default: {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_init(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case SIOCSIFFLAGS: {
|
|
|
|
|
/*
|
|
|
|
|
* Changing the connection forces a reset.
|
|
|
|
|
*/
|
|
|
|
|
if (sc->tulip_flags & TULIP_ALTPHYS) {
|
|
|
|
|
if ((ifp->if_flags & IFF_ALTPHYS) == 0)
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (ifp->if_flags & IFF_ALTPHYS)
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_init(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case SIOCADDMULTI:
|
|
|
|
|
case SIOCDELMULTI: {
|
|
|
|
|
/*
|
|
|
|
|
* Update multicast listeners
|
|
|
|
|
*/
|
|
|
|
|
if (cmd == SIOCADDMULTI)
|
1994-11-13 12:39:38 +00:00
|
|
|
|
error = ether_addmulti(ifr, &sc->tulip_ac);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
else
|
1994-11-13 12:39:38 +00:00
|
|
|
|
error = ether_delmulti(ifr, &sc->tulip_ac);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
if (error == ENETRESET) {
|
|
|
|
|
tulip_addr_filter(sc); /* reset multicast filtering */
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_init(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
error = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(SIOCSIFMTU)
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if !defined(ifr_mtu)
|
|
|
|
|
#define ifr_mtu ifr_metric
|
|
|
|
|
#endif
|
1994-11-13 12:39:38 +00:00
|
|
|
|
case SIOCSIFMTU:
|
|
|
|
|
/*
|
|
|
|
|
* Set the interface MTU.
|
|
|
|
|
*/
|
|
|
|
|
if (ifr->ifr_mtu > ETHERMTU) {
|
|
|
|
|
error = EINVAL;
|
|
|
|
|
} else {
|
|
|
|
|
ifp->if_mtu = ifr->ifr_mtu;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
default: {
|
|
|
|
|
error = EINVAL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_attach(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
struct ifnet * const ifp = &sc->tulip_if;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-04-13 04:46:40 +00:00
|
|
|
|
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
ifp->if_ioctl = tulip_ioctl;
|
|
|
|
|
ifp->if_output = ether_output;
|
|
|
|
|
ifp->if_start = tulip_start;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#ifdef __FreeBSD__
|
1995-05-05 20:09:51 +00:00
|
|
|
|
printf("%s%d", sc->tulip_name, sc->tulip_unit);
|
|
|
|
|
#endif
|
1995-05-30 08:16:23 +00:00
|
|
|
|
printf(": %s%s pass %d.%d Ethernet address %s\n",
|
1995-04-13 04:46:40 +00:00
|
|
|
|
sc->tulip_boardsw->bd_description,
|
1995-05-05 20:09:51 +00:00
|
|
|
|
tulip_chipdescs[sc->tulip_chipid],
|
1994-10-01 20:16:47 +00:00
|
|
|
|
(sc->tulip_revinfo & 0xF0) >> 4,
|
|
|
|
|
sc->tulip_revinfo & 0x0F,
|
|
|
|
|
ether_sprintf(sc->tulip_hwaddr));
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if ((*sc->tulip_boardsw->bd_media_probe)(sc)) {
|
|
|
|
|
ifp->if_flags |= IFF_ALTPHYS;
|
|
|
|
|
} else {
|
|
|
|
|
sc->tulip_flags |= TULIP_ALTPHYS;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
1994-11-09 15:12:44 +00:00
|
|
|
|
if_attach(ifp);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
ether_ifattach(ifp);
|
|
|
|
|
#endif
|
1994-11-09 15:12:44 +00:00
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
|
bpfattach(&sc->tulip_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_initcsrs(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc,
|
1994-10-01 20:16:47 +00:00
|
|
|
|
volatile tulip_uint32_t *va_csrs,
|
|
|
|
|
size_t csr_size)
|
|
|
|
|
{
|
|
|
|
|
sc->tulip_csrs.csr_busmode = va_csrs + 0 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_txpoll = va_csrs + 1 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_rxpoll = va_csrs + 2 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_rxlist = va_csrs + 3 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_txlist = va_csrs + 4 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_status = va_csrs + 5 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_command = va_csrs + 6 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_intr = va_csrs + 7 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_missed_frame = va_csrs + 8 * csr_size;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (sc->tulip_chipid == TULIP_DC21040) {
|
|
|
|
|
sc->tulip_csrs.csr_enetrom = (tulip_sint32_t *) va_csrs + 9 * csr_size;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
sc->tulip_csrs.csr_reserved = va_csrs + 10 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_full_duplex = va_csrs + 11 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_sia_status = va_csrs + 12 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_sia_connectivity = va_csrs + 13 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_sia_tx_rx = va_csrs + 14 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_sia_general = va_csrs + 15 * csr_size;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
} else if (sc->tulip_chipid == TULIP_DC21140 || sc->tulip_chipid == TULIP_DC21041) {
|
|
|
|
|
sc->tulip_csrs.csr_srom_mii = va_csrs + 9 * csr_size;
|
1995-04-09 04:46:15 +00:00
|
|
|
|
sc->tulip_csrs.csr_gp_timer = va_csrs + 11 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_gp = va_csrs + 12 * csr_size;
|
|
|
|
|
sc->tulip_csrs.csr_watchdog = va_csrs + 15 * csr_size;
|
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_initring(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc,
|
|
|
|
|
tulip_ringinfo_t * const ri,
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_desc_t *descs,
|
|
|
|
|
int ndescs)
|
|
|
|
|
{
|
|
|
|
|
ri->ri_max = ndescs;
|
|
|
|
|
ri->ri_first = descs;
|
|
|
|
|
ri->ri_last = ri->ri_first + ri->ri_max;
|
|
|
|
|
bzero((caddr_t) ri->ri_first, sizeof(ri->ri_first[0]) * ri->ri_max);
|
|
|
|
|
ri->ri_last[-1].d_flag = TULIP_DFLAG_ENDRING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This is the PCI configuration support. Since the DC21040 is available
|
|
|
|
|
* on both EISA and PCI boards, one must be careful in how defines the
|
|
|
|
|
* DC21040 in the config file.
|
|
|
|
|
*/
|
1995-02-02 13:12:18 +00:00
|
|
|
|
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#define PCI_CFID 0x00 /* Configuration ID */
|
|
|
|
|
#define PCI_CFCS 0x04 /* Configurtion Command/Status */
|
|
|
|
|
#define PCI_CFRV 0x08 /* Configuration Revision */
|
|
|
|
|
#define PCI_CFLT 0x0c /* Configuration Latency Timer */
|
|
|
|
|
#define PCI_CBIO 0x10 /* Configuration Base IO Address */
|
|
|
|
|
#define PCI_CBMA 0x14 /* Configuration Base Memory Address */
|
|
|
|
|
#define PCI_CFIT 0x3c /* Configuration Interrupt */
|
|
|
|
|
#define PCI_CFDA 0x40 /* Configuration Driver Area */
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__alpha__)
|
|
|
|
|
#define TULIP_PCI_CSRSIZE (256 / sizeof(tulip_uint32_t))
|
|
|
|
|
#define TULIP_PCI_CSROFFSET (24 / sizeof(tulip_uint32_t))
|
|
|
|
|
#elif defined(__i386__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#define TULIP_PCI_CSRSIZE (8 / sizeof(tulip_uint32_t))
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#define TULIP_PCI_CSROFFSET 0
|
|
|
|
|
#endif
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
|
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
|
|
|
|
|
|
#define TULIP_PCI_ATTACH_ARGS pcici_t config_id, int unit
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_pci_shutdown(
|
1995-05-26 02:02:44 +00:00
|
|
|
|
struct kern_devconf * const kdc,
|
1995-05-05 20:09:51 +00:00
|
|
|
|
int force)
|
|
|
|
|
{
|
|
|
|
|
if (kdc->kdc_unit < NDE) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(kdc->kdc_unit);
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at
|
1995-05-05 20:09:51 +00:00
|
|
|
|
33MHz that comes to two microseconds but wait a
|
|
|
|
|
bit longer anyways) */
|
|
|
|
|
}
|
|
|
|
|
(void) dev_detach(kdc);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-12 02:33:23 +00:00
|
|
|
|
static char*
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_pci_probe(
|
1994-10-12 02:33:23 +00:00
|
|
|
|
pcici_t config_id,
|
|
|
|
|
pcidi_t device_id)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (device_id == 0x00021011ul)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
return "Digital DC21040 Ethernet";
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (device_id == 0x00141011ul)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
return "Digital DC21041 Ethernet";
|
1995-05-05 20:09:51 +00:00
|
|
|
|
if (device_id == 0x00091011ul)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
return "Digital DC21140 Fast Ethernet";
|
1994-10-12 11:19:36 +00:00
|
|
|
|
return NULL;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
static void tulip_pci_attach(TULIP_PCI_ATTACH_ARGS);
|
|
|
|
|
static u_long tulip_pci_count;
|
|
|
|
|
|
|
|
|
|
struct pci_device dedevice = {
|
|
|
|
|
"de",
|
|
|
|
|
tulip_pci_probe,
|
|
|
|
|
tulip_pci_attach,
|
|
|
|
|
&tulip_pci_count,
|
|
|
|
|
tulip_pci_shutdown,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DATA_SET (pcidevice_set, dedevice);
|
|
|
|
|
#endif /* __FreeBSD__ */
|
|
|
|
|
|
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
#define TULIP_PCI_ATTACH_ARGS struct device *parent, struct device *self, void *aux
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tulip_pci_shutdown(
|
|
|
|
|
void *arg)
|
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = (tulip_softc_t *) arg;
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at
|
1995-05-05 20:09:51 +00:00
|
|
|
|
33MHz that comes to two microseconds but wait a
|
|
|
|
|
bit longer anyways) */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_pci_match(
|
|
|
|
|
pci_devaddr_t *pa)
|
|
|
|
|
{
|
|
|
|
|
int irq;
|
|
|
|
|
unsigned id;
|
|
|
|
|
|
|
|
|
|
id = pci_inl(pa, PCI_VENDOR_ID);
|
|
|
|
|
if ((id & 0xFFFF) != 0x1011)
|
|
|
|
|
return 0;
|
|
|
|
|
id >>= 16;
|
|
|
|
|
if (id != 2 && id != 9 && id != 0x14)
|
|
|
|
|
return 0;
|
|
|
|
|
irq = pci_inl(pa, PCI_I_PIN) & 0xFF;
|
|
|
|
|
if (irq == 0 || irq >= 16)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
static int
|
1995-05-05 20:09:51 +00:00
|
|
|
|
tulip_pci_probe(
|
|
|
|
|
struct device *parent,
|
|
|
|
|
struct cfdata *cf,
|
|
|
|
|
void *aux)
|
|
|
|
|
{
|
1995-05-26 02:02:44 +00:00
|
|
|
|
struct isa_attach_args * const ia = (struct isa_attach_args *) aux;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
unsigned irq;
|
|
|
|
|
pci_devaddr_t *pa;
|
|
|
|
|
|
|
|
|
|
pa = pci_scan(tulip_pci_match);
|
|
|
|
|
if (pa == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
irq = (1 << (pci_inl(pa, PCI_I_PIN) & 0xFF));
|
|
|
|
|
|
|
|
|
|
if (ia->ia_irq != IRQUNK && irq != ia->ia_irq) {
|
|
|
|
|
printf("fpa%d: error: desired IRQ of %d does not match device's actual IRQ of %d,\n",
|
|
|
|
|
cf->cf_unit,
|
|
|
|
|
ffs(ia->ia_irq) - 1, ffs(irq) - 1);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (ia->ia_irq == IRQUNK) {
|
|
|
|
|
if ((irq = isa_irqalloc(irq)) == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
ia->ia_irq = irq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* PCI bus masters don't use host DMA channels */
|
|
|
|
|
ia->ia_drq = DRQNONE;
|
|
|
|
|
|
|
|
|
|
/* Get the memory base address; assume the BIOS set it up correctly */
|
|
|
|
|
ia->ia_maddr = (caddr_t) (pci_inl(pa, PCI_CBMA) & ~7);
|
|
|
|
|
pci_outl(pa, PCI_CBMA, 0xFFFFFFFF);
|
|
|
|
|
ia->ia_msize = ((~pci_inl(pa, PCI_CBMA)) | 7) + 1;
|
|
|
|
|
pci_outl(pa, PCI_CBMA, (int) ia->ia_maddr);
|
|
|
|
|
|
|
|
|
|
/* Disable I/O space access */
|
|
|
|
|
pci_outl(pa, PCI_COMMAND, pci_inl(pa, PCI_COMMAND) & ~1);
|
|
|
|
|
ia->ia_iobase = 0;
|
|
|
|
|
ia->ia_iosize = 0;
|
|
|
|
|
|
|
|
|
|
ia->ia_aux = (void *) pa;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void tulip_pci_attach(TULIP_PCI_ATTACH_ARGS);
|
|
|
|
|
|
|
|
|
|
struct cfdriver decd = {
|
|
|
|
|
0, "de", tulip_pci_probe, tulip_pci_attach, DV_IFNET, sizeof(tulip_softc_t)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* __bsdi__ */
|
1995-05-26 02:02:44 +00:00
|
|
|
|
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
#define TULIP_PCI_ATTACH_ARGS struct device *parent, struct device *self, void *aux
|
|
|
|
|
|
|
|
|
|
#if 0 /* XXX! */
|
|
|
|
|
static void
|
|
|
|
|
tulip_pci_shutdown(
|
|
|
|
|
void *arg)
|
|
|
|
|
{
|
|
|
|
|
tulip_softc_t * const sc = (tulip_softc_t *) arg;
|
|
|
|
|
TULIP_WRITE_CSR(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at
|
1995-05-26 02:02:44 +00:00
|
|
|
|
33MHz that comes to two microseconds but wait a
|
|
|
|
|
bit longer anyways) */
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tulip_pci_probe(
|
|
|
|
|
struct device *parent,
|
|
|
|
|
void *match,
|
|
|
|
|
void *aux)
|
|
|
|
|
{
|
|
|
|
|
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
|
|
|
|
|
|
|
|
|
|
if (pa->pa_id == 0x00021011ul
|
|
|
|
|
|| pa->pa_id == 0x00141011ul
|
|
|
|
|
|| pa->pa_id == 0x00091011ul)
|
|
|
|
|
return 1;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
1995-05-26 02:02:44 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void tulip_pci_attach(TULIP_PCI_ATTACH_ARGS);
|
|
|
|
|
|
|
|
|
|
struct cfdriver decd = {
|
|
|
|
|
0, "de", tulip_pci_probe, tulip_pci_attach, DV_IFNET, sizeof(tulip_softc_t)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* __NetBSD__ */
|
|
|
|
|
|
1994-10-12 02:33:23 +00:00
|
|
|
|
static void
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_pci_attach(
|
1995-05-05 20:09:51 +00:00
|
|
|
|
TULIP_PCI_ATTACH_ARGS)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
{
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_softc_t *sc;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__bsdi__)
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_softc_t * const sc = (tulip_softc_t *) self;
|
|
|
|
|
struct isa_attach_args * const ia = (struct isa_attach_args *) aux;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
pci_devaddr_t *pa = (pci_devaddr_t *) ia->ia_aux;
|
|
|
|
|
int unit = sc->tulip_dev.dv_unit;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
tulip_softc_t * const sc = (tulip_softc_t *) self;
|
|
|
|
|
struct pci_attach_args * const pa = (struct pci_attach_args *) aux;
|
|
|
|
|
int unit = sc->tulip_dev.dv_unit;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
int retval, idx, revinfo, id;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
vm_offset_t va_csrs, pa_csrs;
|
|
|
|
|
tulip_desc_t *rxdescs, *txdescs;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
tulip_chipid_t chipid;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1995-04-09 04:46:15 +00:00
|
|
|
|
if (unit >= NDE) {
|
|
|
|
|
printf("de%d: not configured; kernel is built for only %d device%s.\n",
|
|
|
|
|
unit, NDE, NDE == 1 ? "" : "s");
|
|
|
|
|
return;
|
|
|
|
|
}
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1995-04-09 04:46:15 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1995-04-13 04:46:40 +00:00
|
|
|
|
revinfo = pci_conf_read(config_id, PCI_CFRV) & 0xFF;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
id = pci_conf_read(config_id, PCI_CFID);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
revinfo = pci_inl(pa, PCI_CFRV) & 0xFF;
|
|
|
|
|
id = pci_inl(pa, PCI_CFID);
|
|
|
|
|
#endif
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
revinfo = pci_conf_read(pa->pa_tag, PCI_CFRV) & 0xFF;
|
|
|
|
|
id = pa->pa_id;
|
|
|
|
|
#endif
|
1995-05-05 20:09:51 +00:00
|
|
|
|
|
|
|
|
|
if (id == 0x00021011ul) chipid = TULIP_DC21040;
|
|
|
|
|
else if (id == 0x00091011) chipid = TULIP_DC21140;
|
|
|
|
|
else if (id == 0x00141011) chipid = TULIP_DC21041;
|
|
|
|
|
else return;
|
|
|
|
|
|
|
|
|
|
if (chipid == TULIP_DC21040 && revinfo < 0x20) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
|
printf("de%d", unit);
|
|
|
|
|
#endif
|
|
|
|
|
printf(": not configured; DC21040 pass 2.0 required (%d.%d found)\n",
|
|
|
|
|
revinfo >> 4, revinfo & 0x0f);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
return;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
} else if (chipid == TULIP_DC21140 && revinfo < 0x11) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
|
printf("de%d", unit);
|
|
|
|
|
#endif
|
|
|
|
|
printf(": not configured; DC21140 pass 1.1 required (%d.%d found)\n",
|
|
|
|
|
revinfo >> 4, revinfo & 0x0f);
|
1995-04-13 04:46:40 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc = (tulip_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
|
|
|
|
|
if (sc == NULL)
|
1994-10-12 02:33:23 +00:00
|
|
|
|
return;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
bzero(sc, sizeof(*sc)); /* Zero out the softc*/
|
|
|
|
|
#endif
|
1994-10-01 20:16:47 +00:00
|
|
|
|
|
|
|
|
|
rxdescs = (tulip_desc_t *)
|
|
|
|
|
malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT);
|
|
|
|
|
if (rxdescs == NULL) {
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
free((caddr_t) sc, M_DEVBUF);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1994-10-12 02:33:23 +00:00
|
|
|
|
return;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
txdescs = (tulip_desc_t *)
|
|
|
|
|
malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT);
|
|
|
|
|
if (txdescs == NULL) {
|
|
|
|
|
free((caddr_t) rxdescs, M_DEVBUF);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
free((caddr_t) sc, M_DEVBUF);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
1994-10-12 02:33:23 +00:00
|
|
|
|
return;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
sc->tulip_chipid = chipid;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc->tulip_unit = unit;
|
|
|
|
|
sc->tulip_name = "de";
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-10-01 20:16:47 +00:00
|
|
|
|
retval = pci_map_mem(config_id, PCI_CBMA, &va_csrs, &pa_csrs);
|
1994-10-12 02:33:23 +00:00
|
|
|
|
if (!retval) {
|
1994-10-01 20:16:47 +00:00
|
|
|
|
free((caddr_t) txdescs, M_DEVBUF);
|
|
|
|
|
free((caddr_t) rxdescs, M_DEVBUF);
|
|
|
|
|
free((caddr_t) sc, M_DEVBUF);
|
1994-10-12 02:33:23 +00:00
|
|
|
|
return;
|
1994-10-01 20:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
tulips[unit] = sc;
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
va_csrs = (vm_offset_t) mapphys((vm_offset_t) ia->ia_maddr, ia->ia_msize);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
if (pci_map_mem(pa->pa_tag, PCI_CBMA, &va_csrs, &pa_csrs)) {
|
|
|
|
|
free((caddr_t) txdescs, M_DEVBUF);
|
|
|
|
|
free((caddr_t) rxdescs, M_DEVBUF);
|
|
|
|
|
return;
|
|
|
|
|
}
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
sc->tulip_revinfo = revinfo;
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_initcsrs(sc, ((volatile tulip_uint32_t *) va_csrs) + TULIP_PCI_CSROFFSET,
|
|
|
|
|
TULIP_PCI_CSRSIZE);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_initring(sc, &sc->tulip_rxinfo, rxdescs, TULIP_RXDESCS);
|
|
|
|
|
tulip_initring(sc, &sc->tulip_txinfo, txdescs, TULIP_TXDESCS);
|
|
|
|
|
if ((retval = tulip_read_macaddr(sc)) < 0) {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
|
printf("%s%d", sc->tulip_name, sc->tulip_unit);
|
|
|
|
|
#endif
|
|
|
|
|
printf(": can't read ENET ROM (why=%d) (", retval);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
for (idx = 0; idx < 32; idx++)
|
|
|
|
|
printf("%02x", sc->tulip_rombuf[idx]);
|
|
|
|
|
printf("\n");
|
1995-04-13 04:46:40 +00:00
|
|
|
|
printf("%s%d: %s%s pass %d.%d Ethernet address %s\n",
|
1994-10-01 20:16:47 +00:00
|
|
|
|
sc->tulip_name, sc->tulip_unit,
|
1995-04-13 04:46:40 +00:00
|
|
|
|
(sc->tulip_boardsw != NULL ? sc->tulip_boardsw->bd_description : ""),
|
1995-05-05 20:09:51 +00:00
|
|
|
|
tulip_chipdescs[sc->tulip_chipid],
|
1994-10-01 20:16:47 +00:00
|
|
|
|
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F,
|
|
|
|
|
"unknown");
|
|
|
|
|
} else {
|
1995-05-26 02:02:44 +00:00
|
|
|
|
tulip_reset(sc);
|
1994-10-01 20:16:47 +00:00
|
|
|
|
tulip_attach(sc);
|
1995-05-26 02:02:44 +00:00
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
|
sc->tulip_ih = pci_map_int(pa->pa_tag, PCI_IPL_NET, tulip_intr, sc);
|
|
|
|
|
if (sc->tulip_ih == NULL) {
|
|
|
|
|
printf("%s%d: couldn't map interrupt\n",
|
|
|
|
|
sc->tulip_name, sc->tulip_unit);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#if defined(__FreeBSD__)
|
1994-11-13 12:39:38 +00:00
|
|
|
|
pci_map_int (config_id, tulip_intr, (void*) sc, &net_imask);
|
1995-05-05 20:09:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(__bsdi__)
|
|
|
|
|
isa_establish(&sc->tulip_id, &sc->tulip_dev);
|
1995-03-17 04:27:21 +00:00
|
|
|
|
|
1995-05-05 20:09:51 +00:00
|
|
|
|
sc->tulip_ih.ih_fun = tulip_intr;
|
|
|
|
|
sc->tulip_ih.ih_arg = (void *)sc;
|
|
|
|
|
intr_establish(ia->ia_irq, &sc->tulip_ih, DV_NET);
|
|
|
|
|
|
|
|
|
|
sc->tulip_ats.func = tulip_pci_shutdown;
|
|
|
|
|
sc->tulip_ats.arg = (void *) sc;
|
|
|
|
|
atshutdown(&sc->tulip_ats, ATSH_ADD);
|
|
|
|
|
#endif
|
1995-04-09 04:46:15 +00:00
|
|
|
|
}
|
1995-03-17 04:27:21 +00:00
|
|
|
|
}
|
1994-10-01 20:16:47 +00:00
|
|
|
|
#endif /* NDE > 0 */
|