[svn-commits] mattf: branch mattf/zaptel-1.4-mtp2enhancements r4247 - in /team/mattf/zaptel...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 9 11:26:59 CDT 2008


Author: mattf
Date: Fri May  9 11:26:58 2008
New Revision: 4247

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4247
Log:
Add new channel type of MTP2 which performs a lot of things that need to be done in MTP2 in kernel space, such as automatic message repetition and discard of same signalling units sent in a row.  This will reduce the number of kernel/userspace transitions needed to maintain an MTP2 link and will increase link reliability under heavy system load.

Modified:
    team/mattf/zaptel-1.4-mtp2enhancements/kernel/wct4xxp/base.c
    team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel-base.c
    team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel.h
    team/mattf/zaptel-1.4-mtp2enhancements/ztcfg.c

Modified: team/mattf/zaptel-1.4-mtp2enhancements/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-mtp2enhancements/kernel/wct4xxp/base.c?view=diff&rev=4247&r1=4246&r2=4247
==============================================================================
--- team/mattf/zaptel-1.4-mtp2enhancements/kernel/wct4xxp/base.c (original)
+++ team/mattf/zaptel-1.4-mtp2enhancements/kernel/wct4xxp/base.c Fri May  9 11:26:58 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: team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel-base.c?view=diff&rev=4247&r1=4246&r2=4247
==============================================================================
--- team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel-base.c (original)
+++ team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel-base.c Fri May  9 11:26:58 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:
@@ -3802,6 +3804,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 +5755,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 +6822,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 +6866,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: team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel.h?view=diff&rev=4247&r1=4246&r2=4247
==============================================================================
--- team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel.h (original)
+++ team/mattf/zaptel-1.4-mtp2enhancements/kernel/zaptel.h Fri May  9 11:26:58 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: team/mattf/zaptel-1.4-mtp2enhancements/ztcfg.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-mtp2enhancements/ztcfg.c?view=diff&rev=4247&r1=4246&r2=4247
==============================================================================
--- team/mattf/zaptel-1.4-mtp2enhancements/ztcfg.c (original)
+++ team/mattf/zaptel-1.4-mtp2enhancements/ztcfg.c Fri May  9 11:26:58 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