From 596c402835bab2a01fba7d7233512009eb4142f5 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sat, 16 Jun 2018 19:29:50 +0200 Subject: add gsm_timers, for Tnnn definitions usable by FSMs Change-Id: If212fcd042051b6fa53484254223614c5b93a9c6 --- include/osmocom/bsc/Makefile.am | 1 + include/osmocom/bsc/gsm_data.h | 41 +++--------------------------- include/osmocom/bsc/gsm_timers.h | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 include/osmocom/bsc/gsm_timers.h (limited to 'include/osmocom/bsc') diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am index 1e26c3403..0f134c850 100644 --- a/include/osmocom/bsc/Makefile.am +++ b/include/osmocom/bsc/Makefile.am @@ -19,6 +19,7 @@ noinst_HEADERS = \ gsm_04_08_rr.h \ gsm_04_80.h \ gsm_data.h \ + gsm_timers.h \ handover.h \ handover_cfg.h \ handover_decision.h \ diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 287249382..272b192ce 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -32,6 +32,8 @@ #include #include +#define GSM_T3122_DEFAULT 10 + struct mgcp_client_conf; struct mgcp_client; struct mgcp_ctx; @@ -1192,23 +1194,6 @@ static const struct rate_ctr_group_desc bsc_ctrg_desc = { bsc_ctr_description, }; -#define GSM_T3101_DEFAULT 3 /* s */ -#define GSM_T3103_DEFAULT 5 /* s */ -#define GSM_T3105_DEFAULT 100 /* ms */ -#define GSM_T3107_DEFAULT 5 /* s */ -#define GSM_T3109_DEFAULT 5 /* s, must be 2s + radio_link_timeout*0.48 */ -#define GSM_T3111_DEFAULT 2 /* s */ -#define GSM_T3113_DEFAULT 10 /* s */ -#define GSM_T3115_DEFAULT 10 -#define GSM_T3117_DEFAULT 10 -#define GSM_T3119_DEFAULT 10 -#define GSM_T3122_DEFAULT 10 -#define GSM_T3141_DEFAULT 10 -#define GSM_T10_DEFAULT 6 /* RR Assignment timeout, in seconds */ -#define GSM_T7_DEFAULT 10 /* inter-BSC MO Handover first timeout, in seconds */ -#define GSM_T8_DEFAULT 10 /* inter-BSC MO Handover second timeout, in seconds */ -#define GSM_T101_DEFAULT 10 /* inter-BSC MT Handover timeout, in seconds */ - struct gsm_tz { int override; /* if 0, use system's time zone instead. */ int hr; /* hour */ @@ -1240,23 +1225,8 @@ struct gsm_network { unsigned int num_bts; struct llist_head bts_list; - /* timer values */ - int T3101; - int T3103; /*< Handover timeout */ - int T3105; - int T3107; - int T3109; - int T3111; - int T3113; - int T3115; - int T3117; - int T3119; - int T3122; - int T3141; - int T10; /*< RR Assignment timeout, in seconds */ - int T7; /*< inter-BSC handover MO timeout from Handover Required to Handover Command */ - int T8; /*< inter-BSC handover MO timeout from Handover Command to final Clear*/ - int T101; /*< inter-BSC handover MT timeout from Handover Request to Handover Accept */ + /* shall reference gsm_network_T[] */ + struct T_def *T_defs; enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T]; @@ -1290,9 +1260,6 @@ struct gsm_network { * pointer is NULL to indicate absence of a bsc_subscribers list. */ struct llist_head *bsc_subscribers; - /* Periodic location update default value */ - uint8_t t3212; - /* Timer for periodic channel load measurements to maintain each BTS's T3122. */ struct osmo_timer_list t3122_chan_load_timer; diff --git a/include/osmocom/bsc/gsm_timers.h b/include/osmocom/bsc/gsm_timers.h new file mode 100644 index 000000000..fde8c93c0 --- /dev/null +++ b/include/osmocom/bsc/gsm_timers.h @@ -0,0 +1,55 @@ +/* API to define Tnnn timers globally, configure in VTY and use for FSM state changes. */ +#pragma once + +#include +#include + +struct osmo_fsm_inst; +struct vty; + +enum T_unit { + T_S = 0, /*< most T are in seconds, keep 0 as default. */ + T_MS, /*< milliseconds */ + T_M, /*< minutes */ + T_CUSTOM, +}; + +extern const struct value_string T_unit_names[]; +static inline const char *T_unit_name(enum T_unit val) +{ return get_value_string(T_unit_names, val); } + +/* Define a GSM timer of the form Tnnn, with unit, default value and doc string. */ +struct T_def { + const int T; /*< T1234 number */ + const int default_val; /*< timeout duration (according to unit), default value. */ + const enum T_unit unit; + const char *desc; + int val; /*< currently active value, e.g. set by user config. */ +}; + +/* Iterate an array of struct T_def, the last item should be fully zero, i.e. "{}" */ +#define for_each_T_def(d, T_defs) \ + for (d = T_defs; d && (d->T || d->default_val || d->desc); d++) + +int T_def_get(struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present); +void T_defs_reset(struct T_def *T_defs); +struct T_def *T_def_get_entry(struct T_def *T_defs, int T); + +void T_defs_vty_init(struct T_def *T_defs, int cfg_parent_node); +void T_defs_vty_write(struct vty *vty, const char *indent); + + +struct state_timeout { + int T; + bool keep_timer; +}; + +struct state_timeout *get_state_timeout(uint32_t state, struct state_timeout *timeouts_array); + +#define fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout) \ + _fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout, \ + __FILE__, __LINE__) +int _fsm_inst_state_chg_T(struct osmo_fsm_inst *fi, uint32_t state, + struct state_timeout *timeouts_array, + struct T_def *T_defs, int default_timeout, + const char *file, int line); -- cgit v1.2.3