[svn-commits] fjoe: freebsd/trunk r10329 - in /freebsd/trunk: drivers/dahdi/ freebsd/dahdi/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Nov 7 13:32:21 CST 2011


Author: fjoe
Date: Mon Nov  7 13:32:13 2011
New Revision: 10329

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10329
Log:
- increase the number of buffers for nethdlc because receiver is now run
in a taskqueue
- return ENOBUFS when there are not enough output buffers on nethdlc send

Modified:
    freebsd/trunk/drivers/dahdi/dahdi-base.c
    freebsd/trunk/freebsd/dahdi/ng_dahdi_iface.c
    freebsd/trunk/include/dahdi/kernel.h

Modified: freebsd/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=10329&r1=10328&r2=10329
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi-base.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi-base.c Mon Nov  7 13:32:13 2011
@@ -2011,14 +2011,14 @@
 }
 #endif
 
-int dahdi_net_chan_init(struct dahdi_chan *ms)
+int dahdi_net_chan_init(struct dahdi_chan *ms, int numbufs)
 {
 	int res;
 
 	ms->txbufpolicy = DAHDI_POLICY_IMMEDIATE;
 	ms->rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
 
-	res = dahdi_reallocbufs(ms, DAHDI_DEFAULT_MTU_MRU, DAHDI_DEFAULT_NUM_BUFS);
+	res = dahdi_reallocbufs(ms, DAHDI_DEFAULT_MTU_MRU, numbufs);
 	if (res)
 		return res;
 

Modified: freebsd/trunk/freebsd/dahdi/ng_dahdi_iface.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi/ng_dahdi_iface.c?view=diff&rev=10329&r1=10328&r2=10329
==============================================================================
--- freebsd/trunk/freebsd/dahdi/ng_dahdi_iface.c (original)
+++ freebsd/trunk/freebsd/dahdi/ng_dahdi_iface.c Mon Nov  7 13:32:13 2011
@@ -297,7 +297,7 @@
 	    NG_NODE_NAME(node));
 
 	/* setup channel */
-	if (dahdi_net_chan_init(chan)) {
+	if (dahdi_net_chan_init(chan, DAHDI_DEFAULT_NUM_BUFS * 8)) {
 		printf("dahdi_iface(%s): Error: Failed to initialize channel\n",
 		    NG_NODE_NAME(node));
 		goto error;
@@ -355,9 +355,19 @@
 dahdi_iface_rx(struct dahdi_chan *chan)
 {
 	struct dahdi_iface *iface;
+	int oldreadbuf;
 
 	if ((iface = chan->iface) == NULL)
 		return;
+
+	/* switch buffers */
+	if ((oldreadbuf = chan->inreadbuf) >= 0) {
+		chan->inreadbuf = (chan->inreadbuf + 1) % chan->numbufs;
+		if (chan->inreadbuf == chan->outreadbuf)
+			chan->inreadbuf = -1;		/* no more buffers to receive to */
+		if (chan->outreadbuf < 0)
+			chan->outreadbuf = oldreadbuf;	/* new buffer to read from */
+	}
 
 	taskqueue_enqueue_fast(iface->rx_taskqueue, &iface->rx_task);
 }
@@ -373,38 +383,49 @@
 	struct dahdi_chan *chan = context;
 	struct dahdi_iface *iface;
 	unsigned long flags;
+	int oldreadbuf;
 
 	if ((iface = chan->iface) == NULL)
 		return;
 
-	/*
-	 * Our network receiver logic is MUCH different.
-	 * We actually only use a single buffer
-	 */
 	spin_lock_irqsave(&chan->lock, flags);
-	if (iface->upper != NULL && chan->readn[chan->inreadbuf] > 1) {
-		struct mbuf *m;
-
-		/* Drop the FCS */
-		chan->readn[chan->inreadbuf] -= 2;
-
-		MGETHDR(m, M_NOWAIT, MT_DATA);
+	while ((oldreadbuf = chan->outreadbuf) >= 0) {
+		struct mbuf *m = NULL;
+
+		/* read frame */
+		if (iface->upper != NULL && chan->readn[chan->outreadbuf] > 1) {
+
+			/* Drop the FCS */
+			chan->readn[chan->outreadbuf] -= 2;
+
+			MGETHDR(m, M_NOWAIT, MT_DATA);
+			if (m != NULL) {
+				if (chan->readn[chan->outreadbuf] >= MINCLSIZE) {
+					MCLGET(m, M_NOWAIT);
+				}
+
+				/* copy data */
+				m_append(m, chan->readn[chan->outreadbuf], chan->readbuf[chan->outreadbuf]);
+			}
+		}
+
+		/* switch buffers */
+		chan->readn[chan->outreadbuf] = 0;
+		chan->readidx[chan->outreadbuf] = 0;
+		chan->outreadbuf = (chan->outreadbuf + 1) % chan->numbufs;
+		if (chan->outreadbuf == chan->inreadbuf)
+			chan->outreadbuf = -1;		/* no more buffers to read from */
+		if (chan->inreadbuf < 0)
+			chan->inreadbuf = oldreadbuf;	/* new buffer to read to */
+
 		if (m != NULL) {
 			int error;
 
-			if (chan->readn[chan->inreadbuf] >= MINCLSIZE) {
-				MCLGET(m, M_NOWAIT);
-			}
-
-			/* copy data */
-			m_append(m, chan->readn[chan->inreadbuf], chan->readbuf[chan->inreadbuf]);
+			spin_unlock_irqrestore(&chan->lock, flags);
 			NG_SEND_DATA_ONLY(error, iface->upper, m);
+			spin_lock_irqsave(&chan->lock, flags);
 		}
 	}
-
-	/* We don't cycle through buffers, just reuse the same one */
-	chan->readn[chan->inreadbuf] = 0;
-	chan->readidx[chan->inreadbuf] = 0;
 	spin_unlock_irqrestore(&chan->lock, flags);
 }
 
@@ -565,7 +586,7 @@
 	}
 	if (ss->inwritebuf < 0) {
 		/* no space */
-		retval = ENXIO;
+		retval = ENOBUFS;
 		goto out;
 	}
 

Modified: freebsd/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/kernel.h?view=diff&rev=10329&r1=10328&r2=10329
==============================================================================
--- freebsd/trunk/include/dahdi/kernel.h (original)
+++ freebsd/trunk/include/dahdi/kernel.h Mon Nov  7 13:32:13 2011
@@ -1362,7 +1362,7 @@
 
 void dahdi_poll_wait(struct file *file, struct pollinfo *sel, struct poll_table_struct *wait_table);
 
-int dahdi_net_chan_init(struct dahdi_chan *chan);
+int dahdi_net_chan_init(struct dahdi_chan *chan, int numbufs);
 void dahdi_net_chan_destroy(struct dahdi_chan *chan);
 void dahdi_net_chan_xmit(struct dahdi_chan *chan);
 




More information about the svn-commits mailing list