Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/qbus Copied from ../../arch/vax/if/if_qe.c, v



details:   https://anonhg.NetBSD.org/src/rev/c474340a4183
branches:  trunk
changeset: 473532:c474340a4183
user:      ragge <ragge%NetBSD.org@localhost>
date:      Sun Jun 06 19:26:44 1999 +0000

description:
Copied from ../../arch/vax/if/if_qe.c,v

diffstat:

 sys/dev/qbus/if_qe.c |  1119 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1119 insertions(+), 0 deletions(-)

diffs (truncated from 1123 to 300 lines):

diff -r b82658a18305 -r c474340a4183 sys/dev/qbus/if_qe.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/qbus/if_qe.c      Sun Jun 06 19:26:44 1999 +0000
@@ -0,0 +1,1119 @@
+/*     $NetBSD: if_qe.c,v 1.36 1999/06/06 19:26:44 ragge Exp $ */
+
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Digital Equipment Corp.
+ *
+ * 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. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)if_qe.c     7.20 (Berkeley) 3/28/91
+ */
+
+/* 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.                      *
+ *                                                             *
+ *       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 *
+ *   representations about the suitability of this software for *
+ *   any purpose.  It is supplied "As Is" without expressed  or *
+ *   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.                                  *
+ *                                                             *
+ ****************************************************************/
+/* ---------------------------------------------------------------------
+ * Modification History
+ *
+ * 15-Apr-86  -- afd
+ *     Rename "unused_multi" to "qunused_multi" for extending Generic
+ *     kernel to MicroVAXen.
+ *
+ * 18-mar-86  -- jaw    br/cvec changed to NOT use registers.
+ *
+ * 12 March 86 -- Jeff Chase
+ *     Modified to handle the new MCLGET macro
+ *     Changed if_qe_data.c to use more receive buffers
+ *     Added a flag to poke with adb to log qe_restarts on console
+ *
+ * 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
+ *     mprintf.
+ *
+ *  09/16/85 -- Larry Cohen
+ *             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
+ *     was chained.  The first should never happen because non-existant
+ *     memory interrupts cause a bus reset. The second should never happen
+ *     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.
+ *
+ *  27 Feb. 85 -- ejf
+ *     Return default hardware address on ioctl request.
+ *
+ *  12 Feb. 85 -- ejf
+ *     Added internal extended loopback capability.
+ *
+ *  27 Dec. 84 -- rjl
+ *     Fixed bug that caused every other transmit descriptor to be used
+ *     instead of every descriptor.
+ *
+ *  21 Dec. 84 -- rjl
+ *     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
+ *     copying instead of m-buf shuffleing.
+ *     A number of deficencies in the hardware/firmware were compensated
+ *     for. See comments in qestart and qerint.
+ *
+ *  14 Nov. 84 -- jf
+ *     Added usage counts for multicast addresses.
+ *     Updated general protocol support to allow access to the Ethernet
+ *     header.
+ *
+ *  04 Oct. 84 -- jf
+ *     Added support for new ioctls to add and delete multicast addresses
+ *     and set the physical address.
+ *     Add support for general protocols.
+ *
+ *  14 Aug. 84 -- rjl
+ *     Integrated Shannon changes. (allow arp above 1024 and ? )
+ *
+ *  13 Feb. 84 -- rjl
+ *
+ *     Initial version of driver. derived from IL driver.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * Digital Q-BUS to NI Adapter
+ * supports DEQNA and DELQA in DEQNA-mode.
+ */
+
+#include "opt_inet.h"
+#include "opt_ccitt.h"
+#include "opt_llc.h"
+#include "opt_iso.h"
+#include "opt_ns.h"
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/buf.h>
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/reboot.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_dl.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_inarp.h>
+#endif
+
+#ifdef NS
+#include <netns/ns.h>
+#include <netns/ns_if.h>
+#endif
+
+#ifdef ISO
+#include <netiso/iso.h>
+#include <netiso/iso_var.h>
+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/rpb.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 NTOT   (NXMT + NRCV)
+
+#define QETIMEOUT      2               /* transmit timeout, must be > 1 */
+#define QESLOWTIMEOUT  40              /* timeout when no xmits in progress */
+
+#define MINDATA 60
+
+/*
+ * Ethernet software status per interface.
+ *
+ * Each interface is referenced by a network interface structure,
+ * qe_if, which the routing code uses to locate the interface.
+ * This structure contains the output queue for the interface, its address, ...
+ */
+struct qe_softc {
+       struct  device qe_dev;          /* Configuration common part    */
+       struct  ethercom qe_ec;         /* Ethernet common part         */
+#define qe_if  qe_ec.ec_if             /* network-visible interface    */
+       struct  ifubinfo qe_uba;        /* Q-bus resources              */
+       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
+#define QEF_SETADDR    0x02
+#define QEF_FASTTIMEO  0x04
+       int     setupaddr;              /* mapping info for setup pkts  */
+       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        */
+       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                  */
+       int     setupqueued;            /* setup packet queued          */
+       int     setuplength;            /* length of setup packet       */
+       int     nxmit;                  /* Transmits in progress        */
+       int     qe_restarts;            /* timeouts                     */
+};
+
+int    qematch __P((struct device *, struct cfdata *, void *));
+void   qeattach __P((struct device *, struct device *, void *));
+void   qereset __P((int));
+void   qeinit __P((struct qe_softc *));
+void   qestart __P((struct ifnet *));
+void   qeintr __P((int));
+void   qetint __P((int));
+void   qerint __P((int));
+int    qeioctl __P((struct ifnet *, u_long, caddr_t));
+void   qe_setaddr __P((u_char *, struct qe_softc *));
+void   qeinitdesc __P((struct qe_ring *, caddr_t, int));
+void   qesetup __P((struct qe_softc *));
+void   qeread __P((struct qe_softc *, struct ifrw *, int));
+void   qetimeout __P((struct ifnet *));
+void   qerestart __P((struct qe_softc *));
+
+struct cfattach qe_ca = {
+       sizeof(struct qe_softc), qematch, qeattach
+};
+
+extern struct cfdriver qe_cd;
+
+#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
+ * chaining buffers (which we aren't prepared to handle) we allocate 2kb
+ * size buffers.
+ */
+#define MAXPACKETSIZE 2048             /* Should really be ETHERMTU    */
+
+/*
+ * Probe the QNA to see if it's there
+ */
+int
+qematch(parent, cf, aux)
+       struct  device *parent;
+       struct  cfdata *cf;
+       void    *aux;
+{
+       struct  qe_softc sc;
+       struct  uba_attach_args *ua = aux;
+       struct  uba_softc *ubasc = (struct uba_softc *)parent;



Home | Main Index | Thread Index | Old Index