diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 1997-09-10 08:28:43 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 1997-09-10 08:28:43 +0000 |
commit | 7ee17d6b3862934e2abfa86ded9fdde7be1133ca (patch) | |
tree | dfb678cb72706fd77e4d70fadd0027a3c1b87ce0 /sys | |
parent | f901e1c269a36d910c1f51b683c3ce6dd98ac417 (diff) |
Sync with NetBSD 970516. -moj
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/vax/if/if_de.c | 26 | ||||
-rw-r--r-- | sys/arch/vax/if/if_le.c | 44 | ||||
-rw-r--r-- | sys/arch/vax/if/if_qe.c | 207 | ||||
-rw-r--r-- | sys/arch/vax/if/if_qereg.h | 11 |
4 files changed, 218 insertions, 70 deletions
diff --git a/sys/arch/vax/if/if_de.c b/sys/arch/vax/if/if_de.c index 0984fb92d44..f9ab288aef9 100644 --- a/sys/arch/vax/if/if_de.c +++ b/sys/arch/vax/if/if_de.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_de.c,v 1.9 1997/05/28 23:10:59 niklas Exp $ */ -/* $NetBSD: if_de.c,v 1.25 1996/11/15 03:11:19 thorpej Exp $ */ +/* $OpenBSD: if_de.c,v 1.10 1997/09/10 08:28:39 maja Exp $ */ +/* $NetBSD: if_de.c,v 1.27 1997/04/19 15:02:29 ragge Exp $ */ /* * Copyright (c) 1982, 1986, 1989 Regents of the University of California. @@ -91,8 +91,8 @@ extern char all_es_snpa[], all_is_snpa[]; #include <vax/uba/ubareg.h> #include <vax/uba/ubavar.h> -#define NXMT 3 /* number of transmit buffers */ -#define NRCV 7 /* number of receive buffers (must be > 1) */ +#define NXMT 3 /* number of transmit buffers */ +#define NRCV 7 /* number of receive buffers (must be > 1) */ int dedebug = 0; @@ -145,16 +145,16 @@ int dematch __P((struct device *, void *, void *)); void deattach __P((struct device *, struct device *, void *)); int dewait __P((struct de_softc *, char *)); void deinit __P((struct de_softc *)); -int deioctl __P((struct ifnet *, u_long, caddr_t)); +int deioctl __P((struct ifnet *, u_long, caddr_t)); void dereset __P((int)); -void destart __P((struct ifnet *)); +void destart __P((struct ifnet *)); void deread __P((struct de_softc *, struct ifrw *, int)); -void derecv __P((int)); +void derecv __P((int)); void de_setaddr __P((u_char *, struct de_softc *)); void deintr __P((int)); -struct cfdriver de_cd = { +struct cfdriver de_cd = { NULL, "de", DV_IFNET }; @@ -362,7 +362,7 @@ void destart(ifp) struct ifnet *ifp; { - int len; + int len; register struct de_softc *ds = ifp->if_softc; volatile struct dedevice *addr = ds->ds_vaddr; register struct de_ring *rp; @@ -495,7 +495,7 @@ deintr(unit) * If input error just drop packet. * Otherwise purge input buffered data path and examine * packet to determine type. If can't determine length - * from type, then have to drop packet. Othewise decapsulate + * from type, then have to drop packet. Othewise decapsulate * packet based on type and pass to type specific higher-level * input routine. */ @@ -557,7 +557,7 @@ deread(ds, ifrw, len) int len; { struct ether_header *eh; - struct mbuf *m; + struct mbuf *m; /* * Deal with trailer protocol: if type is trailer type @@ -689,7 +689,7 @@ dematch(parent, match, aux) void *match, *aux; { struct uba_attach_args *ua = aux; - volatile struct dedevice *addr = (struct dedevice *)ua->ua_addr; + volatile struct dedevice *addr = (struct dedevice *)ua->ua_addr; int i; /* @@ -720,7 +720,7 @@ dematch(parent, match, aux) DELAY(50000); ua->ua_ivec = deintr; - ua->ua_reset = dereset; /* Wish to be called after ubareset */ + ua->ua_reset = dereset; /* Wish to be called after ubareset */ return 1; } diff --git a/sys/arch/vax/if/if_le.c b/sys/arch/vax/if/if_le.c index 67ab2fec5e4..2982f30160b 100644 --- a/sys/arch/vax/if/if_le.c +++ b/sys/arch/vax/if/if_le.c @@ -1,7 +1,6 @@ -/* $OpenBSD: if_le.c,v 1.2 1997/05/29 00:04:32 niklas Exp $ */ -/* $NetBSD: if_le.c,v 1.3 1996/10/13 03:34:53 christos Exp $ */ +/* $OpenBSD: if_le.c,v 1.3 1997/09/10 08:28:40 maja Exp $ */ +/* $NetBSD: if_le.c,v 1.8 1997/04/21 22:04:23 ragge Exp $ */ -#define LEDEBUG 1 /* debug-level: 0 or 1 */ /* #define LE_CHIP_IS_POKEY /* does VS2000 need this ??? */ /*- @@ -49,6 +48,7 @@ #include <sys/syslog.h> #include <sys/socket.h> #include <sys/device.h> +#include <sys/reboot.h> #include <net/if.h> @@ -69,6 +69,7 @@ #include <machine/uvax.h> #include <machine/ka410.h> #include <machine/vsbus.h> +#include <machine/rpb.h> #include <dev/ic/am7990reg.h> #define LE_NEED_BUF_CONTIG @@ -104,12 +105,15 @@ struct cfattach le_ca = { sizeof(struct le_softc), lematch, leattach }; -integrate void +hide void lewrcsr __P ((struct am7990_softc *, u_int16_t, u_int16_t)); +hide u_int16_t lerdcsr __P ((struct am7990_softc *, u_int16_t)); + +hide void lewrcsr(sc, port, val) - struct le_softc *sc; + struct am7990_softc *sc; u_int16_t port, val; { - struct lereg1 *ler1 = sc->sc_r1; + struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1; #ifdef LE_CHIP_IS_POKEY LEWREG(port, ler1->ler1_rap); @@ -120,12 +124,12 @@ lewrcsr(sc, port, val) #endif } -integrate u_int16_t +hide u_int16_t lerdcsr(sc, port) - struct le_softc *sc; + struct am7990_softc *sc; u_int16_t port; { - struct lereg1 *ler1 = sc->sc_r1; + struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1; u_int16_t val; #ifdef LE_CHIP_IS_POKEY @@ -138,6 +142,12 @@ lerdcsr(sc, port) return (val); } +integrate void +lehwinit(sc) + struct am7990_softc *sc; +{ +} + int lematch(parent, match, aux) struct device *parent; @@ -176,6 +186,10 @@ leattach(parent, self, aux) sc->sc_am7990.sc_mem = le_iomem; sc->sc_am7990.sc_addr = le_ioaddr; sc->sc_am7990.sc_memsize = LE_IOSIZE; + sc->sc_am7990.sc_wrcsr = lewrcsr; + sc->sc_am7990.sc_rdcsr = lerdcsr; + sc->sc_am7990.sc_hwinit = lehwinit; + sc->sc_am7990.sc_nocarrier = NULL; xdebug(("leattach: mem=%x, addr=%x, size=%x (%d)\n", sc->sc_am7990.sc_mem, sc->sc_am7990.sc_addr, @@ -204,12 +218,14 @@ leattach(parent, self, aux) vsbus_intr_register(ca, am7990_intr, &sc->sc_am7990); vsbus_intr_enable(ca); -} -integrate void -lehwinit(sc) - struct le_softc *sc; -{ + /* + * Register this device as boot device if we booted from it. + * This will fail if there are more than one le in a machine, + * fortunately there may be only one. + */ + if (B_TYPE(bootdev) == BDEV_LE) + booted_from = self; } #ifdef LE_CHIP_IS_POKEY diff --git a/sys/arch/vax/if/if_qe.c b/sys/arch/vax/if/if_qe.c index 9b26d02f754..0ba98510161 100644 --- a/sys/arch/vax/if/if_qe.c +++ b/sys/arch/vax/if/if_qe.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_qe.c,v 1.8 1997/05/29 00:04:32 niklas Exp $ */ -/* $NetBSD: if_qe.c,v 1.18 1996/10/13 03:34:55 christos Exp $ */ +/* $OpenBSD: if_qe.c,v 1.9 1997/09/10 08:28:41 maja Exp $ */ +/* $NetBSD: if_qe.c,v 1.22 1997/05/02 17:11:24 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. @@ -39,29 +39,29 @@ * @(#)if_qe.c 7.20 (Berkeley) 3/28/91 */ -/* from @(#)if_qe.c 1.15 (ULTRIX) 4/16/86 */ +/* from @(#)if_qe.c 1.15 (ULTRIX) 4/16/86 */ /**************************************************************** * * - * Licensed from Digital Equipment Corporation * - * Copyright (c) * - * Digital Equipment Corporation * - * Maynard, Massachusetts * - * 1985, 1986 * - * All rights reserved. * + * Licensed from Digital Equipment Corporation * + * Copyright (c) * + * Digital Equipment Corporation * + * Maynard, Massachusetts * + * 1985, 1986 * + * All rights reserved. * * * - * The Information in this software is subject to change * + * The Information in this software is subject to change * * without notice and should not be construed as a commitment * - * by Digital Equipment Corporation. Digital makes no * + * by Digital Equipment Corporation. Digital makes no * * representations about the suitability of this software for * * any purpose. It is supplied "As Is" without expressed or * - * implied warranty. * + * implied warranty. * * * - * If the Regents of the University of California or its * - * licensees modify the software in a manner creating * - * derivative copyright rights, appropriate copyright * - * legends may be placed on the derivative work in addition * - * to that set forth above. * + * If the Regents of the University of California or its * + * licensees modify the software in a manner creating * + * derivative copyright rights, appropriate copyright * + * legends may be placed on the derivative work in addition * + * to that set forth above. * * * ****************************************************************/ /* --------------------------------------------------------------------- @@ -71,7 +71,7 @@ * Rename "unused_multi" to "qunused_multi" for extending Generic * kernel to MicroVAXen. * - * 18-mar-86 -- jaw br/cvec changed to NOT use registers. + * 18-mar-86 -- jaw br/cvec changed to NOT use registers. * * 12 March 86 -- Jeff Chase * Modified to handle the new MCLGET macro @@ -80,11 +80,11 @@ * * 19 Oct 85 -- rjl * Changed the watch dog timer from 30 seconds to 3. VMS is using - * less than 1 second in their's. Also turned the printf into an + * less than 1 second in their's. Also turned the printf into an * mprintf. * * 09/16/85 -- Larry Cohen - * Add 43bsd alpha tape changes for subnet routing + * Add 43bsd alpha tape changes for subnet routing * * 1 Aug 85 -- rjl * Panic on a non-existent memory interrupt and the case where a packet @@ -93,8 +93,8 @@ * because we hang 2k input buffers on the device. * * 1 Aug 85 -- rich - * Fixed the broadcast loopback code to handle Clusters without - * wedging the system. + * Fixed the broadcast loopback code to handle Clusters without + * wedging the system. * * 27 Feb. 85 -- ejf * Return default hardware address on ioctl request. @@ -110,7 +110,7 @@ * Added watchdog timer to mask hardware bug that causes device lockup. * * 18 Dec. 84 -- rjl - * Reworked driver to use q-bus mapping routines. MicroVAX-I now does + * Reworked driver to use q-bus mapping routines. MicroVAX-I now does * copying instead of m-buf shuffleing. * A number of deficencies in the hardware/firmware were compensated * for. See comments in qestart and qerint. @@ -137,7 +137,11 @@ /* * Digital Q-BUS to NI Adapter + * supports DEQNA and DELQA in DEQNA-mode. */ + +#include "bpfilter.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -174,20 +178,32 @@ extern char all_es_snpa[], all_is_snpa[], all_l1is_snpa[], all_l2is_snpa[]; #endif +#if defined(CCITT) && defined(LLC) +#include <sys/socketvar.h> +#include <netccitt/x25.h> +#include <netccitt/pk.h> +#include <netccitt/pk_var.h> +#include <netccitt/pk_extern.h> +#endif + +#if NBPFILTER > 0 +#include <net/bpf.h> +#include <net/bpfdesc.h> +#endif + #include <machine/pte.h> #include <machine/cpu.h> -#include <machine/mtpr.h> #include <vax/if/if_qereg.h> #include <vax/if/if_uba.h> #include <vax/uba/ubareg.h> #include <vax/uba/ubavar.h> -#define NRCV 15 /* Receive descriptors */ -#define NXMT 5 /* Transmit descriptors */ +#define NRCV 15 /* Receive descriptors */ +#define NXMT 5 /* Transmit descriptors */ #define NTOT (NXMT + NRCV) -#define QETIMEOUT 2 /* transmit timeout, must be > 1 */ +#define QETIMEOUT 2 /* transmit timeout, must be > 1 */ #define QESLOWTIMEOUT 40 /* timeout when no xmits in progress */ #define MINDATA 60 @@ -205,8 +221,8 @@ struct qe_softc { #define qe_if qe_ac.ac_if /* network-visible interface */ #define qe_addr qe_ac.ac_enaddr /* hardware Ethernet address */ struct ifubinfo qe_uba; /* Q-bus resources */ - struct ifrw qe_ifr[NRCV]; /* for receive buffers; */ - struct ifxmt qe_ifw[NXMT]; /* for xmit buffers; */ + struct ifrw qe_ifr[NRCV]; /* for receive buffers; */ + struct ifxmt qe_ifw[NXMT]; /* for xmit buffers; */ struct qedevice *qe_vaddr; int qe_flags; /* software state */ #define QEF_RUNNING 0x01 @@ -216,15 +232,16 @@ struct qe_softc { int ipl; /* interrupt priority */ struct qe_ring *rringaddr; /* mapping info for rings */ struct qe_ring *tringaddr; /* "" */ - struct qe_ring rring[NRCV+1]; /* Receive ring descriptors */ - struct qe_ring tring[NXMT+1]; /* Xmit ring descriptors */ + struct qe_ring rring[NRCV+1]; /* Receive ring descriptors */ + struct qe_ring tring[NXMT+1]; /* Xmit ring descriptors */ u_char setup_pkt[16][8]; /* Setup packet */ int rindex; /* Receive index */ int tindex; /* Transmit index */ int otindex; /* Old transmit index */ int qe_intvec; /* Interrupt vector */ - struct qedevice *addr; /* device addr */ + struct qedevice *addr; /* device addr */ int setupqueued; /* setup packet queued */ + int setuplength; /* length if setup packet */ int nxmit; /* Transmits in progress */ int qe_restarts; /* timeouts */ }; @@ -253,7 +270,7 @@ struct cfattach qe_ca = { sizeof(struct qe_softc), qematch, qeattach }; -#define QEUNIT(x) minor(x) +#define QEUNIT(x) minor(x) /* * The deqna shouldn't receive more than ETHERMTU + sizeof(struct ether_header) * but will actually take in up to 2048 bytes. To guard against the receiver @@ -273,8 +290,8 @@ qematch(parent, match, aux) struct qe_softc *sc = match; struct uba_attach_args *ua = aux; struct uba_softc *ubasc = (struct uba_softc *)parent; - struct qe_ring *rp; - struct qe_ring *prp; /* physical rp */ + struct qe_ring *rp; + struct qe_ring *prp; /* physical rp */ volatile struct qedevice *addr = (struct qedevice *)ua->ua_addr; int i; @@ -370,7 +387,8 @@ qeattach(parent, self, aux) * The Deqna is cable of transmitting broadcasts, but * doesn't listen to its own. */ - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | + IFF_MULTICAST; /* * Read the address from the prom and save it. @@ -395,6 +413,10 @@ qeattach(parent, self, aux) sc->qe_uba.iff_flags = UBA_CANTWAIT; if_attach(ifp); ether_ifattach(ifp); + +#if NBPFILTER > 0 + bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); +#endif } /* @@ -444,7 +466,7 @@ qeinit(sc) sizeof(sc->setup_pkt), 0); if (i == 0) goto fail; - sc->setupaddr = UBAI_ADDR(i); + sc->setupaddr = UBAI_ADDR(i); /* * init buffers and maps */ @@ -541,7 +563,7 @@ qestart(ifp) rp = &sc->tring[index]; if( sc->setupqueued ) { buf_addr = sc->setupaddr; - len = 128; + len = sc->setuplength; rp->qe_setup = 1; sc->setupqueued = 0; } else { @@ -550,6 +572,10 @@ qestart(ifp) splx(s); return; } +#if NBPFILTER > 0 + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m); +#endif buf_addr = sc->qe_ifw[index].ifw_info; len = if_ubaput(&sc->qe_uba, &sc->qe_ifw[index], m); } @@ -769,6 +795,7 @@ qeioctl(ifp, cmd, data) { struct qe_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; + struct ifreq *ifr = (struct ifreq *)data; int s = splnet(), error = 0; switch (cmd) { @@ -805,6 +832,28 @@ qeioctl(ifp, cmd, data) } else if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_RUNNING && (sc->qe_flags & QEF_RUNNING) == 0) qerestart(sc); + else + qeinit(sc); + + break; + + case SIOCADDMULTI: + case SIOCDELMULTI: + /* + * Update our multicast list. + */ + error = (cmd == SIOCADDMULTI) ? + ether_addmulti(ifr, &sc->qe_ac): + ether_delmulti(ifr, &sc->qe_ac); + + if (error == ENETRESET) { + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + qeinit(sc); + error = 0; + } break; default: @@ -840,7 +889,7 @@ qe_setaddr(physaddr, sc) void qeinitdesc(rp, addr, len) register struct qe_ring *rp; - caddr_t addr; /* mapped address */ + caddr_t addr; /* mapped address */ int len; { /* @@ -880,12 +929,54 @@ qesetup(sc) for (i = 0; i < 6; i++) { sc->setup_pkt[i][2] = 0xff; #ifdef ISO + /* + * XXX layer violation, should use SIOCADDMULTI. + * Will definitely break with IPmulticast. + */ + sc->setup_pkt[i][3] = all_es_snpa[i]; sc->setup_pkt[i][4] = all_is_snpa[i]; sc->setup_pkt[i][5] = all_l1is_snpa[i]; sc->setup_pkt[i][6] = all_l2is_snpa[i]; #endif } + if (sc->qe_if.if_flags & IFF_PROMISC) { + sc->setuplength = QE_PROMISC; + /* XXX no IFF_ALLMULTI support in 4.4bsd */ + } else if (sc->qe_if.if_flags & IFF_ALLMULTI) { + sc->setuplength = QE_ALLMULTI; + } else { + register k; + struct ether_multi *enm; + struct ether_multistep step; + /* + * Step through our list of multicast addresses, putting them + * in the third through fourteenth address slots of the setup + * packet. (See the DEQNA manual to understand the peculiar + * layout of the bytes within the setup packet.) If we have + * too many multicast addresses, or if we have to listen to + * a range of multicast addresses, turn on reception of all + * multicasts. + */ + sc->setuplength = QE_SOMEMULTI; + i = 2; + k = 0; + ETHER_FIRST_MULTI(step, &sc->qe_ac, enm); + while (enm != NULL) { + if ((++i > 7 && k != 0) || + bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { + sc->setuplength = QE_ALLMULTI; + break; + } + if (i > 7) { + i = 1; + k = 8; + } + for (j = 0; j < 6; j++) + sc->setup_pkt[j+k][i] = enm->enm_addrlo[j]; + ETHER_NEXT_MULTI(step, enm); + } + } sc->setupqueued++; } @@ -899,8 +990,9 @@ qeread(sc, ifrw, len) struct ifrw *ifrw; int len; { + struct ifnet *ifp = (struct ifnet *)&sc->qe_if; struct ether_header *eh; - struct mbuf *m; + struct mbuf *m; /* * Deal with trailer protocol: if type is INET trailer @@ -925,9 +1017,42 @@ if (m) { *(((u_long *)m->m_data)+1), *(((u_long *)m->m_data)+2), *(((u_long *)m->m_data)+3) -); } +; } #endif +#if NBPFILTER > 0 + /* + * Check for a BPF filter; if so, hand it up. + * Note that we have to stick an extra mbuf up front, because + * bpf_mtap expects to have the ether header at the front. + * It doesn't matter that this results in an ill-formatted mbuf chain, + * since BPF just looks at the data. (It doesn't try to free the mbuf, + * tho' it will make a copy for tcpdump.) + */ + if (sc->qe_if.if_bpf) { + struct mbuf m0; + m0.m_len = sizeof (struct ether_header); + m0.m_data = (caddr_t)eh; + m0.m_next = m; + + /* Pass it up */ + bpf_mtap(sc->qe_if.if_bpf, &m0); + + /* + * Note that the interface cannot be in promiscuous mode if + * there are no BPF listeners. And if we are in promiscuous + * mode, we have to check if this packet is really ours. + */ + if ((ifp->if_flags & IFF_PROMISC) && + (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ + bcmp(eh->ether_dhost, sc->qe_addr, + sizeof(eh->ether_dhost)) != 0) { + m_freem(m); + return; + } + } +#endif /* NBPFILTER > 0 */ + if (m) ether_input((struct ifnet *)&sc->qe_if, eh, m); } diff --git a/sys/arch/vax/if/if_qereg.h b/sys/arch/vax/if/if_qereg.h index 99ed1a45657..bac037498c8 100644 --- a/sys/arch/vax/if/if_qereg.h +++ b/sys/arch/vax/if/if_qereg.h @@ -1,5 +1,5 @@ -/* $OpenBSD: if_qereg.h,v 1.2 1997/05/29 00:04:33 niklas Exp $ */ -/* $NetBSD: if_qereg.h,v 1.1 1995/03/30 20:26:41 ragge Exp $ */ +/* $OpenBSD: if_qereg.h,v 1.3 1997/09/10 08:28:42 maja Exp $ */ +/* $NetBSD: if_qereg.h,v 1.2 1997/05/15 20:10:23 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -171,3 +171,10 @@ struct qe_ring { #define QE_NOTYET 0x8000 /* Descriptor not in use yet */ #define QE_INUSE 0x4000 /* Descriptor being used by QNA */ #define QE_MASK 0xc000 /* Lastnot/error/used mask */ + +/* + * Values for the length of the setup packet that control reception filter. + */ +#define QE_SOMEMULTI 128 /* Receive up to 12 multicasts */ +#define QE_ALLMULTI 129 /* Receive all multicasts */ +#define QE_PROMISC 130 /* Receive all packets */ |