summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/dahdi/dahdi-base.c20
-rw-r--r--drivers/dahdi/wct4xxp/base.c57
-rw-r--r--drivers/dahdi/wct4xxp/wct4xxp.h9
-rw-r--r--include/dahdi/user.h24
4 files changed, 95 insertions, 15 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index f3a677c..12d57a6 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -3483,6 +3483,7 @@ void dahdi_alarm_notify(struct dahdi_span *span)
int x;
span->alarms &= ~DAHDI_ALARM_LOOPBACK;
+ span->alarms &= ~DAHDI_ALARM_SYNC;
/* Determine maint status */
if (span->maintstat || span->mainttimer)
span->alarms |= DAHDI_ALARM_LOOPBACK;
@@ -3497,12 +3498,28 @@ void dahdi_alarm_notify(struct dahdi_span *span)
/* Switch to other master if current master in alarm */
for (x=1; x<maxspans; x++) {
if (spans[x] && !spans[x]->alarms && (spans[x]->flags & DAHDI_FLAG_RUNNING)) {
- if(master != spans[x])
+ if (master != spans[x]) {
module_printk(KERN_NOTICE, "Master changed to %s\n", spans[x]->name);
+ span->alarms |= DAHDI_ALARM_SYNC;
+ }
master = spans[x];
break;
}
}
+
+ /* XXX: Remove - Report more detailed alarms */
+ if (span->alarms & DAHDI_ALARM_LOS)
+ module_printk(KERN_NOTICE, "Span %d: Loss of signal\n", span->spanno);
+ if (span->alarms & DAHDI_ALARM_LFA)
+ module_printk(KERN_NOTICE, "Span %d: Loss of Frame Alignment\n", span->spanno);
+ if (span->alarms & DAHDI_ALARM_LMFA)
+ module_printk(KERN_NOTICE, "Span %d: Loss of Multi-Frame Alignment\n", span->spanno);
+ if (span->alarms & DAHDI_ALARM_XLS)
+ module_printk(KERN_NOTICE, "Span %d: Transmit Line Short\n", span->spanno);
+ if (span->alarms & DAHDI_ALARM_XLO)
+ module_printk(KERN_NOTICE, "Span %d: Transmit Line Open\n", span->spanno);
+ if (span->alarms & DAHDI_ALARM_SYNC)
+ module_printk(KERN_NOTICE, "Span %d: Change of syncronization signal\n", span->spanno);
}
}
@@ -4552,6 +4569,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
case DAHDI_MAINT_BIPOLAR_DEFECT:
case DAHDI_MAINT_PRBS:
case DAHDI_RESET_COUNTERS:
+ case DAHDI_MAINT_ALARM_SIM:
/* Prevent notifying an alarm state for generic
maintenance functions, unless the driver is
already in a maint state */
diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c
index 77ef562..6d83c0e 100644
--- a/drivers/dahdi/wct4xxp/base.c
+++ b/drivers/dahdi/wct4xxp/base.c
@@ -462,6 +462,8 @@ static void t4_check_sigbits(struct t4 *wc, int span);
#define LIM1_T 0x37 /* Line interface mode 1 register */
#define LIM1_RL (1 << 1) /* Remote Loop */
+#define FMR0 0x1C /* Framer Mode Register 0 */
+#define FMR0_SIM (1 << 0) /* Alarm Simulation */
#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 */
@@ -1437,6 +1439,7 @@ static int t4_maint(struct dahdi_span *span, int cmd)
struct t4_span *ts = container_of(span, struct t4_span, span);
struct t4 *wc = ts->owner;
unsigned int reg;
+ unsigned long flags;
if (ts->spantype == TYPE_E1) {
switch(cmd) {
@@ -1458,6 +1461,11 @@ static int t4_maint(struct dahdi_span *span, int cmd)
dev_info(&wc->dev->dev,
"Only local loop supported in E1 mode\n");
return -ENOSYS;
+ case DAHDI_MAINT_ALARM_SIM:
+ dev_info(&wc->dev->dev, "Invoking alarm state");
+ reg = t4_framer_in(wc, span->offset, FMR0);
+ t4_framer_out(wc, span->offset, FMR0, (reg|FMR0_SIM));
+ break;
default:
dev_info(&wc->dev->dev,
"Unknown E1 maint command: %d\n", cmd);
@@ -1545,6 +1553,25 @@ static int t4_maint(struct dahdi_span *span, int cmd)
case DAHDI_RESET_COUNTERS:
t4_reset_counters(span);
break;
+ case DAHDI_MAINT_ALARM_SIM:
+// dev_info(&wc->dev->dev, "Invoking alarm state\n");
+ reg = t4_framer_in(wc, span->offset, FMR0);
+ //dev_info(&wc->dev->dev, "FMR0: %X\n", reg);
+
+ // The alarm simulation state machine requires us to bring this bit
+ // up and down for at least 1 clock cycle
+ // lock register writes to ensure nobody else tries to write to FMR0, while we delay
+ spin_lock_irqsave(&wc->reglock, flags);
+ __t4_framer_out(wc, span->offset, FMR0, (reg|FMR0_SIM));
+ udelay(1);
+ __t4_framer_out(wc, span->offset, FMR0, (reg&~FMR0_SIM));
+ udelay(1);
+ spin_unlock_irqrestore(&wc->reglock, flags);
+
+ //dev_info(&wc->dev->dev, "FMR0: %X\n", reg|FMR0_SIM);
+ reg = t4_framer_in(wc, span->offset, 0x4e);
+ dev_info(&wc->dev->dev, "FRS2(alarm state): %d\n", ((reg&0xe0)>> 5));
+ break;
default:
dev_info(&wc->dev->dev, "Unknown T1 maint command:%d\n",
cmd);
@@ -1952,12 +1979,9 @@ static void init_spans(struct t4 *wc)
/* Enable 1sec timer interrupt */
reg = t4_framer_in(wc, x, FMR1_T);
t4_framer_out(wc, x, FMR1_T, (reg | FMR1_ECM));
- dev_info(&wc->dev->dev, "Enabled 1sec error counter "\
- "interrupt\n");
/* Enable Errored Second interrupt */
t4_framer_out(wc, x, ESM, 0);
- dev_info(&wc->dev->dev, "Enabled errored second interrupt\n");
t4_reset_counters(&ts->span);
@@ -2883,6 +2907,7 @@ static void t4_check_alarms(struct t4 *wc, int span)
alarms |= DAHDI_ALARM_NOTOPEN;
}
+ /* Loss of Frame Alignment */
if (c & 0x20) {
if (ts->alarmcount >= alarmdebounce) {
@@ -2903,7 +2928,8 @@ static void t4_check_alarms(struct t4 *wc, int span)
} else
ts->alarmcount = 0;
- if (c & 0x80) { /* LOS */
+ /* Loss of Signal */
+ if (c & 0x80) {
if (ts->losalarmcount >= losalarmdebounce) {
/* Disable Slip Interrupts */
e = __t4_framer_in(wc, span, 0x17);
@@ -2922,7 +2948,8 @@ static void t4_check_alarms(struct t4 *wc, int span)
} else
ts->losalarmcount = 0;
- if (c & 0x40) { /* AIS */
+ /* Alarm Indication Signal */
+ if (c & 0x40) {
if (ts->aisalarmcount >= aisalarmdebounce)
alarms |= DAHDI_ALARM_BLUE;
else {
@@ -2937,6 +2964,19 @@ static void t4_check_alarms(struct t4 *wc, int span)
} else
ts->aisalarmcount = 0;
+ /* Add detailed alarm status information to a red alarm state */
+ if (alarms & DAHDI_ALARM_RED) {
+ if (c & FRS0_LOS)
+ alarms |= DAHDI_ALARM_LOS;
+ if (c & FRS0_LFA)
+ alarms |= DAHDI_ALARM_LFA;
+ if (c & FRS0_LMFA)
+ alarms |= DAHDI_ALARM_LMFA;
+ if (d & FRS1_XLS)
+ alarms |= DAHDI_ALARM_XLS;
+ if (d & FRS1_XLO)
+ alarms |= DAHDI_ALARM_XLO;
+ }
if (((!ts->span.alarms) && alarms) ||
(ts->span.alarms && (!alarms)))
@@ -3112,6 +3152,7 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
gis, isr0, isr1, isr2, isr3, isr4, wc->intcount);
}
+ /* Collect performance counters once per second */
if (isr3 & ISR3_SEC) {
ts->span.count.fe += t4_framer_in(wc, span, FECL_T);
ts->span.count.crc4 += t4_framer_in(wc, span, CEC1L_T);
@@ -3121,6 +3162,7 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
ts->span.count.prbs = t4_framer_in(wc, span, FRS1_T);
}
+ /* Collect errored second counter once per second */
if (isr3 & ISR3_ES) {
ts->span.count.errsec += 1;
}
@@ -3145,7 +3187,10 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
} else {
/* T1 checks */
if (isr2 || (isr3 & 0x08)) {
- printk("card %d span %d: isr2=%x isr3=%x\n", wc->num, span, isr2, isr3);
+ if (debug & DEBUG_MAIN) {
+ printk("card %d span %d: isr2=%x isr3=%x\n",
+ wc->num, span, isr2, isr3);
+ }
t4_check_alarms(wc, span);
}
}
diff --git a/drivers/dahdi/wct4xxp/wct4xxp.h b/drivers/dahdi/wct4xxp/wct4xxp.h
index fb12173..7a53238 100644
--- a/drivers/dahdi/wct4xxp/wct4xxp.h
+++ b/drivers/dahdi/wct4xxp/wct4xxp.h
@@ -96,6 +96,15 @@
#define FRMR_SIS_XFW 0x40
#define FRMR_TXFIFO 0x00
+#define FRS0 0x4c
+#define FRS0_LOS (1<<7)
+#define FRS0_LFA (1<<5)
+#define FRS0_LMFA (1<<1)
+
+#define FRS1 0x4d
+#define FRS1_XLS (1<<1)
+#define FRS1_XLO (1<<0)
+
#define NUM_REGS 0xa9
#define NUM_PCI 12
diff --git a/include/dahdi/user.h b/include/dahdi/user.h
index 84cae22..6417e79 100644
--- a/include/dahdi/user.h
+++ b/include/dahdi/user.h
@@ -314,13 +314,20 @@ enum {
#define DAHDI_CONF_PSEUDO_TALKER 0x800 /* pseudo is a talker on the conference */
/* Alarm Condition bits */
-#define DAHDI_ALARM_NONE 0 /* No alarms */
-#define DAHDI_ALARM_RECOVER 1 /* Recovering from alarm */
-#define DAHDI_ALARM_LOOPBACK 2 /* In loopback */
-#define DAHDI_ALARM_YELLOW 4 /* Yellow Alarm */
-#define DAHDI_ALARM_RED 8 /* Red Alarm */
-#define DAHDI_ALARM_BLUE 16 /* Blue Alarm */
-#define DAHDI_ALARM_NOTOPEN 32
+#define DAHDI_ALARM_NONE 0 /* No alarms */
+#define DAHDI_ALARM_RECOVER (1 << 0) /* Recovering from alarm */
+#define DAHDI_ALARM_LOOPBACK (1 << 1) /* In loopback */
+#define DAHDI_ALARM_YELLOW (1 << 2) /* Yellow Alarm */
+#define DAHDI_ALARM_RED (1 << 3) /* Red Alarm */
+#define DAHDI_ALARM_BLUE (1 << 4) /* Blue Alarm */
+#define DAHDI_ALARM_NOTOPEN (1 << 5)
+/* Verbose alarm states (upper byte) */
+#define DAHDI_ALARM_LOS (1 << 8) /* Loss of Signal */
+#define DAHDI_ALARM_LFA (1 << 9) /* Loss of Frame Alignment */
+#define DAHDI_ALARM_LMFA (1 << 10) /* Loss of Multi-Frame Alignment */
+#define DAHDI_ALARM_XLS (1 << 11) /* Transmit line Short */
+#define DAHDI_ALARM_XLO (1 << 12) /* Transmit line Open */
+#define DAHDI_ALARM_SYNC (1 << 13) /* Loss of Sync source */
/* Maintenance modes */
#define DAHDI_MAINT_NONE 0 /* Normal Mode */
@@ -338,7 +345,8 @@ enum {
#define DAHDI_MAINT_BIPOLAR_DEFECT 11 /* insert a FAS defect */
#define DAHDI_MAINT_PRBS 12 /* enable the PRBS gen/mon */
#define DAHDI_MAINT_NETWORKPAYLOADLOOP 13 /* Remote Loopback */
-#define DAHDI_RESET_COUNTERS 14 /* clear the error counters */
+#define DAHDI_RESET_COUNTERS 14 /* Clear the error counters */
+#define DAHDI_MAINT_ALARM_SIM 15 /* Simulate alarms */
/* Flag Value for IOMUX, read avail */
#define DAHDI_IOMUX_READ 1