Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2010 02:07:26 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r214408 - stable/7/sys/pci
Message-ID:  <201010270207.o9R27Qta083796@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Wed Oct 27 02:07:25 2010
New Revision: 214408
URL: http://svn.freebsd.org/changeset/base/214408

Log:
  MFC r213796:
    Rewrite interrupt handler to give fairness for both RX and TX.
    Previously rl(4) continuously checked whether there are RX events
    or TX completions in forever loop. This caused TX starvation under
    high RX load as well as consuming too much CPU cycles in the
    interrupt handler. If interrupt was shared with other devices which
    may be always true due to USB devices in these days, rl(4) also
    tried to process the interrupt. This means polling(4) was the only
    way to mitigate the these issues.
  
    To address these issues, rl(4) now disables interrupts when it
    knows the interrupt is ours and limit the number of iteration of
    the loop to 16. The interrupt would be enabled again before exiting
    interrupt handler if the driver is still running. Because RX buffer
    is 64KB in size, the number of iterations in the loop has nothing
    to do with number of RX packets being processed. This change
    ensures sending TX frames under high RX load.
  
    RX handler drops a driver lock to pass received frames to upper
    stack such that there is a window that user can down the interface.
    So rl(4) now checks whether driver is still running before serving
    RX or TX completion in the loop.
  
    While I'm here, exit interrupt handler when driver initialized
    controller.
  
    With this change, now rl(4) can send frames under high RX load even
    though the TX performance is still not good(rl(4) controllers can't
    queue more than 4 frames at a time so low TX performance was one of
    design issue of rl(4) controllers). It's much better than previous
    TX starvation and you should not notice RX performance drop with
    this change. Controller still shows poor performance under high
    network load but for many cases it's now usable without resorting
    to polling(4).

Modified:
  stable/7/sys/pci/if_rl.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/pci/if_rl.c
==============================================================================
--- stable/7/sys/pci/if_rl.c	Wed Oct 27 02:04:24 2010	(r214407)
+++ stable/7/sys/pci/if_rl.c	Wed Oct 27 02:07:25 2010	(r214408)
@@ -1613,6 +1613,7 @@ rl_intr(void *arg)
 	struct rl_softc		*sc = arg;
 	struct ifnet		*ifp = sc->rl_ifp;
 	uint16_t		status;
+	int			count;
 
 	RL_LOCK(sc);
 
@@ -1624,30 +1625,41 @@ rl_intr(void *arg)
 		goto done_locked;
 #endif
 
-	for (;;) {
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+		goto done_locked2;
+	status = CSR_READ_2(sc, RL_ISR);
+	if (status == 0xffff || (status & RL_INTRS) == 0)
+		goto done_locked;
+	/*
+	 * Ours, disable further interrupts.
+	 */
+	CSR_WRITE_2(sc, RL_IMR, 0);
+	for (count = 16; count > 0; count--) {
+		CSR_WRITE_2(sc, RL_ISR, status);
+		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+			if (status & (RL_ISR_RX_OK | RL_ISR_RX_ERR))
+				rl_rxeof(sc);
+			if (status & (RL_ISR_TX_OK | RL_ISR_TX_ERR))
+				rl_txeof(sc);
+			if (status & RL_ISR_SYSTEM_ERR) {
+				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+				rl_init_locked(sc);
+				RL_UNLOCK(sc);
+				return;
+			}
+		}
 		status = CSR_READ_2(sc, RL_ISR);
 		/* If the card has gone away, the read returns 0xffff. */
-		if (status == 0xffff)
+		if (status == 0xffff || (status & RL_INTRS) == 0)
 			break;
-		if (status != 0)
-			CSR_WRITE_2(sc, RL_ISR, status);
-		if ((status & RL_INTRS) == 0)
-			break;
-		if (status & RL_ISR_RX_OK)
-			rl_rxeof(sc);
-		if (status & RL_ISR_RX_ERR)
-			rl_rxeof(sc);
-		if ((status & RL_ISR_TX_OK) || (status & RL_ISR_TX_ERR))
-			rl_txeof(sc);
-		if (status & RL_ISR_SYSTEM_ERR) {
-			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
-			rl_init_locked(sc);
-		}
 	}
 
 	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 		rl_start_locked(ifp);
 
+done_locked2:
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		CSR_WRITE_2(sc, RL_IMR, RL_INTRS);
 done_locked:
 	RL_UNLOCK(sc);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010270207.o9R27Qta083796>