summaryrefslogtreecommitdiffstats
path: root/sys/pci
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2003-02-22 14:46:31 +0000
committerbmilekic <bmilekic@FreeBSD.org>2003-02-22 14:46:31 +0000
commitc0bff2da93b76aa93a9c4d085301e5179a443f43 (patch)
treeb1f5d75ea9581de6605bd3007d8f5188db9eef63 /sys/pci
parent07faa547b1f7df445539addc4da6918d3ed4568a (diff)
downloadFreeBSD-src-c0bff2da93b76aa93a9c4d085301e5179a443f43.zip
FreeBSD-src-c0bff2da93b76aa93a9c4d085301e5179a443f43.tar.gz
Make xl use m_getcl() to allocate an mbuf and a cluster in one shot,
as opposed to one after the other. This is faster in both -CURRENT and -STABLE. Additionally, there is less code duplication for error-checking. One thing to note is that this code seems to return(1) when no buffers are available; perhaps ENOBUFS should be the correct return value? Partially submitted & tested by: Hiten Pandya <hiten@unixdaemons.com> MFC after: 1 week
Diffstat (limited to 'sys/pci')
-rw-r--r--sys/pci/if_xl.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index 7920792..cc4c6d5 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -1939,16 +1939,10 @@ xl_newbuf(sc, c)
int error;
u_int32_t baddr;
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
+ m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (m_new == NULL)
return(ENOBUFS);
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m_new);
- return(ENOBUFS);
- }
-
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
/* Force longword alignment for packet payload. */
@@ -2441,24 +2435,16 @@ xl_encap(sc, c, m_head)
* and would waste cycles.
*/
if (error) {
- struct mbuf *m_new = NULL;
+ struct mbuf *m_new;
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
+ m_new = m_head->m_pkthdr.len > MHLEN ?
+ m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR) :
+ m_get(M_DONTWAIT, MT_DATA);
if (m_new == NULL) {
m_freem(m_head);
printf("xl%d: no memory for tx list\n", sc->xl_unit);
return(1);
}
- if (m_head->m_pkthdr.len > MHLEN) {
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m_new);
- m_freem(m_head);
- printf("xl%d: no memory for tx list\n",
- sc->xl_unit);
- return(1);
- }
- }
m_copydata(m_head, 0, m_head->m_pkthdr.len,
mtod(m_new, caddr_t));
m_new->m_pkthdr.len = m_new->m_len = m_head->m_pkthdr.len;
OpenPOWER on IntegriCloud