diff options
author | thompsa <thompsa@FreeBSD.org> | 2009-03-08 06:56:13 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2009-03-08 06:56:13 +0000 |
commit | 30842195f478f6d07840316d4339ce323129d633 (patch) | |
tree | f8840fac98912d5ee77f2dce764ceb88a2ed2d0a /sys/dev/usb | |
parent | 47f7c87c96050c796aa951a7000f612148079930 (diff) | |
download | FreeBSD-src-30842195f478f6d07840316d4339ce323129d633.zip FreeBSD-src-30842195f478f6d07840316d4339ce323129d633.tar.gz |
Move m_getcl() into its own function. This also fixes a bug where the m_adj for
ETHER_ALIGN was having no effect since m_len had not been set.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/net/if_cdce.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/net/usb_ethernet.c | 19 | ||||
-rw-r--r-- | sys/dev/usb/net/usb_ethernet.h | 1 |
3 files changed, 18 insertions, 7 deletions
diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c index 42df553..a54ddc0 100644 --- a/sys/dev/usb/net/if_cdce.c +++ b/sys/dev/usb/net/if_cdce.c @@ -665,13 +665,10 @@ cdce_bulk_read_callback(struct usb2_xfer *xfer) */ for (x = 0; x != 1; x++) { if (sc->sc_rx_buf[x] == NULL) { - m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + m = usb2_ether_newbuf(); if (m == NULL) goto tr_stall; sc->sc_rx_buf[x] = m; - /* adjust for ethernet */ - m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); } else { m = sc->sc_rx_buf[x]; } diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index ac4b701..80b8852 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -512,6 +512,20 @@ static moduledata_t usb2_ether_mod = { 0 }; +struct mbuf * +usb2_ether_newbuf(void) +{ + struct mbuf *m_new; + + m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m_new == NULL) + return (NULL); + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + + m_adj(m_new, ETHER_ALIGN); + return (m_new); +} + int usb2_ether_rxmbuf(struct usb2_ether *ue, struct mbuf *m, unsigned int len) @@ -539,16 +553,15 @@ usb2_ether_rxbuf(struct usb2_ether *ue, struct usb2_page_cache *pc, UE_LOCK_ASSERT(ue, MA_OWNED); - if (len < ETHER_HDR_LEN || len > MCLBYTES) + if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) return (1); - m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + m = usb2_ether_newbuf(); if (m == NULL) { ifp->if_ierrors++; return (ENOMEM); } - m_adj(m, ETHER_ALIGN); usb2_copy_out(pc, offset, mtod(m, uint8_t *), len); /* finalize mbuf */ diff --git a/sys/dev/usb/net/usb_ethernet.h b/sys/dev/usb/net/usb_ethernet.h index 0ee36f2..3f45e6f 100644 --- a/sys/dev/usb/net/usb_ethernet.h +++ b/sys/dev/usb/net/usb_ethernet.h @@ -111,6 +111,7 @@ void *usb2_ether_getsc(struct usb2_ether *); int usb2_ether_ifattach(struct usb2_ether *); void usb2_ether_ifdetach(struct usb2_ether *); int usb2_ether_ioctl(struct ifnet *, u_long, caddr_t); +struct mbuf *usb2_ether_newbuf(void); int usb2_ether_rxmbuf(struct usb2_ether *, struct mbuf *, unsigned int); int usb2_ether_rxbuf(struct usb2_ether *, |