PERFORCE change 89228 for review

Kip Macy kmacy at FreeBSD.org
Thu Jan 5 11:54:11 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=89228

Change 89228 by kmacy at kmacy:freebsd7_xen3 on 2006/01/05 19:53:06

	fix networking performance problems:
	xn_start needs to be called from xn_intr
	rx.sring->rsp_event needs to be reset or we won't get interrupts on receive

Affected files ...

.. //depot/projects/xen3/src/sys/dev/xen/netfront/netfront.c#3 edit

Differences ...

==== //depot/projects/xen3/src/sys/dev/xen/netfront/netfront.c#3 (text+ko) ====

@@ -521,10 +521,7 @@
 
 	info->irq = bind_evtchn_to_irqhandler(
 		info->evtchn, "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE);
-#if 0
-	/* XXX need this for re-location to work well */
-	(void)send_fake_arp(netdev);
-#endif
+
 	show_device(info);
 	
 	return 0;
@@ -676,6 +673,7 @@
 		rx_mcl[i].args[0] = (unsigned long)mtod(m_new,vm_offset_t);
 		rx_mcl[i].args[1] = 0;
 		rx_mcl[i].args[2] = 0;
+		rx_mcl[i].args[2] = 0;
 
 	} 
 	
@@ -750,7 +748,7 @@
 		
 		rx = RING_GET_RESPONSE(&np->rx, i);
 		KASSERT(rx->id != 0, ("xn_rxeof: found free receive index of 0\n"));
-				/*
+		/*
                  * This definitely indicates a bug, either in this driver or
                  * in the backend driver. In future this should flag the bad
                  * situation to the system controller to reboot the backed.
@@ -862,6 +860,8 @@
 	
 	network_alloc_rx_buffers(np);
 
+	np->rx.sring->rsp_event = i + 1;
+
 }
 
 static void 
@@ -943,27 +943,24 @@
 {
 	struct netfront_info *np = xsc;
 	struct ifnet *ifp = np->xn_ifp;
-	TRACE_ENTER;
 
-	/* XXX this seems like a recipe for poor performance if not livelock */
 
-	XN_RX_LOCK(np);
-
-	/* sometimes we seem to lose packets.  stay in the interrupt handler while
-	 * there is stuff to process: continually recheck the response producer.
-	 */
-	do {		
-		if (np->rx.rsp_cons != np->rx.sring->rsp_prod &&
-		    np->user_state == UST_OPEN)
-			xn_rxeof(np);
-		
-	} while (np->rx.rsp_cons != np->rx.sring->rsp_prod &&
-		 np->user_state == UST_OPEN);
-
-	XN_RX_UNLOCK(np);
-
-	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-		xn_start(ifp);
+	while (np->rx.rsp_cons != np->rx.sring->rsp_prod &&
+	       np->user_state == UST_OPEN && 
+	       ifp->if_drv_flags & IFF_DRV_RUNNING) {
+	
+		XN_RX_LOCK(np);
+		xn_rxeof(np);	
+		XN_RX_UNLOCK(np);
+		if (np->tx.rsp_cons != np->tx.sring->rsp_prod) {
+			XN_TX_LOCK(np);
+			xn_txeof(np);
+			XN_TX_UNLOCK(np);			
+		}
+		if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
+		    !IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+			xn_start(ifp);
+	}
 	return;
 }
 
@@ -1057,6 +1054,7 @@
 	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&sc->tx, notify);
 	if (notify)
 		notify_remote_via_irq(sc->irq);
+
 	xn_txeof(sc);
 
 	if (RING_FULL(&sc->tx)) {


More information about the p4-projects mailing list