summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_ti.c
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2000-10-21 00:13:35 +0000
committerbmilekic <bmilekic@FreeBSD.org>2000-10-21 00:13:35 +0000
commitdc0e61621e14874862edaf5a6b31ce14023d87cf (patch)
treeb48941d60bef2ec0f44bf64012be5efcd0f58aac /sys/pci/if_ti.c
parent78015e935d99ffac32a52125b4d9d377377bca32 (diff)
downloadFreeBSD-src-dc0e61621e14874862edaf5a6b31ce14023d87cf.zip
FreeBSD-src-dc0e61621e14874862edaf5a6b31ce14023d87cf.tar.gz
(Introduce something sitting in my repo for 3 weeks now...)
Have if_ti stop "hiding" the softc pointer in the buffer region. Rather, use the available void * passed to the free routine and pass the softc pointer through there. To note: in MEXTADD(), TI_JUMBO_FRAMELEN should probably be TI_JLEN. I left it unchanged, because this way I'm sure to not damage anything in this respect...
Diffstat (limited to 'sys/pci/if_ti.c')
-rw-r--r--sys/pci/if_ti.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c
index 3f88504..6cf8632 100644
--- a/sys/pci/if_ti.c
+++ b/sys/pci/if_ti.c
@@ -614,20 +614,12 @@ static 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;
- ptr += (TI_JLEN - sizeof(u_int64_t));
+ sc->ti_cdata.ti_jslots[i] = ptr;
+ ptr += TI_JLEN;
entry = malloc(sizeof(struct ti_jpool_entry),
M_DEVBUF, M_NOWAIT);
if (entry == NULL) {
@@ -662,7 +654,7 @@ static void *ti_jalloc(sc)
SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
- return(sc->ti_cdata.ti_jslots[entry->slot].ti_buf);
+ return(sc->ti_cdata.ti_jslots[entry->slot]);
}
/*
@@ -673,19 +665,17 @@ static void ti_jfree(buf, args)
void *args;
{
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 *)args;
if (sc == NULL)
- panic("ti_jfree: can't find softc pointer!");
+ panic("ti_jfree: didn't get softc pointer!");
/* calculate the slot this buffer belongs to */
- i = ((vm_offset_t)aptr
+ i = ((vm_offset_t)buf
- (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
if ((i < 0) || (i >= TI_JSLOTS))
@@ -824,7 +814,8 @@ static int ti_newbuf_jumbo(sc, i, m)
/* Attach the buffer to the mbuf. */
m_new->m_data = (void *) buf;
m_new->m_len = m_new->m_pkthdr.len = TI_JUMBO_FRAMELEN;
- MEXTADD(m_new, buf, TI_JUMBO_FRAMELEN, ti_jfree, NULL);
+ MEXTADD(m_new, buf, TI_JUMBO_FRAMELEN, ti_jfree,
+ (struct ti_softc *)sc);
} else {
m_new = m;
m_new->m_data = m_new->m_ext.ext_buf;
OpenPOWER on IntegriCloud