[svn-commits] rmudgett: branch 1.4 r2113 - in /branches/1.4: pri_internal.h pri_q921.h q921.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 11 20:31:37 CST 2010


Author: rmudgett
Date: Thu Nov 11 20:31:24 2010
New Revision: 2113

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2113
Log:
Asterisk is getting a "No D-channels available!" warning message every 4 seconds.

For PTP links, libpri generated the PRI_EVENT_DCHAN_DOWN event every time
it failed to bring layer 2 up because the physical layer is down.

For PTP links, made generate the PRI_EVENT_DCHAN_UP/PRI_EVENT_DCHAN_DOWN
only when it enters/exits the Q.921 superstate consisting of states
7(Q921_MULTI_FRAME_ESTABLISHED) and 8(Q921_TIMER_RECOVERY).

Also changed the PTP link restart delay to be link specific instead of D
channel specific because the GR-303 PTP switch types have more than one
Q.921 link.

(closes issue #17270)
Reported by: jmls

Modified:
    branches/1.4/pri_internal.h
    branches/1.4/pri_q921.h
    branches/1.4/q921.c

Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=2113&r1=2112&r2=2113
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Thu Nov 11 20:31:24 2010
@@ -119,8 +119,6 @@
 	int t201_timer;
 	/*! Number of times T201 has expired. */
 	int t201_expirycnt;
-	/*! PTP layer 2 restart delay timer */
-	int restart_timer;
 	
 	int cref;			/* Next call reference value */
 

Modified: branches/1.4/pri_q921.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_q921.h?view=diff&rev=2113&r1=2112&r2=2113
==============================================================================
--- branches/1.4/pri_q921.h (original)
+++ branches/1.4/pri_q921.h Thu Nov 11 20:31:24 2010
@@ -246,6 +246,8 @@
 	int n202_counter;
 	/*! Max idle time */
 	int t203_timer;
+	/*! PTP restart delay timer */
+	int restart_timer;
 
 	/* MDL variables */
 	int mdl_timer;

Modified: branches/1.4/q921.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q921.c?view=diff&rev=2113&r1=2112&r2=2113
==============================================================================
--- branches/1.4/q921.c (original)
+++ branches/1.4/q921.c Thu Nov 11 20:31:24 2010
@@ -548,17 +548,18 @@
 	}
 }
 
-static void restart_timer_expire(void *vctrl)
-{
-	struct pri *ctrl = vctrl;
-	struct q921_link *link;
+static void restart_timer_expire(void *vlink)
+{
+	struct q921_link *link = vlink;
+	struct pri *ctrl;
+
+	ctrl = link->ctrl;
 
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "Kick starting layer 2\n");
-	}
-
-	ctrl->restart_timer = 0;
-	link = &ctrl->link;
+		pri_message(ctrl, "SAPI/TEI=%d/%d Kick starting link\n", link->sapi, link->tei);
+	}
+
+	link->restart_timer = 0;
 
 	switch (link->state) {
 	case Q921_TEI_ASSIGNED:
@@ -570,31 +571,42 @@
 		break;
 	default:
 		/* Looks like someone forgot to stop the restart timer. */
-		pri_error(ctrl, "Layer 2 restart delay timer expired in state %d(%s)\n",
-			link->state, q921_state2str(link->state));
-		break;
-	}
-}
-
-static void restart_timer_stop(struct pri *ctrl)
-{
-	pri_schedule_del(ctrl, ctrl->restart_timer);
-	ctrl->restart_timer = 0;
-}
-
-static void restart_timer_start(struct pri *ctrl)
-{
+		pri_error(ctrl, "SAPI/TEI=%d/%d Link restart delay timer expired in state %d(%s)\n",
+			link->sapi, link->tei, link->state, q921_state2str(link->state));
+		break;
+	}
+}
+
+static void restart_timer_stop(struct q921_link *link)
+{
+	struct pri *ctrl;
+
+	ctrl = link->ctrl;
+	pri_schedule_del(ctrl, link->restart_timer);
+	link->restart_timer = 0;
+}
+
+static void restart_timer_start(struct q921_link *link)
+{
+	struct pri *ctrl;
+
+	ctrl = link->ctrl;
+
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP) {
-		pri_message(ctrl, "-- Starting layer 2 restart delay timer\n");
-	}
-	pri_schedule_del(ctrl, ctrl->restart_timer);
-	ctrl->restart_timer =
-		pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], restart_timer_expire, ctrl);
-}
-
-static pri_event *q921_ptp_delay_restart(struct pri *ctrl)
+		pri_message(ctrl, "SAPI/TEI=%d/%d Starting link restart delay timer\n",
+			link->sapi, link->tei);
+	}
+	pri_schedule_del(ctrl, link->restart_timer);
+	link->restart_timer =
+		pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], restart_timer_expire, link);
+}
+
+static pri_event *q921_ptp_delay_restart(struct q921_link *link)
 {
 	pri_event *ev;
+	struct pri *ctrl;
+
+	ctrl = link->ctrl;
 
 	if (PTP_MODE(ctrl)) {
 		/*
@@ -602,12 +614,20 @@
 		 * got an L3 that depends on us keeping L2 automatically alive
 		 * and happy for PTP links.
 		 */
-		restart_timer_start(ctrl);
-
-		/* Notify the upper layer that layer 2 is down. */
-		ctrl->schedev = 1;
-		ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
-		ev = &ctrl->ev;
+		restart_timer_start(link);
+
+		switch (link->state) {
+		case Q921_MULTI_FRAME_ESTABLISHED:
+		case Q921_TIMER_RECOVERY:
+			/* Notify the upper layer that layer 2 went down. */
+			ctrl->schedev = 1;
+			ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+			ev = &ctrl->ev;
+			break;
+		default:
+			ev = NULL;
+			break;
+		}
 	} else {
 		ev = NULL;
 	}
@@ -817,6 +837,10 @@
 			q921_establish_data_link(link);
 			link->l3_initiated = 0;
 			q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
+			if (PTP_MODE(ctrl)) {
+				ctrl->schedev = 1;
+				ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+			}
 		}
 		break;
 	case Q921_AWAITING_ESTABLISHMENT:
@@ -825,12 +849,12 @@
 			q921_send_sabme(link);
 			start_t200(link);
 		} else {
+			q921_ptp_delay_restart(link);
 			q921_discard_iqueue(link);
 			q921_mdl_error(link, 'G');
 			q921_setstate(link, Q921_TEI_ASSIGNED);
 			/* DL-RELEASE indication */
 			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
-			q921_ptp_delay_restart(ctrl);
 		}
 		break;
 	case Q921_AWAITING_RELEASE:
@@ -839,11 +863,11 @@
 			q921_send_disc(link, 1);
 			start_t200(link);
 		} else {
+			q921_ptp_delay_restart(link);
 			q921_mdl_error(link, 'H');
 			/* DL-RELEASE confirm */
 			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 			q921_setstate(link, Q921_TEI_ASSIGNED);
-			q921_ptp_delay_restart(ctrl);
 		}
 		break;
 	default:
@@ -943,7 +967,7 @@
 	switch (link->state) {
 	case Q921_TEI_ASSIGNED:
 		/* If we aren't in a state compatiable with DL-DATA requests, start getting us there here */
-		restart_timer_stop(ctrl);
+		restart_timer_stop(link);
 		q921_establish_data_link(link);
 		link->l3_initiated = 1;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
@@ -1666,7 +1690,7 @@
 		}
 		break;
 	case Q921_TEI_ASSIGNED:
-		restart_timer_stop(ctrl);
+		restart_timer_stop(link);
 		q921_send_ua(link, h->u.p_f);
 		q921_clear_exception_conditions(link);
 		link->v_s = link->v_a = link->v_r = 0;
@@ -1719,6 +1743,7 @@
 		break;
 	case Q921_MULTI_FRAME_ESTABLISHED:
 	case Q921_TIMER_RECOVERY:
+		res = q921_ptp_delay_restart(link);
 		q921_discard_iqueue(link);
 		q921_send_ua(link, h->u.p_f);
 		/* DL-RELEASE indication */
@@ -1727,7 +1752,6 @@
 		if (link->state == Q921_MULTI_FRAME_ESTABLISHED)
 			stop_t203(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
-		res = q921_ptp_delay_restart(ctrl);
 		break;
 	default:
 		pri_error(ctrl, "Don't know what to do with DISC in state %d(%s)\n",
@@ -1760,7 +1784,7 @@
 
 	switch (link->state) {
 	case Q921_TEI_ASSIGNED:
-		restart_timer_stop(ctrl);
+		restart_timer_stop(link);
 		/* XXX: deviation! Since we don't have a UI queue, we just discard our I-queue */
 		q921_discard_iqueue(link);
 		q921_setstate(link, Q921_TEI_UNASSIGNED);
@@ -1906,6 +1930,16 @@
 	ctrl = link->ctrl;
 
 	switch (error) {
+	case 'J':
+		/*
+		 * This is for the transition to Q921_AWAITING_ESTABLISHMENT.
+		 * The event is genereated here rather than where the MDL_ERROR
+		 * 'J' is posted because of the potential event conflict with
+		 * incoming I-frame information passed to Q.931.
+		 */
+		ctrl->schedev = 1;
+		ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+		break;
 	case 'A':
 	case 'B':
 	case 'C':
@@ -1915,7 +1949,6 @@
 	case 'G':
 	case 'H':
 	case 'I':
-	case 'J':
 	case 'K':
 		break;
 	default:
@@ -2122,11 +2155,11 @@
 		if (!h->u.p_f) {
 			q921_mdl_error(link, 'D');
 		} else {
+			res = q921_ptp_delay_restart(link);
 			/* DL-RELEASE confirm */
 			q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 			stop_t200(link);
 			q921_setstate(link, Q921_TEI_ASSIGNED);
-			res = q921_ptp_delay_restart(ctrl);
 		}
 		break;
 	default:
@@ -2423,6 +2456,10 @@
 		q921_establish_data_link(link);
 		link->l3_initiated = 0;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
+		if (PTP_MODE(ctrl)) {
+			ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+			res = &ctrl->ev;
+		}
 		break;
 	case Q921_TEI_ASSIGNED:
 	case Q921_AWAITING_ESTABLISHMENT:
@@ -2558,7 +2595,7 @@
 		if (h->u.p_f)
 			break;
 		/* else */
-		restart_timer_stop(ctrl);
+		restart_timer_stop(link);
 		q921_establish_data_link(link);
 		link->l3_initiated = 1;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
@@ -2567,21 +2604,21 @@
 		if (!h->u.p_f)
 			break;
 
+		res = q921_ptp_delay_restart(link);
 		q921_discard_iqueue(link);
 		/* DL-RELEASE indication */
 		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
-		res = q921_ptp_delay_restart(ctrl);
 		break;
 	case Q921_AWAITING_RELEASE:
 		if (!h->u.p_f)
 			break;
+		res = q921_ptp_delay_restart(link);
 		/* DL-RELEASE confirm */
 		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
 		stop_t200(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
-		res = q921_ptp_delay_restart(ctrl);
 		break;
 	case Q921_MULTI_FRAME_ESTABLISHED:
 		if (h->u.p_f) {
@@ -2593,6 +2630,10 @@
 		q921_establish_data_link(link);
 		link->l3_initiated = 0;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
+		if (PTP_MODE(ctrl)) {
+			ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+			res = &ctrl->ev;
+		}
 		break;
 	case Q921_TIMER_RECOVERY:
 		if (h->u.p_f) {
@@ -2603,6 +2644,10 @@
 		q921_establish_data_link(link);
 		link->l3_initiated = 0;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
+		if (PTP_MODE(ctrl)) {
+			ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
+			res = &ctrl->ev;
+		}
 		break;
 	default:
 		pri_error(ctrl, "Don't know what to do with DM frame in state %d(%s)\n",




More information about the svn-commits mailing list