summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1999-10-03 13:06:31 +0000
committerJason Wright <jason@cvs.openbsd.org>1999-10-03 13:06:31 +0000
commitacf611fac7337a77b1c9cf6c5bae460d879c1227 (patch)
treec7cc9229ac2bd56d92bdf144b83b6985e8cc8344 /sys/dev/pci
parent2fe8dec400bbd731a59e8575c1d58bc22aca15f9 (diff)
take advantage of m->m_ext.ext_handle for storing the softc
(instead of stashing it in the buffer)
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_sk.c29
-rw-r--r--sys/dev/pci/if_skreg.h15
-rw-r--r--sys/dev/pci/if_ti.c36
-rw-r--r--sys/dev/pci/if_tireg.h13
4 files changed, 29 insertions, 64 deletions
diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c
index 05bcb4c4001..1ba91c4030b 100644
--- a/sys/dev/pci/if_sk.c
+++ b/sys/dev/pci/if_sk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sk.c,v 1.1 1999/10/01 02:52:22 jason Exp $ */
+/* $OpenBSD: if_sk.c,v 1.2 1999/10/03 13:06:30 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -598,6 +598,7 @@ int sk_newbuf(sc_if, c, m)
m_new->m_len = m_new->m_pkthdr.len = SK_MCLBYTES;
m_new->m_data = m_new->m_ext.ext_buf;
}
+ m->m_ext.ext_handle = sc_if;
/*
* Adjust alignment so packet payload begins on a
@@ -651,18 +652,10 @@ int sk_alloc_jumbo_mem(sc_if)
/*
* Now divide it up into 9K pieces and save the addresses
- * in an array. Note that we play an evil trick here by using
- * the first few bytes in the buffer to hold the the address
- * of the softc structure for this interface. This is because
- * sk_jfree() needs it, but it is called by the mbuf management
- * code which will not pass it to us explicitly.
+ * in an array.
*/
ptr = sc_if->sk_cdata.sk_jumbo_buf;
for (i = 0; i < SK_JSLOTS; i++) {
- u_int64_t **aptr;
- aptr = (u_int64_t **)ptr;
- aptr[0] = (u_int64_t *)sc_if;
- ptr += sizeof(u_int64_t);
sc_if->sk_cdata.sk_jslots[i].sk_buf = ptr;
sc_if->sk_cdata.sk_jslots[i].sk_inuse = 0;
ptr += SK_MCLBYTES;
@@ -718,12 +711,10 @@ sk_jref(m)
caddr_t buf = m->m_ext.ext_buf;
u_int size = m->m_ext.ext_size;
struct sk_if_softc *sc_if;
- u_int64_t **aptr;
register int i;
/* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc_if = (struct sk_if_softc *)(aptr[0]);
+ sc_if = (struct sk_if_softc *)m->m_ext.ext_handle;
if (sc_if == NULL)
panic("sk_jref: can't find softc pointer!");
@@ -733,8 +724,7 @@ sk_jref(m)
/* calculate the slot this buffer belongs to */
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
+ i = ((vaddr_t)buf - (vaddr_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
if ((i < 0) || (i >= SK_JSLOTS))
panic("sk_jref: asked to reference buffer "
@@ -743,8 +733,6 @@ sk_jref(m)
panic("sk_jref: buffer already free!");
else
sc_if->sk_cdata.sk_jslots[i].sk_inuse++;
-
- return;
}
/*
@@ -757,13 +745,11 @@ sk_jfree(m)
caddr_t buf = m->m_ext.ext_buf;
u_int size = m->m_ext.ext_size;
struct sk_if_softc *sc_if;
- u_int64_t **aptr;
int i;
struct sk_jpool_entry *entry;
/* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc_if = (struct sk_if_softc *)(aptr[0]);
+ sc_if = (struct sk_if_softc *)m->m_ext.ext_handle;
if (sc_if == NULL)
panic("sk_jfree: can't find softc pointer!");
@@ -773,8 +759,7 @@ sk_jfree(m)
/* calculate the slot this buffer belongs to */
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
+ i = ((vaddr_t)aptr - (vaddr_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
if ((i < 0) || (i >= SK_JSLOTS))
panic("sk_jfree: asked to free buffer that we don't manage!");
diff --git a/sys/dev/pci/if_skreg.h b/sys/dev/pci/if_skreg.h
index e117fefeadb..853b53bb7e6 100644
--- a/sys/dev/pci/if_skreg.h
+++ b/sys/dev/pci/if_skreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_skreg.h,v 1.2 1999/10/01 02:54:15 jason Exp $ */
+/* $OpenBSD: if_skreg.h,v 1.3 1999/10/03 13:06:30 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -1076,13 +1076,12 @@ struct sk_tx_desc {
#define SK_JUMBO_MTU (SK_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define SK_JSLOTS 384
-#define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
-#define SK_JLEN (SK_JRAWLEN + (sizeof(u_int64_t) - \
- (SK_JRAWLEN % sizeof(u_int64_t))))
-#define SK_MCLBYTES (SK_JLEN - sizeof(u_int64_t))
-#define SK_JPAGESZ PAGE_SIZE
-#define SK_RESID (SK_JPAGESZ - (SK_JLEN * SK_JSLOTS) % SK_JPAGESZ)
-#define SK_JMEM ((SK_JLEN * SK_JSLOTS) + SK_RESID)
+#define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN)
+#define SK_JLEN SK_JRAWLEN
+#define SK_MCLBYTES SK_JLEN
+#define SK_JPAGESZ PAGE_SIZE
+#define SK_RESID (SK_JPAGESZ - (SK_JLEN * SK_JSLOTS) % SK_JPAGESZ)
+#define SK_JMEM ((SK_JLEN * SK_JSLOTS) + SK_RESID)
struct sk_jslot {
caddr_t sk_buf;
diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c
index 74d4c18b46f..72d51b2e0eb 100644
--- a/sys/dev/pci/if_ti.c
+++ b/sys/dev/pci/if_ti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ti.c,v 1.4 1999/10/01 02:02:20 jason Exp $ */
+/* $OpenBSD: if_ti.c,v 1.5 1999/10/03 13:06:30 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -584,21 +584,13 @@ int ti_alloc_jumbo_mem(sc)
/*
* Now divide it up into 9K pieces and save the addresses
- * in an array. Note that we play an evil trick here by using
- * the first few bytes in the buffer to hold the the address
- * of the softc structure for this interface. This is because
- * ti_jfree() needs it, but it is called by the mbuf management
- * code which will not pass it to us explicitly.
+ * in an array.
*/
ptr = sc->ti_cdata.ti_jumbo_buf;
for (i = 0; i < TI_JSLOTS; i++) {
- u_int64_t **aptr;
- aptr = (u_int64_t **)ptr;
- aptr[0] = (u_int64_t *)sc;
- ptr += sizeof(u_int64_t);
sc->ti_cdata.ti_jslots[i].ti_buf = ptr;
sc->ti_cdata.ti_jslots[i].ti_inuse = 0;
- ptr += (TI_JLEN - sizeof(u_int64_t));
+ ptr += TI_JLEN;
entry = malloc(sizeof(struct ti_jpool_entry),
M_DEVBUF, M_NOWAIT);
if (entry == NULL) {
@@ -648,12 +640,10 @@ ti_jref(m)
caddr_t buf = m->m_ext.ext_buf;
u_int size = m->m_ext.ext_size;
struct ti_softc *sc;
- u_int64_t **aptr;
register int i;
/* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc = (struct ti_softc *)(aptr[0]);
+ sc = (struct ti_softc *)m->m_ext.ext_handle;
if (sc == NULL)
panic("ti_jref: can't find softc pointer!");
@@ -662,9 +652,7 @@ ti_jref(m)
panic("ti_jref: adjusting refcount of buf of wrong size!");
/* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
+ i = ((vaddr_t)buf - (vaddr_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
if ((i < 0) || (i >= TI_JSLOTS))
panic("ti_jref: asked to reference buffer "
@@ -673,8 +661,6 @@ ti_jref(m)
panic("ti_jref: buffer already free!");
else
sc->ti_cdata.ti_jslots[i].ti_inuse++;
-
- return;
}
/*
@@ -687,13 +673,11 @@ ti_jfree(m)
caddr_t buf = m->m_ext.ext_buf;
u_int size = m->m_ext.ext_size;
struct ti_softc *sc;
- u_int64_t **aptr;
int i;
struct ti_jpool_entry *entry;
/* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc = (struct ti_softc *)(aptr[0]);
+ sc = (struct ti_softc *)m->m_ext.ext_handle;
if (sc == NULL)
panic("ti_jfree: can't find softc pointer!");
@@ -702,9 +686,7 @@ ti_jfree(m)
panic("ti_jfree: freeing buffer of wrong size!");
/* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
+ i = ((vaddr_t)buf - (vaddr_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
if ((i < 0) || (i >= TI_JSLOTS))
panic("ti_jfree: asked to free buffer that we don't manage!");
@@ -722,8 +704,6 @@ ti_jfree(m)
entry, jpool_entries);
}
}
-
- return;
}
/*
@@ -861,6 +841,8 @@ int ti_newbuf_jumbo(sc, i, m)
m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
}
+ m->m_ext.ext_handle = sc;
+
m_adj(m_new, ETHER_ALIGN);
/* Set up the descriptor. */
r = &sc->ti_rdata->ti_rx_jumbo_ring[i];
diff --git a/sys/dev/pci/if_tireg.h b/sys/dev/pci/if_tireg.h
index 6d183883048..b9f84248c29 100644
--- a/sys/dev/pci/if_tireg.h
+++ b/sys/dev/pci/if_tireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tireg.h,v 1.2 1999/09/26 03:22:40 jason Exp $ */
+/* $OpenBSD: if_tireg.h,v 1.3 1999/10/03 13:06:30 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -1030,12 +1030,11 @@ struct ti_event_desc {
#define TI_MSLOTS 256
#define TI_JSLOTS 256
-#define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
-#define TI_JLEN (TI_JRAWLEN + (sizeof(u_int64_t) - \
- (TI_JRAWLEN % sizeof(u_int64_t))))
-#define TI_JPAGESZ PAGE_SIZE
-#define TI_RESID (TI_JPAGESZ - (TI_JLEN * TI_JSLOTS) % TI_JPAGESZ)
-#define TI_JMEM ((TI_JLEN * TI_JSLOTS) + TI_RESID)
+#define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN)
+#define TI_JLEN TI_JRAWLEN
+#define TI_JPAGESZ PAGE_SIZE
+#define TI_RESID (TI_JPAGESZ - (TI_JLEN * TI_JSLOTS) % TI_JPAGESZ)
+#define TI_JMEM ((TI_JLEN * TI_JSLOTS) + TI_RESID)
struct ti_jslot {
caddr_t ti_buf;