Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 2002 17:16:28 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        silby@silby.com
Cc:        csmith@its.uq.edu.au, hardware@freebsd.org, net@freebsd.org
Subject:   [PATCH: if_ti] Re: High interrupt load on firewalls
Message-ID:  <3DA769DC.58E6BBF0@mindspring.com>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------0C5A8C380344382790784831
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Mike Silbersack wrote:
> On Wed, 9 Oct 2002, Christopher Smith wrote:
> > The rule processing can't be done on the other CPU, can it ?  Am I right in
> > saying that at this point in time, buying a dual CPU (vs single CPU) machine
> > for firewalling with FreeBSD is just a waste of money ?
> 
> Even if it could be done, I doubt that would be the most cost effectively
> solution to the problem.  Try out different NICs, then move on to kernel
> profiling if it's still a problem.
> 
> Luigi can probably comment more on this, but one thing which comes to mind
> is that the if_ti driver might not be updated to use the new m_getcl
> function Luigi added.  Luigi claimed a 10% increase in forwarding speed
> for drivers using it, I believe. :)


Please find attached a patch for the if_ti to support DEVICE_POLLING
(the patch is against -current).

-- Terry
--------------0C5A8C380344382790784831
Content-Type: text/plain; charset=us-ascii;
 name="tipoll.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="tipoll.diff"

Index: if_ti.c
===================================================================
RCS file: /cvs/src/sys/pci/if_ti.c,v
retrieving revision 1.63
diff -c -r1.63 if_ti.c
*** if_ti.c	24 Aug 2002 00:02:03 -0000	1.63
--- if_ti.c	11 Oct 2002 20:09:48 -0000
***************
*** 2520,2525 ****
--- 2520,2533 ----
  		u_int16_t		vlan_tag = 0;
  		int			have_tag = 0;
  
+ #ifdef DEVICE_POLLING
+ 		if (ifp->if_flags & IFF_POLLING) {
+ 			if (sc->rxcycles <= 0)
+ 				break;
+ 			sc->rxcycles--;
+ 		}
+ #endif /* DEVICE_POLLING */
+ 
  		cur_rx =
  		    &sc->ti_rdata->ti_rx_return_ring[sc->ti_rx_saved_considx];
  		rxidx = cur_rx->ti_idx;
***************
*** 2678,2683 ****
--- 2686,2731 ----
  	return;
  }
  
+ #ifdef DEVICE_POLLING
+ static poll_handler_t ti_poll;
+ 
+ static void
+ ti_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+ {
+ 	struct	ti_softc *sc = ifp->if_softc;
+ 
+ 	TI_LOCK(sc);
+ 	if (cmd == POLL_DEREGISTER) { /* final call, enable interrupts */
+ 		CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
+ 		goto done;
+ 	}
+ 
+ 	/*
+ 	 * Before returning to intr mode we must make sure that all
+ 	 * possible pending sources of interrupts have been served.
+ 	 * In practice this means run to completion the *eof routines,
+ 	 * and then call the interrupt routine
+ 	 */
+ 	sc->rxcycles = count;
+ 	if (ifp->if_snd.ifq_head != NULL)
+ 		ti_start(ifp);
+ 
+ 	if (sc->rxcycles > 0 || cmd == POLL_AND_CHECK_STATUS) {
+ 		if (ifp->if_flags & IFF_RUNNING) {
+ 			/* Check RX return ring producer/consumer */
+ 			ti_rxeof(sc);
+ 
+ 			/* Check TX ring producer/consumer */
+ 			ti_txeof(sc);
+ 		}
+ 		ti_handle_events(sc);
+ 	}
+ done:
+ 	TI_UNLOCK(sc);
+ 	return;
+ }
+ #endif /* DEVICE_POLLING */
+ 
  static void
  ti_intr(xsc)
  	void			*xsc;
***************
*** 2688,2693 ****
--- 2736,2749 ----
  	sc = xsc;
  	TI_LOCK(sc);
  	ifp = &sc->arpcom.ac_if;
+ #ifdef DEVICE_POLLING
+ 	if (ifp->if_flags & IFF_POLLING)
+ 		goto done;
+ 	if (ether_poll_register(ti_poll, ifp)) { /* ok, disable interrupts */
+ 		CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
+ 		goto done;
+ 	}
+ #endif /* DEVICE_POLLING */
  
  /*#ifdef notdef*/
  	/* Avoid this for now -- checking this register is expensive. */
***************
*** 2716,2722 ****
  
  	if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
  		ti_start(ifp);
! 
  	TI_UNLOCK(sc);
  
  	return;
--- 2772,2780 ----
  
  	if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
  		ti_start(ifp);
! #ifdef DEVICE_POLLING
! done:
! #endif /* DEVICE_POLLING */
  	TI_UNLOCK(sc);
  
  	return;
***************
*** 2999,3004 ****
--- 3057,3071 ----
  	TI_DO_CMD(TI_CMD_HOST_STATE, TI_CMD_CODE_STACK_UP, 0);
  
  	/* Enable host interrupts. */
+ #ifdef DEVICE_POLLING
+ 	/*
+ 	 * ... only enable interrupts if we are not polling, make sure
+ 	 * they are off otherwise.
+ 	 */
+ 	if (ifp->if_flags & IFF_POLLING)
+ 		CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
+ 	else
+ #endif /* DEVICE_POLLING */
  	CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
  
  	ifp->if_flags |= IFF_RUNNING;
***************
*** 3613,3618 ****
--- 3680,3688 ----
  	TI_LOCK(sc);
  
  	ifp = &sc->arpcom.ac_if;
+ #ifdef DEVICE_POLLING
+ 	ether_poll_deregister(ifp);
+ #endif
  
  	/* Disable host interrupts. */
  	CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
Index: if_tireg.h
===================================================================
RCS file: /cvs/src/sys/pci/if_tireg.h,v
retrieving revision 1.25
diff -c -r1.25 if_tireg.h
*** if_tireg.h	26 Jun 2002 03:34:52 -0000	1.25
--- if_tireg.h	11 Oct 2002 19:25:04 -0000
***************
*** 1026,1031 ****
--- 1026,1034 ----
  	struct mtx		ti_mtx;
  	ti_flag_vals		ti_flags;
  	dev_t			dev;
+ #ifdef DEVICE_POLLING
+ 	int			rxcycles;
+ #endif
  };
  
  #define	TI_LOCK(_sc)		mtx_lock(&(_sc)->ti_mtx)

--------------0C5A8C380344382790784831--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hardware" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DA769DC.58E6BBF0>