summaryrefslogtreecommitdiff
path: root/xhfc/xhfc_st_state.c
diff options
context:
space:
mode:
authorNoe Rubinstein <nrubinstein@proformatique.com>2010-11-12 13:45:24 +0100
committerNoe Rubinstein <nrubinstein@proformatique.com>2010-11-12 13:45:24 +0100
commita80aeaabdcd15d5ec68adc80a7fb92eb41378e7b (patch)
tree503ee895ab980e09d4daddc5b2d5d604eb22fdd9 /xhfc/xhfc_st_state.c
parent0765bf9a051d735855f9617cbe2a54d231a56ba9 (diff)
debug traces, cleanup/fix
Diffstat (limited to 'xhfc/xhfc_st_state.c')
-rw-r--r--xhfc/xhfc_st_state.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/xhfc/xhfc_st_state.c b/xhfc/xhfc_st_state.c
index 809d80f..9f3f6e6 100644
--- a/xhfc/xhfc_st_state.c
+++ b/xhfc/xhfc_st_state.c
@@ -27,11 +27,6 @@
enum te_state { F0, F1, F2, F3, F4, F5, F6, F7, F8 };
enum nt_state { G0, G1, G2, G3 };
-void activate_request(struct xhfc_span* s);
-void deactivate_request(struct xhfc_span* s);
-void handle_state_change(struct xhfc_span* s);
-void handle_st_timers(struct xhfc_span* s)
-
static void expiry_T1(struct xhfc_span* s);
static void expiry_T3(struct xhfc_span* s);
@@ -47,6 +42,12 @@ static void print_current_state(struct xhfc_span* s);
void activate_request(struct xhfc_span* s)
{
u8 a_su_wr_sta = 0;
+
+ if(DBG_ST && DBG_SPAN(s))
+ printk(KERN_DEBUG DRIVER_NAME
+ ": activate on port %d\n",
+ xhfc_span->port);
+
SET_V_SU_ACT(a_su_wr_sta, V_SU_ACT_ACTIVATE);
write_xhfc(s->xhfc, R_SU_SEL, s->port);
@@ -56,6 +57,20 @@ void activate_request(struct xhfc_span* s)
else s->t3++;
}
+void deactivate_request(struct xhfc_span* s) /* XXX not called */
+{
+
+ int sta = GET_V_SU_STA(s->state);
+
+ if(DBG_ST && DBG_SPAN(s))
+ printk(KERN_DEBUG DRIVER_NAME
+ ": deactivate on port %d\n",
+ xhfc_span->port);
+
+ if(s->nt && (sta == G2 || sta == G3))
+ set_st_state(s, G4);
+}
+
void handle_state_change(struct xhfc_span* s)
{
struct xhfc* x = s->xhfc;
@@ -65,10 +80,10 @@ void handle_state_change(struct xhfc_span* s)
write_xhfc(x, R_SU_SEL, s->port);
s->state = read_xhfc(x, A_SU_RD_STA);
- if(DBG_ST)
+ if(DBG_ST && DBG_SPAN(s))
print_state(s);
- if(s->prev_state == s->state) {
+ if(unlikely(s->prev_state == s->state)) {
printk(KERN_WARNING DRIVER_NAME ": a state change has been "
"reported on port %d but it looks like the "
"state has not changed?", s->port + 1);
@@ -153,7 +168,6 @@ static void handle_state_change_te(struct xhfc_span* s)
}
signal_f7_transition(s);
- s->f6_f7_transition = NOT_RUNNING;
break;
}
@@ -161,25 +175,38 @@ static void handle_state_change_te(struct xhfc_span* s)
void handle_st_timers(struct xhfc_span* s)
{
- if(s->t1 && ++t1 > T1_MS) expiry_T1(s);
- if(s->t3 && ++t3 > T3_MS) expiry_T3(s);
- if(s->f6_f7_transition && ++f6_f7_transition > F6_F7_MS)
+ if(unlikely(s->t1 && ++t1 > T1_MS)) expiry_T1(s);
+ if(unlikely(s->t3 && ++t3 > T3_MS)) expiry_T3(s);
+ if(unlikely(s->f6_f7_transition && ++f6_f7_transition > F6_F7_MS))
signal_f7_transition(s);
}
static void signal_f7_transition(struct xhfc_span* s)
{
+ if(DBG_ST && DBG_SPAN(s))
+ printk(KERN_DEBUG DRIVER_NAME ": signalling transition to F7 "
+ "on port %d", s->port + 1);
+
s->span.alarms = DAHDI_ALARM_NONE;
+ s->f6_f7_transition = NOT_RUNNING;
}
static void expiry_T1(struct xhfc_span* s)
{
+ if(DBG_ST && DBG_SPAN(s))
+ printk(KERN_INFO DRIVER_NAME ": NT activation timeout"
+ " on port %d", s->port + 1);
+
set_st_state(s, G4);
s->t1 = NOT_RUNNING;
}
static void expiry_T3(struct xhfc_span* s);
{
+ if(DBG_ST && DBG_SPAN(s))
+ printk(KERN_INFO DRIVER_NAME ": TE activation timeout"
+ " on port %d", s->port + 1);
+
set_st_state(s, F3);
s->t3 = NOT_RUNNING;
}
@@ -187,6 +214,16 @@ static void expiry_T3(struct xhfc_span* s);
static void set_st_state(struct xhfc_span* s, int state)
{
u8 a_su_wr_sta = 0;
+
+ s->prev_state = s->state;
+ s->state = state;
+
+ if(DBG_ST && DBG_SPAN(s)) {
+ printk(KERN_DEBUG DRIVER_NAME "port %d: "
+ "Forcing state change:\n", s->port +1);
+ print_state(s);
+ }
+
SET_V_SU_SET_STA(a_su_wr_sta, state);
SET_V_SU_LD_STA(a_su_wr_sta, 1);