Subject: Patches to COM.C for FIFO_LEVEL
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Robert Shady <rls@zeus.id.net>
List: current-users
Date: 03/23/1994 13:24:59
Not sure if this is wanted or not, but someone else came up with an idea
that sounded good to me, so I quickly implemented it, and I am now testing
it on our main SLIP server to see if it helps reduce problems.  I am not
sure if it will actually help increase performance or not, but we'll give
it a try.  Basically, this patch adds the default ability to reduce the
FIFO interrupt from FIFO_TRIGGER_14 all the way down to FIFO_TRIGGER_1, and
also provides the means for which you could increase it from 1 to 14 as
well (although code is there, it is not implemented.  You would probably
want to test the line and do a speed/throughput analysis to see if you
would be willing to raise it again).

Let me know how these work out for you folks..

--- Cut Here ---

*** com.c.orig	Wed Mar 23 10:47:48 1994
--- com.c 		Wed Mar 23 11:14:36 1994
***************
*** 173,178 ****
--- 173,233 ----
  	return COM_NPORTS;
  }
  
+ void	
+ adapt_fifo( sc, state )
+ 	struct com_softc *sc;
+ 	u_short state;
+ {
+ /* 
+  * Adapt FIFO trigger levels according to line conditions.  Provisions have
+  * been provided to DECREASE (state==0), or INCREASE (state==1) the FIFO
+  * interrupt level.  This code has been modified to automatically decrease
+  * the interrupt level as soon as a single SILO overflow is received.  
+  * Code has not been provided to automatically increase this value if
+  * things have been going well.  Feel free to modify & redistribute as
+  * needed.
+  *		Rob Shady (rls@id.net)
+  */
+ 	u_short iobase = sc->sc_iobase;
+ 	u_short	cur_fifo, new_fifo;
+ 
+     if ((sc->sc_hwflags & COM_HW_FIFO) == COM_HW_FIFO)
+ 		{
+ 		if ((inb(iobase + com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK)
+ 			{
+ 			cur_fifo = inb(iobase + com_fifo);
+ 			if ((cur_fifo & FIFO_TRIGGER_14) == FIFO_TRIGGER_14)
+ 				if (state)
+ 					;
+ 				else
+ 					new_fifo = FIFO_TRIGGER_8;
+ 			else if ((cur_fifo & FIFO_TRIGGER_8) == FIFO_TRIGGER_8)	
+ 				if (state)
+ 					new_fifo = FIFO_TRIGGER_14;
+ 				else
+ 					new_fifo = FIFO_TRIGGER_4;
+ 			else if ((cur_fifo & FIFO_TRIGGER_4) == FIFO_TRIGGER_4)
+ 				if (state)
+ 					new_fifo = FIFO_TRIGGER_8;
+ 				else
+ 					new_fifo = FIFO_TRIGGER_1;
+ 			else 
+ 				if (state)
+ 					new_fifo = FIFO_TRIGGER_4;
+ 				else
+ 					;
+ 			outb(iobase + com_fifo,
+ 	    		FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | new_fifo );
+ 			if (state)
+ 				log(LOG_WARNING, "%s: bumped FIFO up to %d\n", 
+ 					sc->sc_dev.dv_xname, new_fifo);
+ 			else
+ 				log(LOG_WARNING, "%s: bumped FIFO down to %d\n",
+ 					sc->sc_dev.dv_xname, new_fifo);
+ 		}
+ 	}
+ }
+ 
  int
  comattach(isa_dev)
  	struct isa_device *isa_dev;
***************
*** 683,689 ****
--- 738,747 ----
  	else if (stat & LSR_PE)
  		c |= TTY_PE;
  	if (stat & LSR_OE)
+ 	{
  		log(LOG_WARNING, "%s: silo overflow\n", sc->sc_dev.dv_xname);
+ 		adapt_fifo( sc, 0 );
+ 	}
  	/* XXXX put in FIFO and process later */
  	(*linesw[tp->t_line].l_rint)(c, tp);
  }

------------------------------------------------------------------------------