aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-09-05 14:48:35 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-09-12 14:17:07 +0200
commit28f160e76c3c53029bc6e8de101b2d7ee26eea16 (patch)
tree53ba9a527bda9de647d77c70803d092db0613aec /src
parent45fdc44d683365b806b90e694cb7b960dc967b31 (diff)
Introduce osmo_tdef infra and timer VTY commands
This will allow for configuration of some of the timers by the user, and allow him to inspect current values being used. It will be also useful for TTCN3 tests which may want to test some of the timers without having to wait for lots of time. Timers are splitted into 2 groups: BTS controlled ones and PCU controlled ones. The BTS controlled ones are read-only by the user (hence no "timer" VTY command is provided to change them). TbfTest.err output changes due to timers being set up correctly as a consequence of changes. Other application such as pcu_emu.cpp and pcu_main.cpp had to previosuly set the initial values by hand (and did so), but apparently TbfTest.c was missing that part, which is now fixed for free. Depends: libosmocore.git Id56a1226d724a374f04231df85fe5b49ffd2c43c Change-Id: I5cfb9ef01706124be262d4536617b9edb4601dd5
Diffstat (limited to 'src')
-rw-r--r--src/bts.cpp23
-rw-r--r--src/bts.h9
-rw-r--r--src/pcu_l1_if.cpp10
-rw-r--r--src/pcu_main.cpp5
-rw-r--r--src/pcu_vty.c37
-rw-r--r--src/tbf.cpp38
-rw-r--r--src/tbf.h8
-rw-r--r--src/tbf_dl.cpp7
-rw-r--r--src/tbf_ul.cpp2
9 files changed, 102 insertions, 37 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 60f74dd6..a913ca0a 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -68,6 +68,21 @@ extern "C" {
static BTS s_bts;
+static struct osmo_tdef T_defs_bts[] = {
+ { .T=3142, .default_val=20, .unit=OSMO_TDEF_S, .desc="timer (s)", .val=0 },
+ { .T=3169, .default_val=5, .unit=OSMO_TDEF_S, .desc="Reuse of USF and TFI(s) after the MS uplink TBF assignment is invalid (s)", .val=0 },
+ { .T=3191, .default_val=5, .unit=OSMO_TDEF_S, .desc="Reuse of TFI(s) after sending (1) last RLC Data Block on TBF(s), or (2) PACKET TBF RELEASE for an MBMS radio bearer (s)", .val=0 },
+ { .T=3193, .default_val=100, .unit=OSMO_TDEF_MS, .desc="Reuse of TFI(s) after reception of final PACKET DOWNLINK ACK/NACK from MS for TBF (ms)", .val=0 },
+ { .T=3195, .default_val=5, .unit=OSMO_TDEF_S, .desc="Reuse of TFI(s) upon no response from the MS (radio failure or cell change) for TBF/MBMS radio bearer (s)", .val=0 },
+ {}
+};
+static struct osmo_tdef T_defs_pcu[] = {
+ { .T=-2000, .default_val=2, .unit=OSMO_TDEF_MS, .desc="Tbf reject for PRR timer (ms)", .val=0 },
+ { .T=-2001, .default_val=2, .unit=OSMO_TDEF_S, .desc="PACCH assignment timer (s)", .val=0 },
+ { .T=-2002, .default_val=200, .unit=OSMO_TDEF_MS, .desc="Waiting after IMM.ASS confirm timer (ms)", .val=0 },
+ {}
+};
+
/**
* For gcc-4.4 compat do not use extended initializer list but keep the
* order from the enum here. Once we support GCC4.7 and up we can change
@@ -217,6 +232,10 @@ BTS::BTS()
memset(&m_bts, 0, sizeof(m_bts));
m_bts.bts = this;
m_bts.dl_tbf_preemptive_retransmission = true;
+ m_bts.T_defs_bts = T_defs_bts;
+ m_bts.T_defs_pcu = T_defs_pcu;
+ osmo_tdefs_reset(m_bts.T_defs_bts);
+ osmo_tdefs_reset(m_bts.T_defs_pcu);
/* initialize back pointers */
for (size_t trx_no = 0; trx_no < ARRAY_SIZE(m_bts.trx); ++trx_no) {
@@ -570,7 +589,7 @@ int BTS::rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn)
LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli);
if (dl_tbf->m_wait_confirm)
- T_START(dl_tbf, T0, 0, T_ASS_AGCH_USEC, "assignment (AGCH)", true);
+ T_START(dl_tbf, T0, -2002, "assignment (AGCH)", true);
return 0;
}
@@ -761,7 +780,7 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, bool is_11bit,
tbf->set_ta(ta);
TBF_SET_STATE(tbf, GPRS_RLCMAC_FLOW);
TBF_ASS_TYPE_SET(tbf, GPRS_RLCMAC_FLAG_CCCH);
- T_START(tbf, T3169, m_bts.t3169, 0, "RACH (new UL-TBF)", true);
+ T_START(tbf, T3169, 3169, "RACH (new UL-TBF)", true);
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] START\n");
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] RACH "
"qbit-ta=%d ra=0x%02x, Fn=%d "
diff --git a/src/bts.h b/src/bts.h
index 45d52a97..6d92ae15 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -26,6 +26,7 @@ extern "C" {
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/stat_item.h>
+#include <osmocom/core/tdef.h>
#include <osmocom/gsm/l1sap.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <mslot_class.h>
@@ -117,11 +118,9 @@ struct gprs_rlcmac_bts {
uint32_t llc_discard_csec;
uint32_t llc_idle_ack_csec;
uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */
- uint8_t t3142;
- uint8_t t3169;
- uint8_t t3191;
- uint16_t t3193_msec;
- uint8_t t3195;
+ /* Timer defintions */
+ struct osmo_tdef *T_defs_bts; /* timers controlled by BTS, received through PCUIF */
+ struct osmo_tdef *T_defs_pcu; /* timers controlled by PCU */
uint8_t n3101;
uint8_t n3103;
uint8_t n3105;
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index da85df4e..6ffebcf6 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -508,11 +508,11 @@ bssgp_failed:
if (!bts->cs1 && !bts->cs2 && !bts->cs3 && !bts->cs4)
bts->cs1 = 1;
if (info_ind->t3142) { /* if timer values are set */
- bts->t3142 = info_ind->t3142;
- bts->t3169 = info_ind->t3169;
- bts->t3191 = info_ind->t3191;
- bts->t3193_msec = info_ind->t3193_10ms * 10;
- bts->t3195 = info_ind->t3195;
+ osmo_tdef_set(bts->T_defs_bts, 3142, info_ind->t3142, OSMO_TDEF_S);
+ osmo_tdef_set(bts->T_defs_bts, 3169, info_ind->t3169, OSMO_TDEF_S);
+ osmo_tdef_set(bts->T_defs_bts, 3191, info_ind->t3191, OSMO_TDEF_S);
+ osmo_tdef_set(bts->T_defs_bts, 3193, info_ind->t3193_10ms * 10, OSMO_TDEF_MS);
+ osmo_tdef_set(bts->T_defs_bts, 3195, info_ind->t3195, OSMO_TDEF_S);
bts->n3101 = info_ind->n3101;
bts->n3103 = info_ind->n3103;
bts->n3105 = info_ind->n3105;
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 21cb2441..6f71ca5f 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -202,11 +202,6 @@ int main(int argc, char *argv[])
bts->initial_cs_dl = bts->initial_cs_ul = 1;
bts->initial_mcs_dl = bts->initial_mcs_ul = 1;
bts->cs1 = 1;
- bts->t3142 = 20;
- bts->t3169 = 5;
- bts->t3191 = 5;
- bts->t3193_msec = 100;
- bts->t3195 = 5;
bts->n3101 = 10;
bts->n3103 = 4;
bts->n3105 = 8;
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index a566e735..380b173a 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -4,6 +4,8 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <osmocom/core/tdef.h>
+#include <osmocom/vty/tdef_vty.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/stats.h>
#include <osmocom/vty/misc.h>
@@ -1109,6 +1111,38 @@ DEFUN(cfg_pcu_gb_dialect,
return CMD_SUCCESS;
}
+DEFUN(show_bts_timer, show_bts_timer_cmd,
+ "show bts-timer " OSMO_TDEF_VTY_ARG_T_OPTIONAL,
+ SHOW_STR "Show BTS controlled timers\n"
+ OSMO_TDEF_VTY_DOC_T)
+{
+ struct gprs_rlcmac_bts *bts = bts_main_data();
+ const char *T_arg = argc > 0 ? argv[0] : NULL;
+ return osmo_tdef_vty_show_cmd(vty, bts->T_defs_bts, T_arg, NULL);
+}
+
+DEFUN(show_timer, show_timer_cmd,
+ "show timer " OSMO_TDEF_VTY_ARG_T_OPTIONAL,
+ SHOW_STR "Show PCU timers\n"
+ OSMO_TDEF_VTY_DOC_T)
+{
+ struct gprs_rlcmac_bts *bts = bts_main_data();
+ const char *T_arg = argc > 0 ? argv[0] : NULL;
+ return osmo_tdef_vty_show_cmd(vty, bts->T_defs_pcu, T_arg, NULL);
+}
+
+DEFUN(cfg_pcu_timer, cfg_pcu_timer_cmd,
+ "timer " OSMO_TDEF_VTY_ARG_SET_OPTIONAL,
+ "Configure or show PCU timers\n"
+ OSMO_TDEF_VTY_DOC_SET)
+{
+ struct gprs_rlcmac_bts *bts = bts_main_data();
+ /* If any arguments are missing, redirect to 'show' */
+ if (argc < 2)
+ return show_timer(self, vty, argc, argv);
+ return osmo_tdef_vty_set_cmd(vty, bts->T_defs_pcu, argv);
+}
+
DEFUN(show_tbf,
show_tbf_cmd,
"show tbf (all|ccch|pacch)",
@@ -1251,12 +1285,15 @@ int pcu_vty_init(void)
install_element(PCU_NODE, &cfg_pcu_no_gsmtap_categ_cmd);
install_element(PCU_NODE, &cfg_pcu_sock_cmd);
install_element(PCU_NODE, &cfg_pcu_gb_dialect_cmd);
+ install_element(PCU_NODE, &cfg_pcu_timer_cmd);
install_element_ve(&show_bts_stats_cmd);
install_element_ve(&show_tbf_cmd);
install_element_ve(&show_ms_all_cmd);
install_element_ve(&show_ms_tlli_cmd);
install_element_ve(&show_ms_imsi_cmd);
+ install_element_ve(&show_bts_timer_cmd);
+ install_element_ve(&show_timer_cmd);
return 0;
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index d3021e4f..37435f5d 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -428,7 +428,7 @@ gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
}
tbf->m_contention_resolution_done = 1;
TBF_SET_ASS_ON(tbf, GPRS_RLCMAC_FLAG_PACCH, false);
- T_START(tbf, T3169, bts->t3169, 0, "allocation (UL-TBF)", true);
+ T_START(tbf, T3169, 3169, "allocation (UL-TBF)", true);
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
OSMO_ASSERT(tbf->ms());
@@ -661,12 +661,18 @@ T_CBACK(T3191, true)
T_CBACK(T3193, false)
T_CBACK(T3195, true)
-void gprs_rlcmac_tbf::t_start(enum tbf_timers t, uint32_t sec, uint32_t microsec, const char *reason, bool force,
+void gprs_rlcmac_tbf::t_start(enum tbf_timers t, int T, const char *reason, bool force,
const char *file, unsigned line)
{
int current_fn = get_current_fn();
+ int sec;
+ int microsec;
+ struct osmo_tdef *tdef;
- if (t >= T_MAX) {
+ if (!(tdef = osmo_tdef_get_entry(bts->bts_data()->T_defs_bts, T)))
+ tdef = osmo_tdef_get_entry(bts->bts_data()->T_defs_pcu, T);
+
+ if (t >= T_MAX || !tdef) {
LOGPSRC(DTBF, LOGL_ERROR, file, line, "%s attempting to start unknown timer %s [%s], cur_fn=%d\n",
tbf_name(this), get_value_string(tbf_timers_names, t), reason, current_fn);
return;
@@ -675,6 +681,20 @@ void gprs_rlcmac_tbf::t_start(enum tbf_timers t, uint32_t sec, uint32_t microsec
if (!force && osmo_timer_pending(&Tarr[t]))
return;
+ switch (tdef->unit) {
+ case OSMO_TDEF_MS:
+ sec = 0;
+ microsec = tdef->val * 1000;
+ break;
+ case OSMO_TDEF_S:
+ sec = tdef->val;
+ microsec = 0;
+ break;
+ default:
+ /* so far only timers using MS and S */
+ OSMO_ASSERT(false);
+ }
+
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s %sstarting timer %s [%s] with %u sec. %u microsec, cur_fn=%d\n",
tbf_name(this), osmo_timer_pending(&Tarr[t]) ? "re" : "",
get_value_string(tbf_timers_names, t), reason, sec, microsec, current_fn);
@@ -790,7 +810,7 @@ void gprs_rlcmac_tbf::poll_timeout()
if (n_inc(N3101)) {
TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
- T_START(this, T3169, bts->bts_data()->t3169, 0, "MAX N3101 reached", false);
+ T_START(this, T3169, 3169, "MAX N3101 reached", false);
return;
}
@@ -805,7 +825,7 @@ void gprs_rlcmac_tbf::poll_timeout()
if (ul_tbf->n_inc(N3103)) {
bts->pkt_ul_ack_nack_poll_failed();
TBF_SET_STATE(ul_tbf, GPRS_RLCMAC_RELEASING);
- T_START(ul_tbf, T3169, ul_tbf->bts->bts_data()->t3169, 0, "MAX N3103 reached", false);
+ T_START(ul_tbf, T3169, 3169, "MAX N3103 reached", false);
return;
}
/* reschedule UL ack */
@@ -824,7 +844,7 @@ void gprs_rlcmac_tbf::poll_timeout()
bts->pua_poll_timedout();
if (n_inc(N3105)) {
TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
- T_START(this, T3195, bts_data()->t3195, 0, "MAX N3105 reached", true);
+ T_START(this, T3195, 3195, "MAX N3105 reached", true);
bts->rlc_ass_failed();
bts->pua_poll_failed();
return;
@@ -843,7 +863,7 @@ void gprs_rlcmac_tbf::poll_timeout()
bts->pda_poll_timedout();
if (n_inc(N3105)) {
TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
- T_START(this, T3195, bts_data()->t3195, 0, "MAX N3105 reached", true);
+ T_START(this, T3195, 3195, "MAX N3105 reached", true);
bts->rlc_ass_failed();
bts->pda_poll_failed();
return;
@@ -869,7 +889,7 @@ void gprs_rlcmac_tbf::poll_timeout()
if (dl_tbf->n_inc(N3105)) {
TBF_SET_STATE(dl_tbf, GPRS_RLCMAC_RELEASING);
- T_START(dl_tbf, T3195, dl_tbf->bts_data()->t3195, 0, "MAX N3105 reached", true);
+ T_START(dl_tbf, T3195, 3195, "MAX N3105 reached", true);
bts->pkt_dl_ack_nack_poll_failed();
bts->rlc_ack_failed();
return;
@@ -1321,7 +1341,7 @@ struct msgb *gprs_rlcmac_tbf::create_packet_access_reject()
/* Start Tmr only if it is UL TBF */
if (direction == GPRS_RLCMAC_UL_TBF)
- T_START(this, T0, 0, T_REJ_PACCH_USEC, "reject (PACCH)", true);
+ T_START(this, T0, -2000, "reject (PACCH)", true);
return msg;
diff --git a/src/tbf.h b/src/tbf.h
index 16ccf43e..6eab9d0d 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -42,10 +42,6 @@ struct gprs_rlcmac_bts;
* TBF instance
*/
-#define T_ASS_AGCH_USEC 200000 /* waiting after IMM.ASS confirm */
-#define T_ASS_PACCH_SEC 2 /* timeout for pacch assignment */
-#define T_REJ_PACCH_USEC 2000 /* timeout for tbf reject for PRR*/
-
enum gprs_rlcmac_tbf_state {
GPRS_RLCMAC_NULL = 0, /* new created TBF */
GPRS_RLCMAC_ASSIGN, /* wait for downlink assignment */
@@ -193,7 +189,7 @@ enum tbf_counters { /* TBF counters from 3GPP TS 44.060 ยง13.4 */
#define GPRS_RLCMAC_FLAG_TO_DL_ASS 7
#define GPRS_RLCMAC_FLAG_TO_MASK 0xf0 /* timeout bits */
-#define T_START(tbf, t, sec, usec, r, f) tbf->t_start(t, sec, usec, r, f, __FILE__, __LINE__)
+#define T_START(tbf, t, T, r, f) tbf->t_start(t, T, r, f, __FILE__, __LINE__)
#define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } while(0)
#define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0)
@@ -250,7 +246,7 @@ struct gprs_rlcmac_tbf {
void stop_timers(const char *reason);
bool timers_pending(enum tbf_timers t);
void t_stop(enum tbf_timers t, const char *reason);
- void t_start(enum tbf_timers t, uint32_t sec, uint32_t microsec, const char *reason, bool force,
+ void t_start(enum tbf_timers t, int T, const char *reason, bool force,
const char *file, unsigned line);
int establish_dl_tbf_on_pacch();
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 510a65c5..a7671c96 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -499,7 +499,7 @@ void gprs_rlcmac_dl_tbf::trigger_ass(struct gprs_rlcmac_tbf *old_tbf)
TBF_SET_ASS_ON(this, GPRS_RLCMAC_FLAG_PACCH, true);
/* start timer */
- T_START(this, T0, T_ASS_PACCH_SEC, 0, "assignment (PACCH)", true);
+ T_START(this, T0, -2001, "assignment (PACCH)", true);
} else {
LOGPTBFDL(this, LOGL_DEBUG, "Send dowlink assignment on PCH, no TBF exist (IMSI=%s)\n",
imsi());
@@ -843,7 +843,7 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
m_tx_counter = 0;
/* start timer whenever we send the final block */
if (is_final)
- T_START(this, T3191, bts_data()->t3191, 0, "final block (DL-TBF)", true);
+ T_START(this, T3191, 3191, "final block (DL-TBF)", true);
state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK); /* clear poll timeout flag */
@@ -1104,8 +1104,7 @@ int gprs_rlcmac_dl_tbf::release()
TBF_SET_STATE(this, GPRS_RLCMAC_WAIT_RELEASE);
/* start T3193 */
- T_START(this, T3193, bts_data()->t3193_msec / 1000, (bts_data()->t3193_msec % 1000) * 1000,
- "release (DL-TBF)", true);
+ T_START(this, T3193, 3193, "release (DL-TBF)", true);
/* reset rlc states */
m_tx_counter = 0;
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 55c83e7a..e4f00831 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -197,7 +197,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged(
unsigned int block_idx;
/* restart T3169 */
- T_START(this, T3169, bts_data()->t3169, 0, "acked (data)", true);
+ T_START(this, T3169, 3169, "acked (data)", true);
/* Increment RX-counter */
this->m_rx_counter++;