Driver for DEC "Tulip" based WAN cards from LanMedia Corporation.

This driver should support both the SSI (V.35 etc) E1/T1 unchannelized,
DS3 and HSSI cards.  Only tested on the SSI card.

More info at: http://www.lanmedia.com

Thanks to LanMedia for donating two LMC1000P cards.

if_de.c driver modified by:     LanMedia
NetGraphification by:   	Stephen Kiernan <sk-ports@vegamuse.org>
This commit is contained in:
Poul-Henning Kamp 2000-04-26 20:16:56 +00:00
parent dd1863690a
commit 599fcb028d
10 changed files with 613 additions and 577 deletions

@ -408,6 +408,7 @@ options NETGRAPH_UI
options NETGRAPH_VJC
device mn # Munich32x/Falc54 Nx64kbit/sec cards.
device lmc # tulip based LanMedia WAN cards
#
# Network interfaces:

@ -169,6 +169,7 @@ dev/iicbus/iicsmb.c optional iicsmb \
dev/isp/isp.c optional isp
dev/isp/isp_freebsd.c optional isp
dev/isp/isp_target.c optional isp
dev/lmc/if_lmc.c optional lmc
dev/mca/mca_bus.c optional mca
dev/md/md.c optional md
dev/mii/amphy.c optional miibus

File diff suppressed because it is too large Load Diff

@ -1,7 +1,3 @@
/* $FreeBSD$ */
/* From NetBSD: if_de.c,v 1.56.2.1 1997/10/27 02:13:25 thorpej Exp */
/* $Id: if_lmc_common.c,v 1.12 1999/03/01 15:22:37 explorer Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* Copyright (c) LAN Media Corporation 1998, 1999.
@ -25,6 +21,10 @@
* 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.
*
* $FreeBSD$
* From NetBSD: if_de.c,v 1.56.2.1 1997/10/27 02:13:25 thorpej Exp
* $Id: if_lmc_common.c,v 1.12 1999/03/01 15:22:37 explorer Exp $
*/
/*

@ -1,9 +1,7 @@
/* $FreeBSD$ */
/* $Id: if_lmc_fbsd.c,v 1.3 1999/01/12 13:27:42 explorer Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* Copyright (c) LAN Media Corporation 1998, 1999.
* Copyright (c) 2000 Stephen Kiernan (sk-ports@vegamuse.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -24,6 +22,9 @@
* 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.
*
* $FreeBSD$
* $Id: if_lmc_fbsd.c,v 1.3 1999/01/12 13:27:42 explorer Exp $
*/
/*
@ -35,7 +36,9 @@
#define PCI_GETBUSDEVINFO(sc) (sc)->lmc_pci_busno = (config_id->bus), \
(sc)->lmc_pci_devno = (config_id->slot)
#if 0
static void lmc_shutdown(int howto, void * arg);
#endif
#if defined(LMC_DEVCONF)
static int
@ -51,7 +54,7 @@ lmc_pci_shutdown(struct kern_devconf * const kdc, int force)
}
#endif
static char*
static const char*
lmc_pci_probe(pcici_t config_id, pcidi_t device_id)
{
u_int32_t id;
@ -104,13 +107,17 @@ struct pci_device lmcdevice = {
#endif
};
DATA_SET (pcidevice_set, lmcdevice);
#ifdef COMPAT_PCI_DRIVER
COMPAT_PCI_DRIVER(ti, lmcdevice);
#else
DATA_SET(pcidevice_set, lmcdevice);
#endif /* COMPAT_PCI_DRIVER */
static void
lmc_pci_attach(pcici_t config_id, int unit)
{
lmc_softc_t *sc;
int retval, idx;
int retval;
u_int32_t revinfo, cfdainfo, id, ssid;
#if !defined(LMC_IOMAPPED)
vm_offset_t pa_csrs;
@ -119,7 +126,6 @@ lmc_pci_attach(pcici_t config_id, int unit)
unsigned csrsize = LMC_PCI_CSRSIZE;
lmc_csrptr_t csr_base;
lmc_spl_t s;
lmc_intrfunc_t (*intr_rtn)(void *) = lmc_intr_normal;
if (unit >= LMC_MAX_DEVICES) {
printf("lmc%d", unit);
@ -185,9 +191,6 @@ lmc_pci_attach(pcici_t config_id, int unit)
sc->lmc_unit = unit;
sc->lmc_name = "lmc";
sc->lmc_revinfo = revinfo;
#if BSD >= 199506
sc->lmc_if.if_softc = sc;
#endif
#if defined(LMC_IOMAPPED)
retval = pci_map_port(config_id, PCI_CBIO, &csr_base);
#else
@ -240,18 +243,20 @@ lmc_pci_attach(pcici_t config_id, int unit)
}
lmc_read_macaddr(sc);
printf("pass %d.%d, serial " LMC_EADDR_FMT "\n",
printf("lmc%d: pass %d.%d, serial " LMC_EADDR_FMT "\n", unit,
(sc->lmc_revinfo & 0xF0) >> 4, sc->lmc_revinfo & 0x0F,
LMC_EADDR_ARGS(sc->lmc_enaddr));
if (!pci_map_int (config_id, intr_rtn, (void*) sc, &net_imask)) {
if (!pci_map_int (config_id, lmc_intr_normal, (void*) sc, &net_imask)) {
printf(LMC_PRINTF_FMT ": couldn't map interrupt\n",
LMC_PRINTF_ARGS);
return;
}
#if 0
#if !defined(LMC_DEVCONF)
at_shutdown(lmc_shutdown, sc, SHUTDOWN_POST_SYNC);
#endif
#endif
s = LMC_RAISESPL();
@ -261,6 +266,7 @@ lmc_pci_attach(pcici_t config_id, int unit)
LMC_RESTORESPL(s);
}
#if 0
static void
lmc_shutdown(int howto, void * arg)
{
@ -272,3 +278,4 @@ lmc_shutdown(int howto, void * arg)
printf("lmc: 5\n");
lmc_led_on(sc, LMC_MII16_LED_ALL);
}
#endif

@ -1,9 +1,7 @@
/* $FreeBSD$ */
/* $Id: if_lmc_media.c,v 1.23 1999/03/01 15:12:24 explorer Exp $ */
/*-
/*
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* Copyright (c) LAN Media Corporation 1998, 1999.
* Copyright (c) 2000 Stephen Kiernan (sk-ports@vegamuse.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -24,6 +22,9 @@
* 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.
*
* $FreeBSD$
* $Id: if_lmc_media.c,v 1.23 1999/03/01 15:12:24 explorer Exp $
*/
/*
@ -684,24 +685,6 @@ lmc_set_protocol(lmc_softc_t * const sc, lmc_ctl_t *ctl)
return;
}
#if defined(__NetBSD__) || defined(__FreeBSD__)
if (ctl->keepalive_onoff != sc->ictl.keepalive_onoff) {
switch (ctl->keepalive_onoff) {
case LMC_CTL_ON:
printf(LMC_PRINTF_FMT ": enabling keepalive\n",
LMC_PRINTF_ARGS);
sc->ictl.keepalive_onoff = LMC_CTL_ON;
sc->lmc_sppp.pp_flags = PP_CISCO | PP_KEEPALIVE;
break;
case LMC_CTL_OFF:
printf(LMC_PRINTF_FMT ": disabling keepalive\n",
LMC_PRINTF_ARGS);
sc->ictl.keepalive_onoff = LMC_CTL_OFF;
sc->lmc_sppp.pp_flags = PP_CISCO;
}
}
#endif
}
/*
@ -718,6 +701,7 @@ static void lmc_t1_write(lmc_softc_t * const sc, int a, int d)
lmc_mii_writereg(sc, 0, 18, d);
}
#if 0
/* XXX future to be integtrated with if_lmc.c for alarms */
static int lmc_t1_read(lmc_softc_t * const sc, int a)
@ -725,6 +709,7 @@ static int lmc_t1_read(lmc_softc_t * const sc, int a)
lmc_mii_writereg(sc, 0, 17, a);
return lmc_mii_readreg(sc, 0, 18);
}
#endif
static void
lmc_t1_init(lmc_softc_t * const sc)

@ -1,6 +1,3 @@
/* $FreeBSD$ */
/* $Id: if_lmcioctl.h,v 1.9 1999/02/18 10:30:18 explorer Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* Copyright (c) LAN Media Corporation 1998, 1999.
@ -24,6 +21,9 @@
* 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.
*
* $FreeBSD$
* $Id: if_lmcioctl.h,v 1.9 1999/02/18 10:30:18 explorer Exp $
*/
/*

@ -1,10 +1,7 @@
/* $FreeBSD$ */
/* From NetBSD: if_devar.h,v 1.21 1997/10/16 22:02:32 matt Exp */
/* $Id: if_lmcvar.h,v 1.6 1999/01/12 14:16:58 explorer Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* Copyright (c) LAN Media Corporation 1998, 1999.
* Copyright (c) 2000 Stephen Kiernan (sk-ports@vegamuse.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -25,10 +22,14 @@
* 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.
*
* $FreeBSD$
* From NetBSD: if_devar.h,v 1.21 1997/10/16 22:02:32 matt Exp
* $Id: if_lmcvar.h,v 1.6 1999/01/12 14:16:58 explorer Exp $
*/
#if !defined(_DEVAR_H)
#define _DEVAR_H
#if !defined(_DEV_LMC_IF_LMCVAR_H)
#define _DEV_LMC_IF_LMCVAR_H
#define LMC_MTU 1500
#define PPP_HEADER_LEN 4
@ -50,33 +51,12 @@
#define PCI_PRODUCT_LMC_T1 0x0006
#endif
#if defined(__NetBSD__)
#include "rnd.h"
#if NRND > 0
#include <sys/rnd.h>
#endif
typedef bus_addr_t lmc_csrptr_t;
#define LMC_CSR_READ(sc, csr) \
bus_space_read_4((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr)
#define LMC_CSR_WRITE(sc, csr, val) \
bus_space_write_4((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr, (val))
#define LMC_CSR_READBYTE(sc, csr) \
bus_space_read_1((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr)
#define LMC_CSR_WRITEBYTE(sc, csr, val) \
bus_space_write_1((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr, (val))
#endif /* __NetBSD__ */
#ifdef LMC_IOMAPPED
#define LMC_EISA_CSRSIZE 16
#define LMC_EISA_CSROFFSET 0
#define LMC_PCI_CSRSIZE 8
#define LMC_PCI_CSROFFSET 0
#if !defined(__NetBSD__)
typedef u_int16_t lmc_csrptr_t;
#define LMC_CSR_READ(sc, csr) (inl((sc)->lmc_csrs.csr))
@ -84,14 +64,12 @@ typedef u_int16_t lmc_csrptr_t;
#define LMC_CSR_READBYTE(sc, csr) (inb((sc)->lmc_csrs.csr))
#define LMC_CSR_WRITEBYTE(sc, csr, val) outb((sc)->lmc_csrs.csr, val)
#endif /* __NetBSD__ */
#else /* LMC_IOMAPPED */
#define LMC_PCI_CSRSIZE 8
#define LMC_PCI_CSROFFSET 0
#if !defined(__NetBSD__)
typedef volatile u_int32_t *lmc_csrptr_t;
/*
@ -101,7 +79,6 @@ typedef volatile u_int32_t *lmc_csrptr_t;
*/
#define LMC_CSR_READ(sc, csr) (0 + *(sc)->lmc_csrs.csr)
#define LMC_CSR_WRITE(sc, csr, val) ((void)(*(sc)->lmc_csrs.csr = (val)))
#endif /* __NetBSD__ */
#endif /* LMC_IOMAPPED */
@ -257,29 +234,9 @@ typedef struct {
*
*/
struct lmc___softc {
#if defined(__bsdi__)
struct device lmc_dev; /* base device */
struct isadev lmc_id; /* ISA device */
struct intrhand lmc_ih; /* intrrupt vectoring */
struct atshutdown lmc_ats; /* shutdown hook */
struct p2pcom lmc_p2pcom; /* point-to-point common stuff */
#define lmc_if lmc_p2pcom.p2p_if /* network-visible interface */
#endif /* __bsdi__ */
#if defined(__NetBSD__)
struct device lmc_dev; /* base device */
void *lmc_ih; /* intrrupt vectoring */
void *lmc_ats; /* shutdown hook */
bus_space_tag_t lmc_bustag;
bus_space_handle_t lmc_bushandle; /* CSR region handle */
pci_chipset_tag_t lmc_pc;
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__)
struct sppp lmc_sppp;
#define lmc_if lmc_sppp.pp_if
#endif
const char *lmc_name;
int lmc_unit;
u_int8_t lmc_enaddr[6]; /* yes, a small hack... */
lmc_regfile_t lmc_csrs;
@ -312,29 +269,54 @@ struct lmc___softc {
lmc_ctl_t ictl;
LMC_XINFO lmc_xinfo;
#if defined(__NetBSD__)
struct device *lmc_pci_busno; /* needed for multiport boards */
#else
u_int8_t lmc_pci_busno; /* needed for multiport boards */
#endif
u_int8_t lmc_pci_devno; /* needed for multiport boards */
#if defined(__FreeBSD__)
tulip_desc_t *lmc_rxdescs;
tulip_desc_t *lmc_txdescs;
#else
tulip_desc_t lmc_rxdescs[LMC_RXDESCS];
tulip_desc_t lmc_txdescs[LMC_TXDESCS];
#endif
#if defined(__NetBSD__) && NRND > 0
rndsource_element_t lmc_rndsource;
#endif
u_int32_t lmc_crcSize;
char lmc_timing; /* for HSSI and SSI */
u_int16_t t1_alarm1_status;
u_int16_t t1_alarm2_status;
int lmc_running;
char lmc_nodename[NG_NODELEN + 1];
int lmc_datahooks;
node_p lmc_node;
hook_p lmc_hook;
hook_p lmc_debug_hook;
struct ifqueue lmc_xmitq_hipri;
struct ifqueue lmc_xmitq;
struct callout_handle lmc_handle;
char lmc_xmit_busy;
int lmc_out_dog;
u_long lmc_inbytes, lmc_outbytes; /* stats */
u_long lmc_lastinbytes, lmc_lastoutbytes; /* a second ago */
u_long lmc_inrate, lmc_outrate; /* highest rate seen */
u_long lmc_inlast; /* last input N secs ago */
u_long lmc_out_deficit; /* output since last input */
u_long lmc_oerrors, lmc_ierrors;
u_long lmc_opackets, lmc_ipackets;
};
#define LMC_DOG_HOLDOFF 6 /* dog holds off for 6 secs */
#define LMC_QUITE_A_WHILE 300 /* 5 MINUTES */
#define LMC_LOTS_OF_PACKETS 100
/* Node type name and type cookie */
#define NG_LMC_NODE_TYPE "lmc"
#define NG_LMC_COOKIE 956095698
/* Netgraph hooks */
#define NG_LMC_HOOK_DEBUG "debug"
#define NG_LMC_HOOK_CONTROL "control"
#define NG_LMC_HOOK_RAW "rawdata"
/* Netgraph commands understood by this node type */
enum {
NGM_LMC_SET_CTL = 1,
NGM_LMC_GET_CTL,
};
/*
@ -432,70 +414,19 @@ static const char * const lmc_status_bits[] = {
*/
#define LMC_MAX_DEVICES 32
#if defined(__FreeBSD__)
typedef void ifnet_ret_t;
typedef int ioctl_cmd_t;
static lmc_softc_t *tulips[LMC_MAX_DEVICES];
#if BSD >= 199506
#define LMC_IFP_TO_SOFTC(ifp) ((lmc_softc_t *)((ifp)->if_softc))
#if NBPFILTER > 0
#define LMC_BPF_MTAP(sc, m) bpf_mtap(&(sc)->lmc_sppp.pp_if, m)
#define LMC_BPF_TAP(sc, p, l) bpf_tap(&(sc)->lmc_sppp.pp_if, p, l)
#define LMC_BPF_ATTACH(sc) bpfattach(&(sc)->lmc_sppp.pp_if, DLT_PPP, PPP_HEADER_LEN)
#endif
#define lmc_intrfunc_t void
#define LMC_VOID_INTRFUNC
#define IFF_NOTRAILERS 0
#define CLBYTES PAGE_SIZE
#define LMC_EADDR_FMT "%6D"
#define LMC_EADDR_ARGS(addr) addr, ":"
#else
extern int bootverbose;
#define LMC_IFP_TO_SOFTC(ifp) (LMC_UNIT_TO_SOFTC((ifp)->if_unit))
#include <sys/devconf.h>
#define LMC_DEVCONF
#endif
#define LMC_UNIT_TO_SOFTC(unit) (tulips[unit])
#define LMC_BURSTSIZE(unit) pci_max_burst_len
#define loudprintf if (bootverbose) printf
#endif
#if defined(__bsdi__)
typedef int ifnet_ret_t;
typedef u_long ioctl_cmd_t;
extern struct cfdriver lmccd;
#define LMC_UNIT_TO_SOFTC(unit) ((lmc_softc_t *)lmccd.cd_devs[unit])
#define LMC_IFP_TO_SOFTC(ifp) (LMC_UNIT_TO_SOFTC((ifp)->if_unit))
#define loudprintf aprint_verbose
#define MCNT(x) (sizeof(x) / sizeof(struct ifmedia_entry))
#define lmc_unit lmc_dev.dv_unit
#define lmc_name lmc_p2pcom.p2p_if.if_name
#define LMC_BPF_MTAP(sc, m)
#define LMC_BPF_TAP(sc, p, l)
#define LMC_BPF_ATTACH(sc)
#endif /* __bsdi__ */
#if defined(__NetBSD__)
typedef void ifnet_ret_t;
typedef u_long ioctl_cmd_t;
extern struct cfattach de_ca;
extern struct cfdriver de_cd;
#define LMC_UNIT_TO_SOFTC(unit) ((lmc_softc_t *) de_cd.cd_devs[unit])
#define LMC_IFP_TO_SOFTC(ifp) ((lmc_softc_t *)((ifp)->if_softc))
#define lmc_unit lmc_dev.dv_unit
#define lmc_xname lmc_if.if_xname
#define LMC_RAISESPL() splnet()
#define LMC_RAISESOFTSPL() splsoftnet()
#define LMC_RESTORESPL(s) splx(s)
#define lmc_enaddr lmc_enaddr
#define loudprintf printf
#define LMC_PRINTF_FMT "%s"
#define LMC_PRINTF_ARGS sc->lmc_xname
#if defined(__alpha__)
/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
#define LMC_KVATOPHYS(sc, va) alpha_XXX_dmamap((vm_offset_t)(va))
#endif
#endif /* __NetBSD__ */
#ifndef LMC_PRINTF_FMT
#define LMC_PRINTF_FMT "%s%d"
@ -508,23 +439,6 @@ extern struct cfdriver de_cd;
#define LMC_BURSTSIZE(unit) 3
#endif
#ifndef lmc_unit
#define lmc_unit lmc_sppp.pp_if.if_unit
#endif
#ifndef lmc_name
#define lmc_name lmc_sppp.pp_if.if_name
#endif
#if !defined(lmc_bpf)
#if defined(__NetBSD__) || defined(__FreeBSD__)
#define lmc_bpf lmc_sppp.pp_if.if_bpf
#endif
#if defined(__bsdi__)
#define lmc_bpf lmc_if.if_bpf
#endif
#endif
#if !defined(lmc_intrfunc_t)
#define lmc_intrfunc_t int
#endif
@ -575,4 +489,4 @@ extern struct cfdriver de_cd;
typedef int lmc_spl_t;
#endif /* !defined(_DEVAR_H) */
#endif /* !defined(_DEV_LMC_IF_LMCVAR_H) */

@ -408,6 +408,7 @@ options NETGRAPH_UI
options NETGRAPH_VJC
device mn # Munich32x/Falc54 Nx64kbit/sec cards.
device lmc # tulip based LanMedia WAN cards
#
# Network interfaces:

@ -408,6 +408,7 @@ options NETGRAPH_UI
options NETGRAPH_VJC
device mn # Munich32x/Falc54 Nx64kbit/sec cards.
device lmc # tulip based LanMedia WAN cards
#
# Network interfaces: