1995-11-21 02:32:04 +00:00
|
|
|
/*
|
1999-10-17 09:40:04 +00:00
|
|
|
* Copyright (c) 1995, 1999 John Hay. All rights reserved.
|
1995-11-21 02:32:04 +00:00
|
|
|
*
|
|
|
|
* 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.
|
1999-10-17 09:40:04 +00:00
|
|
|
* 3. Neither the name of the author nor the names of any co-contributors
|
1995-11-21 02:32:04 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY John Hay ``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 John Hay BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Programming assumptions and other issues.
|
|
|
|
*
|
|
|
|
* The descriptors of a DMA channel will fit in a 16K memory window.
|
|
|
|
*
|
|
|
|
* The buffers of a transmit DMA channel will fit in a 16K memory window.
|
|
|
|
*
|
1996-04-12 19:57:44 +00:00
|
|
|
* Only the ISA bus cards with X.21 and V.35 is tested.
|
1995-11-21 02:32:04 +00:00
|
|
|
*
|
|
|
|
* When interface is going up, handshaking is set and it is only cleared
|
|
|
|
* when the interface is down'ed.
|
|
|
|
*
|
|
|
|
* There should be a way to set/reset Raw HDLC/PPP, Loopback, DCE/DTE,
|
|
|
|
* internal/external clock, etc.....
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#include "opt_netgraph.h"
|
1995-11-21 02:32:04 +00:00
|
|
|
#include "ar.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/kernel.h>
|
1997-09-02 01:19:47 +00:00
|
|
|
#include <sys/malloc.h>
|
1995-11-21 02:32:04 +00:00
|
|
|
#include <sys/mbuf.h>
|
1996-10-31 20:22:40 +00:00
|
|
|
#include <sys/sockio.h>
|
1995-11-21 02:32:04 +00:00
|
|
|
#include <sys/socket.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/bus.h>
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
#include <net/if.h>
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
#include <netgraph/ng_message.h>
|
|
|
|
#include <netgraph/netgraph.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <i386/isa/if_ar.h>
|
|
|
|
#else /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
#include <net/if_sppp.h>
|
|
|
|
#include <net/bpf.h>
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
#include <machine/clock.h>
|
1996-06-25 20:31:01 +00:00
|
|
|
#include <machine/md_var.h>
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
#include <i386/isa/if_arregs.h>
|
|
|
|
#include <i386/isa/ic/hd64570.h>
|
1998-06-17 13:54:59 +00:00
|
|
|
#include <i386/isa/isa_device.h>
|
1995-11-21 02:32:04 +00:00
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
#ifndef COMPAT_OLDISA
|
|
|
|
#error "The ar device requires the old isa compatibility shims"
|
|
|
|
#endif
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1998-01-08 23:42:31 +00:00
|
|
|
#include "sppp.h"
|
|
|
|
#if NSPPP <= 0
|
|
|
|
#error device 'ar' require sppp.
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NSPPP <= 0 */
|
|
|
|
#endif /* NETGRAPH */
|
1998-01-08 23:42:31 +00:00
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
#ifdef TRACE
|
|
|
|
#define TRC(x) x
|
|
|
|
#else
|
|
|
|
#define TRC(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TRCL(x) x
|
|
|
|
|
|
|
|
#define PPP_HEADER_LEN 4
|
|
|
|
|
|
|
|
#define ARC_GET_WIN(addr) ((addr >> ARC_WIN_SHFT) & AR_WIN_MSK)
|
|
|
|
|
|
|
|
#define ARC_SET_MEM(iobase,win) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
|
|
|
|
ARC_GET_WIN(win))
|
|
|
|
#define ARC_SET_SCA(iobase,ch) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
|
|
|
|
AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0))
|
|
|
|
#define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0)
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
struct ar_hardc {
|
1995-11-21 02:32:04 +00:00
|
|
|
int cunit;
|
|
|
|
struct ar_softc *sc;
|
|
|
|
u_short iobase;
|
1999-10-17 09:40:04 +00:00
|
|
|
int isa_irq;
|
1995-11-21 02:32:04 +00:00
|
|
|
int numports;
|
|
|
|
caddr_t mem_start;
|
|
|
|
caddr_t mem_end;
|
1999-10-17 09:40:04 +00:00
|
|
|
u_char *orbase;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
u_int memsize; /* in bytes */
|
1999-10-17 09:40:04 +00:00
|
|
|
u_int winsize; /* in bytes */
|
|
|
|
u_int winmsk;
|
1995-11-21 02:32:04 +00:00
|
|
|
u_char bustype; /* ISA, MCA, PCI.... */
|
1999-10-17 09:40:04 +00:00
|
|
|
u_char interface[NPORT];/* X21, V.35, EIA-530.... */
|
1995-11-21 02:32:04 +00:00
|
|
|
u_char revision;
|
|
|
|
u_char handshake; /* handshake lines supported by card. */
|
|
|
|
|
|
|
|
u_char txc_dtr[NPORT/NCHAN]; /* the register is write only */
|
|
|
|
u_int txc_dtr_off[NPORT/NCHAN];
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca[NPORT/NCHAN];
|
|
|
|
|
|
|
|
};
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
static int next_ar_unit = 0;
|
|
|
|
static struct ar_hardc ar_hardc[NAR];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
struct ar_softc {
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
struct sppp ifsppp;
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
int unit; /* With regards to all ar devices */
|
|
|
|
int subunit; /* With regards to this card */
|
|
|
|
struct ar_hardc *hc;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
struct buf_block {
|
|
|
|
u_int txdesc; /* On card address */
|
|
|
|
u_int txstart; /* On card address */
|
|
|
|
u_int txend; /* On card address */
|
|
|
|
u_int txtail; /* Index of first unused buffer */
|
|
|
|
u_int txmax; /* number of usable buffers/descriptors */
|
|
|
|
u_int txeda; /* Error descriptor addresses */
|
|
|
|
}block[AR_TX_BLOCKS];
|
|
|
|
|
|
|
|
char xmit_busy; /* Transmitter is busy */
|
|
|
|
char txb_inuse; /* Number of tx blocks currently in use */
|
1999-05-06 18:58:05 +00:00
|
|
|
u_char txb_new; /* Index to where new buffer will be added */
|
|
|
|
u_char txb_next_tx; /* Index to next block ready to tx */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
u_int rxdesc; /* On card address */
|
|
|
|
u_int rxstart; /* On card address */
|
|
|
|
u_int rxend; /* On card address */
|
|
|
|
u_int rxhind; /* Index to the head of the rx buffers. */
|
|
|
|
u_int rxmax; /* number of usable buffers/descriptors */
|
|
|
|
|
|
|
|
int scano;
|
|
|
|
int scachan;
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca;
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
int running; /* something is attached so we are running */
|
|
|
|
int dcd; /* do we have dcd? */
|
|
|
|
/* ---netgraph bits --- */
|
|
|
|
char nodename[NG_NODELEN + 1]; /* store our node name */
|
|
|
|
int datahooks; /* number of data hooks attached */
|
|
|
|
node_p node; /* netgraph node */
|
|
|
|
hook_p hook; /* data hook */
|
|
|
|
hook_p debug_hook;
|
|
|
|
struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
|
|
|
|
struct ifqueue xmitq; /* transmit queue */
|
|
|
|
int flags; /* state */
|
|
|
|
#define SCF_RUNNING 0x01 /* board is active */
|
|
|
|
#define SCF_OACTIVE 0x02 /* output is active */
|
|
|
|
int out_dog; /* watchdog cycles output count-down */
|
|
|
|
struct callout_handle handle; /* timeout(9) handle */
|
|
|
|
u_long inbytes, outbytes; /* stats */
|
|
|
|
u_long lastinbytes, lastoutbytes; /* a second ago */
|
|
|
|
u_long inrate, outrate; /* highest rate seen */
|
|
|
|
u_long inlast; /* last input N secs ago */
|
|
|
|
u_long out_deficit; /* output since last input */
|
|
|
|
u_long oerrors, ierrors[6];
|
|
|
|
u_long opackets, ipackets;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
};
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
|
|
|
|
#define QUITE_A_WHILE 300 /* 5 MINUTES */
|
|
|
|
#define LOTS_OF_PACKETS 100
|
|
|
|
#endif /* NETGRAPH */
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static int arprobe(struct isa_device *id);
|
1999-10-17 09:40:04 +00:00
|
|
|
static int arattach_isa(struct isa_device *id);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This translate from irq numbers to
|
|
|
|
* the value that the arnet card needs
|
|
|
|
* in the lower part of the AR_INT_SEL
|
|
|
|
* register.
|
|
|
|
*/
|
|
|
|
static int irqtable[16] = {
|
|
|
|
0, /* 0 */
|
|
|
|
0, /* 1 */
|
|
|
|
0, /* 2 */
|
|
|
|
1, /* 3 */
|
|
|
|
0, /* 4 */
|
|
|
|
2, /* 5 */
|
|
|
|
0, /* 6 */
|
|
|
|
3, /* 7 */
|
|
|
|
0, /* 8 */
|
|
|
|
0, /* 9 */
|
|
|
|
4, /* 10 */
|
|
|
|
5, /* 11 */
|
|
|
|
6, /* 12 */
|
|
|
|
0, /* 13 */
|
|
|
|
0, /* 14 */
|
|
|
|
7 /* 15 */
|
|
|
|
};
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
struct isa_driver ardriver = {
|
|
|
|
INTR_TYPE_NET,
|
|
|
|
arprobe,
|
|
|
|
arattach_isa,
|
|
|
|
"ar"
|
|
|
|
};
|
|
|
|
COMPAT_ISA_DRIVER(ar, ardriver);
|
1999-10-17 09:40:04 +00:00
|
|
|
|
|
|
|
struct ar_hardc *arattach_pci(int unit, vm_offset_t mem_addr);
|
|
|
|
void arintr_hc(struct ar_hardc *hc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1998-10-22 05:58:45 +00:00
|
|
|
static ointhand2_t arintr;
|
1999-10-17 09:40:04 +00:00
|
|
|
static int arattach(struct ar_hardc *hc);
|
1996-03-17 00:29:35 +00:00
|
|
|
static void ar_xmit(struct ar_softc *sc);
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-10 13:40:44 +00:00
|
|
|
static void arstart(struct ifnet *ifp);
|
1998-06-07 17:13:14 +00:00
|
|
|
static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
|
1995-12-10 13:40:44 +00:00
|
|
|
static void arwatchdog(struct ifnet *ifp);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
static void arstart(struct ar_softc *sc);
|
|
|
|
static void arwatchdog(struct ar_softc *sc);
|
|
|
|
#endif /* NETGRAPH */
|
1995-12-15 00:54:32 +00:00
|
|
|
static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
|
|
|
|
static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
|
1996-04-12 19:57:44 +00:00
|
|
|
static void ar_eat_packet(struct ar_softc *sc, int single);
|
1995-12-15 00:54:32 +00:00
|
|
|
static void ar_get_packets(struct ar_softc *sc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
static int ar_read_pim_iface(volatile struct ar_hardc *hc, int channel);
|
1995-11-21 02:32:04 +00:00
|
|
|
static void ar_up(struct ar_softc *sc);
|
|
|
|
static void ar_down(struct ar_softc *sc);
|
1999-10-17 09:40:04 +00:00
|
|
|
static void arc_init(struct ar_hardc *hc);
|
1995-11-21 02:32:04 +00:00
|
|
|
static void ar_init_sca(struct ar_hardc *hc, int scano);
|
|
|
|
static void ar_init_msci(struct ar_softc *sc);
|
|
|
|
static void ar_init_rx_dmac(struct ar_softc *sc);
|
|
|
|
static void ar_init_tx_dmac(struct ar_softc *sc);
|
|
|
|
static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
|
|
|
|
static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
|
|
|
|
static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
static void ngar_watchdog_frame(void * arg);
|
|
|
|
static void ngar_init(void* ignored);
|
|
|
|
|
1999-11-01 10:09:34 +00:00
|
|
|
static ng_constructor_t ngar_constructor;
|
|
|
|
static ng_rcvmsg_t ngar_rcvmsg;
|
|
|
|
static ng_shutdown_t ngar_rmnode;
|
|
|
|
static ng_newhook_t ngar_newhook;
|
|
|
|
/*static ng_findhook_t ngar_findhook; */
|
|
|
|
static ng_connect_t ngar_connect;
|
|
|
|
static ng_rcvdata_t ngar_rcvdata;
|
|
|
|
static ng_disconnect_t ngar_disconnect;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
static struct ng_type typestruct = {
|
|
|
|
NG_VERSION,
|
|
|
|
NG_AR_NODE_TYPE,
|
|
|
|
NULL,
|
|
|
|
ngar_constructor,
|
|
|
|
ngar_rcvmsg,
|
|
|
|
ngar_rmnode,
|
|
|
|
ngar_newhook,
|
|
|
|
NULL,
|
|
|
|
ngar_connect,
|
|
|
|
ngar_rcvdata,
|
|
|
|
ngar_rcvdata,
|
1999-12-01 09:34:14 +00:00
|
|
|
ngar_disconnect,
|
|
|
|
NULL
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ngar_done_init = 0;
|
|
|
|
#endif /* NETGRAPH */
|
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
/*
|
|
|
|
* Register the Adapter.
|
|
|
|
* Probe to see if it is there.
|
|
|
|
* Get its information and fill it in.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
|
|
|
arprobe(struct isa_device *id)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
struct ar_hardc *hc = &ar_hardc[id->id_unit];
|
|
|
|
u_int tmp;
|
|
|
|
u_short port;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the card.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now see if the card is realy there.
|
|
|
|
*
|
|
|
|
* XXX For now I just check the undocumented ports
|
|
|
|
* for "570". We will probably have to do more checking.
|
|
|
|
*/
|
|
|
|
port = id->id_iobase;
|
|
|
|
|
|
|
|
if((inb(port+AR_ID_5) != '5') || (inb(port+AR_ID_7) != '7') ||
|
|
|
|
(inb(port+AR_ID_0) != '0'))
|
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* We have a card here, fill in what we can.
|
|
|
|
*/
|
|
|
|
tmp = inb(port + AR_BMI);
|
|
|
|
hc->bustype = tmp & AR_BUS_MSK;
|
|
|
|
hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
|
|
|
|
hc->memsize = 1 << hc->memsize;
|
|
|
|
hc->memsize <<= 16;
|
1999-10-17 09:40:04 +00:00
|
|
|
hc->interface[0] = (tmp & AR_IFACE_MSK);
|
|
|
|
hc->interface[1] = hc->interface[0];
|
|
|
|
hc->interface[2] = hc->interface[0];
|
|
|
|
hc->interface[3] = hc->interface[0];
|
|
|
|
tmp = inb(port + AR_REV);
|
|
|
|
hc->revision = tmp & AR_REV_MSK;
|
|
|
|
hc->winsize = 1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT);
|
|
|
|
hc->winsize *= ARC_WIN_SIZ;
|
|
|
|
hc->winmsk = hc->winsize - 1;
|
1995-11-21 02:32:04 +00:00
|
|
|
hc->numports = inb(port + AR_PNUM);
|
|
|
|
hc->handshake = inb(port + AR_HNDSH);
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
id->id_msize = hc->winsize;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
hc->iobase = id->id_iobase;
|
|
|
|
hc->mem_start = id->id_maddr;
|
|
|
|
hc->mem_end = id->id_maddr + id->id_msize;
|
|
|
|
hc->cunit = id->id_unit;
|
1999-10-17 09:40:04 +00:00
|
|
|
hc->isa_irq = id->id_irq;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
switch(hc->interface[0]) {
|
1995-11-21 02:32:04 +00:00
|
|
|
case AR_IFACE_EIA_232:
|
|
|
|
printf("ar%d: The EIA 232 interface is not supported.\n",
|
|
|
|
id->id_unit);
|
|
|
|
return 0;
|
|
|
|
case AR_IFACE_V_35:
|
|
|
|
break;
|
|
|
|
case AR_IFACE_EIA_530:
|
|
|
|
printf("ar%d: WARNING: The EIA 530 interface is untested.\n",
|
|
|
|
id->id_unit);
|
|
|
|
break;
|
|
|
|
case AR_IFACE_X_21:
|
|
|
|
break;
|
|
|
|
case AR_IFACE_COMBO:
|
|
|
|
printf("ar%d: WARNING: The COMBO interface is untested.\n",
|
|
|
|
id->id_unit);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do a little sanity check.
|
|
|
|
*/
|
|
|
|
if((hc->numports > NPORT) || (hc->memsize > (512*1024)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return ARC_IO_SIZ; /* return the amount of IO addresses used. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Malloc memory for the softc structures.
|
|
|
|
* Reset the card to put it in a known state.
|
|
|
|
* Register the ports on the adapter.
|
|
|
|
* Fill in the info for each port.
|
|
|
|
* Attach each port to sppp and bpf.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1999-10-17 09:40:04 +00:00
|
|
|
arattach_isa(struct isa_device *id)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
struct ar_hardc *hc = &ar_hardc[id->id_unit];
|
1999-10-17 09:40:04 +00:00
|
|
|
id->id_ointr = arintr;
|
|
|
|
return arattach(hc);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ar_hardc *
|
|
|
|
arattach_pci(int unit, vm_offset_t mem_addr)
|
|
|
|
{
|
|
|
|
struct ar_hardc *hc;
|
|
|
|
u_int i, tmp;
|
|
|
|
|
|
|
|
hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK);
|
|
|
|
bzero(hc, sizeof(struct ar_hardc));
|
|
|
|
|
|
|
|
hc->cunit = unit;
|
|
|
|
hc->mem_start = (caddr_t)mem_addr;
|
|
|
|
hc->sca[0] = (sca_regs *)(mem_addr + AR_PCI_SCA_1_OFFSET);
|
|
|
|
hc->sca[1] = (sca_regs *)(mem_addr + AR_PCI_SCA_2_OFFSET);
|
|
|
|
hc->iobase = 0;
|
|
|
|
hc->orbase = (u_char *)(mem_addr + AR_PCI_ORBASE_OFFSET);
|
|
|
|
|
|
|
|
tmp = hc->orbase[AR_BMI * 4];
|
|
|
|
hc->bustype = tmp & AR_BUS_MSK;
|
|
|
|
hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
|
|
|
|
hc->memsize = 1 << hc->memsize;
|
|
|
|
hc->memsize <<= 16;
|
|
|
|
hc->interface[0] = (tmp & AR_IFACE_MSK);
|
|
|
|
tmp = hc->orbase[AR_REV * 4];
|
|
|
|
hc->revision = tmp & AR_REV_MSK;
|
|
|
|
hc->winsize = (1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT)) * 16 * 1024;
|
|
|
|
hc->mem_end = (caddr_t)(mem_addr + hc->winsize);
|
|
|
|
hc->winmsk = hc->winsize - 1;
|
|
|
|
hc->numports = hc->orbase[AR_PNUM * 4];
|
|
|
|
hc->handshake = hc->orbase[AR_HNDSH * 4];
|
|
|
|
|
|
|
|
for(i = 1; i < hc->numports; i++)
|
|
|
|
hc->interface[i] = hc->interface[0];
|
|
|
|
|
|
|
|
TRC(printf("arp%d: bus %x, rev %d, memstart %p, winsize %d, "
|
|
|
|
"winmsk %x, interface %x\n",
|
|
|
|
unit, hc->bustype, hc->revision, hc->mem_start, hc->winsize,
|
|
|
|
hc->winmsk, hc->interface[0]));
|
|
|
|
|
|
|
|
arattach(hc);
|
|
|
|
return hc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
arattach(struct ar_hardc *hc)
|
|
|
|
{
|
1995-11-21 02:32:04 +00:00
|
|
|
struct ar_softc *sc;
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
struct ifnet *ifp;
|
1999-11-18 08:32:02 +00:00
|
|
|
char *iface;
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
int unit;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
printf("arc%d: %uK RAM, %u ports, rev %u.\n",
|
|
|
|
hc->cunit,
|
1995-11-21 02:32:04 +00:00
|
|
|
hc->memsize/1024,
|
|
|
|
hc->numports,
|
1999-10-17 09:40:04 +00:00
|
|
|
hc->revision);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
arc_init(hc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
sc = hc->sc;
|
|
|
|
|
|
|
|
for(unit=0;unit<hc->numports;unit+=NCHAN)
|
|
|
|
ar_init_sca(hc, unit / NCHAN);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now configure each port on the card.
|
|
|
|
*/
|
|
|
|
for(unit=0;unit<hc->numports;sc++,unit++) {
|
|
|
|
sc->hc = hc;
|
|
|
|
sc->subunit = unit;
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->unit = next_ar_unit;
|
|
|
|
next_ar_unit++;
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->scano = unit / NCHAN;
|
|
|
|
sc->scachan = unit%NCHAN;
|
|
|
|
|
|
|
|
ar_init_rx_dmac(sc);
|
|
|
|
ar_init_tx_dmac(sc);
|
|
|
|
ar_init_msci(sc);
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
ifp = &sc->ifsppp.pp_if;
|
|
|
|
|
1996-02-06 18:51:28 +00:00
|
|
|
ifp->if_softc = sc;
|
1999-10-17 09:40:04 +00:00
|
|
|
ifp->if_unit = sc->unit;
|
1995-11-21 02:32:04 +00:00
|
|
|
ifp->if_name = "ar";
|
|
|
|
ifp->if_mtu = PP_MTU;
|
|
|
|
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
|
|
|
|
ifp->if_ioctl = arioctl;
|
|
|
|
ifp->if_start = arstart;
|
|
|
|
ifp->if_watchdog = arwatchdog;
|
|
|
|
|
|
|
|
sc->ifsppp.pp_flags = PP_KEEPALIVE;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
switch(hc->interface[unit]) {
|
|
|
|
default: iface = "UNKNOWN"; break;
|
|
|
|
case AR_IFACE_EIA_232: iface = "EIA-232"; break;
|
|
|
|
case AR_IFACE_V_35: iface = "EIA-232 or V.35"; break;
|
|
|
|
case AR_IFACE_EIA_530: iface = "EIA-530"; break;
|
|
|
|
case AR_IFACE_X_21: iface = "X.21"; break;
|
|
|
|
case AR_IFACE_COMBO: iface = "COMBO X.21 / EIA-530"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("ar%d: Adapter %d, port %d, interface %s.\n",
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->unit,
|
|
|
|
hc->cunit,
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->subunit,
|
|
|
|
iface);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
sppp_attach((struct ifnet *)&sc->ifsppp);
|
|
|
|
if_attach(ifp);
|
|
|
|
|
1996-02-06 18:51:28 +00:00
|
|
|
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
/*
|
|
|
|
* we have found a node, make sure our 'type' is availabe.
|
|
|
|
*/
|
|
|
|
if (ngar_done_init == 0) ngar_init(NULL);
|
|
|
|
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
|
|
|
return (0);
|
|
|
|
sc->node->private = sc;
|
|
|
|
callout_handle_init(&sc->handle);
|
|
|
|
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
|
|
|
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
|
|
|
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
|
|
|
if (ng_name_node(sc->node, sc->nodename)) {
|
|
|
|
ng_rmnode(sc->node);
|
|
|
|
ng_unref(sc->node);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
sc->running = 0;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(hc->iobase);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First figure out which SCA gave the interrupt.
|
|
|
|
* Process it.
|
|
|
|
* See if there is other interrupts pending.
|
|
|
|
* Repeat until there is no more interrupts.
|
|
|
|
*/
|
1998-10-22 05:58:45 +00:00
|
|
|
static void
|
1996-03-17 00:29:35 +00:00
|
|
|
arintr(int unit)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
struct ar_hardc *hc;
|
|
|
|
|
|
|
|
hc = &ar_hardc[unit];
|
|
|
|
arintr_hc(hc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
arintr_hc(struct ar_hardc *hc)
|
|
|
|
{
|
|
|
|
sca_regs *sca;
|
1995-11-21 02:32:04 +00:00
|
|
|
u_char isr0, isr1, isr2, arisr;
|
|
|
|
int scano;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
/* XXX Use the PCI interrupt score board register later */
|
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
arisr = hc->orbase[AR_ISTAT * 4];
|
|
|
|
else
|
|
|
|
arisr = inb(hc->iobase + AR_ISTAT);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
while(arisr & AR_BD_INT) {
|
1999-10-17 09:40:04 +00:00
|
|
|
TRC(printf("arisr = %x\n", arisr));
|
1995-11-21 02:32:04 +00:00
|
|
|
if(arisr & AR_INT_0)
|
|
|
|
scano = 0;
|
|
|
|
else if(arisr & AR_INT_1)
|
|
|
|
scano = 1;
|
|
|
|
else {
|
|
|
|
/* XXX Oops this shouldn't happen. */
|
1999-10-17 09:40:04 +00:00
|
|
|
printf("arc%d: Interrupted with no interrupt.\n",
|
|
|
|
hc->cunit);
|
1995-11-21 02:32:04 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-10-17 09:40:04 +00:00
|
|
|
sca = hc->sca[scano];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
isr0 = sca->isr0;
|
|
|
|
isr1 = sca->isr1;
|
|
|
|
isr2 = sca->isr2;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
TRC(printf("arc%d: ARINTR isr0 %x, isr1 %x, isr2 %x\n",
|
1999-10-17 09:40:04 +00:00
|
|
|
hc->cunit,
|
1995-11-21 02:32:04 +00:00
|
|
|
isr0,
|
|
|
|
isr1,
|
|
|
|
isr2));
|
|
|
|
if(isr0)
|
|
|
|
ar_msci_intr(hc, scano, isr0);
|
|
|
|
|
|
|
|
if(isr1)
|
|
|
|
ar_dmac_intr(hc, scano, isr1);
|
|
|
|
|
|
|
|
if(isr2)
|
|
|
|
ar_timer_intr(hc, scano, isr2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Proccess the second sca's interrupt if available.
|
|
|
|
* Else see if there are any new interrupts.
|
|
|
|
*/
|
|
|
|
if((arisr & AR_INT_0) && (arisr & AR_INT_1))
|
|
|
|
arisr &= ~AR_INT_0;
|
1999-10-17 09:40:04 +00:00
|
|
|
else {
|
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
arisr = hc->orbase[AR_ISTAT * 4];
|
|
|
|
else
|
|
|
|
arisr = inb(hc->iobase + AR_ISTAT);
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(hc->iobase);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
/*
|
|
|
|
* This will only start the transmitter. It is assumed that the data
|
|
|
|
* is already there. It is normally called from arstart() or ar_dmac_intr().
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ar_xmit(struct ar_softc *sc)
|
|
|
|
{
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1999-10-17 09:40:04 +00:00
|
|
|
struct ifnet *ifp;
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac_channel *dmac;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1999-10-17 09:40:04 +00:00
|
|
|
ifp = &sc->ifsppp.pp_if;
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
|
1996-03-17 00:29:35 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1996-03-17 00:29:35 +00:00
|
|
|
dmac->cda = (u_short)(sc->block[sc->txb_next_tx].txdesc & 0xffff);
|
|
|
|
|
|
|
|
dmac->eda = (u_short)(sc->block[sc->txb_next_tx].txeda & 0xffff);
|
|
|
|
dmac->dsr = SCA_DSR_DE;
|
|
|
|
|
|
|
|
sc->xmit_busy = 1;
|
|
|
|
|
|
|
|
sc->txb_next_tx++;
|
|
|
|
if(sc->txb_next_tx == AR_TX_BLOCKS)
|
|
|
|
sc->txb_next_tx = 0;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
ifp->if_timer = 2; /* Value in seconds. */
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
|
|
|
|
#endif /* NETGRAPH */
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(sc->hc->iobase);
|
1996-03-17 00:29:35 +00:00
|
|
|
}
|
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
/*
|
|
|
|
* This function will be called from the upper level when a user add a
|
|
|
|
* packet to be send, and from the interrupt handler after a finished
|
|
|
|
* transmit.
|
|
|
|
*
|
|
|
|
* NOTE: it should run at spl_imp().
|
|
|
|
*
|
1996-03-17 00:29:35 +00:00
|
|
|
* This function only place the data in the oncard buffers. It does not
|
|
|
|
* start the transmition. ar_xmit() does that.
|
|
|
|
*
|
1995-11-21 02:32:04 +00:00
|
|
|
* Transmitter idle state is indicated by the IFF_OACTIVE flag. The function
|
1998-04-17 22:37:19 +00:00
|
|
|
* that clears that should ensure that the transmitter and its DMA is
|
1995-11-21 02:32:04 +00:00
|
|
|
* in a "good" idle state.
|
|
|
|
*/
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
|
|
|
arstart(struct ifnet *ifp)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ar_softc *sc = ifp->if_softc;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
static void
|
|
|
|
arstart(struct ar_softc *sc)
|
|
|
|
{
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
int i, len, tlen;
|
|
|
|
struct mbuf *mtx;
|
|
|
|
u_char *txdata;
|
|
|
|
sca_descriptor *txdesc;
|
1996-03-17 00:29:35 +00:00
|
|
|
struct buf_block *blkp;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
if(!(ifp->if_flags & IFF_RUNNING))
|
|
|
|
return;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
/* XXX */
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
top_arstart:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we have space for more packets.
|
|
|
|
*/
|
|
|
|
if(sc->txb_inuse == AR_TX_BLOCKS) {
|
1999-10-25 23:14:04 +00:00
|
|
|
#ifndef NETGRAPH
|
1999-10-21 09:06:11 +00:00
|
|
|
ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
|
|
|
|
#else /* NETGRAPH */
|
|
|
|
/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
|
|
|
|
#endif /* NETGRAPH */
|
1996-03-17 00:29:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
mtx = sppp_dequeue(ifp);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
|
|
|
if (mtx == NULL) {
|
|
|
|
IF_DEQUEUE(&sc->xmitq, mtx);
|
|
|
|
}
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
if(!mtx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It is OK to set the memory window outside the loop because
|
|
|
|
* all tx buffers and descriptors are assumed to be in the same
|
|
|
|
* 16K window.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We stay in this loop until there is nothing in the
|
|
|
|
* TX queue left or the tx buffer is full.
|
|
|
|
*/
|
|
|
|
i = 0;
|
1996-03-17 00:29:35 +00:00
|
|
|
blkp = &sc->block[sc->txb_new];
|
1995-11-21 02:32:04 +00:00
|
|
|
txdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (blkp->txdesc & sc->hc->winmsk));
|
|
|
|
txdata = (u_char *)(sc->hc->mem_start + (blkp->txstart & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
for(;;) {
|
|
|
|
len = mtx->m_pkthdr.len;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
TRC(printf("ar%d: ARstart len %u\n", sc->unit, len));
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We can do this because the tx buffers don't wrap.
|
|
|
|
*/
|
|
|
|
m_copydata(mtx, 0, len, txdata);
|
|
|
|
tlen = len;
|
|
|
|
while(tlen > AR_BUF_SIZ) {
|
|
|
|
txdesc->stat = 0;
|
|
|
|
txdesc->len = AR_BUF_SIZ;
|
|
|
|
tlen -= AR_BUF_SIZ;
|
|
|
|
txdesc++;
|
|
|
|
txdata += AR_BUF_SIZ;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
/* XXX Move into the loop? */
|
|
|
|
txdesc->stat = SCA_DESC_EOM;
|
|
|
|
txdesc->len = tlen;
|
|
|
|
txdesc++;
|
|
|
|
txdata += AR_BUF_SIZ;
|
|
|
|
i++;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-02-06 18:51:28 +00:00
|
|
|
if(ifp->if_bpf)
|
|
|
|
bpf_mtap(ifp, mtx);
|
1995-11-21 02:32:04 +00:00
|
|
|
m_freem(mtx);
|
|
|
|
++sc->ifsppp.pp_if.if_opackets;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
m_freem(mtx);
|
|
|
|
sc->outbytes += len;
|
|
|
|
++sc->opackets;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we have space for another mbuf.
|
|
|
|
* XXX This is hardcoded. A packet won't be larger
|
|
|
|
* than 3 buffers (3 x 512).
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
if((i + 3) >= blkp->txmax)
|
1995-11-21 02:32:04 +00:00
|
|
|
break;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
mtx = sppp_dequeue(ifp);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
|
|
|
if (mtx == NULL) {
|
|
|
|
IF_DEQUEUE(&sc->xmitq, mtx);
|
|
|
|
}
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
if(!mtx)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
blkp->txtail = i;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark the last descriptor, so that the SCA know where
|
|
|
|
* to stop.
|
|
|
|
*/
|
|
|
|
txdesc--;
|
|
|
|
txdesc->stat |= SCA_DESC_EOT;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
txdesc = (sca_descriptor *)blkp->txdesc;
|
|
|
|
blkp->txeda = (u_short)((u_int)&txdesc[i]);
|
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
#if 0
|
|
|
|
printf("ARstart: %p desc->cp %x\n", &txdesc->cp, txdesc->cp);
|
|
|
|
printf("ARstart: %p desc->bp %x\n", &txdesc->bp, txdesc->bp);
|
|
|
|
printf("ARstart: %p desc->bpb %x\n", &txdesc->bpb, txdesc->bpb);
|
|
|
|
printf("ARstart: %p desc->len %x\n", &txdesc->len, txdesc->len);
|
|
|
|
printf("ARstart: %p desc->stat %x\n", &txdesc->stat, txdesc->stat);
|
|
|
|
#endif
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->txb_inuse++;
|
|
|
|
sc->txb_new++;
|
|
|
|
if(sc->txb_new == AR_TX_BLOCKS)
|
|
|
|
sc->txb_new = 0;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
if(sc->xmit_busy == 0)
|
|
|
|
ar_xmit(sc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(sc->hc->iobase);
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
goto top_arstart;
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1998-06-07 17:13:14 +00:00
|
|
|
arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
int s, error;
|
|
|
|
int was_up, should_be_up;
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ar_softc *sc = ifp->if_softc;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
TRC(printf("ar%d: arioctl.\n", ifp->if_unit);)
|
|
|
|
|
|
|
|
was_up = ifp->if_flags & IFF_RUNNING;
|
|
|
|
|
|
|
|
error = sppp_ioctl(ifp, cmd, data);
|
|
|
|
TRC(printf("ar%d: ioctl: ifsppp.pp_flags = %x, if_flags %x.\n",
|
|
|
|
ifp->if_unit, ((struct sppp *)ifp)->pp_flags, ifp->if_flags);)
|
|
|
|
if(error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if((cmd != SIOCSIFFLAGS) && cmd != (SIOCSIFADDR))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
TRC(printf("ar%d: arioctl %s.\n", ifp->if_unit,
|
|
|
|
(cmd == SIOCSIFFLAGS) ? "SIOCSIFFLAGS" : "SIOCSIFADDR");)
|
|
|
|
|
|
|
|
s = splimp();
|
|
|
|
should_be_up = ifp->if_flags & IFF_RUNNING;
|
|
|
|
|
|
|
|
if(!was_up && should_be_up) {
|
|
|
|
/* Interface should be up -- start it. */
|
|
|
|
ar_up(sc);
|
|
|
|
arstart(ifp);
|
|
|
|
/* XXX Maybe clear the IFF_UP flag so that the link
|
|
|
|
* will only go up after sppp lcp and ipcp negotiation.
|
|
|
|
*/
|
|
|
|
} else if(was_up && !should_be_up) {
|
|
|
|
/* Interface should be down -- stop it. */
|
|
|
|
ar_down(sc);
|
|
|
|
sppp_flush(ifp);
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is to catch lost tx interrupts.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-10 13:40:44 +00:00
|
|
|
arwatchdog(struct ifnet *ifp)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct ar_softc *sc = ifp->if_softc;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
arwatchdog(struct ar_softc *sc)
|
|
|
|
{
|
|
|
|
#endif /* NETGRAPH */
|
1999-10-17 09:40:04 +00:00
|
|
|
msci_channel *msci = &sc->sca->msci[sc->scachan];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-05 02:01:59 +00:00
|
|
|
if(!(ifp->if_flags & IFF_RUNNING))
|
1995-11-21 02:32:04 +00:00
|
|
|
return;
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
/* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
|
|
|
|
printf("ar%d: transmit failed, "
|
|
|
|
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
|
1999-10-21 09:06:11 +00:00
|
|
|
sc->unit,
|
1996-03-17 00:29:35 +00:00
|
|
|
msci->st0,
|
|
|
|
msci->st1,
|
|
|
|
msci->st3,
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->dmac[DMAC_TXCH(sc->scachan)].dsr);
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
if(msci->st1 & SCA_ST1_UDRN) {
|
|
|
|
msci->cmd = SCA_CMD_TXABORT;
|
|
|
|
msci->cmd = SCA_CMD_TXENABLE;
|
|
|
|
msci->st1 = SCA_ST1_UDRN;
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->xmit_busy = 0;
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
/* XXX ifp->if_flags &= ~IFF_OACTIVE; */
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
if(sc->txb_inuse && --sc->txb_inuse)
|
|
|
|
ar_xmit(sc);
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-12-05 02:01:59 +00:00
|
|
|
arstart(ifp);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
arstart(sc);
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_up(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca;
|
|
|
|
msci_channel *msci;
|
|
|
|
|
|
|
|
sca = sc->sca;
|
|
|
|
msci = &sca->msci[sc->scachan];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
TRC(printf("ar%d: sca %p, msci %p, ch %d\n",
|
|
|
|
sc->unit, sca, msci, sc->scachan));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable transmitter and receiver.
|
|
|
|
* Raise DTR and RTS.
|
|
|
|
* Enable interrupts.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/* XXX
|
|
|
|
* What about using AUTO mode in msci->md0 ???
|
|
|
|
* And what about CTS/DCD etc... ?
|
|
|
|
*/
|
|
|
|
if(sc->hc->handshake & AR_SHSK_RTS)
|
1996-03-03 08:42:28 +00:00
|
|
|
msci->ctl &= ~SCA_CTL_RTS;
|
1995-11-21 02:32:04 +00:00
|
|
|
if(sc->hc->handshake & AR_SHSK_DTR) {
|
1996-03-03 08:42:28 +00:00
|
|
|
sc->hc->txc_dtr[sc->scano] &= sc->scachan ?
|
|
|
|
~AR_TXC_DTR_DTR1 : ~AR_TXC_DTR_DTR0;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_PCI)
|
|
|
|
sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
|
|
|
|
sc->hc->txc_dtr[sc->scano];
|
|
|
|
else
|
|
|
|
outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
|
|
|
|
sc->hc->txc_dtr[sc->scano]);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(sc->scachan == 0) {
|
|
|
|
sca->ier0 |= 0x0F;
|
|
|
|
sca->ier1 |= 0x0F;
|
|
|
|
} else {
|
|
|
|
sca->ier0 |= 0xF0;
|
|
|
|
sca->ier1 |= 0xF0;
|
|
|
|
}
|
|
|
|
|
|
|
|
msci->cmd = SCA_CMD_RXENABLE;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
|
1995-11-21 02:32:04 +00:00
|
|
|
msci->cmd = SCA_CMD_TXENABLE;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(sc->hc->iobase);
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
|
|
|
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
|
|
|
sc->running = 1;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_down(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca;
|
|
|
|
msci_channel *msci;
|
|
|
|
|
|
|
|
sca = sc->sca;
|
|
|
|
msci = &sca->msci[sc->scachan];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifdef NETGRAPH
|
|
|
|
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
|
|
|
sc->running = 0;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
/*
|
|
|
|
* Disable transmitter and receiver.
|
|
|
|
* Lower DTR and RTS.
|
|
|
|
* Disable interrupts.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
msci->cmd = SCA_CMD_RXDISABLE;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
|
1995-11-21 02:32:04 +00:00
|
|
|
msci->cmd = SCA_CMD_TXDISABLE;
|
|
|
|
|
|
|
|
if(sc->hc->handshake & AR_SHSK_RTS)
|
1996-03-03 08:42:28 +00:00
|
|
|
msci->ctl |= SCA_CTL_RTS;
|
1995-11-21 02:32:04 +00:00
|
|
|
if(sc->hc->handshake & AR_SHSK_DTR) {
|
|
|
|
sc->hc->txc_dtr[sc->scano] |= sc->scachan ?
|
|
|
|
AR_TXC_DTR_DTR1 : AR_TXC_DTR_DTR0;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_PCI)
|
|
|
|
sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
|
|
|
|
sc->hc->txc_dtr[sc->scano];
|
|
|
|
else
|
|
|
|
outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
|
|
|
|
sc->hc->txc_dtr[sc->scano]);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(sc->scachan == 0) {
|
|
|
|
sca->ier0 &= ~0x0F;
|
|
|
|
sca->ier1 &= ~0x0F;
|
|
|
|
} else {
|
|
|
|
sca->ier0 &= ~0xF0;
|
|
|
|
sca->ier1 &= ~0xF0;
|
|
|
|
}
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_OFF(sc->hc->iobase);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ar_read_pim_iface(volatile struct ar_hardc *hc, int channel)
|
|
|
|
{
|
|
|
|
int ctype, i, val, x;
|
|
|
|
volatile u_char *pimctrl;
|
|
|
|
|
|
|
|
ctype = 0;
|
|
|
|
val = 0;
|
|
|
|
|
|
|
|
pimctrl = hc->orbase + AR_PIMCTRL;
|
|
|
|
|
|
|
|
/* Reset the PIM */
|
|
|
|
*pimctrl = 0x00;
|
|
|
|
*pimctrl = AR_PIM_STROBE;
|
|
|
|
|
|
|
|
/* Check if there is a PIM */
|
|
|
|
*pimctrl = 0x00;
|
|
|
|
*pimctrl = AR_PIM_READ;
|
|
|
|
x = *pimctrl;
|
|
|
|
TRC(printf("x = %x", x));
|
|
|
|
if(x & AR_PIM_DATA) {
|
|
|
|
printf("No PIM installed\n");
|
|
|
|
return(AR_IFACE_UNKNOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
x = (x >> 1) & 0x01;
|
|
|
|
val |= x << 0;
|
|
|
|
|
|
|
|
/* Now read the next 15 bits */
|
|
|
|
for(i = 1; i < 16; i++) {
|
|
|
|
*pimctrl = AR_PIM_READ;
|
|
|
|
*pimctrl = AR_PIM_READ | AR_PIM_STROBE;
|
|
|
|
x = *pimctrl;
|
|
|
|
TRC(printf(" %x ", x));
|
|
|
|
x = (x >> 1) & 0x01;
|
|
|
|
val |= x << i;
|
|
|
|
if(i == 8 && (val & 0x000f) == 0x0004) {
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
/* Start bit */
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT;
|
|
|
|
|
|
|
|
/* Mode bit */
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT;
|
|
|
|
|
|
|
|
/* Sign bit */
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
|
|
|
|
*pimctrl = AR_PIM_A2D_DOUT;
|
|
|
|
|
|
|
|
/* Select channel */
|
|
|
|
*pimctrl = AR_PIM_A2D_STROBE | ((channel & 2) << 2);
|
|
|
|
*pimctrl = ((channel & 2) << 2);
|
|
|
|
*pimctrl = AR_PIM_A2D_STROBE | ((channel & 1) << 3);
|
|
|
|
*pimctrl = ((channel & 1) << 3);
|
|
|
|
|
|
|
|
*pimctrl = AR_PIM_A2D_STROBE;
|
|
|
|
|
|
|
|
x = *pimctrl;
|
|
|
|
if(x & AR_PIM_DATA)
|
|
|
|
printf("\nOops A2D start bit not zero (%X)\n", x);
|
|
|
|
|
|
|
|
for(ii = 7; ii >= 0; ii--) {
|
|
|
|
*pimctrl = 0x00;
|
|
|
|
*pimctrl = AR_PIM_A2D_STROBE;
|
|
|
|
x = *pimctrl;
|
|
|
|
if(x & AR_PIM_DATA)
|
|
|
|
ctype |= 1 << ii;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRC(printf("\nPIM val %x, ctype %x, %d\n", val, ctype, ctype));
|
|
|
|
*pimctrl = AR_PIM_MODEG;
|
|
|
|
*pimctrl = AR_PIM_MODEG | AR_PIM_AUTO_LED;
|
|
|
|
if(ctype > 255)
|
|
|
|
return(AR_IFACE_UNKNOWN);
|
|
|
|
if(ctype > 239)
|
|
|
|
return(AR_IFACE_V_35);
|
|
|
|
if(ctype > 207)
|
|
|
|
return(AR_IFACE_EIA_232);
|
|
|
|
if(ctype > 178)
|
|
|
|
return(AR_IFACE_X_21);
|
|
|
|
if(ctype > 150)
|
|
|
|
return(AR_IFACE_EIA_530);
|
|
|
|
if(ctype > 25)
|
|
|
|
return(AR_IFACE_UNKNOWN);
|
|
|
|
if(ctype > 7)
|
|
|
|
return(AR_IFACE_LOOPBACK);
|
|
|
|
return(AR_IFACE_UNKNOWN);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the card, allocate memory for the ar_softc structures
|
|
|
|
* and fill in the pointers.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
1999-10-17 09:40:04 +00:00
|
|
|
arc_init(struct ar_hardc *hc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
struct ar_softc *sc;
|
|
|
|
int x;
|
|
|
|
u_int chanmem;
|
|
|
|
u_int bufmem;
|
|
|
|
u_int next;
|
|
|
|
u_int descneeded;
|
|
|
|
u_char isr, mar;
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
MALLOC(sc, struct ar_softc *,
|
|
|
|
hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
|
|
|
|
if (sc == NULL)
|
1999-11-18 08:32:02 +00:00
|
|
|
return;
|
1995-11-21 02:32:04 +00:00
|
|
|
bzero(sc, hc->numports * sizeof(struct ar_softc));
|
1999-10-21 09:06:11 +00:00
|
|
|
hc->sc = sc;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-03 08:42:28 +00:00
|
|
|
hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
|
|
|
|
AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
|
|
|
|
hc->txc_dtr[1] = AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
|
|
|
|
hc->txc_dtr_off[0] = AR_TXC_DTR0;
|
|
|
|
hc->txc_dtr_off[1] = AR_TXC_DTR2;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_PCI) {
|
|
|
|
hc->txc_dtr_off[0] *= 4;
|
|
|
|
hc->txc_dtr_off[1] *= 4;
|
|
|
|
}
|
1996-03-03 08:42:28 +00:00
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
/*
|
|
|
|
* reset the card and wait at least 1uS.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
hc->orbase[AR_TXC_DTR0 * 4] = ~AR_TXC_DTR_NOTRESET &
|
|
|
|
hc->txc_dtr[0];
|
|
|
|
else
|
|
|
|
outb(hc->iobase + AR_TXC_DTR0, ~AR_TXC_DTR_NOTRESET &
|
|
|
|
hc->txc_dtr[0]);
|
1995-11-21 02:32:04 +00:00
|
|
|
DELAY(2);
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
|
|
|
|
else
|
|
|
|
outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA) {
|
|
|
|
/*
|
|
|
|
* Configure the card.
|
|
|
|
* Mem address, irq,
|
|
|
|
*/
|
|
|
|
mar = kvtop(hc->mem_start) >> 16;
|
|
|
|
isr = irqtable[ffs(hc->isa_irq) - 1] << 1;
|
|
|
|
if(isr == 0)
|
|
|
|
printf("ar%d: Warning illegal interrupt %d\n",
|
|
|
|
hc->cunit, ffs(hc->isa_irq) - 1);
|
|
|
|
isr = isr | ((kvtop(hc->mem_start) & 0xc000) >> 10);
|
|
|
|
|
|
|
|
hc->sca[0] = (sca_regs *)hc->mem_start;
|
|
|
|
hc->sca[1] = (sca_regs *)hc->mem_start;
|
|
|
|
|
|
|
|
outb(hc->iobase + AR_MEM_SEL, mar);
|
|
|
|
outb(hc->iobase + AR_INT_SEL, isr | AR_INTS_CEN);
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_PCI && hc->interface[0] == AR_IFACE_PIM)
|
|
|
|
for(x = 0; x < hc->numports; x++)
|
|
|
|
hc->interface[x] = ar_read_pim_iface(hc, x);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
1996-04-12 19:57:44 +00:00
|
|
|
* Set the TX clock direction and enable TX.
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
for(x=0;x<hc->numports;x++) {
|
|
|
|
switch(hc->interface[x]) {
|
|
|
|
case AR_IFACE_V_35:
|
|
|
|
hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
|
|
|
|
AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
|
|
|
|
hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
|
|
|
|
AR_TXC_DTR_TXCS0 : AR_TXC_DTR_TXCS1;
|
|
|
|
break;
|
|
|
|
case AR_IFACE_EIA_530:
|
|
|
|
case AR_IFACE_COMBO:
|
|
|
|
case AR_IFACE_X_21:
|
|
|
|
hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
|
|
|
|
AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
|
|
|
|
else
|
|
|
|
outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
|
|
|
|
if(hc->numports > NCHAN) {
|
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
hc->orbase[AR_TXC_DTR2 * 4] = hc->txc_dtr[1];
|
|
|
|
else
|
|
|
|
outb(hc->iobase + AR_TXC_DTR2, hc->txc_dtr[1]);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chanmem = hc->memsize / hc->numports;
|
|
|
|
next = 0;
|
|
|
|
|
|
|
|
for(x=0;x<hc->numports;x++, sc++) {
|
1996-03-17 00:29:35 +00:00
|
|
|
int blk;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca = hc->sca[x / NCHAN];
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
|
|
|
|
sc->block[blk].txdesc = next;
|
|
|
|
bufmem = (16 * 1024) / AR_TX_BLOCKS;
|
|
|
|
descneeded = bufmem / AR_BUF_SIZ;
|
|
|
|
sc->block[blk].txstart = sc->block[blk].txdesc +
|
1995-11-21 02:32:04 +00:00
|
|
|
((((descneeded * sizeof(sca_descriptor)) /
|
|
|
|
AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->block[blk].txend = next + bufmem;
|
|
|
|
sc->block[blk].txmax =
|
|
|
|
(sc->block[blk].txend - sc->block[blk].txstart)
|
|
|
|
/ AR_BUF_SIZ;
|
|
|
|
next += bufmem;
|
|
|
|
|
|
|
|
TRC(printf("ar%d: blk %d: txdesc %x, txstart %x, "
|
|
|
|
"txend %x, txmax %d\n",
|
|
|
|
x,
|
|
|
|
blk,
|
|
|
|
sc->block[blk].txdesc,
|
|
|
|
sc->block[blk].txstart,
|
|
|
|
sc->block[blk].txend,
|
|
|
|
sc->block[blk].txmax));
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
sc->rxdesc = next;
|
1996-03-17 00:29:35 +00:00
|
|
|
bufmem = chanmem - (bufmem * AR_TX_BLOCKS);
|
1995-11-21 02:32:04 +00:00
|
|
|
descneeded = bufmem / AR_BUF_SIZ;
|
|
|
|
sc->rxstart = sc->rxdesc +
|
|
|
|
((((descneeded * sizeof(sca_descriptor)) /
|
|
|
|
AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
|
|
|
|
sc->rxend = next + bufmem;
|
|
|
|
sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ;
|
|
|
|
next += bufmem;
|
1999-10-17 09:40:04 +00:00
|
|
|
TRC(printf("ar%d: rxdesc %x, rxstart %x, "
|
|
|
|
"rxend %x, rxmax %d\n",
|
|
|
|
x, sc->rxdesc, sc->rxstart, sc->rxend, sc->rxmax));
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
1999-10-17 09:40:04 +00:00
|
|
|
|
|
|
|
if(hc->bustype == AR_BUS_PCI)
|
|
|
|
hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The things done here are channel independent.
|
|
|
|
*
|
|
|
|
* Configure the sca waitstates.
|
|
|
|
* Configure the global interrupt registers.
|
|
|
|
* Enable master dma enable.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_init_sca(struct ar_hardc *hc, int scano)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sca = hc->sca[scano];
|
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do the wait registers.
|
|
|
|
* Set everything to 0 wait states.
|
|
|
|
*/
|
|
|
|
sca->pabr0 = 0;
|
|
|
|
sca->pabr1 = 0;
|
|
|
|
sca->wcrl = 0;
|
|
|
|
sca->wcrm = 0;
|
|
|
|
sca->wcrh = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the interrupt registers.
|
|
|
|
* Most are cleared until the interface is configured.
|
|
|
|
*/
|
|
|
|
sca->ier0 = 0x00; /* MSCI interrupts... Not used with dma. */
|
|
|
|
sca->ier1 = 0x00; /* DMAC interrupts */
|
|
|
|
sca->ier2 = 0x00; /* TIMER interrupts... Not used yet. */
|
|
|
|
sca->itcr = 0x00; /* Use ivr and no intr ack */
|
|
|
|
sca->ivr = 0x40; /* Fill in the interrupt vector. */
|
|
|
|
sca->imvr = 0x40;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the timers.
|
|
|
|
* XXX Later
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
/*
|
|
|
|
* Set the DMA channel priority to rotate between
|
|
|
|
* all four channels.
|
|
|
|
*
|
|
|
|
* Enable all dma channels.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_PCI) {
|
|
|
|
u_char *t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stupid problem with the PCI interface chip that break
|
|
|
|
* things.
|
|
|
|
* XXX
|
|
|
|
*/
|
|
|
|
t = (u_char *)sca;
|
|
|
|
t[AR_PCI_SCA_PCR] = SCA_PCR_PR2;
|
|
|
|
t[AR_PCI_SCA_DMER] = SCA_DMER_EN;
|
|
|
|
} else {
|
|
|
|
sca->pcr = SCA_PCR_PR2;
|
|
|
|
sca->dmer = SCA_DMER_EN;
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the msci
|
|
|
|
*
|
|
|
|
* NOTE: The serial port configuration is hardcoded at the moment.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_init_msci(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
msci_channel *msci;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
msci = &sc->sca->msci[sc->scachan];
|
|
|
|
|
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
msci->cmd = SCA_CMD_RESET;
|
|
|
|
|
|
|
|
msci->md0 = SCA_MD0_CRC_1 |
|
|
|
|
SCA_MD0_CRC_CCITT |
|
|
|
|
SCA_MD0_CRC_ENABLE |
|
|
|
|
SCA_MD0_MODE_HDLC;
|
|
|
|
msci->md1 = SCA_MD1_NOADDRCHK;
|
|
|
|
msci->md2 = SCA_MD2_DUPLEX | SCA_MD2_NRZ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Acording to the manual I should give a reset after changing the
|
|
|
|
* mode registers.
|
|
|
|
*/
|
|
|
|
msci->cmd = SCA_CMD_RXRESET;
|
1996-03-03 08:42:28 +00:00
|
|
|
msci->ctl = SCA_CTL_IDLPAT | SCA_CTL_UDRNC | SCA_CTL_RTS;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For now all interfaces are programmed to use the RX clock for
|
|
|
|
* the TX clock.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
switch(sc->hc->interface[sc->subunit]) {
|
1995-11-21 02:32:04 +00:00
|
|
|
case AR_IFACE_V_35:
|
1996-04-12 19:57:44 +00:00
|
|
|
msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
|
|
|
|
msci->txs = SCA_TXS_CLK_TXC | SCA_TXS_DIV1;
|
|
|
|
break;
|
1995-11-21 02:32:04 +00:00
|
|
|
case AR_IFACE_X_21:
|
|
|
|
case AR_IFACE_EIA_530:
|
|
|
|
case AR_IFACE_COMBO:
|
|
|
|
msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
|
|
|
|
msci->txs = SCA_TXS_CLK_RX | SCA_TXS_DIV1;
|
|
|
|
}
|
|
|
|
|
|
|
|
msci->tmc = 153; /* This give 64k for loopback */
|
|
|
|
|
|
|
|
/* XXX
|
|
|
|
* Disable all interrupts for now. I think if you are using
|
|
|
|
* the dmac you don't use these interrupts.
|
|
|
|
*/
|
|
|
|
msci->ie0 = 0;
|
|
|
|
msci->ie1 = 0x0C; /* XXX CTS and DCD (DSR on 570I) level change. */
|
|
|
|
msci->ie2 = 0;
|
|
|
|
msci->fie = 0;
|
|
|
|
|
|
|
|
msci->sa0 = 0;
|
|
|
|
msci->sa1 = 0;
|
|
|
|
|
|
|
|
msci->idl = 0x7E; /* XXX This is what cisco does. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is what the ARNET diags use.
|
|
|
|
*/
|
|
|
|
msci->rrc = 0x0E;
|
|
|
|
msci->trc0 = 0x12;
|
|
|
|
msci->trc1 = 0x1F;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the rx dma controller.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_init_rx_dmac(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac_channel *dmac;
|
1995-11-21 02:32:04 +00:00
|
|
|
sca_descriptor *rxd;
|
|
|
|
u_int rxbuf;
|
|
|
|
u_int rxda;
|
|
|
|
u_int rxda_d;
|
1999-10-17 09:40:04 +00:00
|
|
|
int x = 0;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
|
|
|
|
|
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
rxd = (sca_descriptor *)(sc->hc->mem_start + (sc->rxdesc&sc->hc->winmsk));
|
|
|
|
rxda_d = (u_int)sc->hc->mem_start - (sc->rxdesc & ~sc->hc->winmsk);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
for(rxbuf=sc->rxstart;rxbuf<sc->rxend;rxbuf += AR_BUF_SIZ, rxd++) {
|
|
|
|
rxda = (u_int)&rxd[1] - rxda_d;
|
|
|
|
rxd->cp = (u_short)(rxda & 0xfffful);
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
x++;
|
|
|
|
if(x < 6)
|
|
|
|
TRC(printf("Descrp %p, data pt %x, data %x, ",
|
|
|
|
rxd, rxda, rxbuf));
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
rxd->bp = (u_short)(rxbuf & 0xfffful);
|
|
|
|
rxd->bpb = (u_char)((rxbuf >> 16) & 0xff);
|
|
|
|
rxd->len = 0;
|
|
|
|
rxd->stat = 0xff; /* The sca write here when it is finished. */
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(x < 6)
|
1995-11-21 02:32:04 +00:00
|
|
|
TRC(printf("bpb %x, bp %x.\n", rxd->bpb, rxd->bp));
|
|
|
|
}
|
|
|
|
rxd--;
|
|
|
|
rxd->cp = (u_short)(sc->rxdesc & 0xfffful);
|
|
|
|
|
|
|
|
sc->rxhind = 0;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
dmac->dsr = 0; /* Disable DMA transfer */
|
|
|
|
dmac->dcr = SCA_DCR_ABRT;
|
|
|
|
|
|
|
|
/* XXX maybe also SCA_DMR_CNTE */
|
|
|
|
dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
|
|
|
|
dmac->bfl = AR_BUF_SIZ;
|
|
|
|
|
|
|
|
dmac->cda = (u_short)(sc->rxdesc & 0xffff);
|
|
|
|
dmac->sarb = (u_char)((sc->rxdesc >> 16) & 0xff);
|
|
|
|
|
|
|
|
rxd = (sca_descriptor *)sc->rxstart;
|
|
|
|
dmac->eda = (u_short)((u_int)&rxd[sc->rxmax - 1] & 0xffff);
|
|
|
|
|
|
|
|
dmac->dir = 0xF0;
|
|
|
|
|
|
|
|
dmac->dsr = SCA_DSR_DE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the TX DMA descriptors.
|
|
|
|
* Initialize the needed values and chain the descriptors.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_init_tx_dmac(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac_channel *dmac;
|
1996-03-17 00:29:35 +00:00
|
|
|
struct buf_block *blkp;
|
|
|
|
int blk;
|
1995-11-21 02:32:04 +00:00
|
|
|
sca_descriptor *txd;
|
|
|
|
u_int txbuf;
|
|
|
|
u_int txda;
|
|
|
|
u_int txda_d;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
|
|
|
|
|
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
|
|
|
|
blkp = &sc->block[blk];
|
|
|
|
txd = (sca_descriptor *)(sc->hc->mem_start +
|
1999-10-17 09:40:04 +00:00
|
|
|
(blkp->txdesc&sc->hc->winmsk));
|
1996-03-17 00:29:35 +00:00
|
|
|
txda_d = (u_int)sc->hc->mem_start -
|
1999-10-17 09:40:04 +00:00
|
|
|
(blkp->txdesc & ~sc->hc->winmsk);
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
txbuf=blkp->txstart;
|
|
|
|
for(;txbuf<blkp->txend;txbuf += AR_BUF_SIZ, txd++) {
|
|
|
|
txda = (u_int)&txd[1] - txda_d;
|
|
|
|
txd->cp = (u_short)(txda & 0xfffful);
|
|
|
|
|
|
|
|
txd->bp = (u_short)(txbuf & 0xfffful);
|
|
|
|
txd->bpb = (u_char)((txbuf >> 16) & 0xff);
|
|
|
|
TRC(printf("ar%d: txbuf %x, bpb %x, bp %x\n",
|
|
|
|
sc->unit, txbuf, txd->bpb, txd->bp));
|
|
|
|
txd->len = 0;
|
|
|
|
txd->stat = 0;
|
|
|
|
}
|
|
|
|
txd--;
|
|
|
|
txd->cp = (u_short)(blkp->txdesc & 0xfffful);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
blkp->txtail = (u_int)txd - (u_int)sc->hc->mem_start;
|
|
|
|
TRC(printf("TX Descriptors start %x, end %x.\n",
|
1999-10-17 09:40:04 +00:00
|
|
|
blkp->txdesc,
|
1996-03-17 00:29:35 +00:00
|
|
|
blkp->txtail));
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
dmac->dsr = 0; /* Disable DMA */
|
|
|
|
dmac->dcr = SCA_DCR_ABRT;
|
|
|
|
dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
|
|
|
|
dmac->dir = SCA_DIR_EOT | SCA_DIR_BOF | SCA_DIR_COF;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
dmac->sarb = (u_char)((sc->block[0].txdesc >> 16) & 0xff);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look through the descriptors to see if there is a complete packet
|
|
|
|
* available. Stop if we get to where the sca is busy.
|
|
|
|
*
|
|
|
|
* Return the length and status of the packet.
|
|
|
|
* Return nonzero if there is a packet available.
|
1996-04-12 19:57:44 +00:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* It seems that we get the interrupt a bit early. The updateing of
|
|
|
|
* descriptor values is not always completed when this is called.
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
|
|
|
ar_packet_avail(struct ar_softc *sc,
|
1995-11-21 02:32:04 +00:00
|
|
|
int *len,
|
|
|
|
u_char *rxstat)
|
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac_channel *dmac;
|
1995-11-21 02:32:04 +00:00
|
|
|
sca_descriptor *rxdesc;
|
|
|
|
sca_descriptor *endp;
|
1996-04-12 19:57:44 +00:00
|
|
|
sca_descriptor *cda;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
|
|
|
dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
|
1996-04-12 19:57:44 +00:00
|
|
|
cda = (sca_descriptor *)(sc->hc->mem_start +
|
1999-10-17 09:40:04 +00:00
|
|
|
((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
|
1995-11-21 02:32:04 +00:00
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
endp = rxdesc;
|
|
|
|
rxdesc = &rxdesc[sc->rxhind];
|
|
|
|
endp = &endp[sc->rxmax];
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
|
1996-04-12 19:57:44 +00:00
|
|
|
while(rxdesc != cda) {
|
1995-11-21 02:32:04 +00:00
|
|
|
*len += rxdesc->len;
|
|
|
|
|
|
|
|
if(rxdesc->stat & SCA_DESC_EOM) {
|
|
|
|
*rxstat = rxdesc->stat;
|
1999-10-17 09:40:04 +00:00
|
|
|
TRC(printf("ar%d: PKT AVAIL len %d, %x.\n",
|
|
|
|
sc->unit, *len, *rxstat));
|
1995-11-21 02:32:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
1996-04-12 19:57:44 +00:00
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
rxdesc++;
|
|
|
|
if(rxdesc == endp)
|
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
*rxstat = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy a packet from the on card memory into a provided mbuf.
|
|
|
|
* Take into account that buffers wrap and that a packet may
|
|
|
|
* be larger than a buffer.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
|
|
|
ar_copy_rxbuf(struct mbuf *m,
|
1995-11-21 02:32:04 +00:00
|
|
|
struct ar_softc *sc,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
sca_descriptor *rxdesc;
|
|
|
|
u_int rxdata;
|
|
|
|
u_int rxmax;
|
|
|
|
u_int off = 0;
|
|
|
|
u_int tlen;
|
|
|
|
|
|
|
|
rxdata = sc->rxstart + (sc->rxhind * AR_BUF_SIZ);
|
|
|
|
rxmax = sc->rxstart + (sc->rxmax * AR_BUF_SIZ);
|
|
|
|
|
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
rxdesc = &rxdesc[sc->rxhind];
|
|
|
|
|
|
|
|
while(len) {
|
|
|
|
tlen = (len < AR_BUF_SIZ) ? len : AR_BUF_SIZ;
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, rxdata);
|
|
|
|
bcopy(sc->hc->mem_start + (rxdata & sc->hc->winmsk),
|
1995-11-21 02:32:04 +00:00
|
|
|
mtod(m, caddr_t) + off,
|
|
|
|
tlen);
|
|
|
|
|
|
|
|
off += tlen;
|
|
|
|
len -= tlen;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
|
1995-11-21 02:32:04 +00:00
|
|
|
rxdesc->len = 0;
|
|
|
|
rxdesc->stat = 0xff;
|
|
|
|
|
|
|
|
rxdata += AR_BUF_SIZ;
|
|
|
|
rxdesc++;
|
|
|
|
if(rxdata == rxmax) {
|
|
|
|
rxdata = sc->rxstart;
|
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-04-12 19:57:44 +00:00
|
|
|
* If single is set, just eat a packet. Otherwise eat everything up to
|
|
|
|
* where cda points. Update pointers to point to the next packet.
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
1996-04-12 19:57:44 +00:00
|
|
|
ar_eat_packet(struct ar_softc *sc, int single)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
1999-10-17 09:40:04 +00:00
|
|
|
dmac_channel *dmac;
|
1995-11-21 02:32:04 +00:00
|
|
|
sca_descriptor *rxdesc;
|
|
|
|
sca_descriptor *endp;
|
1996-04-12 19:57:44 +00:00
|
|
|
sca_descriptor *cda;
|
|
|
|
int loopcnt = 0;
|
|
|
|
u_char stat;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
|
|
|
dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
|
1996-04-12 19:57:44 +00:00
|
|
|
cda = (sca_descriptor *)(sc->hc->mem_start +
|
1999-10-17 09:40:04 +00:00
|
|
|
((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop until desc->stat == (0xff || EOM)
|
|
|
|
* Clear the status and length in the descriptor.
|
|
|
|
* Increment the descriptor.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
|
1995-11-21 02:32:04 +00:00
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
endp = rxdesc;
|
|
|
|
rxdesc = &rxdesc[sc->rxhind];
|
|
|
|
endp = &endp[sc->rxmax];
|
|
|
|
|
1996-04-12 19:57:44 +00:00
|
|
|
while(rxdesc != cda) {
|
|
|
|
loopcnt++;
|
|
|
|
if(loopcnt > sc->rxmax) {
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("ar%d: eat pkt %d loop, cda %p, "
|
|
|
|
"rxdesc %p, stat %x.\n",
|
1996-04-12 19:57:44 +00:00
|
|
|
sc->unit,
|
|
|
|
loopcnt,
|
1998-08-24 02:28:16 +00:00
|
|
|
(void *)cda,
|
|
|
|
(void *)rxdesc,
|
1996-04-12 19:57:44 +00:00
|
|
|
rxdesc->stat);
|
1995-11-21 02:32:04 +00:00
|
|
|
break;
|
1996-04-12 19:57:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stat = rxdesc->stat;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
rxdesc->len = 0;
|
|
|
|
rxdesc->stat = 0xff;
|
|
|
|
|
|
|
|
rxdesc++;
|
|
|
|
sc->rxhind++;
|
|
|
|
if(rxdesc == endp) {
|
|
|
|
rxdesc = (sca_descriptor *)
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->rxhind = 0;
|
|
|
|
}
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
if(single && (stat == SCA_DESC_EOM))
|
|
|
|
break;
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the eda to the previous descriptor.
|
|
|
|
*/
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
rxdesc = (sca_descriptor *)sc->rxdesc;
|
|
|
|
rxdesc = &rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
|
1996-04-12 19:57:44 +00:00
|
|
|
(u_short)((u_int)rxdesc & 0xffff);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* While there is packets available in the rx buffer, read them out
|
|
|
|
* into mbufs and ship them off.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
|
|
|
ar_get_packets(struct ar_softc *sc)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
sca_descriptor *rxdesc;
|
|
|
|
struct mbuf *m = NULL;
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
u_char rxstat;
|
|
|
|
|
|
|
|
while(ar_packet_avail(sc, &len, &rxstat)) {
|
1999-10-17 09:40:04 +00:00
|
|
|
TRC(printf("apa: len %d, rxstat %x\n", len, rxstat));
|
1996-10-28 19:40:01 +00:00
|
|
|
if(((rxstat & SCA_DESC_ERRORS) == 0) && (len < MCLBYTES)) {
|
1995-11-21 02:32:04 +00:00
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
1996-03-17 00:29:35 +00:00
|
|
|
if(m == NULL) {
|
|
|
|
/* eat packet if get mbuf fail!! */
|
1996-04-12 19:57:44 +00:00
|
|
|
ar_eat_packet(sc, 1);
|
|
|
|
continue;
|
1996-03-17 00:29:35 +00:00
|
|
|
}
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
m->m_pkthdr.rcvif = NULL;
|
|
|
|
sc->inbytes += len;
|
|
|
|
sc->inlast = 0;
|
|
|
|
#endif /* NETGRAPH */
|
1996-03-17 00:29:35 +00:00
|
|
|
m->m_pkthdr.len = m->m_len = len;
|
|
|
|
if(len > MHLEN) {
|
1995-11-21 02:32:04 +00:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1996-03-17 00:29:35 +00:00
|
|
|
if((m->m_flags & M_EXT) == 0) {
|
1995-11-21 02:32:04 +00:00
|
|
|
m_freem(m);
|
1996-04-12 19:57:44 +00:00
|
|
|
ar_eat_packet(sc, 1);
|
|
|
|
continue;
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
1996-03-17 00:29:35 +00:00
|
|
|
ar_copy_rxbuf(m, sc, len);
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
if(sc->ifsppp.pp_if.if_bpf)
|
|
|
|
bpf_mtap(&sc->ifsppp.pp_if, m);
|
|
|
|
sppp_input(&sc->ifsppp.pp_if, m);
|
|
|
|
sc->ifsppp.pp_if.if_ipackets++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
ng_queue_data(sc->hook, m, NULL);
|
|
|
|
sc->ipackets++;
|
|
|
|
#endif /* NETGRAPH */
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the eda to the previous descriptor.
|
|
|
|
*/
|
|
|
|
i = (len + AR_BUF_SIZ - 1) / AR_BUF_SIZ;
|
|
|
|
sc->rxhind = (sc->rxhind + i) % sc->rxmax;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
rxdesc = (sca_descriptor *)sc->rxdesc;
|
|
|
|
rxdesc =
|
|
|
|
&rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
|
1996-04-12 19:57:44 +00:00
|
|
|
(u_short)((u_int)rxdesc & 0xffff);
|
1995-11-21 02:32:04 +00:00
|
|
|
} else {
|
1996-10-28 19:40:01 +00:00
|
|
|
int tries = 5;
|
|
|
|
|
|
|
|
while((rxstat == 0xff) && --tries)
|
|
|
|
ar_packet_avail(sc, &len, &rxstat);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It look like we get an interrupt early
|
|
|
|
* sometimes and then the status is not
|
|
|
|
* filled in yet.
|
|
|
|
*/
|
|
|
|
if(tries && (tries != 5))
|
|
|
|
continue;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-04-12 19:57:44 +00:00
|
|
|
ar_eat_packet(sc, 1);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->ifsppp.pp_if.if_ierrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->ierrors[0]++;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
TRCL(printf("ar%d: Receive error chan %d, "
|
1996-04-12 19:57:44 +00:00
|
|
|
"stat %x, msci st3 %x,"
|
|
|
|
"rxhind %d, cda %x, eda %x.\n",
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->unit,
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->scachan,
|
1996-03-17 00:29:35 +00:00
|
|
|
rxstat,
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->msci[sc->scachan].st3,
|
1996-04-12 19:57:44 +00:00
|
|
|
sc->rxhind,
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->dmac[
|
1996-04-12 19:57:44 +00:00
|
|
|
DMAC_RXCH(sc->scachan)].cda,
|
1999-10-17 09:40:04 +00:00
|
|
|
sc->sca->dmac[
|
1996-04-12 19:57:44 +00:00
|
|
|
DMAC_RXCH(sc->scachan)].eda));
|
|
|
|
}
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All DMA interrupts come here.
|
|
|
|
*
|
|
|
|
* Each channel has two interrupts.
|
|
|
|
* Interrupt A for errors and Interrupt B for normal stuff like end
|
|
|
|
* of transmit or receive dmas.
|
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
u_char dsr;
|
1996-03-17 00:29:35 +00:00
|
|
|
u_char dotxstart = isr1;
|
1995-11-21 02:32:04 +00:00
|
|
|
int mch;
|
|
|
|
struct ar_softc *sc;
|
1999-10-17 09:40:04 +00:00
|
|
|
sca_regs *sca;
|
1995-11-21 02:32:04 +00:00
|
|
|
dmac_channel *dmac;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
sca = hc->sca[scano];
|
1995-11-21 02:32:04 +00:00
|
|
|
mch = 0;
|
|
|
|
/*
|
|
|
|
* Shortcut if there is no interrupts for dma channel 0 or 1
|
|
|
|
*/
|
|
|
|
if((isr1 & 0x0F) == 0) {
|
|
|
|
mch = 1;
|
|
|
|
isr1 >>= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
sc = &hc->sc[mch + (NCHAN * scano)];
|
|
|
|
|
|
|
|
/*
|
1996-03-17 00:29:35 +00:00
|
|
|
* Transmit channel
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
if(isr1 & 0x0C) {
|
|
|
|
dmac = &sca->dmac[DMAC_TXCH(mch)];
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
dsr = dmac->dsr;
|
|
|
|
dmac->dsr = dsr;
|
|
|
|
|
|
|
|
/* Counter overflow */
|
|
|
|
if(dsr & SCA_DSR_COF) {
|
1996-03-17 00:29:35 +00:00
|
|
|
printf("ar%d: TX DMA Counter overflow, "
|
|
|
|
"txpacket no %lu.\n",
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->unit,
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_opackets);
|
|
|
|
sc->ifsppp.pp_if.if_oerrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->opackets);
|
|
|
|
sc->oerrors++;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Buffer overflow */
|
|
|
|
if(dsr & SCA_DSR_BOF) {
|
1996-03-17 00:29:35 +00:00
|
|
|
printf("ar%d: TX DMA Buffer overflow, "
|
|
|
|
"txpacket no %lu, dsr %02x, "
|
|
|
|
"cda %04x, eda %04x.\n",
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->unit,
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_opackets,
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->opackets,
|
|
|
|
#endif /* NETGRAPH */
|
1996-03-17 00:29:35 +00:00
|
|
|
dsr,
|
|
|
|
dmac->cda,
|
|
|
|
dmac->eda);
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_oerrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->oerrors++;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of Transfer */
|
|
|
|
if(dsr & SCA_DSR_EOT) {
|
|
|
|
/*
|
1996-03-17 00:29:35 +00:00
|
|
|
* This should be the most common case.
|
1995-11-21 02:32:04 +00:00
|
|
|
*
|
1996-03-17 00:29:35 +00:00
|
|
|
* Clear the IFF_OACTIVE flag.
|
|
|
|
*
|
|
|
|
* Call arstart to start a new transmit if
|
|
|
|
* there is data to transmit.
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->xmit_busy = 0;
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
|
|
|
|
sc->ifsppp.pp_if.if_timer = 0;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
/* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
|
|
|
|
sc->out_dog = 0; /* XXX */
|
|
|
|
#endif /* NETGRAPH */
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
if(sc->txb_inuse && --sc->txb_inuse)
|
|
|
|
ar_xmit(sc);
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-03-17 00:29:35 +00:00
|
|
|
* Receive channel
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
|
|
|
if(isr1 & 0x03) {
|
1996-03-17 00:29:35 +00:00
|
|
|
dmac = &sca->dmac[DMAC_RXCH(mch)];
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
dsr = dmac->dsr;
|
|
|
|
dmac->dsr = dsr;
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
TRC(printf("AR: RX DSR %x\n", dsr));
|
|
|
|
|
|
|
|
/* End of frame */
|
|
|
|
if(dsr & SCA_DSR_EOM) {
|
1996-04-12 19:57:44 +00:00
|
|
|
TRC(int tt = sc->ifsppp.pp_if.if_ipackets;)
|
|
|
|
TRC(int ind = sc->rxhind;)
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
ar_get_packets(sc);
|
1996-04-12 19:57:44 +00:00
|
|
|
TRC(
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-04-12 19:57:44 +00:00
|
|
|
if(tt == sc->ifsppp.pp_if.if_ipackets) {
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
if(tt == sc->ipackets) {
|
|
|
|
#endif /* NETGRAPH */
|
1996-04-12 19:57:44 +00:00
|
|
|
sca_descriptor *rxdesc;
|
|
|
|
int i;
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1996-04-12 19:57:44 +00:00
|
|
|
printf("AR: RXINTR isr1 %x, dsr %x, "
|
|
|
|
"no data %d pkts, orxhind %d.\n",
|
|
|
|
dotxstart,
|
|
|
|
dsr,
|
|
|
|
tt,
|
|
|
|
ind);
|
|
|
|
printf("AR: rxdesc %x, rxstart %x, "
|
|
|
|
"rxend %x, rxhind %d, "
|
|
|
|
"rxmax %d.\n",
|
|
|
|
sc->rxdesc,
|
|
|
|
sc->rxstart,
|
|
|
|
sc->rxend,
|
|
|
|
sc->rxhind,
|
|
|
|
sc->rxmax);
|
|
|
|
printf("AR: cda %x, eda %x.\n",
|
|
|
|
dmac->cda,
|
|
|
|
dmac->eda);
|
|
|
|
|
1999-10-17 09:40:04 +00:00
|
|
|
if(sc->hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_MEM(sc->hc->iobase,
|
|
|
|
sc->rxdesc);
|
1996-04-12 19:57:44 +00:00
|
|
|
rxdesc = (sca_descriptor *)
|
|
|
|
(sc->hc->mem_start +
|
1999-10-17 09:40:04 +00:00
|
|
|
(sc->rxdesc & sc->hc->winmsk));
|
1996-04-12 19:57:44 +00:00
|
|
|
rxdesc = &rxdesc[sc->rxhind];
|
|
|
|
for(i=0;i<3;i++,rxdesc++)
|
|
|
|
printf("AR: rxdesc->stat %x, "
|
|
|
|
"len %d.\n",
|
|
|
|
rxdesc->stat,
|
|
|
|
rxdesc->len);
|
|
|
|
})
|
1996-03-17 00:29:35 +00:00
|
|
|
}
|
|
|
|
|
1995-11-21 02:32:04 +00:00
|
|
|
/* Counter overflow */
|
|
|
|
if(dsr & SCA_DSR_COF) {
|
1996-03-17 00:29:35 +00:00
|
|
|
printf("ar%d: RX DMA Counter overflow, "
|
|
|
|
"rxpkts %lu.\n",
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->unit,
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_ipackets);
|
|
|
|
sc->ifsppp.pp_if.if_ierrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->ipackets);
|
|
|
|
sc->ierrors[1]++;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Buffer overflow */
|
|
|
|
if(dsr & SCA_DSR_BOF) {
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1996-03-17 00:29:35 +00:00
|
|
|
printf("ar%d: RX DMA Buffer overflow, "
|
1996-04-12 19:57:44 +00:00
|
|
|
"rxpkts %lu, rxind %d, "
|
|
|
|
"cda %x, eda %x, dsr %x.\n",
|
1995-11-21 02:32:04 +00:00
|
|
|
sc->unit,
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-04-12 19:57:44 +00:00
|
|
|
sc->ifsppp.pp_if.if_ipackets,
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->ipackets,
|
|
|
|
#endif /* NETGRAPH */
|
1996-04-12 19:57:44 +00:00
|
|
|
sc->rxhind,
|
|
|
|
dmac->cda,
|
|
|
|
dmac->eda,
|
|
|
|
dsr);
|
|
|
|
/*
|
|
|
|
* Make sure we eat as many as possible.
|
|
|
|
* Then get the system running again.
|
|
|
|
*/
|
|
|
|
ar_eat_packet(sc, 0);
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_ierrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->ierrors[2]++;
|
|
|
|
#endif /* NETGRAPH */
|
1999-10-17 09:40:04 +00:00
|
|
|
if(hc->bustype == AR_BUS_ISA)
|
|
|
|
ARC_SET_SCA(hc->iobase, scano);
|
1996-04-12 19:57:44 +00:00
|
|
|
sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
|
1996-03-17 00:29:35 +00:00
|
|
|
dmac->dsr = SCA_DSR_DE;
|
1996-04-12 19:57:44 +00:00
|
|
|
|
|
|
|
TRC(printf("ar%d: RX DMA Buffer overflow, "
|
|
|
|
"rxpkts %lu, rxind %d, "
|
|
|
|
"cda %x, eda %x, dsr %x. After\n",
|
|
|
|
sc->unit,
|
|
|
|
sc->ifsppp.pp_if.if_ipackets,
|
|
|
|
sc->rxhind,
|
|
|
|
dmac->cda,
|
|
|
|
dmac->eda,
|
|
|
|
dmac->dsr);)
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of Transfer */
|
|
|
|
if(dsr & SCA_DSR_EOT) {
|
|
|
|
/*
|
1996-03-17 00:29:35 +00:00
|
|
|
* If this happen, it means that we are
|
|
|
|
* receiving faster than what the processor
|
|
|
|
* can handle.
|
1995-11-21 02:32:04 +00:00
|
|
|
*
|
1996-03-17 00:29:35 +00:00
|
|
|
* XXX We should enable the dma again.
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1996-03-17 00:29:35 +00:00
|
|
|
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
|
|
|
|
sc->unit,
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
sc->ifsppp.pp_if.if_ipackets);
|
|
|
|
sc->ifsppp.pp_if.if_ierrors++;
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
sc->ipackets);
|
|
|
|
sc->ierrors[3]++;
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
isr1 >>= 4;
|
1995-11-21 02:32:04 +00:00
|
|
|
|
|
|
|
mch++;
|
|
|
|
}while((mch<NCHAN) && isr1);
|
1996-03-17 00:29:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we have done all the urgent things, see if we
|
|
|
|
* can fill the transmit buffers.
|
|
|
|
*/
|
|
|
|
for(mch = 0; mch < NCHAN; mch++) {
|
|
|
|
if(dotxstart & 0x0C) {
|
|
|
|
sc = &hc->sc[mch + (NCHAN * scano)];
|
1999-10-21 09:06:11 +00:00
|
|
|
#ifndef NETGRAPH
|
1996-03-17 00:29:35 +00:00
|
|
|
arstart(&sc->ifsppp.pp_if);
|
1999-10-21 09:06:11 +00:00
|
|
|
#else /* NETGRAPH */
|
|
|
|
arstart(sc);
|
|
|
|
#endif /* NETGRAPH */
|
1996-03-17 00:29:35 +00:00
|
|
|
}
|
|
|
|
dotxstart >>= 4;
|
|
|
|
}
|
1995-11-21 02:32:04 +00:00
|
|
|
}
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr0)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
printf("arc%d: ARINTR: MSCI\n", hc->cunit);
|
|
|
|
}
|
|
|
|
|
1996-03-17 00:29:35 +00:00
|
|
|
static void
|
|
|
|
ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
|
1995-11-21 02:32:04 +00:00
|
|
|
{
|
|
|
|
printf("arc%d: ARINTR: TIMER\n", hc->cunit);
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
#ifdef NETGRAPH
|
|
|
|
/*****************************************
|
|
|
|
* Device timeout/watchdog routine.
|
|
|
|
* called once per second.
|
|
|
|
* checks to see that if activity was expected, that it hapenned.
|
|
|
|
* At present we only look to see if expected output was completed.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ngar_watchdog_frame(void * arg)
|
|
|
|
{
|
|
|
|
struct ar_softc * sc = arg;
|
|
|
|
int s;
|
|
|
|
int speed;
|
|
|
|
|
|
|
|
if(sc->running == 0)
|
|
|
|
return; /* if we are not running let timeouts die */
|
|
|
|
/*
|
|
|
|
* calculate the apparent throughputs
|
|
|
|
* XXX a real hack
|
|
|
|
*/
|
|
|
|
s = splimp();
|
|
|
|
speed = sc->inbytes - sc->lastinbytes;
|
|
|
|
sc->lastinbytes = sc->inbytes;
|
|
|
|
if ( sc->inrate < speed )
|
|
|
|
sc->inrate = speed;
|
|
|
|
speed = sc->outbytes - sc->lastoutbytes;
|
|
|
|
sc->lastoutbytes = sc->outbytes;
|
|
|
|
if ( sc->outrate < speed )
|
|
|
|
sc->outrate = speed;
|
|
|
|
sc->inlast++;
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
if ((sc->inlast > QUITE_A_WHILE)
|
|
|
|
&& (sc->out_deficit > LOTS_OF_PACKETS)) {
|
|
|
|
log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
|
|
|
|
s = splimp();
|
|
|
|
ar_down(sc);
|
|
|
|
ar_up(sc);
|
|
|
|
sc->inlast = sc->out_deficit = 0;
|
|
|
|
splx(s);
|
|
|
|
} else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
|
|
|
|
if (sc->out_dog == 0) {
|
|
|
|
log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
|
|
|
|
sc->unit);
|
1999-11-19 05:37:37 +00:00
|
|
|
s = splimp();
|
1999-10-21 09:06:11 +00:00
|
|
|
arwatchdog(sc);
|
|
|
|
#if 0
|
|
|
|
ar_down(sc);
|
|
|
|
ar_up(sc);
|
|
|
|
#endif
|
1999-11-19 05:37:37 +00:00
|
|
|
splx(s);
|
1999-10-21 09:06:11 +00:00
|
|
|
sc->inlast = sc->out_deficit = 0;
|
|
|
|
} else {
|
|
|
|
sc->out_dog--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* This section contains the methods for the Netgraph interface
|
|
|
|
***********************************************************************/
|
1995-11-21 02:32:04 +00:00
|
|
|
/*
|
1999-10-21 09:06:11 +00:00
|
|
|
* It is not possible or allowable to create a node of this type.
|
|
|
|
* If the hardware exists, it will already have created it.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ngar_constructor(node_p *nodep)
|
|
|
|
{
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* give our ok for a hook to be added...
|
|
|
|
* If we are not running this should kick the device into life.
|
|
|
|
* The hook's private info points to our stash of info about that
|
|
|
|
* channel.
|
|
|
|
*/
|
2000-01-21 01:39:40 +00:00
|
|
|
static int
|
1999-10-21 09:06:11 +00:00
|
|
|
ngar_newhook(node_p node, hook_p hook, const char *name)
|
|
|
|
{
|
|
|
|
struct ar_softc * sc = node->private;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check if it's our friend the debug hook
|
|
|
|
*/
|
|
|
|
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
|
|
|
hook->private = NULL; /* paranoid */
|
|
|
|
sc->debug_hook = hook;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for raw mode hook.
|
|
|
|
*/
|
|
|
|
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
hook->private = sc;
|
|
|
|
sc->hook = hook;
|
|
|
|
sc->datahooks++;
|
|
|
|
ar_up(sc);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* incoming messages.
|
|
|
|
* Just respond to the generic TEXT_STATUS message
|
1995-11-21 02:32:04 +00:00
|
|
|
*/
|
1999-10-21 09:06:11 +00:00
|
|
|
static int
|
2000-04-28 17:09:00 +00:00
|
|
|
ngar_rcvmsg(node_p node, struct ng_mesg *msg,
|
|
|
|
const char *retaddr, struct ng_mesg **resp, hook_p lasthook)
|
1999-10-21 09:06:11 +00:00
|
|
|
{
|
|
|
|
struct ar_softc * sc;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
sc = node->private;
|
|
|
|
switch (msg->header.typecookie) {
|
|
|
|
case NG_AR_COOKIE:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
case NGM_GENERIC_COOKIE:
|
|
|
|
switch(msg->header.cmd) {
|
|
|
|
case NGM_TEXT_STATUS: {
|
|
|
|
char *arg;
|
|
|
|
int pos = 0;
|
|
|
|
int resplen = sizeof(struct ng_mesg) + 512;
|
|
|
|
MALLOC(*resp, struct ng_mesg *, resplen,
|
|
|
|
M_NETGRAPH, M_NOWAIT);
|
|
|
|
if (*resp == NULL) {
|
|
|
|
error = ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bzero(*resp, resplen);
|
|
|
|
arg = (*resp)->data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put in the throughput information.
|
|
|
|
*/
|
|
|
|
pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
|
|
|
|
"highest rate seen: %ld B/S in, %ld B/S out\n",
|
|
|
|
sc->inbytes, sc->outbytes,
|
|
|
|
sc->inrate, sc->outrate);
|
|
|
|
pos += sprintf(arg + pos,
|
|
|
|
"%ld output errors\n",
|
|
|
|
sc->oerrors);
|
|
|
|
pos += sprintf(arg + pos,
|
|
|
|
"ierrors = %ld, %ld, %ld, %ld\n",
|
|
|
|
sc->ierrors[0],
|
|
|
|
sc->ierrors[1],
|
|
|
|
sc->ierrors[2],
|
|
|
|
sc->ierrors[3]);
|
|
|
|
|
|
|
|
(*resp)->header.version = NG_VERSION;
|
|
|
|
(*resp)->header.arglen = strlen(arg) + 1;
|
|
|
|
(*resp)->header.token = msg->header.token;
|
|
|
|
(*resp)->header.typecookie = NG_AR_COOKIE;
|
|
|
|
(*resp)->header.cmd = msg->header.cmd;
|
|
|
|
strncpy((*resp)->header.cmdstr, "status",
|
|
|
|
NG_CMDSTRLEN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free(msg, M_NETGRAPH);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get data from another node and transmit it to the correct channel
|
|
|
|
*/
|
|
|
|
static int
|
2000-04-28 17:09:00 +00:00
|
|
|
ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
|
|
|
|
struct mbuf **ret_m, meta_p *ret_meta)
|
1999-10-21 09:06:11 +00:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
int error = 0;
|
|
|
|
struct ar_softc * sc = hook->node->private;
|
|
|
|
struct ifqueue *xmitq_p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* data doesn't come in from just anywhere (e.g control hook)
|
|
|
|
*/
|
|
|
|
if ( hook->private == NULL) {
|
|
|
|
error = ENETDOWN;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now queue the data for when it can be sent
|
|
|
|
*/
|
|
|
|
if (meta && meta->priority > 0) {
|
|
|
|
xmitq_p = (&sc->xmitq_hipri);
|
|
|
|
} else {
|
|
|
|
xmitq_p = (&sc->xmitq);
|
|
|
|
}
|
|
|
|
s = splimp();
|
|
|
|
if (IF_QFULL(xmitq_p)) {
|
|
|
|
IF_DROP(xmitq_p);
|
|
|
|
splx(s);
|
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
IF_ENQUEUE(xmitq_p, m);
|
|
|
|
arstart(sc);
|
1999-11-19 05:37:37 +00:00
|
|
|
splx(s);
|
1999-10-21 09:06:11 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
|
|
|
/*
|
|
|
|
* It was an error case.
|
|
|
|
* check if we need to free the mbuf, and then return the error
|
|
|
|
*/
|
|
|
|
NG_FREE_DATA(m, meta);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* do local shutdown processing..
|
|
|
|
* this node will refuse to go away, unless the hardware says to..
|
|
|
|
* don't unref the node, or remove our name. just clear our links up.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ngar_rmnode(node_p node)
|
|
|
|
{
|
|
|
|
struct ar_softc * sc = node->private;
|
|
|
|
|
|
|
|
ar_down(sc);
|
|
|
|
ng_cutlinks(node);
|
|
|
|
node->flags &= ~NG_INVALID; /* bounce back to life */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* already linked */
|
|
|
|
static int
|
|
|
|
ngar_connect(hook_p hook)
|
|
|
|
{
|
|
|
|
/* be really amiable and just say "YUP that's OK by me! " */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* notify on hook disconnection (destruction)
|
|
|
|
*
|
|
|
|
* Invalidate the private data associated with this dlci.
|
|
|
|
* For this type, removal of the last link resets tries to destroy the node.
|
|
|
|
* As the device still exists, the shutdown method will not actually
|
|
|
|
* destroy the node, but reset the device and leave it 'fresh' :)
|
|
|
|
*
|
|
|
|
* The node removal code will remove all references except that owned by the
|
|
|
|
* driver.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ngar_disconnect(hook_p hook)
|
|
|
|
{
|
|
|
|
struct ar_softc * sc = hook->node->private;
|
|
|
|
int s;
|
|
|
|
/*
|
|
|
|
* If it's the data hook, then free resources etc.
|
|
|
|
*/
|
|
|
|
if (hook->private) {
|
|
|
|
s = splimp();
|
|
|
|
sc->datahooks--;
|
|
|
|
if (sc->datahooks == 0)
|
|
|
|
ar_down(sc);
|
|
|
|
splx(s);
|
|
|
|
} else {
|
|
|
|
sc->debug_hook = NULL;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* called during bootup
|
|
|
|
* or LKM loading to put this type into the list of known modules
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ngar_init(void *ignored)
|
|
|
|
{
|
|
|
|
if (ng_newtype(&typestruct))
|
|
|
|
printf("ngar install failed\n");
|
|
|
|
ngar_done_init = 1;
|
|
|
|
}
|
|
|
|
#endif /* NETGRAPH */
|
1995-11-21 02:32:04 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
********************************* END ************************************
|
|
|
|
*/
|