Subject: Matt pointed out a missed constant. I found another :-)
To: 'port-powerpc@netbsd.org' <port-powerpc@netbsd.org>
From: Bruce Korb <bkorb@allegronetworks.com>
List: port-powerpc
Date: 04/18/2001 13:28:16
netbsd/usr/src/sys/arch/macppc/dev/if_gm.c#1 -
/home/bkorb/olive/sys/arch/macppc/dev/if_gm.c ====
@@ -67,6 +67,7 @@
#define NTXBUF 4
#define NRXBUF 32
+#define BUF_SIZE
struct gmac_softc {
struct device sc_dev;
@@ -182,19 +183,21 @@
return;
}
- /* Setup packet buffers and dma descriptors. */
- p = malloc((NRXBUF + NTXBUF) * 2048 + 3 * 0x800, M_DEVBUF,
M_NOWAIT);
+ /* Setup packet buffers, dma descriptors and alignment spare. */
+ #define BUFCT (NRXBUF + NXTBUF + 2)
+
+ p = malloc((BUFCT + 1) * BUF_SIZE, M_DEVBUF, M_NOWAIT);
if (p == NULL) {
printf(": cannot malloc buffers\n");
return;
}
- p = (void *)roundup((vaddr_t)p, 0x800);
- bzero(p, 2048 * (NRXBUF + NTXBUF) + 2 * 0x800);
+ p = (void *)roundup((vaddr_t)p, BUF_SIZE);
+ bzero(p, BUF_SIZE * BUFCT);
sc->sc_rxlist = (void *)p;
- p += 0x800;
+ p += BUF_SIZE;
sc->sc_txlist = (void *)p;
- p += 0x800;
+ p += BUF_SIZE;
dp = sc->sc_rxlist;
for (i = 0; i < NRXBUF; i++) {
@@ -202,7 +205,7 @@
dp->address = htole32(vtophys((vaddr_t)p));
dp->cmd = htole32(GMAC_OWN);
dp++;
- p += 2048;
+ p += BUF_SIZE;
}
dp = sc->sc_txlist;
@@ -210,8 +213,9 @@
sc->sc_txbuf[i] = p;
dp->address = htole32(vtophys((vaddr_t)p));
dp++;
- p += 2048;
+ p += BUF_SIZE;
}
+ #undef BUFCT
printf(": Ethernet address %s\n", ether_sprintf(laddr));
printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
@@ -536,7 +540,7 @@
tlen += len;
MFREE(m, n);
}
- if (tlen > 2048)
+ if (tlen > BUF_SIZE)
panic("%s: gmac_put packet overflow", sc->sc_dev.dv_xname);
return tlen;