Move xxx_newbuf() function, which was the same in all drivers into central
location.
This commit is contained in:
parent
70a18c2253
commit
8a9cf808e6
@ -183,7 +183,6 @@ Static int aue_detach(device_ptr_t);
|
||||
Static void aue_reset_pegasus_II(struct aue_softc *sc);
|
||||
Static int aue_tx_list_init(struct aue_softc *);
|
||||
Static int aue_rx_list_init(struct aue_softc *);
|
||||
Static int aue_newbuf(struct aue_softc *, struct aue_chain *, struct mbuf *);
|
||||
Static int aue_encap(struct aue_softc *, struct mbuf *, int);
|
||||
#ifdef AUE_INTR_PIPE
|
||||
Static void aue_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -649,6 +648,7 @@ USB_ATTACH(aue)
|
||||
|
||||
usbd_devinfo(uaa->device, 0, devinfo);
|
||||
|
||||
sc->aue_dev = self;
|
||||
sc->aue_udev = uaa->device;
|
||||
sc->aue_unit = device_get_unit(self);
|
||||
|
||||
@ -803,42 +803,6 @@ aue_detach(device_ptr_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an RX descriptor and attach an MBUF cluster.
|
||||
*/
|
||||
Static int
|
||||
aue_newbuf(struct aue_softc *sc, struct aue_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
|
||||
if (m_new == NULL) {
|
||||
printf("aue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->aue_unit);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
|
||||
MCLGET(m_new, M_DONTWAIT);
|
||||
if (!(m_new->m_flags & M_EXT)) {
|
||||
printf("aue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->aue_unit);
|
||||
m_freem(m_new);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->aue_mbuf = m_new;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
Static int
|
||||
aue_rx_list_init(struct aue_softc *sc)
|
||||
{
|
||||
@ -851,7 +815,8 @@ aue_rx_list_init(struct aue_softc *sc)
|
||||
c = &cd->aue_rx_chain[i];
|
||||
c->aue_sc = sc;
|
||||
c->aue_idx = i;
|
||||
if (aue_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->aue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->aue_dev));
|
||||
if (c->aue_mbuf == NULL)
|
||||
return (ENOBUFS);
|
||||
if (c->aue_xfer == NULL) {
|
||||
c->aue_xfer = usbd_alloc_xfer(sc->aue_udev);
|
||||
@ -941,7 +906,8 @@ aue_rxstart(struct ifnet *ifp)
|
||||
AUE_LOCK(sc);
|
||||
c = &sc->aue_cdata.aue_rx_chain[sc->aue_cdata.aue_rx_prod];
|
||||
|
||||
if (aue_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->aue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->aue_dev));
|
||||
if (c->aue_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
AUE_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -230,6 +230,7 @@ struct aue_softc {
|
||||
#define GET_MII(sc) (&(sc)->aue_mii)
|
||||
#endif
|
||||
struct arpcom arpcom;
|
||||
device_t aue_dev;
|
||||
device_t aue_miibus;
|
||||
usbd_device_handle aue_udev;
|
||||
usbd_interface_handle aue_iface;
|
||||
|
@ -126,7 +126,6 @@ Static int axe_detach(device_ptr_t);
|
||||
|
||||
Static int axe_tx_list_init(struct axe_softc *);
|
||||
Static int axe_rx_list_init(struct axe_softc *);
|
||||
Static int axe_newbuf(struct axe_softc *, struct axe_chain *, struct mbuf *);
|
||||
Static int axe_encap(struct axe_softc *, struct mbuf *, int);
|
||||
Static void axe_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void axe_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -562,34 +561,6 @@ axe_detach(device_ptr_t dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an RX descriptor and attach an MBUF cluster.
|
||||
*/
|
||||
Static int
|
||||
axe_newbuf(struct axe_softc *sc, struct axe_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
|
||||
if (m_new == NULL) {
|
||||
printf("axe%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->axe_unit);
|
||||
return(ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->axe_mbuf = m_new;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
Static int
|
||||
axe_rx_list_init(struct axe_softc *sc)
|
||||
{
|
||||
@ -602,7 +573,8 @@ axe_rx_list_init(struct axe_softc *sc)
|
||||
c = &cd->axe_rx_chain[i];
|
||||
c->axe_sc = sc;
|
||||
c->axe_idx = i;
|
||||
if (axe_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->axe_mbuf = usb_ether_newbuf(USBDEVNAME(sc->axe_dev));
|
||||
if (c->axe_mbuf == NULL)
|
||||
return(ENOBUFS);
|
||||
if (c->axe_xfer == NULL) {
|
||||
c->axe_xfer = usbd_alloc_xfer(sc->axe_udev);
|
||||
@ -650,7 +622,8 @@ axe_rxstart(struct ifnet *ifp)
|
||||
AXE_LOCK(sc);
|
||||
c = &sc->axe_cdata.axe_rx_chain[sc->axe_cdata.axe_rx_prod];
|
||||
|
||||
if (axe_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->axe_mbuf = usb_ether_newbuf(USBDEVNAME(sc->axe_dev));
|
||||
if (c->axe_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
AXE_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -83,8 +83,6 @@ MODULE_VERSION(cdce, 0);
|
||||
|
||||
Static int cdce_tx_list_init(struct cdce_softc *);
|
||||
Static int cdce_rx_list_init(struct cdce_softc *);
|
||||
Static int cdce_newbuf(struct cdce_softc *, struct cdce_chain *,
|
||||
struct mbuf *);
|
||||
Static int cdce_encap(struct cdce_softc *, struct mbuf *, int);
|
||||
Static void cdce_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void cdce_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -581,30 +579,6 @@ cdce_init(void *xsc)
|
||||
return;
|
||||
}
|
||||
|
||||
Static int
|
||||
cdce_newbuf(struct cdce_softc *sc, struct cdce_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
|
||||
if (m_new == NULL) {
|
||||
printf("%s: no memory for rx list "
|
||||
"-- packet dropped!\n", USBDEVNAME(sc->cdce_dev));
|
||||
return (ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->cdce_mbuf = m_new;
|
||||
return (0);
|
||||
}
|
||||
|
||||
Static int
|
||||
cdce_rx_list_init(struct cdce_softc *sc)
|
||||
{
|
||||
@ -617,7 +591,8 @@ cdce_rx_list_init(struct cdce_softc *sc)
|
||||
c = &cd->cdce_rx_chain[i];
|
||||
c->cdce_sc = sc;
|
||||
c->cdce_idx = i;
|
||||
if (cdce_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->cdce_mbuf = usb_ether_newbuf(USBDEVNAME(sc->cdce_dev));
|
||||
if (c->cdce_mbuf == NULL)
|
||||
return (ENOBUFS);
|
||||
if (c->cdce_xfer == NULL) {
|
||||
c->cdce_xfer = usbd_alloc_xfer(sc->cdce_udev);
|
||||
@ -792,7 +767,8 @@ cdce_rxstart(struct ifnet *ifp)
|
||||
|
||||
c = &sc->cdce_cdata.cdce_rx_chain[sc->cdce_cdata.cdce_rx_prod];
|
||||
|
||||
if (cdce_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->cdce_mbuf = usb_ether_newbuf(USBDEVNAME(sc->cdce_dev));
|
||||
if (c->cdce_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
CDCE_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -98,7 +98,6 @@ Static int cue_detach(device_ptr_t);
|
||||
|
||||
Static int cue_tx_list_init(struct cue_softc *);
|
||||
Static int cue_rx_list_init(struct cue_softc *);
|
||||
Static int cue_newbuf(struct cue_softc *, struct cue_chain *, struct mbuf *);
|
||||
Static int cue_encap(struct cue_softc *, struct mbuf *, int);
|
||||
Static void cue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void cue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -450,6 +449,7 @@ USB_ATTACH(cue)
|
||||
int i;
|
||||
|
||||
bzero(sc, sizeof(struct cue_softc));
|
||||
sc->cue_dev = self;
|
||||
sc->cue_iface = uaa->iface;
|
||||
sc->cue_udev = uaa->device;
|
||||
sc->cue_unit = device_get_unit(self);
|
||||
@ -568,42 +568,6 @@ cue_detach(device_ptr_t dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an RX descriptor and attach an MBUF cluster.
|
||||
*/
|
||||
Static int
|
||||
cue_newbuf(struct cue_softc *sc, struct cue_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
|
||||
if (m_new == NULL) {
|
||||
printf("cue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->cue_unit);
|
||||
return(ENOBUFS);
|
||||
}
|
||||
|
||||
MCLGET(m_new, M_DONTWAIT);
|
||||
if (!(m_new->m_flags & M_EXT)) {
|
||||
printf("cue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->cue_unit);
|
||||
m_freem(m_new);
|
||||
return(ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->cue_mbuf = m_new;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
Static int
|
||||
cue_rx_list_init(struct cue_softc *sc)
|
||||
{
|
||||
@ -616,7 +580,8 @@ cue_rx_list_init(struct cue_softc *sc)
|
||||
c = &cd->cue_rx_chain[i];
|
||||
c->cue_sc = sc;
|
||||
c->cue_idx = i;
|
||||
if (cue_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->cue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->cue_dev));
|
||||
if (c->cue_mbuf == NULL)
|
||||
return(ENOBUFS);
|
||||
if (c->cue_xfer == NULL) {
|
||||
c->cue_xfer = usbd_alloc_xfer(sc->cue_udev);
|
||||
@ -664,7 +629,8 @@ cue_rxstart(struct ifnet *ifp)
|
||||
CUE_LOCK(sc);
|
||||
c = &sc->cue_cdata.cue_rx_chain[sc->cue_cdata.cue_rx_prod];
|
||||
|
||||
if (cue_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->cue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->cue_dev));
|
||||
if (c->cue_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
CUE_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -167,6 +167,7 @@ struct cue_cdata {
|
||||
|
||||
struct cue_softc {
|
||||
struct arpcom arpcom;
|
||||
device_t cue_dev;
|
||||
usbd_device_handle cue_udev;
|
||||
usbd_interface_handle cue_iface;
|
||||
int cue_ed[CUE_ENDPT_MAX];
|
||||
|
@ -132,7 +132,6 @@ Static int kue_detach(device_ptr_t);
|
||||
Static void kue_shutdown(device_ptr_t);
|
||||
Static int kue_tx_list_init(struct kue_softc *);
|
||||
Static int kue_rx_list_init(struct kue_softc *);
|
||||
Static int kue_newbuf(struct kue_softc *, struct kue_chain *, struct mbuf *);
|
||||
Static int kue_encap(struct kue_softc *, struct mbuf *, int);
|
||||
Static void kue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void kue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -419,6 +418,7 @@ USB_ATTACH(kue)
|
||||
int i;
|
||||
|
||||
bzero(sc, sizeof(struct kue_softc));
|
||||
sc->kue_dev = self;
|
||||
sc->kue_iface = uaa->iface;
|
||||
sc->kue_udev = uaa->device;
|
||||
sc->kue_unit = device_get_unit(self);
|
||||
@ -546,41 +546,6 @@ kue_detach(device_ptr_t dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an RX descriptor and attach an MBUF cluster.
|
||||
*/
|
||||
Static int
|
||||
kue_newbuf(struct kue_softc *sc, struct kue_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
|
||||
if (m_new == NULL) {
|
||||
printf("kue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->kue_unit);
|
||||
return(ENOBUFS);
|
||||
}
|
||||
|
||||
MCLGET(m_new, M_DONTWAIT);
|
||||
if (!(m_new->m_flags & M_EXT)) {
|
||||
printf("kue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->kue_unit);
|
||||
m_freem(m_new);
|
||||
return(ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
c->kue_mbuf = m_new;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
Static int
|
||||
kue_rx_list_init(struct kue_softc *sc)
|
||||
{
|
||||
@ -593,7 +558,8 @@ kue_rx_list_init(struct kue_softc *sc)
|
||||
c = &cd->kue_rx_chain[i];
|
||||
c->kue_sc = sc;
|
||||
c->kue_idx = i;
|
||||
if (kue_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->kue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->kue_dev));
|
||||
if (c->kue_mbuf == NULL)
|
||||
return(ENOBUFS);
|
||||
if (c->kue_xfer == NULL) {
|
||||
c->kue_xfer = usbd_alloc_xfer(sc->kue_udev);
|
||||
@ -641,7 +607,8 @@ kue_rxstart(struct ifnet *ifp)
|
||||
KUE_LOCK(sc);
|
||||
c = &sc->kue_cdata.kue_rx_chain[sc->kue_cdata.kue_rx_prod];
|
||||
|
||||
if (kue_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->kue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->kue_dev));
|
||||
if (c->kue_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
return;
|
||||
}
|
||||
|
@ -159,6 +159,7 @@ struct kue_cdata {
|
||||
|
||||
struct kue_softc {
|
||||
struct arpcom arpcom;
|
||||
device_t kue_dev;
|
||||
usbd_device_handle kue_udev;
|
||||
usbd_interface_handle kue_iface;
|
||||
struct kue_ether_desc kue_desc;
|
||||
|
@ -134,7 +134,6 @@ Static int rue_detach(device_ptr_t);
|
||||
|
||||
Static int rue_tx_list_init(struct rue_softc *);
|
||||
Static int rue_rx_list_init(struct rue_softc *);
|
||||
Static int rue_newbuf(struct rue_softc *, struct rue_chain *, struct mbuf *);
|
||||
Static int rue_encap(struct rue_softc *, struct mbuf *, int);
|
||||
#ifdef RUE_INTR_PIPE
|
||||
Static void rue_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -584,6 +583,7 @@ USB_ATTACH(rue)
|
||||
bzero(sc, sizeof (struct rue_softc));
|
||||
usbd_devinfo(uaa->device, 0, devinfo);
|
||||
|
||||
sc->rue_dev = self;
|
||||
sc->rue_udev = uaa->device;
|
||||
sc->rue_unit = device_get_unit(self);
|
||||
|
||||
@ -738,43 +738,6 @@ rue_detach(device_ptr_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an RX descriptor and attach an MBUF cluster.
|
||||
*/
|
||||
|
||||
Static int
|
||||
rue_newbuf(struct rue_softc *sc, struct rue_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
if (m == NULL) {
|
||||
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
|
||||
if (m_new == NULL) {
|
||||
printf("rue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->rue_unit);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
|
||||
MCLGET(m_new, M_DONTWAIT);
|
||||
if (!(m_new->m_flags & M_EXT)) {
|
||||
printf("rue%d: no memory for rx list "
|
||||
"-- packet dropped!\n", sc->rue_unit);
|
||||
m_freem(m_new);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->rue_mbuf = m_new;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
Static int
|
||||
rue_rx_list_init(struct rue_softc *sc)
|
||||
{
|
||||
@ -787,7 +750,8 @@ rue_rx_list_init(struct rue_softc *sc)
|
||||
c = &cd->rue_rx_chain[i];
|
||||
c->rue_sc = sc;
|
||||
c->rue_idx = i;
|
||||
if (rue_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->rue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->rue_dev));
|
||||
if (c->rue_mbuf == NULL)
|
||||
return (ENOBUFS);
|
||||
if (c->rue_xfer == NULL) {
|
||||
c->rue_xfer = usbd_alloc_xfer(sc->rue_udev);
|
||||
@ -874,7 +838,8 @@ rue_rxstart(struct ifnet *ifp)
|
||||
RUE_LOCK(sc);
|
||||
c = &sc->rue_cdata.rue_rx_chain[sc->rue_cdata.rue_rx_prod];
|
||||
|
||||
if (rue_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->rue_mbuf = usb_ether_newbuf(USBDEVNAME(sc->rue_dev));
|
||||
if (c->rue_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
RUE_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -212,6 +212,7 @@ struct rue_cdata {
|
||||
|
||||
struct rue_softc {
|
||||
struct arpcom arpcom;
|
||||
device_t rue_dev;
|
||||
device_t rue_miibus;
|
||||
usbd_device_handle rue_udev;
|
||||
usbd_interface_handle rue_iface;
|
||||
|
@ -161,7 +161,6 @@ Static void udav_shutdown(device_ptr_t);
|
||||
Static int udav_openpipes(struct udav_softc *);
|
||||
Static int udav_rx_list_init(struct udav_softc *);
|
||||
Static int udav_tx_list_init(struct udav_softc *);
|
||||
Static int udav_newbuf(struct udav_softc *, struct udav_chain *, struct mbuf *);
|
||||
Static void udav_start(struct ifnet *);
|
||||
Static int udav_send(struct udav_softc *, struct mbuf *, int);
|
||||
Static void udav_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
@ -1126,41 +1125,6 @@ udav_openpipes(struct udav_softc *sc)
|
||||
return (error);
|
||||
}
|
||||
|
||||
Static int
|
||||
udav_newbuf(struct udav_softc *sc, struct udav_chain *c, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *m_new = NULL;
|
||||
|
||||
DPRINTF(("%s: %s: enter\n", USBDEVNAME(sc->sc_dev), __func__));
|
||||
|
||||
if (m == NULL) {
|
||||
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
|
||||
if (m_new == NULL) {
|
||||
printf("%s: no memory for rx list "
|
||||
"-- packet dropped!\n", USBDEVNAME(sc->sc_dev));
|
||||
return (ENOBUFS);
|
||||
}
|
||||
MCLGET(m_new, M_DONTWAIT);
|
||||
if (!(m_new->m_flags & M_EXT)) {
|
||||
printf("%s: no memory for rx list "
|
||||
"-- packet dropped!\n", USBDEVNAME(sc->sc_dev));
|
||||
m_freem(m_new);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
} else {
|
||||
m_new = m;
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
m_new->m_data = m_new->m_ext.ext_buf;
|
||||
}
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
c->udav_mbuf = m_new;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Static int
|
||||
udav_rx_list_init(struct udav_softc *sc)
|
||||
{
|
||||
@ -1175,7 +1139,8 @@ udav_rx_list_init(struct udav_softc *sc)
|
||||
c = &cd->udav_rx_chain[i];
|
||||
c->udav_sc = sc;
|
||||
c->udav_idx = i;
|
||||
if (udav_newbuf(sc, c, NULL) == ENOBUFS)
|
||||
c->udav_mbuf = usb_ether_newbuf(USBDEVNAME(sc->sc_dev));
|
||||
if (c->udav_mbuf == NULL)
|
||||
return (ENOBUFS);
|
||||
if (c->udav_xfer == NULL) {
|
||||
c->udav_xfer = usbd_alloc_xfer(sc->sc_udev);
|
||||
@ -1469,7 +1434,8 @@ udav_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
if (udav_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->udav_mbuf = usb_ether_newbuf(USBDEVNAME(sc->sc_dev));
|
||||
if (c->udav_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
goto done1;
|
||||
}
|
||||
@ -2026,7 +1992,8 @@ udav_rxstart(struct ifnet *ifp)
|
||||
UDAV_LOCK(sc);
|
||||
c = &sc->sc_cdata.udav_rx_chain[sc->sc_cdata.udav_rx_prod];
|
||||
|
||||
if (udav_newbuf(sc, c, NULL) == ENOBUFS) {
|
||||
c->udav_mbuf = usb_ether_newbuf(USBDEVNAME(sc->sc_dev));
|
||||
if (c->udav_mbuf == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
UDAV_UNLOCK(sc);
|
||||
return;
|
||||
|
@ -142,3 +142,20 @@ void usb_tx_done(m)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
usb_ether_newbuf(const char *devname)
|
||||
{
|
||||
struct mbuf *m_new;
|
||||
|
||||
m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
|
||||
if (m_new == NULL) {
|
||||
printf("%s: no memory for rx list "
|
||||
"-- packet dropped!\n", devname);
|
||||
return (NULL);
|
||||
}
|
||||
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
|
||||
|
||||
m_adj(m_new, ETHER_ALIGN);
|
||||
return (m_new);
|
||||
}
|
||||
|
@ -43,5 +43,6 @@ struct usb_qdat {
|
||||
void usb_register_netisr (void);
|
||||
void usb_ether_input (struct mbuf *);
|
||||
void usb_tx_done (struct mbuf *);
|
||||
struct mbuf *usb_ether_newbuf (const char *);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user