Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Apr 1998 12:24:59 +0200 (MET DST)
From:      Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>
To:        FreeBSD-ISDN@FreeBSD.ORG (FreeBSD ISDN mailinglist)
Subject:   first ICMP reply
Message-ID:  <199804111025.MAA00303@rvc1.informatik.ba-stuttgart.de>

next in thread | raw e-mail | index | archive | help
Hi,

For whatever reason, if doing a ping -c1 via a raw IP interface,
the ICMP reply is not received.

The diff, which is a major rework of isic_bchannel_start(), fixes
this. I know, Hellmuth, you don't like this one, but still...

It reduces duplicate code and simplifies isic_bchannel_start(),
thus enhances readability and maintainability.

There is one caveat: isic_bchannel_start() must not be called if nothing
is enqueued for transmission. The only place where this might happen
is in driver/i4b_isppp.c. This patch includes a fix for this as well.

Again, this diff is against i4b-00.51, if you run the -current version of
i4b-00.51 you'll have to patch some hunks manually. 

Happy Easter,

Wolfgang
--- /home/helbig/src/i4b/layer1/i4b_bchan.c	Wed Mar 11 10:35:55 1998
+++ layer1/i4b_bchan.c	Sat Apr 11 01:41:20 1998
@@ -179,179 +179,29 @@
 #endif
 
 	register isic_Bchan_t *chan = &sc->sc_chan[h_chan];
-	register int next_len;
-	register int len;
 
 	int s;
-	int activity = -1;
-	int cmd = 0;
 
 	s = SPLI4B();				/* enter critical section */
-	if(chan->state & HSCX_TX_ACTIVE)	/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
 
-	
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(isic_hscx_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= HSCX_TX_ACTIVE;		/* we start transmitting */
-	
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = unit;
-		hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		hdr.time = time;
-		MPH_Trace_Ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	len = 0;	/* # of chars put into HSCX tx fifo this time */
-
-	/*
-	 * fill the HSCX tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than HSCX fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the HSCX that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while((len < HSCX_FIFO_LEN) && chan->out_mbuf_cur)
-	{
-		/*
-		 * put as much data into the HSCX fifo as is
-		 * available from the current mbuf
-		 */
-		 
-		if((len + chan->out_mbuf_cur_len) >= HSCX_FIFO_LEN)
-			next_len = HSCX_FIFO_LEN - len;
-		else
-			next_len = chan->out_mbuf_cur_len;
-
-#ifdef NOTDEF		
-		printf("b:mh=%x, mc=%x, mcp=%x, mcl=%d l=%d nl=%d # ",
-			chan->out_mbuf_head,
-			chan->out_mbuf_cur,			
-			chan->out_mbuf_cur_ptr,
-			chan->out_mbuf_cur_len,
-			len,
-			next_len);
-#endif
-
-		/* wait for tx fifo write enabled */
-
-		isic_hscx_waitxfw(sc, h_chan);
-
-		/* write what we have from current mbuf to HSCX fifo */
-
-		HSCX_WRFIFO(h_chan, chan->out_mbuf_cur_ptr, next_len);
-
-		len += next_len;		/* update # of bytes written */
-		chan->txcount += next_len;	/* statistics */
-		chan->out_mbuf_cur_ptr += next_len;	/* data ptr */
-		chan->out_mbuf_cur_len -= next_len;	/* data len */
-
-		/*
-		 * in case the current mbuf (of a possible chain) data
-		 * has been put into the fifo, check if there is a next
-		 * mbuf in the chain. If there is one, get ptr to it
-		 * and update the data ptr and the length
-		 */
-		 
-		if((chan->out_mbuf_cur_len <= 0)	&&
-		  ((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL))
-		{
-			chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-			chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-			if(sc->sc_trace & TRACE_B_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = unit;
-				hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_bcount;
-				hdr.time = time;
-				MPH_Trace_Ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-			}			
-		}
-	}
-
-	/*
-	 * if there is either still data in the current mbuf and/or
-	 * there is a successor on the chain available issue just
-	 * a XTF (transmit) command to HSCX. if ther is no more
-	 * data available from the current mbuf (-chain), issue
-	 * an XTF and an XME (message end) command which will then
-	 * send the CRC and the closing HDLC flag sequence
-	 */
-	 
-	if(chan->out_mbuf_cur && (chan->out_mbuf_cur_len > 0))
-	{
-		/*
-		 * more data available, send current fifo out.
-		 * next xfer to HSCX tx fifo is done in the
-		 * HSCX interrupt routine.
-		 */
-		 
-		cmd |= HSCX_CMDR_XTF;
-	}
-	else
-	{
-		/* end of mbuf chain */
-	
-		if(chan->bprot == BPROT_NONE)
-			cmd |= HSCX_CMDR_XTF;
-		else
-			cmd |= HSCX_CMDR_XTF | HSCX_CMDR_XME;
-		
-		i4b_Bfreembuf(chan->out_mbuf_head);	/* free mbuf chain */
-		
-		chan->out_mbuf_head = NULL;
-		chan->out_mbuf_cur = NULL;			
-		chan->out_mbuf_cur_ptr = NULL;
-		chan->out_mbuf_cur_len = 0;
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->drvr_linktab->bch_activity)(chan->drvr_linktab->unit, activity);
-
-	if(cmd)
-		isic_hscx_cmd(sc, h_chan, cmd);
-		
-	splx(s);	
+ 	if(!(chan->state & HSCX_TX_ACTIVE))	/* already running ? */
+  	{
+ 		/* init mbuf values */
+ 		if (chan->out_mbuf_head != NULL)
+ 			DBGL1(L1_ERROR, "isic_bchannel_start",
+ 			    ("out_mbuf_head != NULL"));
+  		
+ 		DBGL1(L1_MESSAGE, "isic_bchannel_start", ("entered\n"));
+  
+ 		chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
+ 		chan->out_mbuf_cur_len = 0;
+ 		chan->out_mbuf_cur_ptr = NULL;	
+  
+ 		/* provoke an XPR interrupt */
+ 		isic_hscx_cmd(sc, h_chan, HSCX_CMDR_XRES);
+ 	}
+  		
+  	splx(s);	
 }
 
 /*---------------------------------------------------------------------------*
--- /home/helbig/src/i4b/driver/i4b_isppp.c	Thu Mar 19 20:36:51 1998
+++ driver/i4b_isppp.c	Sat Apr 11 01:58:28 1998
@@ -93,6 +93,7 @@
 #include <i4b/i4b_ioctl.h>
 #endif
 
+#include <i4b/include/i4b_global.h>
 #include <i4b/include/i4b_mbuf.h>
 #include <i4b/include/i4b_l3l4.h>
 
@@ -305,7 +306,7 @@
 	switch(cmd) {
 	case SIOCSIFFLAGS:
 #if 0 /* never used ??? */
-		x = splimp();
+		x = SPLI4B();
 		if ((ifp->if_flags & IFF_UP) == 0)
 			UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
 		splx(x);
@@ -324,6 +325,7 @@
 {
 	struct i4bisppp_softc *sc = ifp->if_softc;
 	struct mbuf *m;
+	int enqueued = 0; 
 	int s;
 	int unit = IFP2UNIT(ifp);
 
@@ -333,9 +335,8 @@
 	if(sc->sc_state != ST_CONNECTED)
 		return;
 
-	s = splimp();
+	s = SPLI4B();
 	/*ifp->if_flags |= IFF_OACTIVE; - need to clear this somewhere */
-	splx(s);
 
 	while ((m = sppp_dequeue(&sc->sc_if)) != NULL) {
 #if NBPFILTER > 0
@@ -351,12 +352,16 @@
 		microtime(&ifp->if_lastchange);
 
 		IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
+		enqueued = 1;
 
 		sc->sc_if.if_obytes += m->m_pkthdr.len;
 		sc->sc_outb += m->m_pkthdr.len;
 		sc->sc_if.if_opackets++;
 	}
-	isdn_linktab[unit]->bch_tx_start(isdn_linktab[unit]->unit,
+	splx(s);
+
+	if (enqueued)
+		isdn_linktab[unit]->bch_tx_start(isdn_linktab[unit]->unit,
 					 isdn_linktab[unit]->channel);
 }
 
@@ -469,7 +474,7 @@
 {
 	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
 	struct sppp *sp = &sc->sc_if_un.scu_sp;
-	int s = splimp();
+	int s = SPLI4B();
 
 	sc->sc_cdp = (call_desc_t *)cdp;
 	sc->sc_state = ST_CONNECTED;
@@ -503,7 +508,7 @@
 	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
 	struct sppp *sp = &sc->sc_if_un.scu_sp;
 
-	int s = splimp();
+	int s = SPLI4B();
 
 	/* new stuff to check that the active channel is being closed */
 	if (cd != sc->sc_cdp)
@@ -618,7 +623,7 @@
 	}
 #endif /* NBPFILTER > 0 */
 
-	s = splimp();
+	s = SPLI4B();
 
 	sppp_input(&sc->sc_if, m);
 
@@ -644,7 +649,7 @@
 static void
 i4bisppp_activity(int unit, int rxtx)
 {
-	i4bisppp_softc[unit].sc_cdp->last_active_time = time.tv_sec;
+	i4bisppp_softc[unit].sc_cdp->last_active_time = SECOND;
 }
 
 /*---------------------------------------------------------------------------*

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



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