看板 DFBSD_submit 關於我們 聯絡資訊
Joerg Sonnenberger wrote: > On Tue, Feb 15, 2005 at 10:36:00AM -0800, Scott Michel wrote: > >>If nothing is queued on usbq_tx or usbq_rx, usbintr will not send or >>receive packets, no matter how hard you try to schedule the isr. :-) > > > Argh! I thought the problem was that the ISR is not scheduled (which it > is also true). OK, let's remove this whole USB ethernet queue crap. Actually, the ISR runs like it should. Rather nicely, as a matter of fact. Remove the queuing like this? --- ./net/netisr.h 2005-02-15 10:50:26.000000000 -0800 +++ /usr/src/sys/./net/netisr.h 2005-02-15 10:51:17.000000000 -0800 @@ -114,7 +114,8 @@ #define NETISR_ATALK1 17 /* Appletalk phase 1 */ #define NETISR_ARP 18 /* same as AF_LINK */ #define NETISR_IPX 23 /* same as AF_IPX */ -#define NETISR_USB 25 /* USB soft interrupt */ +#define NETISR_USB_TX 24 /* USB tx soft interrupt */ +#define NETISR_USB_RX 25 /* USB rx soft interrupt */ #define NETISR_PPP 27 /* PPP soft interrupt */ #define NETISR_IPV6 28 /* same as AF_INET6 */ #define NETISR_NATM 29 /* same as AF_NATM */ --- ./bus/usb/usb_ethersubr.c 2005-02-15 10:52:11.000000000 -0800 +++ /usr/src/sys/./bus/usb/usb_ethersubr.c 2005-02-15 10:59:42.000000000 -0800 @@ -73,11 +73,9 @@ #include "usb.h" #include "usb_ethersubr.h" -Static struct ifqueue usbq_rx; -Static struct ifqueue usbq_tx; Static int mtx_inited = 0; -Static int usbintr(struct netmsg *msg) +Static int usbintr_rx(struct netmsg *msg) { struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet; struct usb_qdat *q; @@ -86,31 +84,33 @@ s = splimp(); - /* Check the RX queue */ - while(1) { - IF_DEQUEUE(&usbq_rx, m); - if (m == NULL) - break; - q = (struct usb_qdat *)m->m_pkthdr.rcvif; - ifp = q->ifp; - (*ifp->if_input)(ifp, m); - - /* Re-arm the receiver */ - (*q->if_rxstart)(ifp); - if (!ifq_is_empty(&ifp->if_snd)) - (*ifp->if_start)(ifp); - } - - /* Check the TX queue */ - while(1) { - IF_DEQUEUE(&usbq_tx, m); - if (m == NULL) - break; - ifp = m->m_pkthdr.rcvif; - m_freem(m); - if (!ifq_is_empty(&ifp->if_snd)) - (*ifp->if_start)(ifp); - } + q = (struct usb_qdat *)m->m_pkthdr.rcvif; + ifp = q->ifp; + (*ifp->if_input)(ifp, m); + + /* Re-arm the receiver */ + (*q->if_rxstart)(ifp); + if (!ifq_is_empty(&ifp->if_snd)) + (*ifp->if_start)(ifp); + + splx(s); + + lwkt_replymsg(&msg->nm_lmsg, 0); + return EASYNC; +} + +Static int usbintr_tx(struct netmsg *msg) +{ + struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet; + struct ifnet *ifp; + int s; + + s = splimp(); + + ifp = m->m_pkthdr.rcvif; + m_freem(m); + if (!ifq_is_empty(&ifp->if_snd)) + (*ifp->if_start)(ifp); splx(s); @@ -124,7 +124,8 @@ if (mtx_inited) return; mtx_inited = 1; - netisr_register(NETISR_USB, cpu0_portfn, usbintr); + netisr_register(NETISR_USB_TX, cpu0_portfn, usbintr_tx); + netisr_register(NETISR_USB_RX, cpu0_portfn, usbintr_rx); return; } @@ -135,11 +136,11 @@ void usb_ether_input(struct mbuf *m) { - netisr_queue(NETISR_USB, m); + netisr_queue(NETISR_USB_RX, m); } void usb_tx_done(struct mbuf *m) { - netisr_queue(NETISR_USB, m); + netisr_queue(NETISR_USB_TX, m); }