On request from Allen Briggs, converted this to new ARP
system. Somebody should actually test if this compiles (and works) on Mac68k... I only carefully checked cvs diff -u.
This commit is contained in:
parent
ab9bbd64d6
commit
530a88d144
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_sn.c,v 1.1 1997/03/15 20:26:35 briggs Exp $ */
|
||||
/* $NetBSD: if_sn.c,v 1.2 1997/03/16 13:41:14 is Exp $ */
|
||||
|
||||
/*
|
||||
* National Semiconductor SONIC Driver
|
||||
|
@ -22,15 +22,14 @@
|
|||
#include <sys/device.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet/if_inarp.h>
|
||||
#endif
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
@ -112,8 +111,9 @@ int ethdebug = 0;
|
|||
* to accept packets.
|
||||
*/
|
||||
void
|
||||
snsetup(sc)
|
||||
snsetup(sc, lladdr)
|
||||
struct sn_softc *sc;
|
||||
u_int8_t *lladdr;
|
||||
{
|
||||
struct ifnet *ifp = &sc->sc_if;
|
||||
unsigned char *p;
|
||||
|
@ -211,7 +211,7 @@ snsetup(sc)
|
|||
#if 0
|
||||
camdump(sc);
|
||||
#endif
|
||||
printf(" address %s\n", ether_sprintf(sc->sc_enaddr));
|
||||
printf(" address %s\n", ether_sprintf(lladdr));
|
||||
|
||||
#if 0
|
||||
printf("sonic buffers: rra=%p cda=0x%x rda=0x%x tda=0x%x\n",
|
||||
|
@ -228,7 +228,7 @@ printf("sonic buffers: rra=%p cda=0x%x rda=0x%x tda=0x%x\n",
|
|||
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
||||
#endif
|
||||
if_attach(ifp);
|
||||
ether_ifattach(ifp);
|
||||
ether_ifattach(ifp, lladdr);
|
||||
|
||||
add_nubus_intr(sc->slotno, snintr, (void *) sc);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ snioctl(ifp, cmd, data)
|
|||
#ifdef INET
|
||||
case AF_INET:
|
||||
(void)sninit(ifp->if_softc);
|
||||
arp_ifinit(&sc->sc_arpcom, ifa);
|
||||
arp_ifinit(ifp, ifa);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -289,10 +289,10 @@ snioctl(ifp, cmd, data)
|
|||
case SIOCDELMULTI:
|
||||
if(cmd == SIOCADDMULTI)
|
||||
err = ether_addmulti((struct ifreq *)data,
|
||||
&sc->sc_arpcom);
|
||||
&sc->sc_ethercom);
|
||||
else
|
||||
err = ether_delmulti((struct ifreq *)data,
|
||||
&sc->sc_arpcom);
|
||||
&sc->sc_ethercom);
|
||||
|
||||
if (err == ENETRESET) {
|
||||
/*
|
||||
|
@ -325,7 +325,7 @@ snstart(ifp)
|
|||
struct mbuf *m;
|
||||
int len;
|
||||
|
||||
if ((sc->sc_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
|
||||
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
|
||||
return;
|
||||
|
||||
outloop:
|
||||
|
@ -339,7 +339,7 @@ outloop:
|
|||
return;
|
||||
}
|
||||
|
||||
IF_DEQUEUE(&sc->sc_if.if_snd, m);
|
||||
IF_DEQUEUE(&ifp->if_snd, m);
|
||||
if (m == 0)
|
||||
return;
|
||||
|
||||
|
@ -352,8 +352,8 @@ outloop:
|
|||
* If bpf is listening on this interface, let it
|
||||
* see the packet before we commit it to the wire.
|
||||
*/
|
||||
if (sc->sc_if.if_bpf)
|
||||
bpf_mtap(sc->sc_if.if_bpf, m);
|
||||
if (ifp->if_bpf)
|
||||
bpf_mtap(ifp->if_bpf, m);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -378,7 +378,7 @@ outloop:
|
|||
|
||||
sc->txb_inuse++;
|
||||
|
||||
sc->sc_if.if_opackets++; /* # of pkts */
|
||||
ifp->if_opackets++; /* # of pkts */
|
||||
sc->sc_sum.ls_opacks++; /* # of pkts */
|
||||
|
||||
/* Jump back for possibly more punishment. */
|
||||
|
@ -524,9 +524,9 @@ snwatchdog(ifp)
|
|||
else
|
||||
log(LOG_ERR, "%s: Tx - lost interrupt\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
temp = sc->sc_if.if_flags & IFF_UP;
|
||||
temp = ifp->if_flags & IFF_UP;
|
||||
snreset(sc);
|
||||
sc->sc_if.if_flags |= temp;
|
||||
ifp->if_flags |= temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_sn_nubus.c,v 1.1 1997/03/15 20:26:37 briggs Exp $ */
|
||||
/* $NetBSD: if_sn_nubus.c,v 1.2 1997/03/16 13:41:15 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Allen Briggs
|
||||
|
@ -39,10 +39,13 @@
|
|||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#if 0 /* XXX this shouldn't be necessary; else reinsert */
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet/if_inarp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
@ -57,12 +60,11 @@ static int sn_nubus_match __P((struct device *, struct cfdata *, void *));
|
|||
static void sn_nubus_attach __P((struct device *, struct device *, void *));
|
||||
static int sn_nb_card_vendor __P((struct nubus_attach_args *));
|
||||
|
||||
void snsetup __P((struct sn_softc *));
|
||||
|
||||
struct cfattach sn_nubus_ca = {
|
||||
sizeof(struct sn_softc), sn_nubus_match, sn_nubus_attach
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
sn_nubus_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
|
@ -110,6 +112,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
int i, success;
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh, tmp_bsh;
|
||||
u_int8_t myaddr[ETHER_ADDR_LEN];
|
||||
|
||||
bst = na->na_tag;
|
||||
if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) {
|
||||
|
@ -146,8 +149,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
* Copy out the ethernet address from the card's ROM
|
||||
*/
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, tmp_bsh, i);
|
||||
myaddr[i] = bus_space_read_1(bst, tmp_bsh, i);
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
@ -169,7 +171,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
return;
|
||||
}
|
||||
|
||||
snsetup(sc);
|
||||
snsetup(sc, myaddr);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_sn_obio.c,v 1.1 1997/03/15 20:26:38 briggs Exp $ */
|
||||
/* $NetBSD: if_sn_obio.c,v 1.2 1997/03/16 13:41:16 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Allen Briggs
|
||||
|
@ -39,11 +39,14 @@
|
|||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#if 0 /* XXX this shouldn't be necessary... else reinsert */
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpu.h>
|
||||
|
@ -59,7 +62,6 @@
|
|||
static int sn_obio_match __P((struct device *, struct cfdata *, void *));
|
||||
static void sn_obio_attach __P((struct device *, struct device *, void *));
|
||||
static void sn_obio_getaddr __P((struct sn_softc *));
|
||||
void snsetup __P((struct sn_softc *));
|
||||
|
||||
struct cfattach sn_obio_ca = {
|
||||
sizeof(struct sn_softc), sn_obio_match, sn_obio_attach
|
||||
|
@ -87,6 +89,7 @@ sn_obio_attach(parent, self, aux)
|
|||
{
|
||||
struct obio_attach_args *oa = (struct obio_attach_args *) aux;
|
||||
struct sn_softc *sc = (void *)self;
|
||||
u_int8_t myaddr[ETHER_ADDR_LEN];
|
||||
|
||||
sc->s_dcr = DCR_LBR | DCR_SYNC | DCR_WAIT0 |
|
||||
DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16;
|
||||
|
@ -116,17 +119,18 @@ sn_obio_attach(parent, self, aux)
|
|||
|
||||
sc->slotno = 9;
|
||||
|
||||
sn_obio_getaddr(sc);
|
||||
sn_obio_getaddr(sc, myaddr);
|
||||
|
||||
snsetup(sc);
|
||||
snsetup(sc, myaddr);
|
||||
}
|
||||
|
||||
static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
|
||||
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
|
||||
|
||||
static void
|
||||
sn_obio_getaddr(sc)
|
||||
sn_obio_getaddr(sc, lladdr)
|
||||
struct sn_softc *sc;
|
||||
u_int8_t *lladdr;
|
||||
{
|
||||
bus_space_handle_t bsh;
|
||||
int i, do_bbr;
|
||||
|
@ -145,11 +149,11 @@ sn_obio_getaddr(sc)
|
|||
b = bus_space_read_1(sc->sc_regt, bsh, 0);
|
||||
if (b == 0x10)
|
||||
do_bbr = 1;
|
||||
sc->sc_arpcom.ac_enaddr[0] = (do_bbr) ? bbr(b) : b;
|
||||
lladdr[0] = (do_bbr) ? bbr(b) : b;
|
||||
|
||||
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
|
||||
b = bus_space_read_1(sc->sc_regt, bsh, i);
|
||||
sc->sc_arpcom.ac_enaddr[i] = (do_bbr) ? bbr(b) : b;
|
||||
lladdr[i] = (do_bbr) ? bbr(b) : b;
|
||||
}
|
||||
|
||||
bus_space_unmap(sc->sc_regt, bsh, NBPG);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_snvar.h,v 1.1 1997/03/15 20:26:40 briggs Exp $ */
|
||||
/* $NetBSD: if_snvar.h,v 1.2 1997/03/16 13:41:17 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk)
|
||||
|
@ -92,9 +92,8 @@ typedef struct mtd {
|
|||
*/
|
||||
typedef struct sn_softc {
|
||||
struct device sc_dev;
|
||||
struct arpcom sc_arpcom;
|
||||
#define sc_if sc_arpcom.ac_if /* network visible interface */
|
||||
#define sc_enaddr sc_arpcom.ac_enaddr /* hardware ethernet address */
|
||||
struct ethercom sc_ethercom;
|
||||
#define sc_if sc_ethercom.ec_if /* network visible interface */
|
||||
|
||||
bus_space_tag_t sc_regt;
|
||||
bus_space_handle_t sc_regh;
|
||||
|
@ -217,4 +216,4 @@ typedef struct sn_softc {
|
|||
#define CDA_ENABLE 64 /* mask enabling CAM entries */
|
||||
#define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2))
|
||||
|
||||
void snsetup __P((struct sn_softc *sc));
|
||||
void snsetup __P((struct sn_softc *sc, u_int8_t *));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_sn_nubus.c,v 1.1 1997/03/15 20:26:37 briggs Exp $ */
|
||||
/* $NetBSD: if_sn_nubus.c,v 1.2 1997/03/16 13:41:15 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Allen Briggs
|
||||
|
@ -39,10 +39,13 @@
|
|||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#if 0 /* XXX this shouldn't be necessary; else reinsert */
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet/if_inarp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
@ -57,12 +60,11 @@ static int sn_nubus_match __P((struct device *, struct cfdata *, void *));
|
|||
static void sn_nubus_attach __P((struct device *, struct device *, void *));
|
||||
static int sn_nb_card_vendor __P((struct nubus_attach_args *));
|
||||
|
||||
void snsetup __P((struct sn_softc *));
|
||||
|
||||
struct cfattach sn_nubus_ca = {
|
||||
sizeof(struct sn_softc), sn_nubus_match, sn_nubus_attach
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
sn_nubus_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
|
@ -110,6 +112,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
int i, success;
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh, tmp_bsh;
|
||||
u_int8_t myaddr[ETHER_ADDR_LEN];
|
||||
|
||||
bst = na->na_tag;
|
||||
if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) {
|
||||
|
@ -146,8 +149,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
* Copy out the ethernet address from the card's ROM
|
||||
*/
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, tmp_bsh, i);
|
||||
myaddr[i] = bus_space_read_1(bst, tmp_bsh, i);
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
@ -169,7 +171,7 @@ sn_nubus_attach(parent, self, aux)
|
|||
return;
|
||||
}
|
||||
|
||||
snsetup(sc);
|
||||
snsetup(sc, myaddr);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_sn_obio.c,v 1.1 1997/03/15 20:26:38 briggs Exp $ */
|
||||
/* $NetBSD: if_sn_obio.c,v 1.2 1997/03/16 13:41:16 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Allen Briggs
|
||||
|
@ -39,11 +39,14 @@
|
|||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_ether.h>
|
||||
|
||||
#if 0 /* XXX this shouldn't be necessary... else reinsert */
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpu.h>
|
||||
|
@ -59,7 +62,6 @@
|
|||
static int sn_obio_match __P((struct device *, struct cfdata *, void *));
|
||||
static void sn_obio_attach __P((struct device *, struct device *, void *));
|
||||
static void sn_obio_getaddr __P((struct sn_softc *));
|
||||
void snsetup __P((struct sn_softc *));
|
||||
|
||||
struct cfattach sn_obio_ca = {
|
||||
sizeof(struct sn_softc), sn_obio_match, sn_obio_attach
|
||||
|
@ -87,6 +89,7 @@ sn_obio_attach(parent, self, aux)
|
|||
{
|
||||
struct obio_attach_args *oa = (struct obio_attach_args *) aux;
|
||||
struct sn_softc *sc = (void *)self;
|
||||
u_int8_t myaddr[ETHER_ADDR_LEN];
|
||||
|
||||
sc->s_dcr = DCR_LBR | DCR_SYNC | DCR_WAIT0 |
|
||||
DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16;
|
||||
|
@ -116,17 +119,18 @@ sn_obio_attach(parent, self, aux)
|
|||
|
||||
sc->slotno = 9;
|
||||
|
||||
sn_obio_getaddr(sc);
|
||||
sn_obio_getaddr(sc, myaddr);
|
||||
|
||||
snsetup(sc);
|
||||
snsetup(sc, myaddr);
|
||||
}
|
||||
|
||||
static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
|
||||
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
|
||||
|
||||
static void
|
||||
sn_obio_getaddr(sc)
|
||||
sn_obio_getaddr(sc, lladdr)
|
||||
struct sn_softc *sc;
|
||||
u_int8_t *lladdr;
|
||||
{
|
||||
bus_space_handle_t bsh;
|
||||
int i, do_bbr;
|
||||
|
@ -145,11 +149,11 @@ sn_obio_getaddr(sc)
|
|||
b = bus_space_read_1(sc->sc_regt, bsh, 0);
|
||||
if (b == 0x10)
|
||||
do_bbr = 1;
|
||||
sc->sc_arpcom.ac_enaddr[0] = (do_bbr) ? bbr(b) : b;
|
||||
lladdr[0] = (do_bbr) ? bbr(b) : b;
|
||||
|
||||
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
|
||||
b = bus_space_read_1(sc->sc_regt, bsh, i);
|
||||
sc->sc_arpcom.ac_enaddr[i] = (do_bbr) ? bbr(b) : b;
|
||||
lladdr[i] = (do_bbr) ? bbr(b) : b;
|
||||
}
|
||||
|
||||
bus_space_unmap(sc->sc_regt, bsh, NBPG);
|
||||
|
|
Loading…
Reference in New Issue