Date: Sun, 8 Mar 2009 06:56:14 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r189528 - head/sys/dev/usb/net Message-ID: <200903080656.n286uEBh075431@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Sun Mar 8 06:56:13 2009 New Revision: 189528 URL: http://svn.freebsd.org/changeset/base/189528 Log: 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. Modified: head/sys/dev/usb/net/if_cdce.c head/sys/dev/usb/net/usb_ethernet.c head/sys/dev/usb/net/usb_ethernet.h Modified: head/sys/dev/usb/net/if_cdce.c ============================================================================== --- head/sys/dev/usb/net/if_cdce.c Sun Mar 8 06:20:35 2009 (r189527) +++ head/sys/dev/usb/net/if_cdce.c Sun Mar 8 06:56:13 2009 (r189528) @@ -665,13 +665,10 @@ cdce_bulk_read_callback(struct usb2_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]; } Modified: head/sys/dev/usb/net/usb_ethernet.c ============================================================================== --- head/sys/dev/usb/net/usb_ethernet.c Sun Mar 8 06:20:35 2009 (r189527) +++ head/sys/dev/usb/net/usb_ethernet.c Sun Mar 8 06:56:13 2009 (r189528) @@ -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, 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 */ Modified: head/sys/dev/usb/net/usb_ethernet.h ============================================================================== --- head/sys/dev/usb/net/usb_ethernet.h Sun Mar 8 06:20:35 2009 (r189527) +++ head/sys/dev/usb/net/usb_ethernet.h Sun Mar 8 06:56:13 2009 (r189528) @@ -111,6 +111,7 @@ void *usb2_ether_getsc(struct usb2_ethe 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 *,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903080656.n286uEBh075431>