From: briggs Date: Thu, 10 Apr 1997 02:35:02 +0000 (+0000) Subject: Changes from Denny Gentry : X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=43214a9c3582285c9d803bc0eb7392d88a051829;p=openbsd Changes from Denny Gentry : Change in the way receive buffer areas are handled. Before we gave the chip 16 buffers, each 1536 bytes (big enough for one packet). Now we're handing the chip 8 buffers, each 4 Kbytes, and letting the chip fit as many packets as it can in each one. This should help keep it from running out of buffer space. Also make some of the performance-crucial routines inline. It made no measurable difference except to make me feel better --- diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index e54842cdde5..4dd01df444e 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,5 +1,5 @@ /* $NetBSD: if_sn.c,v 1.7 1997/03/20 17:47:51 scottr Exp $ */ -/* $OpenBSD: if_sn.c,v 1.17 1997/03/29 23:26:48 briggs Exp $ */ +/* $OpenBSD: if_sn.c,v 1.18 1997/04/10 02:35:02 briggs Exp $ */ /* * National Semiconductor SONIC Driver @@ -61,7 +61,7 @@ typedef unsigned char uchar; static void snwatchdog __P((struct ifnet *)); static int sninit __P((struct sn_softc *sc)); static int snstop __P((struct sn_softc *sc)); -static int sonicput __P((struct sn_softc *sc, struct mbuf *m0)); +static inline int sonicput __P((struct sn_softc *sc, struct mbuf *m0)); static int snioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data)); static void snstart __P((struct ifnet *ifp)); static void snreset __P((struct sn_softc *sc)); @@ -207,9 +207,8 @@ snsetup(sc) p = pp + NBPG; - for (i = 0; i < NRBA; i+=2) { + for (i = 0; i < NRBA; i++) { sc->rbuf[i] = (caddr_t) p; - sc->rbuf[i+1] = (caddr_t)(p + (NBPG/2)); p += NBPG; } @@ -543,7 +542,7 @@ snwatchdog(ifp) /* * stuff packet into sonic (at splnet) */ -static int +static inline int sonicput(sc, m0) struct sn_softc *sc; struct mbuf *m0; @@ -633,8 +632,8 @@ sonicput(sc, m0) static void sonictxint __P((struct sn_softc *)); static void sonicrxint __P((struct sn_softc *)); -static int sonic_read __P((struct sn_softc *, caddr_t, int)); -static struct mbuf *sonic_get __P((struct sn_softc *, struct ether_header *, int)); +static inline int sonic_read __P((struct sn_softc *, caddr_t, int)); +static inline struct mbuf *sonic_get __P((struct sn_softc *, struct ether_header *, int)); /* * CAM support @@ -831,10 +830,11 @@ initialise_rra(sc) unsigned int v; int bitmode = sc->bitmode; - if (bitmode) /* eobc must be >= MAXETHERPKT */ + if (bitmode) NIC_PUT(sc, SNR_EOBC, RBASIZE(sc) / 2 - 2); else NIC_PUT(sc, SNR_EOBC, RBASIZE(sc) / 2 - 1); + NIC_PUT(sc, SNR_URRA, UPPER(sc->v_rra[0])); NIC_PUT(sc, SNR_RSA, LOWER(sc->v_rra[0])); /* rea must point just past the end of the rra space */ @@ -846,8 +846,8 @@ initialise_rra(sc) v = kvtop(sc->rbuf[i]); SWO(bitmode, sc->p_rra[i], RXRSRC_PTRHI, UPPER(v)); SWO(bitmode, sc->p_rra[i], RXRSRC_PTRLO, LOWER(v)); - SWO(bitmode, sc->p_rra[i], RXRSRC_WCHI, UPPER(RBASIZE(sc) / 2)); - SWO(bitmode, sc->p_rra[i], RXRSRC_WCLO, LOWER(RBASIZE(sc) / 2)); + SWO(bitmode, sc->p_rra[i], RXRSRC_WCHI, UPPER(NBPG/2)); + SWO(bitmode, sc->p_rra[i], RXRSRC_WCLO, LOWER(NBPG/2)); } sc->sc_rramark = NRBA; NIC_PUT(sc, SNR_RWP, LOWER(sc->v_rra[sc->sc_rramark])); @@ -876,11 +876,11 @@ snintr(arg, slot) NIC_PUT(sc, SNR_ISR, isr); wbflush(); - if (isr & (ISR_BR | ISR_LCD | ISR_PINT | ISR_TC)) + if (isr & (ISR_BR | ISR_LCD | ISR_TC)) printf("%s: unexpected interrupt status 0x%x\n", sc->sc_dev.dv_xname, isr); - if (isr & (ISR_TXDN | ISR_TXER)) + if (isr & (ISR_TXDN | ISR_TXER | ISR_PINT)) sonictxint(sc); if (isr & ISR_PKTRX) @@ -997,22 +997,20 @@ sonicrxint(sc) int rramark; int rdamark; int bitmode = sc->bitmode; - void *tmp1; - void *tmp2; + u_int16_t rxpkt_ptr; rda = sc->p_rda[sc->sc_rxmark]; while (SRO(bitmode, rda, RXPKT_INUSE) == 0) { unsigned status = SRO(bitmode, rda, RXPKT_STATUS); - if ((status & RCR_LPKT) == 0) - printf("%s: more than one packet in RBA!\n", - sc->sc_dev.dv_xname); orra = RBASEQ(SRO(bitmode, rda, RXPKT_SEQNO)) & RRAMASK; + rxpkt_ptr = SRO(bitmode, rda, RXPKT_PTRLO); len = SRO(bitmode, rda, RXPKT_BYTEC) - sizeof(struct ether_header) - FCSSIZE; if (status & RCR_PRX) { - if (sonic_read(sc, sc->rbuf[orra & RBAMASK], len)) { + caddr_t pkt = sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PGOFSET); + if (sonic_read(sc, pkt, len)) { sc->sc_if.if_ipackets++; sc->sc_sum.ls_ipacks++; sc->sc_missed = 0; @@ -1023,8 +1021,9 @@ sonicrxint(sc) /* * give receive buffer area back to chip. * - * orra is now empty of packets and can be freed if - * sonic read didnt copy it out then we would have to + * If this was the last packet in the RRA, give the RRA to + * the chip again. + * If sonic read didnt copy it out then we would have to * wait !! * (dont bother add it back in again straight away) * @@ -1032,25 +1031,29 @@ sonicrxint(sc) * we have to use the macros because SONIC might be in * 16 or 32 bit mode. */ - rramark = sc->sc_rramark; - tmp1 = sc->p_rra[rramark]; - tmp2 = sc->p_rra[orra]; - SWO(bitmode, tmp1, RXRSRC_PTRLO, - SRO(bitmode, tmp2, RXRSRC_PTRLO)); - SWO(bitmode, tmp1, RXRSRC_PTRHI, - SRO(bitmode, tmp2, RXRSRC_PTRHI)); - SWO(bitmode, tmp1, RXRSRC_WCLO, - SRO(bitmode, tmp2, RXRSRC_WCLO)); - SWO(bitmode, tmp1, RXRSRC_WCHI, - SRO(bitmode, tmp2, RXRSRC_WCHI)); - - /* zap old rra for fun */ - SWO(bitmode, tmp2, RXRSRC_WCHI, 0); - SWO(bitmode, tmp2, RXRSRC_WCLO, 0); - - sc->sc_rramark = (++rramark) & RRAMASK; - NIC_PUT(sc, SNR_RWP, LOWER(sc->v_rra[rramark])); - wbflush(); + if (status & RCR_LPKT) { + void *tmp1, *tmp2; + + rramark = sc->sc_rramark; + tmp1 = sc->p_rra[rramark]; + tmp2 = sc->p_rra[orra]; + SWO(bitmode, tmp1, RXRSRC_PTRLO, + SRO(bitmode, tmp2, RXRSRC_PTRLO)); + SWO(bitmode, tmp1, RXRSRC_PTRHI, + SRO(bitmode, tmp2, RXRSRC_PTRHI)); + SWO(bitmode, tmp1, RXRSRC_WCLO, + SRO(bitmode, tmp2, RXRSRC_WCLO)); + SWO(bitmode, tmp1, RXRSRC_WCHI, + SRO(bitmode, tmp2, RXRSRC_WCHI)); + + /* zap old rra for fun */ + SWO(bitmode, tmp2, RXRSRC_WCHI, 0); + SWO(bitmode, tmp2, RXRSRC_WCLO, 0); + + sc->sc_rramark = (++rramark) & RRAMASK; + NIC_PUT(sc, SNR_RWP, LOWER(sc->v_rra[rramark])); + wbflush(); + } /* * give receive descriptor back to chip simple @@ -1074,7 +1077,7 @@ sonicrxint(sc) * sonic_read -- pull packet off interface and forward to * appropriate protocol handler */ -static int +static inline int sonic_read(sc, pkt, len) struct sn_softc *sc; caddr_t pkt; @@ -1131,7 +1134,7 @@ sonic_read(sc, pkt, len) * because we are using stupid buffer management this * is slow. */ -static struct mbuf * +static inline struct mbuf * sonic_get(sc, eh, datalen) struct sn_softc *sc; struct ether_header *eh; diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h index fa6c3aecc1d..d5db4b9987a 100644 --- a/sys/arch/mac68k/dev/if_snvar.h +++ b/sys/arch/mac68k/dev/if_snvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_snvar.h,v 1.3 1997/03/29 23:26:50 briggs Exp $ */ +/* $OpenBSD: if_snvar.h,v 1.4 1997/04/10 02:35:03 briggs Exp $ */ /* * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) @@ -47,12 +47,12 @@ * 1 Rda is 4 words == 16 bytes */ -#define NRBA 16 /* # receive buffers < NRRA */ -#define RBAMASK 0x0f -#define NRDA NRBA +#define NRBA 8 /* # receive buffers < NRRA */ +#define RBAMASK (NRBA-1) +#define NRDA NRBA*4 #define NTDA 4 /* # transmit descriptors */ #define NRRA 32 /* # receive resource descriptors */ -#define RRAMASK 0x1f /* the reason why it must be power of two */ +#define RRAMASK (NRRA-1) /* the reason why it must be power of two */ #define FCSSIZE 4 /* size of FCS appended to packets */ @@ -204,7 +204,7 @@ typedef struct sn_softc { * Transmit Descriptor * This structure holds information about packets to be transmitted. */ -#define FRAGMAX 16 /* maximum number of fragments in a packet */ +#define FRAGMAX 8 /* maximum number of fragments in a packet */ #define TXP_STATUS 0 /* + transmitted packet status */ #define TXP_CONFIG 1 /* transmission configuration */ @@ -217,7 +217,7 @@ typedef struct sn_softc { #define TXP_FPTRHI 1 /* ptr to packet fragment HI */ #define TXP_FSIZE 2 /* fragment size */ -#define TXP_WORDS TXP_FRAGOFF + FRAGMAX*TXP_FSIZE + 1 /* 1 for tlink */ +#define TXP_WORDS TXP_FRAGOFF + (FRAGMAX*TXP_FRAGSIZE) + 1 /* 1 for tlink */ #define TXP_SIZE(sc) ((sc->bitmode) ? (TXP_WORDS*4) : (TXP_WORDS*2)) #define EOL 0x0001 /* end of list marker for link fields */