📄 sl_x100p.c
字号:
iftype:SDL_TYPE_DS0, ifrate:64000, ifgtype:SDL_GTYPE_E1, ifgrate:2048000, ifmode:SDL_MODE_PEER, ifgmode:SDL_GMODE_NONE, ifgcrc:SDL_GCRC_CRC5, ifclock:SDL_CLOCK_SLAVE, ifcoding:SDL_CODING_HDB3, ifframing:SDL_FRAMING_CCS, ifblksize:8, ifleads:0, ifbpv:0, ifalarms:0, ifrxlevel:0, iftxlevel:0, ifsync:0, ifsyncsrc:{0, 0, 0, 0}};STATIC sdl_config_t sdl_default_t1_chan = { ifname:NULL, ifflags:0, iftype:SDL_TYPE_DS0, ifrate:64000, ifgtype:SDL_GTYPE_T1, ifgrate:1544000, ifmode:SDL_MODE_PEER, ifgmode:SDL_GMODE_NONE, ifgcrc:SDL_GCRC_CRC6, ifclock:SDL_CLOCK_SLAVE, ifcoding:SDL_CODING_AMI, ifframing:SDL_FRAMING_SF, ifblksize:8, ifleads:0, ifbpv:0, ifalarms:0, ifrxlevel:0, iftxlevel:0, ifsync:0, ifsyncsrc:{0, 0, 0, 0}};/* * ------------------------------------------------------------------------ * * Timers * * ------------------------------------------------------------------------ */enum { tall, t1, t2, t3, t4, t5, t6, t7, t8, t9 };STATIC int xp_t1_timeout(struct xp *);STATIC streamscall voidxp_t1_expiry(caddr_t data){ ss7_do_timeout(data, "t1", DRV_NAME, &((struct xp *) data)->sl.timers.t1, (int (*)(struct head *)) &xp_t1_timeout, &xp_t1_expiry);}STATIC voidxp_stop_timer_t1(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t1", DRV_NAME, &xp->sl.timers.t1);}STATIC voidxp_start_timer_t1(struct xp *xp){ ss7_start_timer((struct head *) xp, "t1", DRV_NAME, &xp->sl.timers.t1, &xp_t1_expiry, xp->sl.config.t1);};STATIC int xp_t2_timeout(struct xp *);STATIC streamscall voidxp_t2_expiry(caddr_t data){ ss7_do_timeout(data, "t2", DRV_NAME, &((struct xp *) data)->sl.timers.t2, (int (*)(struct head *)) &xp_t2_timeout, &xp_t2_expiry);}STATIC voidxp_stop_timer_t2(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t2", DRV_NAME, &xp->sl.timers.t2);}STATIC voidxp_start_timer_t2(struct xp *xp){ ss7_start_timer((struct head *) xp, "t2", DRV_NAME, &xp->sl.timers.t2, &xp_t2_expiry, xp->sl.config.t2);};STATIC int xp_t3_timeout(struct xp *);STATIC streamscall voidxp_t3_expiry(caddr_t data){ ss7_do_timeout(data, "t3", DRV_NAME, &((struct xp *) data)->sl.timers.t3, (int (*)(struct head *)) &xp_t3_timeout, &xp_t3_expiry);}STATIC voidxp_stop_timer_t3(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t3", DRV_NAME, &xp->sl.timers.t3);}STATIC voidxp_start_timer_t3(struct xp *xp){ ss7_start_timer((struct head *) xp, "t3", DRV_NAME, &xp->sl.timers.t3, &xp_t3_expiry, xp->sl.config.t3);};STATIC int xp_t4_timeout(struct xp *);STATIC streamscall voidxp_t4_expiry(caddr_t data){ ss7_do_timeout(data, "t4", "xp", &((struct xp *) data)->sl.timers.t4, (int (*)(struct head *)) &xp_t4_timeout, &xp_t4_expiry);}STATIC voidxp_stop_timer_t4(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t4", "xp", &xp->sl.timers.t4);}STATIC voidxp_start_timer_t4(struct xp *xp){ ss7_start_timer((struct head *) xp, "t4", "xp", &xp->sl.timers.t4, &xp_t4_expiry, xp->sl.statem.t4v);};STATIC int xp_t5_timeout(struct xp *);STATIC streamscall voidxp_t5_expiry(caddr_t data){ ss7_do_timeout(data, "t5", DRV_NAME, &((struct xp *) data)->sl.timers.t5, (int (*)(struct head *)) &xp_t5_timeout, &xp_t5_expiry);}STATIC voidxp_stop_timer_t5(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t5", DRV_NAME, &xp->sl.timers.t5);}STATIC voidxp_start_timer_t5(struct xp *xp){ ss7_start_timer((struct head *) xp, "t5", DRV_NAME, &xp->sl.timers.t5, &xp_t5_expiry, xp->sl.config.t5);};STATIC int xp_t6_timeout(struct xp *);STATIC streamscall voidxp_t6_expiry(caddr_t data){ ss7_do_timeout(data, "t6", DRV_NAME, &((struct xp *) data)->sl.timers.t6, (int (*)(struct head *)) &xp_t6_timeout, &xp_t6_expiry);}STATIC voidxp_stop_timer_t6(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t6", DRV_NAME, &xp->sl.timers.t6);}STATIC voidxp_start_timer_t6(struct xp *xp){ ss7_start_timer((struct head *) xp, "t6", DRV_NAME, &xp->sl.timers.t6, &xp_t6_expiry, xp->sl.config.t6);};STATIC int xp_t7_timeout(struct xp *);STATIC streamscall voidxp_t7_expiry(caddr_t data){ ss7_do_timeout(data, "t7", DRV_NAME, &((struct xp *) data)->sl.timers.t7, (int (*)(struct head *)) &xp_t7_timeout, &xp_t7_expiry);}STATIC voidxp_stop_timer_t7(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t7", DRV_NAME, &xp->sl.timers.t7);}STATIC voidxp_start_timer_t7(struct xp *xp){ ss7_start_timer((struct head *) xp, "t7", DRV_NAME, &xp->sl.timers.t7, &xp_t7_expiry, xp->sl.config.t7);};STATIC int xp_t8_timeout(struct xp *);STATIC streamscall voidxp_t8_expiry(caddr_t data){ ss7_do_timeout(data, "t8", DRV_NAME, &((struct xp *) data)->sdt.timers.t8, (int (*)(struct head *)) &xp_t8_timeout, &xp_t8_expiry);}STATIC voidxp_stop_timer_t8(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t8", DRV_NAME, &xp->sdt.timers.t8);}STATIC voidxp_start_timer_t8(struct xp *xp){ ss7_start_timer((struct head *) xp, "t8", DRV_NAME, &xp->sdt.timers.t8, &xp_t8_expiry, xp->sdt.config.t8);};#if 0STATIC int xp_t9_timeout(struct xp *);STATIC streamscall voidxp_t9_expiry(caddr_t data){ ss7_do_timeout(data, "t9", "xp", &((struct xp *) data)->sdl.timers.t9, (int (*)(struct head *)) &xp_t9_timeout, &xp_t9_expiry);}STATIC voidxp_stop_timer_t9(struct xp *xp){ ss7_stop_timer((struct head *) xp, "t9", "xp", &xp->sdl.timers.t9);}STATIC voidxp_start_timer_t9(struct xp *xp){ ss7_start_timer((struct head *) xp, "t9", "xp", &xp->sdl.timers.t9, &xp_t9_expiry, xp->sdl.timestamp - jiffies);};#endifSTATIC INLINE void__xp_timer_stop(struct xp *xp, const uint t){ int single = 1; switch (t) { case tall: single = 0; /* fall through */ case t1: xp_stop_timer_t1(xp); if (single) break; /* fall through */ case t2: xp_stop_timer_t2(xp); if (single) break; /* fall through */ case t3: xp_stop_timer_t3(xp); if (single) break; /* fall through */ case t4: xp_stop_timer_t4(xp); if (single) break; /* fall through */ case t5: xp_stop_timer_t5(xp); if (single) break; /* fall through */ case t6: xp_stop_timer_t6(xp); if (single) break; /* fall through */ case t7: xp_stop_timer_t7(xp); if (single) break; /* fall through */ case t8: xp_stop_timer_t8(xp); if (single) break; /* fall through */#if 0 case t9: xp_stop_timer_t9(xp); if (single) break; /* fall through */ break;#endif default: swerr(); break; }}STATIC INLINE voidxp_timer_stop(struct xp *xp, const uint t){ psw_t flags; spin_lock_irqsave(&xp->lock, flags); { __xp_timer_stop(xp, t); } spin_unlock_irqrestore(&xp->lock, flags);}STATIC INLINE voidxp_timer_start(struct xp *xp, const uint t){ psw_t flags; spin_lock_irqsave(&xp->lock, flags); { __xp_timer_stop(xp, t); switch (t) { case t1: xp_start_timer_t1(xp); break; case t2: xp_start_timer_t2(xp); break; case t3: xp_start_timer_t3(xp); break; case t4: xp_start_timer_t4(xp); break; case t5: xp_start_timer_t5(xp); break; case t6: xp_start_timer_t6(xp); break; case t7: xp_start_timer_t7(xp); break; case t8: xp_start_timer_t8(xp); break;#if 0 case t9: xp_start_timer_t9(xp); break;#endif default: swerr(); break; } } spin_unlock_irqrestore(&xp->lock, flags);}/* * ------------------------------------------------------------------------- * * Duration Statistics * * ------------------------------------------------------------------------- */#if 0STATIC voidsl_is_stats(queue_t *q){ struct xp *xp = XP_PRIV(q); if (xp->sl.stamp.sl_dur_unavail) xp->sl.stats.sl_dur_unavail += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail, 0); if (xp->sl.stamp.sl_dur_unavail_rpo) xp->sl.stats.sl_dur_unavail_rpo += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_rpo, 0); if (xp->sl.stamp.sl_dur_unavail_failed) xp->sl.stats.sl_dur_unavail_failed += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_failed, 0); xp->sl.stamp.sl_dur_in_service = jiffies;}STATIC voidsl_oos_stats(queue_t *q){ struct xp *xp = XP_PRIV(q); if (xp->sl.stamp.sl_dur_in_service) xp->sl.stats.sl_dur_in_service += jiffies - xchg(&xp->sl.stamp.sl_dur_in_service, 0); if (xp->sl.stamp.sl_dur_unavail_rpo) xp->sl.stats.sl_dur_unavail_rpo += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_rpo, 0); if (xp->sl.stamp.sl_dur_unavail_failed) xp->sl.stats.sl_dur_unavail_failed += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_failed, 0); xp->sl.stamp.sl_dur_unavail = jiffies;}STATIC voidsl_rpo_stats(queue_t *q){ struct xp *xp = XP_PRIV(q); if (xp->sl.stamp.sl_dur_unavail_rpo) xp->sl.stats.sl_dur_unavail_rpo += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_rpo, 0);}STATIC voidsl_rpr_stats(queue_t *q){ struct xp *xp = XP_PRIV(q); if (xp->sl.stamp.sl_dur_unavail_rpo) xp->sl.stats.sl_dur_unavail_rpo += jiffies - xchg(&xp->sl.stamp.sl_dur_unavail_rpo, 0);}#endif/* * ------------------------------------------------------------------------- * * SL State Machines * * ------------------------------------------------------------------------- */#define SN_OUTSIDE(lower,middle,upper) \ ( ( (lower) <= (upper) ) \ ? ( ( (middle) < (lower) ) || ( (middle) > (upper) ) ) \ : ( ( (middle) < (lower) ) && ( (middle) > (upper) ) ) \ )/* * ----------------------------------------------------------------------- * * STATE MACHINES:- The order of the state machine primitives below may seem somewhat disorganized at first * glance; however, they have been ordered by dependency because they are all inline functions. You see, the L2 * state machine does not required multiple threading because there is never a requirement to invoke the * individual state machines concurrently. This works out good for the driver, because a primitive action * expands inline to the necessary procedure, while the source still takes the appearance of the SDL diagrams in * the SS7 specification for inspection and debugging. * * ----------------------------------------------------------------------- */#define sl_cc_stop sl_cc_normalSTATIC INLINE voidsl_cc_normal(queue_t *q, struct xp *xp){ xp_timer_stop(xp, t5); xp->sl.statem.cc_state = SL_STATE_IDLE;}STATIC INLINE voidsl_rc_stop(queue_t *q, struct xp *xp){ sl_cc_normal(q, xp); xp->sl.statem.rc_state = SL_STATE_IDLE;}STATIC INLINE voidsl_aerm_stop(queue_t *q, struct xp *xp){ xp->sdt.statem.aerm_state = SDT_STATE_IDLE; xp->sdt.statem.Ti = xp->sdt.config.Tin;}STATIC INLINE voidsl_iac_stop(queue_t *q, struct xp *xp){ if (xp->sl.statem.iac_state != SL_STATE_IDLE) { xp_timer_stop(xp, t3); xp_timer_stop(xp, t2); ctrace(xp_timer_stop(xp, t4)); sl_aerm_stop(q, xp); xp->sl.statem.emergency = 0; xp->sl.statem.iac_state = SL_STATE_IDLE; }}STATIC INLINE voidsl_txc_send_sios(queue_t *q, struct xp *xp){ xp_timer_stop(xp, t7); if (xp->option.pvar == SS7_PVAR_ANSI_92) xp_timer_stop(xp, t6); xp->sl.statem.lssu_available = 1; xp->sl.statem.tx.sio = LSSU_SIOS;}STATIC INLINE voidsl_poc_stop(queue_t *q, struct xp *xp){ xp->sl.statem.poc_state = SL_STATE_IDLE;}STATIC INLINE voidsl_eim_stop(queue_t *q, struct xp *xp){ xp->sdt.statem.eim_state = SDT_STATE_IDLE; xp_timer_stop(xp, t8);}STATIC INLINE voidsl_suerm_stop(queue_t *q, struct xp *xp){ sl_eim_stop(q, xp); xp->sdt.statem.suerm_state = SDT_STATE_IDLE;}STATIC INLINE intsl_lsc_link_failure(queue_t *q, struct xp *xp, ulong reason){ int err; if (xp->sl.statem.lsc_state != SL_STATE_OUT_OF_SERVICE) { if ((err = sl_out_of_service_ind(q, xp, reason))) return (err); xp->sl.statem.failure_reason = reason; sl_iac_stop(q, xp); /* ok if not aligning */ xp_timer_stop(xp, t1); /* ok if not running */ sl_suerm_stop(q, xp); /* ok if not running */ sl_rc_stop(q, xp); ctrace(sl_txc_send_sios(q, xp)); sl_poc_stop(q, xp); /* ok if not ITUT */ xp->sl.statem.emergency = 0; xp->sl.statem.local_processor_outage = 0; xp->sl.statem.remote_processor_outage = 0; /* ok if not ANSI */ xp->sl.statem.lsc_state = SL_STATE_OUT_OF_SERVICE; } return (QR_DONE);}STATIC INLINE voidsl_txc_send_sib(queue_t *q, struct xp *xp)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -