From a59faac5f2347e4b2a4275275495bdc0146ae76e Mon Sep 17 00:00:00 2001 From: briggs Date: Fri, 25 Apr 1997 03:29:14 +0000 Subject: [PATCH] A couple of performance improvements from Denny Gentry --- sys/arch/mac68k/dev/if_sn.c | 33 +++++++++++++++++++++------------ sys/arch/mac68k/dev/if_snvar.h | 21 ++++++++++++--------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index 3bd38797bf8..e65ad212d58 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.21 1997/04/18 11:58:34 briggs Exp $ */ +/* $OpenBSD: if_sn.c,v 1.22 1997/04/25 03:29:15 briggs Exp $ */ /* * National Semiconductor SONIC Driver @@ -176,14 +176,6 @@ snsetup(sc) p = (unsigned char *)SOALIGN(sc, p); - for (i = 0; i < NRDA; i++) { - sc->p_rda[i] = (void *) p; - sc->v_rda[i] = kvtop(p); - p += RXPKT_SIZE(sc); - } - - p = (unsigned char *)SOALIGN(sc, p); - for (i = 0; i < NTDA; i++) { struct mtd *mtdp = &sc->mtda[i]; mtdp->mtd_txp = (void *)p; @@ -195,16 +187,33 @@ snsetup(sc) if ((p - pp) > NBPG) { printf ("%s: sizeof RRA (%ld) + CDA (%ld) +" - "RDA (%ld) + TDA (%ld) > NBPG (%d). Punt!\n", + "TDA (%ld) > NBPG (%d). Punt!\n", sc->sc_dev.dv_xname, (ulong)sc->p_cda - (ulong)sc->p_rra[0], - (ulong)sc->p_rda[0] - (ulong)sc->p_cda, - (ulong)sc->mtda[0].mtd_txp - (ulong)sc->p_rda[0], + (ulong)sc->mtda[0].mtd_txp - (ulong)sc->p_cda, (ulong)p - (ulong)sc->mtda[0].mtd_txp, NBPG); return(1); } + p = pp + NBPG; + pp = p; + + if ((NRDA * RXPKT_SIZE(sc)) > NBPG) { + printf ("%s: sizeof NRDA (%d) > NBPG (%d). Punt!\n", + sc->sc_dev.dv_xname, + NRDA * RXPKT_SIZE(sc), NBPG); + return (1); + } + + for (i = 0; i < NRDA; i++) { + sc->p_rda[i] = (void *) p; + sc->v_rda[i] = kvtop(p); + p += RXPKT_SIZE(sc); + } + + p = (unsigned char *)SOALIGN(sc, p); + p = pp + NBPG; for (i = 0; i < NRBA; i++) { diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h index 5f3bd9bf5b2..9d0abe3bd83 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.6 1997/04/23 00:28:22 gene Exp $ */ +/* $OpenBSD: if_snvar.h,v 1.7 1997/04/25 03:29:14 briggs Exp $ */ /* * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) @@ -40,19 +40,22 @@ /* * buffer sizes in 32 bit mode - * 1 TXpkt is 4 hdr words + (3 * FRAGMAX) + 1 link word - * FRAGMAX == 16 => 54 words == 216 bytes + * 1 TXpkt is 4 hdr words + (3 * FRAGMAX) + 1 link word == 23 words == 92 bytes * * 1 RxPkt is 7 words == 28 bytes * 1 Rda is 4 words == 16 bytes + * + * The CDA is 17 words == 68 bytes + * + * total space in page 0 = NTDA * 92 + NRRA * 16 + NRDA * 28 + 68 */ #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 (NRRA-1) /* the reason why it must be power of two */ +#define NRDA 146 +#define NTDA 8 /* # transmit descriptors */ +#define NRRA 16 /* # receive resource descriptors */ +#define RRAMASK (NRRA-1) /* the reason why NRRA must be power of two */ #define FCSSIZE 4 /* size of FCS appended to packets */ @@ -66,10 +69,10 @@ /* * transmit buffer area */ -#define NTXB 10 /* Number of xmit buffers */ +#define NTXB NTDA /* Number of xmit buffers */ #define TXBSIZE 1536 /* 6*2^8 -- the same size as the 8390 TXBUF */ -#define SN_NPAGES 1 + 8 + 5 +#define SN_NPAGES 2 + 8 + 4 /* * Statistics collected over time -- 2.20.1