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.
This commit is contained in:
parent
05fa9d9f25
commit
75fd0939b4
@ -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];
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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 *,
|
||||
|
Loading…
Reference in New Issue
Block a user