[svn-commits] kmoore: linux/trunk r9905 - in /linux/trunk: drivers/dahdi/ include/dahdi/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 15 11:16:22 CDT 2011


Author: kmoore
Date: Fri Apr 15 11:16:19 2011
New Revision: 9905

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9905
Log:
dahdi: Add capability to generate events on buffer underruns and overruns

Add BUFFEVENTS and individual buffer event channel flags so that DAHDI can
notify userspace processes when it is dropping data.  This can be useful when
trouble shooting fax problems since DAHDI currently silently discards data
becasuse of scheduling latency.  With this change, Asterisk could log an event
as opposed to just leaving it up to the tone detectors to figure out there was
some unexpected phase shift.

Acked-by: Shaun Ruffell <sruffell at digium.com>
(original patch by Matt Fredrickson)

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c
    linux/trunk/include/dahdi/kernel.h
    linux/trunk/include/dahdi/user.h

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9905&r1=9904&r2=9905
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Fri Apr 15 11:16:19 2011
@@ -6278,6 +6278,13 @@
 		}
 		break;
 #endif
+	case DAHDI_BUFFER_EVENTS:
+		if (get_user(j, (int __user *)data) != -EFAULT && j)
+			set_bit(DAHDI_FLAGBIT_BUFEVENTS, &chan->flags);
+		else
+			clear_bit(DAHDI_FLAGBIT_BUFEVENTS, &chan->flags);
+
+		break;
 	default:
 		return dahdi_chanandpseudo_ioctl(file, cmd, data);
 	}
@@ -7060,6 +7067,7 @@
 	int getlin;
 	/* How many bytes we need to process */
 	int bytes = DAHDI_CHUNKSIZE, left;
+	bool needtxunderrun = false;
 	int x;
 
 	/* Let's pick something to transmit.  First source to
@@ -7201,11 +7209,23 @@
 			} else {
 				memset(txb, 0xFF, bytes);
 			}
+			needtxunderrun += bytes;
 			bytes = 0;
 		} else {
 			memset(txb, DAHDI_LIN2X(0, ms), bytes);	/* Lastly we use silence on telephony channels */
+			needtxunderrun += bytes;
 			bytes = 0;
 		}
+	}
+
+	if (needtxunderrun) {
+		if (!test_bit(DAHDI_FLAGBIT_TXUNDERRUN, &ms->flags)) {
+			if (test_bit(DAHDI_FLAGBIT_BUFEVENTS, &ms->flags))
+				__qevent(ms, DAHDI_EVENT_WRITE_UNDERRUN);
+			set_bit(DAHDI_FLAGBIT_TXUNDERRUN, &ms->flags);
+		}
+	} else {
+		clear_bit(DAHDI_FLAGBIT_TXUNDERRUN, &ms->flags);
 	}
 
 #ifdef CONFIG_DAHDI_MIRROR
@@ -8383,6 +8403,15 @@
 #endif
 	}
 
+	if (bytes) {
+		if (!test_bit(DAHDI_FLAGBIT_RXOVERRUN, &ms->flags)) {
+			if (test_bit(DAHDI_FLAGBIT_BUFEVENTS, &ms->flags))
+				__qevent(ms, DAHDI_EVENT_READ_OVERRUN);
+			set_bit(DAHDI_FLAGBIT_RXOVERRUN, &ms->flags);
+		}
+	} else {
+		clear_bit(DAHDI_FLAGBIT_RXOVERRUN, &ms->flags);
+	}
 }
 
 static inline void __dahdi_putbuf_chunk(struct dahdi_chan *ss, unsigned char *rxb)

Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=9905&r1=9904&r2=9905
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Fri Apr 15 11:16:19 2011
@@ -719,6 +719,9 @@
 	DAHDI_FLAGBIT_LOOPED	= 18,	/*!< Loopback the receive data from the channel to the transmit */
 	DAHDI_FLAGBIT_MTP2	= 19,	/*!< Repeats last message in buffer and also discards repeating messages sent to us */
 	DAHDI_FLAGBIT_HDLC56	= 20,	/*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K  */
+	DAHDI_FLAGBIT_BUFEVENTS	= 21,	/*!< Report buffer events */
+	DAHDI_FLAGBIT_TXUNDERRUN = 22,	/*!< Transmit underrun condition */
+	DAHDI_FLAGBIT_RXOVERRUN = 23,	/*!< Receive overrun condition */
 	DAHDI_FLAGBIT_DEVFILE	= 25,	/*!< Channel has a sysfs dev file */
 };
 
@@ -783,6 +786,9 @@
 #define DAHDI_FLAG_LOOPED	DAHDI_FLAG(LOOPED)
 #define DAHDI_FLAG_MTP2		DAHDI_FLAG(MTP2)
 #define DAHDI_FLAG_HDLC56	DAHDI_FLAG(HDLC56)
+#define DAHDI_FLAG_BUFEVENTS	DAHDI_FLAG(BUFEVENTS)
+#define DAHDI_FLAG_TXUNDERRUN	DAHDI_FLAG(TXUNDERRUN)
+#define DAHDI_FLAG_RXOVERRUN	DAHDI_FLAG(RXOVERRUN)
 
 struct dahdi_span_ops {
 	struct module *owner;		/*!< Which module is exporting this span. */

Modified: linux/trunk/include/dahdi/user.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/user.h?view=diff&rev=9905&r1=9904&r2=9905
==============================================================================
--- linux/trunk/include/dahdi/user.h (original)
+++ linux/trunk/include/dahdi/user.h Fri Apr 15 11:16:19 2011
@@ -447,6 +447,12 @@
 
 /* The echo canceler's NLP (only) was enabled */
 #define DAHDI_EVENT_EC_NLP_ENABLED	28
+
+/* The channel's read buffer encountered an overrun condition */
+#define DAHDI_EVENT_READ_OVERRUN	29
+
+/* The channel's write buffer encountered an underrun condition */
+#define DAHDI_EVENT_WRITE_UNDERRUN	30
 
 #define DAHDI_EVENT_PULSEDIGIT		(1 << 16)	/* This is OR'd with the digit received */
 #define DAHDI_EVENT_DTMFDOWN		(1 << 17)	/* Ditto for DTMF key down event */
@@ -1085,6 +1091,13 @@
 #define DAHDI_TXMIRROR			_IOW(DAHDI_CODE, 104, int)
 #endif /* CONFIG_DAHDI_MIRROR */
 
+/*
+  Set the desired state for channel buffer event generation which is disabled
+  by default to allow for backwards compatibility for dumb users of channels
+  such as pattern utilities.
+ */
+#define DAHDI_BUFFER_EVENTS		_IOW(DAHDI_CODE, 105, int)
+
 /* Get current status IOCTL */
 /* Defines for Radio Status (dahdi_radio_stat.radstat) bits */
 




More information about the svn-commits mailing list