Replace the static "qdat" structure with a per-instance softc field
in all USB ethernet drivers. The qdat structure contains a pointer to the interface's struct ifnet and is used to process incoming packets, so simultaneous use of two similar devices caused crashes and confusion. The if_udav driver appeared in the tree since Daan's PR, so I made similar changes to that driver too. PR: kern/59290 Submitted by: Daan Vreeken <Danovitsch@Vitsch.net>
This commit is contained in:
parent
e6db3b8d6f
commit
6c899c3ffd
@ -175,8 +175,6 @@ Static const struct aue_type aue_devs[] = {
|
||||
};
|
||||
#define aue_lookup(v, p) ((const struct aue_type *)usb_lookup(aue_devs, v, p))
|
||||
|
||||
Static struct usb_qdat aue_qdat;
|
||||
|
||||
Static int aue_match(device_ptr_t);
|
||||
Static int aue_attach(device_ptr_t);
|
||||
Static int aue_detach(device_ptr_t);
|
||||
@ -769,8 +767,8 @@ USB_ATTACH(aue)
|
||||
USB_ATTACH_ERROR_RETURN;
|
||||
}
|
||||
|
||||
aue_qdat.ifp = ifp;
|
||||
aue_qdat.if_rxstart = aue_rxstart;
|
||||
sc->aue_qdat.ifp = ifp;
|
||||
sc->aue_qdat.if_rxstart = aue_rxstart;
|
||||
|
||||
/*
|
||||
* Call MI attach routine.
|
||||
@ -1036,7 +1034,7 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
total_len -= (4 + ETHER_CRC_LEN);
|
||||
|
||||
ifp->if_ipackets++;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&aue_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->aue_qdat;
|
||||
m->m_pkthdr.len = m->m_len = total_len;
|
||||
|
||||
/* Put the packet on the special USB input queue. */
|
||||
|
@ -248,6 +248,7 @@ struct aue_softc {
|
||||
u_int16_t aue_flags;
|
||||
char aue_dying;
|
||||
struct timeval aue_rx_notice;
|
||||
struct usb_qdat aue_qdat;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -113,8 +113,6 @@ Static struct axe_type axe_devs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Static struct usb_qdat axe_qdat;
|
||||
|
||||
Static int axe_match(device_ptr_t);
|
||||
Static int axe_attach(device_ptr_t);
|
||||
Static int axe_detach(device_ptr_t);
|
||||
@ -508,8 +506,8 @@ USB_ATTACH(axe)
|
||||
ifp->if_baudrate = 10000000;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
|
||||
axe_qdat.ifp = ifp;
|
||||
axe_qdat.if_rxstart = axe_rxstart;
|
||||
sc->axe_qdat.ifp = ifp;
|
||||
sc->axe_qdat.if_rxstart = axe_rxstart;
|
||||
|
||||
if (mii_phy_probe(self, &sc->axe_miibus,
|
||||
axe_ifmedia_upd, axe_ifmedia_sts)) {
|
||||
@ -711,7 +709,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
}
|
||||
|
||||
ifp->if_ipackets++;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&axe_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->axe_qdat;
|
||||
m->m_pkthdr.len = m->m_len = total_len;
|
||||
|
||||
/* Put the packet on the special USB input queue. */
|
||||
|
@ -168,6 +168,7 @@ struct axe_softc {
|
||||
unsigned char axe_ipgs[3];
|
||||
unsigned char axe_phyaddrs[2];
|
||||
struct timeval axe_rx_notice;
|
||||
struct usb_qdat axe_qdat;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -91,8 +91,6 @@ Static struct cue_type cue_devs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Static struct usb_qdat cue_qdat;
|
||||
|
||||
Static int cue_match(device_ptr_t);
|
||||
Static int cue_attach(device_ptr_t);
|
||||
Static int cue_detach(device_ptr_t);
|
||||
@ -525,8 +523,8 @@ USB_ATTACH(cue)
|
||||
ifp->if_baudrate = 10000000;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
|
||||
cue_qdat.ifp = ifp;
|
||||
cue_qdat.if_rxstart = cue_rxstart;
|
||||
sc->cue_qdat.ifp = ifp;
|
||||
sc->cue_qdat.if_rxstart = cue_rxstart;
|
||||
|
||||
/*
|
||||
* Call MI attach routine.
|
||||
@ -741,7 +739,7 @@ cue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
|
||||
ifp->if_ipackets++;
|
||||
m_adj(m, sizeof(u_int16_t));
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&cue_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->cue_qdat;
|
||||
m->m_pkthdr.len = m->m_len = total_len;
|
||||
|
||||
/* Put the packet on the special USB input queue. */
|
||||
|
@ -182,6 +182,7 @@ struct cue_softc {
|
||||
#endif
|
||||
char cue_dying;
|
||||
struct timeval cue_rx_notice;
|
||||
struct usb_qdat cue_qdat;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -125,8 +125,6 @@ Static struct kue_type kue_devs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Static struct usb_qdat kue_qdat;
|
||||
|
||||
Static int kue_match(device_ptr_t);
|
||||
Static int kue_attach(device_ptr_t);
|
||||
Static int kue_detach(device_ptr_t);
|
||||
@ -491,8 +489,8 @@ USB_ATTACH(kue)
|
||||
ifp->if_baudrate = 10000000;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
|
||||
kue_qdat.ifp = ifp;
|
||||
kue_qdat.if_rxstart = kue_rxstart;
|
||||
sc->kue_qdat.ifp = ifp;
|
||||
sc->kue_qdat.if_rxstart = kue_rxstart;
|
||||
|
||||
/*
|
||||
* Call MI attach routine.
|
||||
@ -712,7 +710,7 @@ Static void kue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv,
|
||||
}
|
||||
|
||||
ifp->if_ipackets++;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&kue_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->kue_qdat;
|
||||
m->m_pkthdr.len = m->m_len = total_len;
|
||||
|
||||
/* Put the packet on the special USB input queue. */
|
||||
|
@ -174,6 +174,7 @@ struct kue_softc {
|
||||
#endif
|
||||
char kue_dying;
|
||||
struct timeval kue_rx_notice;
|
||||
struct usb_qdat kue_qdat;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -127,8 +127,6 @@ Static struct rue_type rue_devs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Static struct usb_qdat rue_qdat;
|
||||
|
||||
Static int rue_match(device_ptr_t);
|
||||
Static int rue_attach(device_ptr_t);
|
||||
Static int rue_detach(device_ptr_t);
|
||||
@ -704,8 +702,8 @@ USB_ATTACH(rue)
|
||||
goto error1;
|
||||
}
|
||||
|
||||
rue_qdat.ifp = ifp;
|
||||
rue_qdat.if_rxstart = rue_rxstart;
|
||||
sc->rue_qdat.ifp = ifp;
|
||||
sc->rue_qdat.if_rxstart = rue_rxstart;
|
||||
|
||||
/* Call MI attach routine */
|
||||
#if __FreeBSD_version >= 500000
|
||||
@ -975,7 +973,7 @@ rue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
total_len -= ETHER_CRC_LEN;
|
||||
|
||||
ifp->if_ipackets++;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&rue_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->rue_qdat;
|
||||
m->m_pkthdr.len = m->m_len = total_len;
|
||||
|
||||
/* Put the packet on the special USB input queue. */
|
||||
|
@ -228,6 +228,7 @@ struct rue_softc {
|
||||
#endif
|
||||
char rue_dying;
|
||||
struct timeval rue_rx_notice;
|
||||
struct usb_qdat rue_qdat;
|
||||
};
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
@ -150,10 +150,6 @@ MODULE_DEPEND(udav, miibus, 1, 1, 1);
|
||||
USB_DECLARE_DRIVER(udav);
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
Static struct usb_qdat udav_qdat;
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
Static int udav_match(device_ptr_t);
|
||||
Static int udav_attach(device_ptr_t);
|
||||
@ -452,8 +448,8 @@ USB_ATTACH(udav)
|
||||
USB_ATTACH_ERROR_RETURN;
|
||||
}
|
||||
|
||||
udav_qdat.ifp = ifp;
|
||||
udav_qdat.if_rxstart = udav_rxstart;
|
||||
sc->sc_qdat.ifp = ifp;
|
||||
sc->sc_qdat.if_rxstart = udav_rxstart;
|
||||
|
||||
/*
|
||||
* Call MI attach routine.
|
||||
@ -1487,7 +1483,7 @@ udav_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
|
||||
#if defined(__NetBSD__)
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
#elif defined(__FreeBSD__)
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&udav_qdat;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)&sc->sc_qdat;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
|
@ -210,6 +210,7 @@ struct udav_softc {
|
||||
#if defined(__FreeBSD__)
|
||||
device_t sc_miibus ;
|
||||
struct mtx sc_mtx ;
|
||||
struct usb_qdat sc_qdat;
|
||||
#elif defined(__NetBSD__)
|
||||
struct ethercom sc_ec; /* ethernet common */
|
||||
struct mii_data sc_mii;
|
||||
|
Loading…
Reference in New Issue
Block a user