aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2022-12-12 19:22:44 +0100
committerpespin <pespin@sysmocom.de>2022-12-16 11:05:46 +0000
commit345d9ad1b3895e6ca28e978c933df37a28106132 (patch)
tree69c151837ffea7b4c0a006fb5435f066bfdbeb51
parent44347efacd83049ee7cb6ba7e2fcddfe68173280 (diff)
Move first_common_ts from gprs_rlcmac_tbf to GprsMs
The field contains a common value between the 2 active TBFs of the MS, so it makes no sense to have them duplicated on each TBF. It can be sanely stored in the MS object. Change-Id: I8df01a99ccbfaf7a442ade5000ee282bd638fbba
-rw-r--r--src/gprs_ms.c16
-rw-r--r--src/gprs_ms.h5
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp6
-rw-r--r--src/pcu_vty_functions.cpp7
-rw-r--r--src/tbf.cpp18
-rw-r--r--src/tbf.h3
-rw-r--r--src/tbf_ul.cpp2
-rw-r--r--tests/alloc/AllocTest.cpp16
8 files changed, 33 insertions, 40 deletions
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 933953e4..c9eaf975 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -120,6 +120,7 @@ struct GprsMs *ms_alloc(struct gprs_rlcmac_bts *bts, uint32_t tlli)
ms->current_cs_ul = UNKNOWN;
ms->current_cs_dl = UNKNOWN;
ms->is_idle = true;
+ ms->first_common_ts = TBF_TS_UNSET;
INIT_LLIST_HEAD(&ms->list);
INIT_LLIST_HEAD(&ms->old_tbfs);
@@ -383,6 +384,7 @@ void ms_detach_tbf(struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf)
if (!ms->dl_tbf && !ms->ul_tbf) {
ms_set_reserved_slots(ms, NULL, 0, 0);
+ ms->first_common_ts = TBF_TS_UNSET;
if (ms_tlli(ms) != 0)
ms_release_timer_start(ms);
@@ -918,15 +920,15 @@ enum CodingScheme ms_current_cs_dl(const struct GprsMs *ms, enum mcs_kind req_mc
return cs;
}
-int ms_first_common_ts(const struct GprsMs *ms)
+int8_t ms_first_common_ts(const struct GprsMs *ms)
{
- if (ms->dl_tbf)
- return tbf_first_common_ts(dl_tbf_as_tbf(ms->dl_tbf));
-
- if (ms->ul_tbf)
- return tbf_first_common_ts(ul_tbf_as_tbf(ms->ul_tbf));
+ return ms->first_common_ts;
+}
- return -1;
+void ms_set_first_common_ts(struct GprsMs *ms, uint8_t first_common_ts)
+{
+ OSMO_ASSERT(first_common_ts < 8);
+ ms->first_common_ts = first_common_ts;
}
uint8_t ms_dl_slots(const struct GprsMs *ms)
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index 4ff261c3..716ad74e 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -64,6 +64,8 @@ struct GprsMs {
struct gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_dl_tbf *dl_tbf;
struct llist_head old_tbfs; /* list of gprs_rlcmac_tbf */
+ /* First common timeslot number used both in UL and DL, 0..7 or TBF_TS_UNSET (-1): */
+ int8_t first_common_ts;
uint32_t tlli;
uint32_t new_ul_tlli;
@@ -101,7 +103,8 @@ struct GprsMs {
struct GprsMs *ms_alloc(struct gprs_rlcmac_bts *bts, uint32_t tlli);
-int ms_first_common_ts(const struct GprsMs *ms);
+int8_t ms_first_common_ts(const struct GprsMs *ms);
+void ms_set_first_common_ts(struct GprsMs *ms, uint8_t first_common_ts);
void ms_set_reserved_slots(struct GprsMs *ms, struct gprs_rlcmac_trx *trx,
uint8_t ul_slots, uint8_t dl_slots);
struct GprsMs *ms_ref(struct GprsMs *ms);
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index b5757a77..026ad6ea 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -411,8 +411,9 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf,
tbf->trx = trx;
/* the only one TS is the common TS */
- tbf->first_ts = tbf->first_common_ts = ts;
+ tbf->first_ts = ts;
ms_set_reserved_slots(ms, trx, 1 << ts, 1 << ts);
+ ms_set_first_common_ts(ms, ts);
tbf->upgrade_to_multislot = false;
bts_do_rate_ctr_inc(bts, CTR_TBF_ALLOC_ALGO_A);
@@ -945,9 +946,8 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf,
/* Step 4: Update MS and TBF and really allocate the resources */
update_ms_reserved_slots(trx, ms, reserved_ul_slots, reserved_dl_slots, ul_slots, dl_slots);
-
+ ms_set_first_common_ts(ms, first_common_ts);
tbf->trx = trx;
- tbf->first_common_ts = first_common_ts;
tbf->first_ts = first_ts;
if (tbf->direction == GPRS_RLCMAC_DL_TBF)
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index 76baffe8..e35e8170 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -54,21 +54,22 @@ static void tbf_print_vty_info(struct vty *vty, struct gprs_rlcmac_tbf *tbf)
gprs_rlcmac_ul_tbf *ul_tbf = tbf_as_ul_tbf(tbf);
gprs_rlcmac_dl_tbf *dl_tbf = tbf_as_dl_tbf(tbf);
uint32_t state_flags = tbf_state_flags(tbf);
+ struct GprsMs *ms = tbf_ms(tbf);
vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) TA=%u DIR=%s IMSI=%s%s", tbf->tfi(),
tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid",
tbf->ta(),
tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
tbf->imsi(), VTY_NEWLINE);
- vty_out(vty, " created=%lu state=%s flags=%08x [CCCH:%u, PACCH:%u] 1st_TS=%d 1st_cTS=%d ctrl_TS=%d MS_CLASS=%d/%d%s",
+ vty_out(vty, " created=%lu state=%s flags=%08x [CCCH:%u, PACCH:%u] 1st_TS=%d 1st_cTS=%" PRId8 " ctrl_TS=%d MS_CLASS=%d/%d%s",
tbf->created_ts(), tbf->state_name(),
state_flags,
state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH),
state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH),
tbf->first_ts,
- tbf->first_common_ts, tbf->control_ts,
+ ms_first_common_ts(ms), tbf->control_ts,
tbf->ms_class(),
- ms_egprs_ms_class(tbf->ms()),
+ ms_egprs_ms_class(ms),
VTY_NEWLINE);
vty_out(vty, " TS_alloc=");
for (int i = 0; i < 8; i++) {
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 3d9d4537..7483d495 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -91,7 +91,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
direction(dir),
trx(NULL),
first_ts(TBF_TS_UNSET),
- first_common_ts(TBF_TS_UNSET),
control_ts(TBF_TS_UNSET),
fT(0),
num_fT_exp(0),
@@ -308,13 +307,14 @@ int gprs_rlcmac_tbf::update()
void tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf)
{
+ int8_t first_common_ts = ms_first_common_ts(tbf_ms(tbf));
if (tbf->control_ts == TBF_TS_UNSET)
LOGPTBF(tbf, LOGL_INFO, "Setting Control TS %d\n",
- tbf->first_common_ts);
- else if (tbf->control_ts != tbf->first_common_ts)
+ first_common_ts);
+ else if (tbf->control_ts != first_common_ts)
LOGPTBF(tbf, LOGL_INFO, "Changing Control TS %d -> %d\n",
- tbf->control_ts, tbf->first_common_ts);
- tbf->control_ts = tbf->first_common_ts;
+ tbf->control_ts, first_common_ts);
+ tbf->control_ts = first_common_ts;
}
void gprs_rlcmac_tbf::n_reset(enum tbf_counters n)
@@ -738,7 +738,8 @@ uint8_t gprs_rlcmac_tbf::ul_slots() const
if (direction == GPRS_RLCMAC_DL_TBF) {
if (control_ts < 8)
slots |= 1 << control_ts;
- if (first_common_ts < 8)
+ int8_t first_common_ts = ms_first_common_ts(tbf_ms(this));
+ if (first_common_ts != TBF_TS_UNSET)
slots |= 1 << first_common_ts;
return slots;
@@ -825,11 +826,6 @@ struct gprs_llc *tbf_llc(struct gprs_rlcmac_tbf *tbf)
return &tbf->m_llc;
}
-uint8_t tbf_first_common_ts(const struct gprs_rlcmac_tbf *tbf)
-{
- return tbf->first_common_ts;
-}
-
uint8_t tbf_dl_slots(const struct gprs_rlcmac_tbf *tbf)
{
return tbf->dl_slots();
diff --git a/src/tbf.h b/src/tbf.h
index 211b8a7d..d4d52f93 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -134,7 +134,6 @@ struct GprsMs *tbf_ms(const struct gprs_rlcmac_tbf *tbf);
bool tbf_timers_pending(struct gprs_rlcmac_tbf *tbf, enum tbf_timers t);
void tbf_free(struct gprs_rlcmac_tbf *tbf);
struct gprs_llc *tbf_llc(struct gprs_rlcmac_tbf *tbf);
-uint8_t tbf_first_common_ts(const struct gprs_rlcmac_tbf *tbf);
uint8_t tbf_dl_slots(const struct gprs_rlcmac_tbf *tbf);
uint8_t tbf_ul_slots(const struct gprs_rlcmac_tbf *tbf);
bool tbf_is_tfi_assigned(const struct gprs_rlcmac_tbf *tbf);
@@ -220,8 +219,6 @@ struct gprs_rlcmac_tbf {
enum gprs_rlcmac_tbf_direction direction;
struct gprs_rlcmac_trx *trx;
uint8_t first_ts; /* first TS used by TBF */
- uint8_t first_common_ts; /* first TS where the phone can send and
- receive simultaniously */
uint8_t control_ts; /* timeslot control messages and polling */
struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 43cd4f61..e4e4f793 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -167,7 +167,7 @@ struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
ul_tbf->trx = trx;
/* The only one TS is the common, control TS */
ul_tbf->first_ts = ts;
- ul_tbf->first_common_ts = ts;
+ ms_set_first_common_ts(ms, ts);
tbf_assign_control_ts(ul_tbf);
ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
ul_tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(ul_tbf,
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 379e69a9..33167024 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -176,12 +176,13 @@ static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir, bool v
{
if (!verbose)
return;
+ const struct GprsMs *ms = tbf_ms(tbf);
for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
if (tbf->pdch[i])
printf("PDCH[%zu] is used for %s\n", i, dir);
printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir);
- printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir);
+ printf("PDCH[%d] is first common for %s\n", ms_first_common_ts(ms), dir);
}
#define ENABLE_PDCH(ts_no, enable_flag, trx) \
@@ -237,8 +238,6 @@ static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bo
dump_assignment(dl_tbf, "DL", verbose);
- OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
-
check_tfi_usage(bts);
tbf_free(dl_tbf);
@@ -284,12 +283,9 @@ static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bo
dump_assignment(ul_tbf, "UL", verbose);
- OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
-
/* now update the dl_tbf */
dl_tbf->update();
dump_assignment(dl_tbf, "DL", verbose);
- OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
check_tfi_usage(bts);
@@ -334,8 +330,6 @@ static inline bool test_alloc_b_jolly(uint8_t ms_class)
dump_assignment(dl_tbf, "DL", true);
- OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
-
check_tfi_usage(bts);
tbf_free(dl_tbf);
@@ -575,13 +569,13 @@ static unsigned alloc_many_tbfs(struct gprs_rlcmac_bts *bts, unsigned min_class,
trx = ms_current_trx(ms);
OSMO_ASSERT(ul_tbf || dl_tbf);
-
+ OSMO_ASSERT(ms_first_common_ts(ms) != TBF_TS_UNSET);
if (ul_tbf) {
- ul_slots = 1 << ul_tbf->first_common_ts;
+ ul_slots = 1 << (uint8_t)ms_first_common_ts(ms);
tfi = ul_tbf->tfi();
dir = GPRS_RLCMAC_UL_TBF;
} else {
- ul_slots = 1 << dl_tbf->first_common_ts;
+ ul_slots = 1 << (uint8_t)ms_first_common_ts(ms);
tfi = dl_tbf->tfi();
dir = GPRS_RLCMAC_DL_TBF;
}