diff options
author | Bosko Milekic <bmilekic@FreeBSD.org> | 2000-10-12 02:42:25 +0000 |
---|---|---|
committer | Bosko Milekic <bmilekic@FreeBSD.org> | 2000-10-12 02:42:25 +0000 |
commit | 20f1c8364b161db3198ce4ce0e96396622b5665c (patch) | |
tree | 7b529749c8615039e89563485eb7191f28bfd9df | |
parent | 5f3dac9c03a5291d6cc75e27d35ad5974ee5961a (diff) | |
download | src-20f1c8364b161db3198ce4ce0e96396622b5665c.tar.gz src-20f1c8364b161db3198ce4ce0e96396622b5665c.zip |
Make if_sk stop using the "hide the softc structure in the jumbo buffer"
now that the mbuf system can handle passing it to the driver itself.
Reviewed by: wpaul
Tested by: wpaul (Bill Paul) with "jumbograms" enabled
Notes
Notes:
svn path=/head/; revision=66997
-rw-r--r-- | sys/dev/sk/if_sk.c | 31 | ||||
-rw-r--r-- | sys/dev/sk/if_skreg.h | 9 | ||||
-rw-r--r-- | sys/pci/if_sk.c | 31 | ||||
-rw-r--r-- | sys/pci/if_skreg.h | 9 |
4 files changed, 26 insertions, 54 deletions
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index d45ac2634748..a83a606445c4 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -689,9 +689,10 @@ static int sk_newbuf(sc_if, c, m) } /* Attach the buffer to the mbuf */ - MEXTADD(m_new, buf, SK_MCLBYTES, sk_jfree, NULL); + MEXTADD(m_new, buf, SK_JLEN, sk_jfree, + (struct sk_if_softc *)sc_if); m_new->m_data = (void *)buf; - m_new->m_pkthdr.len = m_new->m_len = SK_MCLBYTES; + m_new->m_pkthdr.len = m_new->m_len = SK_JLEN; } else { /* * We're re-using a previously allocated mbuf; @@ -699,7 +700,7 @@ static int sk_newbuf(sc_if, c, m) * default values. */ m_new = m; - m_new->m_len = m_new->m_pkthdr.len = SK_MCLBYTES; + m_new->m_len = m_new->m_pkthdr.len = SK_JLEN; m_new->m_data = m_new->m_ext.ext_buf; } @@ -748,20 +749,12 @@ static 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; - ptr += SK_MCLBYTES; + sc_if->sk_cdata.sk_jslots[i] = ptr; + ptr += SK_JLEN; entry = malloc(sizeof(struct sk_jpool_entry), M_DEVBUF, M_NOWAIT); if (entry == NULL) { @@ -798,7 +791,7 @@ static void *sk_jalloc(sc_if) SLIST_REMOVE_HEAD(&sc_if->sk_jfree_listhead, jpool_entries); SLIST_INSERT_HEAD(&sc_if->sk_jinuse_listhead, entry, jpool_entries); - return(sc_if->sk_cdata.sk_jslots[entry->slot].sk_buf); + return(sc_if->sk_cdata.sk_jslots[entry->slot]); } /* @@ -809,19 +802,17 @@ static void sk_jfree(buf, args) void *args; { 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 *)args; if (sc_if == NULL) - panic("sk_jfree: can't find softc pointer!"); + panic("sk_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_if->sk_cdata.sk_jumbo_buf) / SK_JLEN; if ((i < 0) || (i >= SK_JSLOTS)) diff --git a/sys/dev/sk/if_skreg.h b/sys/dev/sk/if_skreg.h index 24cce27c9537..92a26bea909d 100644 --- a/sys/dev/sk/if_skreg.h +++ b/sys/dev/sk/if_skreg.h @@ -1114,18 +1114,13 @@ 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_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN) #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) -struct sk_jslot { - caddr_t sk_buf; -}; - struct sk_jpool_entry { int slot; SLIST_ENTRY(sk_jpool_entry) jpool_entries; @@ -1147,7 +1142,7 @@ struct sk_chain_data { int sk_rx_cons; int sk_rx_cnt; /* Stick the jumbo mem management stuff here too. */ - struct sk_jslot sk_jslots[SK_JSLOTS]; + caddr_t sk_jslots[SK_JSLOTS]; void *sk_jumbo_buf; }; diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c index d45ac2634748..a83a606445c4 100644 --- a/sys/pci/if_sk.c +++ b/sys/pci/if_sk.c @@ -689,9 +689,10 @@ static int sk_newbuf(sc_if, c, m) } /* Attach the buffer to the mbuf */ - MEXTADD(m_new, buf, SK_MCLBYTES, sk_jfree, NULL); + MEXTADD(m_new, buf, SK_JLEN, sk_jfree, + (struct sk_if_softc *)sc_if); m_new->m_data = (void *)buf; - m_new->m_pkthdr.len = m_new->m_len = SK_MCLBYTES; + m_new->m_pkthdr.len = m_new->m_len = SK_JLEN; } else { /* * We're re-using a previously allocated mbuf; @@ -699,7 +700,7 @@ static int sk_newbuf(sc_if, c, m) * default values. */ m_new = m; - m_new->m_len = m_new->m_pkthdr.len = SK_MCLBYTES; + m_new->m_len = m_new->m_pkthdr.len = SK_JLEN; m_new->m_data = m_new->m_ext.ext_buf; } @@ -748,20 +749,12 @@ static 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; - ptr += SK_MCLBYTES; + sc_if->sk_cdata.sk_jslots[i] = ptr; + ptr += SK_JLEN; entry = malloc(sizeof(struct sk_jpool_entry), M_DEVBUF, M_NOWAIT); if (entry == NULL) { @@ -798,7 +791,7 @@ static void *sk_jalloc(sc_if) SLIST_REMOVE_HEAD(&sc_if->sk_jfree_listhead, jpool_entries); SLIST_INSERT_HEAD(&sc_if->sk_jinuse_listhead, entry, jpool_entries); - return(sc_if->sk_cdata.sk_jslots[entry->slot].sk_buf); + return(sc_if->sk_cdata.sk_jslots[entry->slot]); } /* @@ -809,19 +802,17 @@ static void sk_jfree(buf, args) void *args; { 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 *)args; if (sc_if == NULL) - panic("sk_jfree: can't find softc pointer!"); + panic("sk_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_if->sk_cdata.sk_jumbo_buf) / SK_JLEN; if ((i < 0) || (i >= SK_JSLOTS)) diff --git a/sys/pci/if_skreg.h b/sys/pci/if_skreg.h index 24cce27c9537..92a26bea909d 100644 --- a/sys/pci/if_skreg.h +++ b/sys/pci/if_skreg.h @@ -1114,18 +1114,13 @@ 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_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN) #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) -struct sk_jslot { - caddr_t sk_buf; -}; - struct sk_jpool_entry { int slot; SLIST_ENTRY(sk_jpool_entry) jpool_entries; @@ -1147,7 +1142,7 @@ struct sk_chain_data { int sk_rx_cons; int sk_rx_cnt; /* Stick the jumbo mem management stuff here too. */ - struct sk_jslot sk_jslots[SK_JSLOTS]; + caddr_t sk_jslots[SK_JSLOTS]; void *sk_jumbo_buf; }; |