[svn-commits] rmeyerriecks: branch linux/rmeyerriecks/dahdi-linux-maintmodes r7430 - in /li...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 28 16:06:43 CDT 2009


Author: rmeyerriecks
Date: Wed Oct 28 16:06:39 2009
New Revision: 7430

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7430
Log:
Maintenance modes additions. Added error counters. adjusted ioctls to export
the error counters. Added local loopback capability and control via the 
corresponding ioctls


Modified:
    linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/dahdi-base.c
    linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/wct4xxp/base.c
    linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/kernel.h
    linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/user.h

Modified: linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/dahdi-base.c?view=diff&rev=7430&r1=7429&r2=7430
==============================================================================
--- linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/dahdi-base.c Wed Oct 28 16:06:39 2009
@@ -3814,8 +3814,12 @@
 		stack.spaninfo.bpvcount = spans[i]->bpvcount;	/* get BPV count */
 		stack.spaninfo.rxlevel = spans[i]->rxlevel;	/* get rx level */
 		stack.spaninfo.txlevel = spans[i]->txlevel;	/* get tx level */
+		stack.spaninfo.fecount = spans[i]->fecount;	/* get Framing error count */
 		stack.spaninfo.crc4count = spans[i]->crc4count;	/* get CRC4 error count */
+		stack.spaninfo.cvcount = spans[i]->cvcount;	/* get Code Violation error count */
 		stack.spaninfo.ebitcount = spans[i]->ebitcount;	/* get E-bit error count */
+		stack.spaninfo.becount = spans[i]->becount;	/* get bit error count */
+		stack.spaninfo.prbscount = spans[i]->prbscount;	/* get prbs status register */
 		stack.spaninfo.fascount = spans[i]->fascount;	/* get FAS error count */
 		stack.spaninfo.irqmisses = spans[i]->irqmisses;	/* get IRQ miss count */
 		stack.spaninfo.syncsrc = spans[i]->syncsrc;	/* get active sync source */
@@ -4417,6 +4421,19 @@
 			if (rv)
 				return rv;
 			rv = schluffen(&spans[maint.spanno]->maintq);
+			if (rv)
+				return rv;
+			spin_lock_irqsave(&spans[maint.spanno]->lock, flags);
+			break;
+		case DAHDI_MAINT_FAS_DEFECT:
+		case DAHDI_MAINT_MULTI_DEFECT:
+		case DAHDI_MAINT_CRC_DEFECT:
+		case DAHDI_MAINT_CAS_DEFECT:
+		case DAHDI_MAINT_PRBS_DEFECT:
+		case DAHDI_MAINT_BIPOLAR_DEFECT:
+		case DAHDI_MAINT_PRBS:
+			rv = spans[maint.spanno]->maint(spans[maint.spanno], maint.command);
+			spin_unlock_irqrestore(&spans[maint.spanno]->lock, flags);
 			if (rv)
 				return rv;
 			spin_lock_irqsave(&spans[maint.spanno]->lock, flags);

Modified: linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/wct4xxp/base.c?view=diff&rev=7430&r1=7429&r2=7430
==============================================================================
--- linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/team/rmeyerriecks/dahdi-linux-maintmodes/drivers/dahdi/wct4xxp/base.c Wed Oct 28 16:06:39 2009
@@ -418,6 +418,44 @@
 #define WC_RED    (1)
 #define WC_GREEN  (2)
 #define WC_YELLOW (3)
+
+#define LIM0_T 0x36 		/* Line interface mode 0 register */
+#define LIM0_LL (1 << 1)	/* Local Loop */
+#define LIM1_T 0x37		/* Line interface mode 1 register */
+#define LIM1_RL (1 << 1)	/* Remote Loop */
+
+#define FMR1_T 0x1D		/* Framer Mode Register 1 */
+#define FMR1_ECM (1 << 2)	/* Error Counter 1sec Interrupt Enable */
+#define DEC_T 0x60		/* Diable Error Counter */
+#define IERR_T 0x1B		/* Single Bit Defect Insertion Register */
+enum{IBV, IPE, ICASE, ICRCE, IMFE, IFASE};
+#define ISR3_SEC (1 << 6)	/* Internal one-second interrupt bit mask */
+
+#define FECL_T 0x50		/* Framing Error Counter Lower Byte */
+#define FECH_T 0x51		/* Framing Error Counter Higher Byte */
+#define CVCL_T 0x52		/* Code Violation Counter Lower Byte */
+#define CVCH_T 0x53		/* Code Violation Counter Higher Byte */
+#define CEC1L_T 0x54		/* CRC Error Counter 1 Lower Byte */
+#define CEC1H_T 0x55		/* CRC Error Counter 1 Higher Byte */
+#define EBCL_T 0x56		/* E-Bit Error Counter Lower Byte */
+#define EBCH_T 0x57		/* E-Bit Error Counter Higher Byte */
+#define BECL_T 0x58		/* Bit Error Counter Lower Byte */
+#define BECH_T 0x59		/* Bit Error Counter Higher Byte */
+#define COEC_T 0x5A		/* COFA Event Counter */
+#define PRBSSTA_T 0xDA		/* PRBS Status Register */
+
+#define LCR1_T 0x3B		/* Loop Code Register 1 */
+#define EPRM (1 << 7)		/* Enable PRBS rx */
+#define XPRBS (1 << 6)		/* Enable PRBS tx */
+#define FLLB (1 << 1)		/* Framed line loop/Invert */
+#define LLBP (1 << 0)		/* Line Loopback Pattern */
+#define TPC0_T 0xA8		/* Test Pattern Control Register */
+#define FRA (1 << 6)		/* Framed/Unframed Selection */
+#define PRBS23 (3 << 4)		/* Pattern selection (23 poly) */
+#define PRM (1 << 2)		/* Non framed mode */
+#define FRS1_T 0x4D		/* Framer Receive Status Reg 1 */
+#define LLBDD (1 << 4)
+#define LLBAD (1 << 3)
 
 #define MAX_T4_CARDS 64
 
@@ -1320,6 +1358,7 @@
 {
 	struct t4_span *ts = span->pvt;
 	struct t4 *wc = ts->owner;
+	unsigned int reg;
 
 	if (ts->spantype == TYPE_E1) {
 		switch(cmd) {
@@ -1347,25 +1386,77 @@
 		}
 	} else {
 		switch(cmd) {
-	    case DAHDI_MAINT_NONE:
+		case DAHDI_MAINT_NONE:
 			printk(KERN_NOTICE "XXX Turn off local and remote loops T1 XXX\n");
+
+			reg = t4_framer_in(wc, span->offset, LIM0_T);
+			t4_framer_out(wc, span->offset, LIM0_T, (reg & ~LIM0_LL));
+
+			reg = t4_framer_in(wc, span->offset, LIM1_T);
+			t4_framer_out(wc, span->offset, LIM1_T, (reg & ~LIM1_RL));
+
+			reg = t4_framer_in(wc, span->offset, LCR1_T);
+			t4_framer_out(wc, span->offset, LCR1_T, (reg & ~XPRBS));
+
+			reg = t4_framer_in(wc, span->offset, LCR1_T);
+			t4_framer_out(wc, span->offset, LCR1_T, (reg & ~EPRM));
+
+			span->mainttimer = 0;
 			break;
-	    case DAHDI_MAINT_LOCALLOOP:
+		case DAHDI_MAINT_LOCALLOOP:
 			printk(KERN_NOTICE "XXX Turn on local loop and no remote loop XXX\n");
+			reg = t4_framer_in(wc, span->offset, LIM0_T);
+			t4_framer_out(wc, span->offset, LIM0_T, (reg | LIM0_LL));
 			break;
-	    case DAHDI_MAINT_REMOTELOOP:
+		case DAHDI_MAINT_REMOTELOOP:
 			printk(KERN_NOTICE "XXX Turn on remote loopup XXX\n");
+			reg = t4_framer_in(wc, span->offset, LIM1_T);
+			t4_framer_out(wc, span->offset, LIM1_T, (reg | LIM1_RL));
 			break;
-	    case DAHDI_MAINT_LOOPUP:
+		case DAHDI_MAINT_LOOPUP:
 			t4_framer_out(wc, span->offset, 0x21, 0x50);	/* FMR5: Nothing but RBS mode */
 			break;
-	    case DAHDI_MAINT_LOOPDOWN:
+		case DAHDI_MAINT_LOOPDOWN:
 			t4_framer_out(wc, span->offset, 0x21, 0x60);	/* FMR5: Nothing but RBS mode */
 			break;
-	    case DAHDI_MAINT_LOOPSTOP:
+		case DAHDI_MAINT_LOOPSTOP:
 			t4_framer_out(wc, span->offset, 0x21, 0x40);	/* FMR5: Nothing but RBS mode */
 			break;
-	    default:
+		case DAHDI_MAINT_FAS_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, IFASE);
+			break;
+		case DAHDI_MAINT_MULTI_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, IMFE);
+			break;
+		case DAHDI_MAINT_CRC_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, ICRCE);
+			break;
+		case DAHDI_MAINT_CAS_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, ICASE);
+			break;
+		case DAHDI_MAINT_PRBS_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, IPE);
+			break;
+		case DAHDI_MAINT_BIPOLAR_DEFECT:
+			t4_framer_out(wc, span->offset, IERR_T, IBV);
+			break;
+		case DAHDI_MAINT_PRBS:
+			printk(KERN_NOTICE "Enabling PRBS!\n");
+			span->mainttimer = 1;
+			// Enable PRBS monitor
+			reg = t4_framer_in(wc, span->offset, LCR1_T);
+			reg |= EPRM;
+
+			// Setup PRBS xmit
+			t4_framer_out(wc, span->offset, TPC0_T, 0);
+
+			// Enable PRBS transmit
+			reg |= XPRBS;
+			reg &= ~LLBP;
+			reg &= ~FLLB;
+			t4_framer_out(wc, span->offset, LCR1_T, reg);
+			break;
+		default:
 			printk(KERN_NOTICE "TE%dXXP: Unknown T1 maint command: %d\n", wc->numspans, cmd);
 			break;
 	   }
@@ -1610,6 +1701,7 @@
 	int gen2;
 	int offset = 1;
 	struct t4_span *ts;
+	unsigned int reg;
 	
 	gen2 = (wc->tspans[0]->spanflags & FLAG_2NDGEN);
 	if (!wc->t1e1)
@@ -1691,6 +1783,11 @@
 				mychans->readchunk = (void *)(wc->readchunk + (x * 32 + y + offset) * 2);
 			}
 		}
+
+		/* Enable 1sec timer interrupt */
+		reg = t4_framer_in(wc, x, FMR1_T);
+		t4_framer_out(wc, x, FMR1_T, (reg | FMR1_ECM));
+		printk(KERN_DEBUG "Enabled 1sec error counter interrupt\n");
 	}
 	set_span_devicetype(wc);
 }
@@ -1977,7 +2074,7 @@
 	__t4_framer_out(wc, unit, FRMR_IMR0, 0xff & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR0_MASK : 0));	/* IMR0: We care about CAS changes, etc */
 	__t4_framer_out(wc, unit, FRMR_IMR1, 0xff & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR1_MASK : 0));	/* IMR1: We care about nothing */
 	__t4_framer_out(wc, unit, 0x16, 0x00);	/* IMR2: We care about all the alarm stuff! */
-	__t4_framer_out(wc, unit, 0x17, 0xf4);	/* IMR3: We care about AIS and friends */
+	__t4_framer_out(wc, unit, 0x17, 0xb4);	/* IMR3: We care about AIS and friends */
 	__t4_framer_out(wc, unit, 0x18, 0x3f);  /* IMR4: We care about slips on transmit */
 
 	printk(KERN_INFO "TE%dXXP: Span %d configured for %s/%s\n", wc->numspans, unit + 1, framing, line);
@@ -2694,7 +2791,7 @@
 static inline void t4_framer_interrupt(struct t4 *wc, int span)
 {
 	/* Check interrupts for a given span */
-	unsigned char gis, isr0, isr1, isr2, isr3, isr4;
+	unsigned char gis, isr0, isr1, isr2, isr3, isr4, reg;
 	int readsize = -1;
 	struct t4_span *ts = wc->tspans[span];
 	struct dahdi_chan *sigchan;
@@ -2712,7 +2809,32 @@
 	isr4 = (gis & FRMR_GIS_ISR4) ? t4_framer_in(wc, span, FRMR_ISR4) : 0;
 
 	if (debug & DEBUG_FRAMER)
-		printk(KERN_DEBUG "gis: %02x, isr0: %02x, isr1: %02x, isr2: %02x, isr3: %02x, isr4: %02x\n", gis, isr0, isr1, isr2, isr3, isr4);
+		printk(KERN_DEBUG "gis: %02x, isr0: %02x, isr1: %02x, isr2: %02x, isr3: %08x, isr4: %02x\n", gis, isr0, isr1, isr2, isr3, isr4);
+
+	if (isr3 & ISR3_SEC) {
+		printk(KERN_DEBUG "Received 1sec interrupt\n");
+		ts->span.fecount += t4_framer_in(wc, span, FECL_T);
+		ts->span.crc4count += t4_framer_in(wc, span, CEC1L_T);
+		ts->span.cvcount += t4_framer_in(wc, span, CVCL_T);
+		ts->span.ebitcount += t4_framer_in(wc, span, EBCL_T);
+		ts->span.becount += t4_framer_in(wc, span, BECL_T);
+		ts->span.prbscount = t4_framer_in(wc, span, FRS1_T);
+		printk(KERN_DEBUG "FEC : %d\n", ts->span.fecount);
+		printk(KERN_DEBUG "CEC : %d\n", ts->span.crc4count);
+		printk(KERN_DEBUG "CVC : %d\n", ts->span.cvcount);
+		printk(KERN_DEBUG "EBC : %d\n", ts->span.ebitcount);
+		printk(KERN_DEBUG "BEC : %d\n", ts->span.becount);
+		printk(KERN_DEBUG "PRBS: %d\n", ts->span.prbscount);
+	}
+
+	if (isr3 & 0x08) {
+		reg = t4_framer_in(wc, span, FRS1_T);
+		printk(KERN_INFO "FRS1: %d\n", reg);
+		if(reg & LLBDD) {
+			printk(KERN_DEBUG "Line Loop-Back Activation Signal Detected with status: %01d\n",
+				reg & LLBAD);		
+		}
+	}
 
 	if (isr0)
 		t4_check_sigbits(wc, span);
@@ -2837,7 +2959,6 @@
 	if (isr1 & FRMR_ISR1_ALLS) {
 		if (debug & DEBUG_FRAMER) printk(KERN_DEBUG "ALLS received\n");
 	}
-
 }
 
 #ifdef SUPPORT_GEN1

Modified: linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/kernel.h?view=diff&rev=7430&r1=7429&r2=7430
==============================================================================
--- linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/kernel.h (original)
+++ linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/kernel.h Wed Oct 28 16:06:39 2009
@@ -759,10 +759,14 @@
 	int txlevel;			/*!< Tx level */
 	int rxlevel;			/*!< Rx level */
 	int syncsrc;			/*!< current sync src (gets copied here) */
+	unsigned int fecount;		/*!< Framing error counter */
+	unsigned int cvcount;		/*!< Coding violations counter */
 	unsigned int bpvcount;		/*!< BPV counter */
 	unsigned int crc4count;	        /*!< CRC4 error counter */
 	unsigned int ebitcount;		/*!< current E-bit error count */
 	unsigned int fascount;		/*!< current FAS error count */
+	unsigned int becount;		/*!< current bit error count */
+	unsigned int prbscount;		/*!< current PRBS detected pattern */
 
 	int maintstat;			/*!< Maintenance state */
 	wait_queue_head_t maintq;	/*!< Maintenance queue */

Modified: linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/user.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/user.h?view=diff&rev=7430&r1=7429&r2=7430
==============================================================================
--- linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/user.h (original)
+++ linux/team/rmeyerriecks/dahdi-linux-maintmodes/include/dahdi/user.h Wed Oct 28 16:06:39 2009
@@ -326,6 +326,13 @@
 #define DAHDI_MAINT_LOOPUP		3	/* send loopup code */
 #define DAHDI_MAINT_LOOPDOWN		4	/* send loopdown code */
 #define DAHDI_MAINT_LOOPSTOP		5	/* stop sending loop codes */
+#define DAHDI_MAINT_FAS_DEFECT		6	/* insert a FAS defect */
+#define DAHDI_MAINT_MULTI_DEFECT	7	/* insert a Multiframe defect */
+#define DAHDI_MAINT_CRC_DEFECT		8	/* insert a FAS defect */
+#define DAHDI_MAINT_CAS_DEFECT		9	/* insert a FAS defect */
+#define DAHDI_MAINT_PRBS_DEFECT		10	/* insert a FAS defect */
+#define DAHDI_MAINT_BIPOLAR_DEFECT	11	/* insert a FAS defect */
+#define DAHDI_MAINT_PRBS		12	/* enable the PRBS gen/mon */
 
 /* Flag Value for IOMUX, read avail */
 #define DAHDI_IOMUX_READ	1
@@ -530,9 +537,13 @@
 	int	txlevel;	/* what TX level is set to */
 	int	rxlevel;	/* current RX level */
 	int	bpvcount;	/* current BPV count */
+	int	fecount;	/* current Framing error count */
 	int	crc4count;	/* current CRC4 error count */
+	int	cvcount;	/* current Code Violation error count */
 	int	ebitcount;	/* current E-bit error count */
 	int	fascount;	/* current FAS error count */
+	int	becount;	/* current bit error count */
+	int	prbscount;	/* current PRBS detection register */
 	int	irqmisses;	/* current IRQ misses */
 	int	syncsrc;	/* span # of current sync source, or 0 for free run  */
 	int	numchans;	/* number of configured channels on this span */




More information about the svn-commits mailing list