[svn-commits] mattf: branch 1.4 r4250 - in /branches/1.4: ./ kernel/ kernel/wct4xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat May 10 20:57:09 CDT 2008


Author: mattf
Date: Sat May 10 20:57:08 2008
New Revision: 4250

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4250
Log:
Merge in kernel level MTP2 branch.

Modified:
    branches/1.4/kernel/wct4xxp/base.c
    branches/1.4/kernel/zaptel-base.c
    branches/1.4/kernel/zaptel.h
    branches/1.4/ztcfg.c

Modified: branches/1.4/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wct4xxp/base.c?view=diff&rev=4250&r1=4249&r2=4250
==============================================================================
--- branches/1.4/kernel/wct4xxp/base.c (original)
+++ branches/1.4/kernel/wct4xxp/base.c Sat May 10 20:57:08 2008
@@ -1626,7 +1626,7 @@
 		for (y=0;y<wc->tspans[x]->span.channels;y++) {
 			struct zt_chan *mychans = ts->chans + y;
 			sprintf(mychans->name, "TE%d/%d/%d/%d", wc->numspans, wc->num, x + 1, y + 1);
-			mychans->sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_FXSKS | ZT_SIG_HARDHDLC |
+			mychans->sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_FXSKS | ZT_SIG_HARDHDLC | ZT_SIG_MTP2 |
 									 ZT_SIG_FXOLS | ZT_SIG_FXOGS | ZT_SIG_FXOKS | ZT_SIG_CAS | ZT_SIG_EM_E1 | ZT_SIG_DACS_RBS;
 			mychans->pvt = wc;
 			mychans->chanpos = y + 1;

Modified: branches/1.4/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel-base.c?view=diff&rev=4250&r1=4249&r2=4250
==============================================================================
--- branches/1.4/kernel/zaptel-base.c (original)
+++ branches/1.4/kernel/zaptel-base.c Sat May 10 20:57:08 2008
@@ -502,6 +502,8 @@
 			return "HDLCNET";
 		case ZT_SIG_HARDHDLC:
 			return "Hardware-assisted HDLC";
+		case ZT_SIG_MTP2:
+			return "MTP2";
 		case ZT_SIG_SLAVE:
 			return "Slave";
 		case ZT_SIG_CAS:
@@ -823,6 +825,7 @@
 		newbuf = kmalloc(j * 2 * numbufs, GFP_KERNEL);
 		if (!newbuf) 
 			return (-ENOMEM);
+		memset(newbuf, 0, j * 2 * numbufs);
 	} else
 		newbuf = NULL;
 	  /* Now that we've allocated our new buffer, we can safely
@@ -3802,6 +3805,11 @@
 				chans[ch.chan]->flags |= ZT_FLAG_NOSTDTXRX;
 			} else
 				chans[ch.chan]->flags &= ~ZT_FLAG_NOSTDTXRX;
+
+			if ((ch.sigtype & ZT_SIG_MTP2) == ZT_SIG_MTP2)
+				chans[ch.chan]->flags |= ZT_FLAG_MTP2;
+			else
+				chans[ch.chan]->flags &= ~ZT_FLAG_MTP2;
 		}
 #ifdef CONFIG_ZAPATA_NET
 		if (!res && 
@@ -5748,18 +5756,30 @@
 				oldbuf = ms->outwritebuf;
 				/* Clear out write index and such */
 				ms->writeidx[oldbuf] = 0;
-				ms->writen[oldbuf] = 0;
 				ms->outwritebuf = (ms->outwritebuf + 1) % ms->numbufs;
-				if (ms->outwritebuf == ms->inwritebuf) {
-					/* Whoopsies, we're run out of buffers.  Mark ours
-					as -1 and wait for the filler to notify us that
-					there is something to write */
-					ms->outwritebuf = -1;
-					if (ms->iomask & (ZT_IOMUX_WRITE | ZT_IOMUX_WRITEEMPTY))
-						wake_up_interruptible(&ms->eventbufq);
-					/* If we're only supposed to start when full, disable the transmitter */
-					if (ms->txbufpolicy == ZT_POLICY_WHEN_FULL)
-						ms->txdisable = 1;
+
+				if (!(ms->flags & ZT_FLAG_MTP2)) {
+					ms->writen[oldbuf] = 0;
+					if (ms->outwritebuf == ms->inwritebuf) {
+						/* Whoopsies, we're run out of buffers.  Mark ours
+						as -1 and wait for the filler to notify us that
+						there is something to write */
+						ms->outwritebuf = -1;
+						if (ms->iomask & (ZT_IOMUX_WRITE | ZT_IOMUX_WRITEEMPTY))
+							wake_up_interruptible(&ms->eventbufq);
+						/* If we're only supposed to start when full, disable the transmitter */
+						if (ms->txbufpolicy == ZT_POLICY_WHEN_FULL)
+							ms->txdisable = 1;
+					}
+				} else {
+					if (ms->outwritebuf == ms->inwritebuf) {
+						ms->outwritebuf = oldbuf;
+						if (ms->iomask & (ZT_IOMUX_WRITE | ZT_IOMUX_WRITEEMPTY))
+							wake_up_interruptible(&ms->eventbufq);
+						/* If we're only supposed to start when full, disable the transmitter */
+						if (ms->txbufpolicy == ZT_POLICY_WHEN_FULL)
+							ms->txdisable = 1;
+					}
 				}
 				if (ms->inwritebuf < 0) {
 					/* The filler doesn't have a place to put data.  Now
@@ -6803,21 +6823,40 @@
 				} else 
 #endif
 				{
-					ms->inreadbuf = (ms->inreadbuf + 1) % ms->numbufs;
-					if (ms->inreadbuf == ms->outreadbuf) {
-						/* Whoops, we're full, and have no where else
-						to store into at the moment.  We'll drop it
-						until there's a buffer available */
+					/* This logic might confuse and astound.  Basically we need to find
+					 * the previous buffer index.  It should be safe because, regardless
+					 * of whether or not it has been copied to user space, nothing should
+					 * have messed around with it since then */
+
+					int comparemessage;
+
+					if (ms->flags & ZT_FLAG_MTP2) {
+						comparemessage = (ms->inreadbuf - 1) & (ms->numbufs - 1);
+
+						res = memcmp(ms->readbuf[comparemessage], ms->readbuf[ms->inreadbuf], ms->readn[ms->inreadbuf]);
+					}
+
+					if ((ms->flags & ZT_FLAG_MTP2) && !res) {
+						/* Our messages are the same, so discard -
+						 * 	Don't advance buffers, reset indexes and buffer sizes. */
+						ms->readn[ms->inreadbuf] = 0;
+						ms->readidx[ms->inreadbuf] = 0;
+					} else {
+						ms->inreadbuf = (ms->inreadbuf + 1) % ms->numbufs;
+						if (ms->inreadbuf == ms->outreadbuf) {
+							/* Whoops, we're full, and have no where else
+							to store into at the moment.  We'll drop it
+							until there's a buffer available */
 #ifdef CONFIG_ZAPATA_DEBUG
-						printk("Out of storage space\n");
-#endif
-						ms->inreadbuf = -1;
-						/* Enable the receiver in case they've got POLICY_WHEN_FULL */
-						ms->rxdisable = 0;
-					}
-					if (ms->outreadbuf < 0) { /* start out buffer if not already */
-						ms->outreadbuf = oldbuf;
-					}
+							printk("Out of storage space\n");
+#endif
+							ms->inreadbuf = -1;
+							/* Enable the receiver in case they've got POLICY_WHEN_FULL */
+							ms->rxdisable = 0;
+						}
+						if (ms->outreadbuf < 0) { /* start out buffer if not already */
+							ms->outreadbuf = oldbuf;
+						}
 /* In the very orignal driver, it was quite well known to me (Jim) that there
 was a possibility that a channel sleeping on a receive block needed to
 be potentially woken up EVERY time a buffer was filled, not just on the first
@@ -6828,16 +6867,17 @@
 with an infinite loop that gets broken out of upon an active condition,
 otherwise keeps sleeping and looking. The part in this code got "optimized"
 out in the later versions, and is put back now. */
-					if (!ms->rxdisable) { /* if receiver enabled */
-						/* Notify a blocked reader that there is data available
-						to be read, unless we're waiting for it to be full */
+						if (!ms->rxdisable) { /* if receiver enabled */
+							/* Notify a blocked reader that there is data available
+							to be read, unless we're waiting for it to be full */
 #ifdef CONFIG_ZAPATA_DEBUG
-						printk("Notifying reader data in block %d\n", oldbuf);
-#endif
-						wake_up_interruptible(&ms->readbufq);
-						wake_up_interruptible(&ms->sel);
-						if (ms->iomask & ZT_IOMUX_READ)
-							wake_up_interruptible(&ms->eventbufq);
+							printk("Notifying reader data in block %d\n", oldbuf);
+#endif
+							wake_up_interruptible(&ms->readbufq);
+							wake_up_interruptible(&ms->sel);
+							if (ms->iomask & ZT_IOMUX_READ)
+								wake_up_interruptible(&ms->eventbufq);
+						}
 					}
 				}
 			}

Modified: branches/1.4/kernel/zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel.h?view=diff&rev=4250&r1=4249&r2=4250
==============================================================================
--- branches/1.4/kernel/zaptel.h (original)
+++ branches/1.4/kernel/zaptel.h Sat May 10 20:57:08 2008
@@ -143,6 +143,7 @@
 #define ZT_SIG_EM_E1	(1 << 17)			/* E1 E&M Variation */
 #define ZT_SIG_DACS_RBS	((1 << 18) | __ZT_SIG_DACS)	/* Cross connect w/ RBS */
 #define ZT_SIG_HARDHDLC	((1 << 19) | ZT_SIG_CLEAR)
+#define ZT_SIG_MTP2	((1 << 20) | ZT_SIG_HDLCFCS)	/* MTP2 support  Need HDLC bitstuff and FCS calcuation too */
 
 /* tone flag values */
 #define	ZT_REVERSE_RXTONE 1  /* reverse polarity rx tone logic */
@@ -1554,6 +1555,7 @@
 #define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */
 #define ZT_FLAG_NOSTDTXRX		(1 << 17)	/* Do NOT do standard transmit and receive on every interrupt */
 #define ZT_FLAG_LOOPED			(1 << 18)	/* Loopback the receive data from the channel to the transmit */
+#define ZT_FLAG_MTP2			(1 << 19)	/* Repeats last message in buffer and also discards repeating messages sent to us */
 
 /* This is a redefinition of the flags from above to allow use of the kernel atomic bit testing and changing routines.
  * See the above descriptions for ZT_FLAG_....  for documentation about function. */
@@ -1577,6 +1579,7 @@
 	ZT_FLAGBIT_SIGFREEZE  = 16,
 	ZT_FLAGBIT_NOSTDTXRX  = 17,
 	ZT_FLAGBIT_LOOPED     = 18,
+	ZT_FLAGBIT_MTP2       = 19,
 };
 
 struct zt_span {

Modified: branches/1.4/ztcfg.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ztcfg.c?view=diff&rev=4250&r1=4249&r2=4250
==============================================================================
--- branches/1.4/ztcfg.c (original)
+++ branches/1.4/ztcfg.c Sat May 10 20:57:08 2008
@@ -160,6 +160,8 @@
 		return "HDLC with FCS check";
 	case ZT_SIG_HARDHDLC:
 		return "Hardware assisted D-channel";
+	case ZT_SIG_MTP2:
+		return "MTP2";
 	default:
 		return "Unknown";
 	}
@@ -590,6 +592,9 @@
 			} else if (!strcasecmp(keyword, "hardhdlc")) {
 				sig[x] = "Hardware assisted D-channel";
 				cc[x].sigtype = ZT_SIG_HARDHDLC;
+			} else if (!strcasecmp(keyword, "mtp2")) {
+				sig[x] = "MTP2";
+				cc[x].sigtype = ZT_SIG_MTP2;
 			} else {
 				fprintf(stderr, "Huh? (%s)\n", keyword);
 			}
@@ -1201,6 +1206,7 @@
 	{ "nethdlc", chanconfig },
 	{ "fcshdlc", chanconfig },
 	{ "hardhdlc", chanconfig },
+	{ "mtp2", chanconfig },
 	{ "dchan", chanconfig },
 	{ "bchan", chanconfig },
 	{ "indclear", chanconfig },




More information about the svn-commits mailing list