summaryrefslogtreecommitdiffstats
path: root/sys/pci
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
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')
-rw-r--r--sys/pci/if_ti.c27
-rw-r--r--sys/pci/if_tireg.h8
2 files changed, 11 insertions, 24 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;
diff --git a/sys/pci/if_tireg.h b/sys/pci/if_tireg.h
index d64cc7a..0eaff14 100644
--- a/sys/pci/if_tireg.h
+++ b/sys/pci/if_tireg.h
@@ -1037,17 +1037,13 @@ struct ti_event_desc {
#define TI_MSLOTS 256
#define TI_JSLOTS 384
-#define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
+#define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN)
#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)
-struct ti_jslot {
- caddr_t ti_buf;
-};
-
/*
* Ring structures. Most of these reside in host memory and we tell
* the NIC where they are via the ring control blocks. The exceptions
@@ -1087,7 +1083,7 @@ struct ti_chain_data {
struct mbuf *ti_rx_jumbo_chain[TI_JUMBO_RX_RING_CNT];
struct mbuf *ti_rx_mini_chain[TI_MINI_RX_RING_CNT];
/* Stick the jumbo mem management stuff here too. */
- struct ti_jslot ti_jslots[TI_JSLOTS];
+ caddr_t ti_jslots[TI_JSLOTS];
void *ti_jumbo_buf;
};
OpenPOWER on IntegriCloud