DragonFly BSD
DragonFly submit List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: kue0 not receiving patch


From: Joerg Sonnenberger <joerg@xxxxxxxxxxxxxxxxx>
Date: Wed, 16 Feb 2005 18:17:16 +0100
Mail-followup-to: submit@crater.dragonflybsd.org

On Mon, Feb 14, 2005 at 08:06:00PM -0800, Scott Michel wrote:
> This patch ought to fix the USB Ethernet transmit/receive problems for 
> all adaptors, not just kue (cue too!?)
> 
> Plenty of opportunity to clean this code up to remove usbq_rx and 
> usbq_tx, since the messages handle the queuing for us. But this fix gets 
> things working...

I'd prefer to do the right thing and just remove the intermediate queues.

Does the attached patch work?

Joerg
Index: bus/usb/usb_ethersubr.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/bus/usb/usb_ethersubr.c,v
retrieving revision 1.11
diff -u -r1.11 usb_ethersubr.c
--- bus/usb/usb_ethersubr.c	15 Feb 2005 10:30:11 -0000	1.11
+++ bus/usb/usb_ethersubr.c	16 Feb 2005 17:08:27 -0000
@@ -73,44 +73,18 @@
 #include "usb.h"
 #include "usb_ethersubr.h"
 
-Static struct ifqueue usbq_rx;
-Static struct ifqueue usbq_tx;
-Static int mtx_inited = 0;
+Static int netisr_inited = 0;
 
 Static int usbintr(struct netmsg *msg)
 {
 	struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet;
-	struct usb_qdat		*q;
-	struct ifnet		*ifp;
-	int			s;
+	struct ifnet *ifp;
+	int s;
 
 	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);
-	}
+	ifp = m->m_pkthdr.rcvif;
+	(*ifp->if_input)(ifp, m);
 
 	splx(s);
 
@@ -121,11 +95,10 @@
 void
 usb_register_netisr(void)
 {
-	if (mtx_inited)
-		return;
-	mtx_inited = 1;
-	netisr_register(NETISR_USB, cpu0_portfn, usbintr);
-	return;
+	if (netisr_inited == 0) {
+		netisr_inited = 1;
+		netisr_register(NETISR_USB, cpu0_portfn, usbintr);
+	}
 }
 
 /*
@@ -137,9 +110,3 @@
 {
 	netisr_queue(NETISR_USB, m);
 }
-
-void
-usb_tx_done(struct mbuf *m)
-{
-	netisr_queue(NETISR_USB, m);
-}
Index: bus/usb/usb_ethersubr.h
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/bus/usb/usb_ethersubr.h,v
retrieving revision 1.4
diff -u -r1.4 usb_ethersubr.h
--- bus/usb/usb_ethersubr.h	30 Dec 2003 01:01:44 -0000	1.4
+++ bus/usb/usb_ethersubr.h	16 Feb 2005 16:42:56 -0000
@@ -43,6 +43,5 @@
 
 void usb_register_netisr	(void);
 void usb_ether_input		(struct mbuf *);
-void usb_tx_done		(struct mbuf *);
 
 #endif
Index: dev/netif/aue/if_aue.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/dev/netif/aue/if_aue.c,v
retrieving revision 1.16
diff -u -r1.16 if_aue.c
--- dev/netif/aue/if_aue.c	15 Feb 2005 16:44:23 -0000	1.16
+++ dev/netif/aue/if_aue.c	16 Feb 2005 17:13:14 -0000
@@ -173,8 +173,6 @@
 };
 #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);
@@ -767,9 +765,6 @@
 		USB_ATTACH_ERROR_RETURN;
 	}
 
-	aue_qdat.ifp = ifp;
-	aue_qdat.if_rxstart = aue_rxstart;
-
 	/*
 	 * Call MI attach routine.
 	 */
@@ -1025,11 +1020,12 @@
 	total_len -= (4 + ETHER_CRC_LEN);
 
 	ifp->if_ipackets++;
-	m->m_pkthdr.rcvif = (struct ifnet *)&aue_qdat;
+	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.len = m->m_len = total_len;
 
 	/* Put the packet on the special USB input queue. */
 	usb_ether_input(m);
+	aue_start(ifp);
 	AUE_UNLOCK(sc);
 	return;
 done:
@@ -1078,8 +1074,7 @@
 	usbd_get_xfer_status(c->aue_xfer, NULL, NULL, NULL, &err);
 
 	if (c->aue_mbuf != NULL) {
-		c->aue_mbuf->m_pkthdr.rcvif = ifp;
-		usb_tx_done(c->aue_mbuf);
+		m_free(c->aue_mbuf);
 		c->aue_mbuf = NULL;
 	}
 
Index: dev/netif/axe/if_axe.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/dev/netif/axe/if_axe.c,v
retrieving revision 1.8
diff -u -r1.8 if_axe.c
--- dev/netif/axe/if_axe.c	15 Feb 2005 19:19:11 -0000	1.8
+++ dev/netif/axe/if_axe.c	16 Feb 2005 17:12:54 -0000
@@ -112,8 +112,6 @@
 	{ 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);
@@ -504,9 +502,6 @@
 	ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
 	ifq_set_ready(&ifp->if_snd);
 
-	axe_qdat.ifp = ifp;
-	axe_qdat.if_rxstart = axe_rxstart;
-
 	if (mii_phy_probe(self, &sc->axe_miibus,
 	    axe_ifmedia_upd, axe_ifmedia_sts)) {
 		printf("axe%d: MII without any PHY!\n", sc->axe_unit);
@@ -704,11 +699,12 @@
 	}
 
 	ifp->if_ipackets++;
-	m->m_pkthdr.rcvif = (struct ifnet *)&axe_qdat;
+	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.len = m->m_len = total_len;
 
 	/* Put the packet on the special USB input queue. */
 	usb_ether_input(m);
+	axe_rxstart(ifp);
 	splx(s);
 
 	return;
@@ -761,8 +757,7 @@
 	usbd_get_xfer_status(c->axe_xfer, NULL, NULL, NULL, &err);
 
 	if (c->axe_mbuf != NULL) {
-		c->axe_mbuf->m_pkthdr.rcvif = ifp;
-		usb_tx_done(c->axe_mbuf);
+		m_freem(c->axe_mbuf);
 		c->axe_mbuf = NULL;
 	}
 
Index: dev/netif/cue/if_cue.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/dev/netif/cue/if_cue.c,v
retrieving revision 1.16
diff -u -r1.16 if_cue.c
--- dev/netif/cue/if_cue.c	15 Feb 2005 20:23:10 -0000	1.16
+++ dev/netif/cue/if_cue.c	16 Feb 2005 17:12:21 -0000
@@ -93,8 +93,6 @@
 	{ 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);
@@ -522,9 +520,6 @@
 	ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
 	ifq_set_ready(&ifp->if_snd);
 
-	cue_qdat.ifp = ifp;
-	cue_qdat.if_rxstart = cue_rxstart;
-
 	/*
 	 * Call MI attach routine.
 	 */
@@ -727,11 +722,13 @@
 
 	ifp->if_ipackets++;
 	m_adj(m, sizeof(u_int16_t));
-	m->m_pkthdr.rcvif = (struct ifnet *)&cue_qdat;
+	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.len = m->m_len = total_len;
 
 	/* Put the packet on the special USB input queue. */
 	usb_ether_input(m);
+	cue_rxstart(ifp);
+
 	CUE_UNLOCK(sc);
 
 	return;
@@ -782,8 +779,7 @@
 	usbd_get_xfer_status(c->cue_xfer, NULL, NULL, NULL, &err);
 
 	if (c->cue_mbuf != NULL) {
-		c->cue_mbuf->m_pkthdr.rcvif = ifp;
-		usb_tx_done(c->cue_mbuf);
+		m_freem(c->cue_mbuf);
 		c->cue_mbuf = NULL;
 	}
 
Index: dev/netif/kue/if_kue.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/dev/netif/kue/if_kue.c,v
retrieving revision 1.13
diff -u -r1.13 if_kue.c
--- dev/netif/kue/if_kue.c	14 Oct 2004 18:31:02 -0000	1.13
+++ dev/netif/kue/if_kue.c	16 Feb 2005 17:12:15 -0000
@@ -74,6 +74,7 @@
 #include <sys/socket.h>
 
 #include <net/if.h>
+#include <net/ifq_var.h>
 #include <net/if_arp.h>
 #include <net/ethernet.h>
 #include <net/if_dl.h>
@@ -124,8 +125,6 @@
 	{ 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);
@@ -485,10 +484,8 @@
 	ifp->if_watchdog = kue_watchdog;
 	ifp->if_init = kue_init;
 	ifp->if_baudrate = 10000000;
-	ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
-
-	kue_qdat.ifp = ifp;
-	kue_qdat.if_rxstart = kue_rxstart;
+	ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
+	ifq_set_ready(&ifp->if_snd);
 
 	/*
 	 * Call MI attach routine.
@@ -700,11 +697,13 @@
 	}
 
 	ifp->if_ipackets++;
-	m->m_pkthdr.rcvif = (struct ifnet *)&kue_qdat;
+	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.len = m->m_len = total_len;
 
 	/* Put the packet on the special USB input queue. */
 	usb_ether_input(m);
+	kue_rxstart(ifp);
+
 	KUE_UNLOCK(sc);
 
 	return;
@@ -757,8 +756,7 @@
 	usbd_get_xfer_status(c->kue_xfer, NULL, NULL, NULL, &err);
 
 	if (c->kue_mbuf != NULL) {
-		c->kue_mbuf->m_pkthdr.rcvif = ifp;
-		usb_tx_done(c->kue_mbuf);
+		m_freem(c->kue_mbuf);
 		c->kue_mbuf = NULL;
 	}
 
@@ -824,18 +822,18 @@
 		return;
 	}
 
-	IF_DEQUEUE(&ifp->if_snd, m_head);
+	m_head = ifq_poll(&ifp->if_snd);
 	if (m_head == NULL) {
 		KUE_UNLOCK(sc);
 		return;
 	}
 
 	if (kue_encap(sc, m_head, 0)) {
-		IF_PREPEND(&ifp->if_snd, m_head);
 		ifp->if_flags |= IFF_OACTIVE;
 		KUE_UNLOCK(sc);
 		return;
 	}
+	m_head = ifq_dequeue(&ifp->if_snd);
 
 	/*
 	 * If there's a BPF listener, bounce a copy of this frame
@@ -1008,7 +1006,7 @@
 	usbd_get_xfer_status(c->kue_xfer, NULL, NULL, NULL, &stat);
 	kue_txeof(c->kue_xfer, c, stat);
 
-	if (ifp->if_snd.ifq_head != NULL)
+	if (ifq_is_empty(&ifp->if_snd))
 		kue_start(ifp);
 	KUE_UNLOCK(sc);
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]