aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-05-13 18:39:36 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-05-19 12:50:25 +0200
commit1a1557a60a1f3f86017e298f95a452d8c7811a0e (patch)
tree1a483be092e4e9ea3207d773416624d6df1b3cac
parentf62b0ec37dede666f96c17302a106483525441a0 (diff)
Move TBF list from BTS to the TRX structure
The TBFs are managed per TRX. Move the global list from BTS to TRX. Related: OS#1541 Change-Id: Id3c59c11d57d765fe68aaebaac94290c0d84feb2
-rw-r--r--src/bts.cpp6
-rw-r--r--src/bts.h10
-rw-r--r--src/gprs_rlcmac_sched.cpp13
-rw-r--r--src/pcu_vty_functions.cpp26
-rw-r--r--src/tbf.cpp16
-rw-r--r--src/tbf.h4
-rw-r--r--src/tbf_dl.cpp2
-rw-r--r--src/tbf_ul.cpp4
-rw-r--r--tests/alloc/AllocTest.cpp4
-rw-r--r--tests/ulc/PdchUlcTest.cpp2
10 files changed, 47 insertions, 40 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 94cdcb33..dc550ef1 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -263,9 +263,6 @@ struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr)
bts->T_defs_bts = T_defs_bts;
osmo_tdefs_reset(bts->T_defs_bts);
- INIT_LLIST_HEAD(&bts->ul_tbfs);
- INIT_LLIST_HEAD(&bts->dl_tbfs);
-
/* initialize back pointers */
for (size_t trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no)
bts_trx_init(&bts->trx[trx_no], bts, trx_no);
@@ -1185,6 +1182,9 @@ void bts_trx_init(struct gprs_rlcmac_trx *trx, struct gprs_rlcmac_bts *bts, uint
trx->trx_no = trx_no;
trx->bts = bts;
+ INIT_LLIST_HEAD(&trx->ul_tbfs);
+ INIT_LLIST_HEAD(&trx->dl_tbfs);
+
for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ts_no++)
pdch_init(&trx->pdch[ts_no], trx, ts_no);
}
diff --git a/src/bts.h b/src/bts.h
index 11b5113b..52c89b9c 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -59,6 +59,11 @@ struct gprs_rlcmac_trx {
struct gprs_rlcmac_bts *bts;
uint8_t trx_no;
+ /* list of uplink TBFs */
+ struct llist_head ul_tbfs; /* list of gprs_rlcmac_tbf */
+ /* list of downlink TBFs */
+ struct llist_head dl_tbfs; /* list of gprs_rlcmac_tbf */
+
};
@@ -254,11 +259,6 @@ struct gprs_rlcmac_bts {
struct osmo_stat_item_group *statg;
struct GprsMsStorage *ms_store;
-
- /* list of uplink TBFs */
- struct llist_head ul_tbfs; /* list of gprs_rlcmac_tbf */
- /* list of downlink TBFs */
- struct llist_head dl_tbfs; /* list of gprs_rlcmac_tbf */
};
#ifdef __cplusplus
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 0068eae5..cd326538 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -41,19 +41,18 @@ struct tbf_sched_candidates {
struct gprs_rlcmac_ul_tbf *ul_ack;
};
-static void get_ctrl_msg_tbf_candidates(const struct gprs_rlcmac_bts *bts,
- const struct gprs_rlcmac_pdch *pdch,
+static void get_ctrl_msg_tbf_candidates(const struct gprs_rlcmac_pdch *pdch,
struct tbf_sched_candidates *tbf_cand)
{
struct gprs_rlcmac_ul_tbf *ul_tbf;
struct gprs_rlcmac_dl_tbf *dl_tbf;
struct llist_item *pos;
- llist_for_each_entry(pos, &bts->ul_tbfs, list) {
+ llist_for_each_entry(pos, &pdch->trx->ul_tbfs, list) {
ul_tbf = as_ul_tbf((struct gprs_rlcmac_tbf *)pos->entry);
OSMO_ASSERT(ul_tbf);
/* this trx, this ts */
- if (ul_tbf->trx->trx_no != pdch->trx->trx_no || !ul_tbf->is_control_ts(pdch->ts_no))
+ if (!ul_tbf->is_control_ts(pdch->ts_no))
continue;
if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
tbf_cand->ul_ack = ul_tbf;
@@ -68,11 +67,11 @@ static void get_ctrl_msg_tbf_candidates(const struct gprs_rlcmac_bts *bts,
/* FIXME: Is this supposed to be fair? The last TBF for each wins? Maybe use llist_add_tail and skip once we have all
states? */
}
- llist_for_each_entry(pos, &bts->dl_tbfs, list) {
+ llist_for_each_entry(pos, &pdch->trx->dl_tbfs, list) {
dl_tbf = as_dl_tbf((struct gprs_rlcmac_tbf *)pos->entry);
OSMO_ASSERT(dl_tbf);
/* this trx, this ts */
- if (dl_tbf->trx->trx_no != pdch->trx->trx_no || !dl_tbf->is_control_ts(pdch->ts_no))
+ if (!dl_tbf->is_control_ts(pdch->ts_no))
continue;
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
tbf_cand->dl_ass = dl_tbf;
@@ -481,7 +480,7 @@ int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
if (usf_tbf && req_mcs_kind == EGPRS && ms_mode(usf_tbf->ms()) != EGPRS)
req_mcs_kind = EGPRS_GMSK;
- get_ctrl_msg_tbf_candidates(bts, pdch, &tbf_cand);
+ get_ctrl_msg_tbf_candidates(pdch, &tbf_cand);
/* Prio 1: select control message */
if ((msg = sched_select_ctrl_msg(pdch, fn, block_nr, &tbf_cand))) {
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index c2250d9e..0b83a68f 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -44,7 +44,7 @@ extern "C" {
#include "coding_scheme.h"
}
-static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
+static void tbf_print_vty_info(struct vty *vty, struct gprs_rlcmac_tbf *tbf)
{
gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf);
gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf);
@@ -104,20 +104,28 @@ static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts, uint32_t flags)
{
struct llist_item *iter;
+ const struct gprs_rlcmac_trx *trx;
struct gprs_rlcmac_tbf *tbf;
+ size_t trx_no;
vty_out(vty, "UL TBFs%s", VTY_NEWLINE);
- llist_for_each_entry(iter, &bts->ul_tbfs, list) {
- tbf = (struct gprs_rlcmac_tbf *)iter->entry;
- if (tbf->state_flags & flags)
- tbf_print_vty_info(vty, tbf);
+ for (trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); trx_no++) {
+ trx = &bts->trx[trx_no];
+ llist_for_each_entry(iter, &trx->ul_tbfs, list) {
+ tbf = (struct gprs_rlcmac_tbf *)iter->entry;
+ if (tbf->state_flags & flags)
+ tbf_print_vty_info(vty, tbf);
+ }
}
vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE);
- llist_for_each_entry(iter, &bts->dl_tbfs, list) {
- tbf = (struct gprs_rlcmac_tbf *)iter->entry;
- if (tbf->state_flags & flags)
- tbf_print_vty_info(vty, tbf);
+ for (trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); trx_no++) {
+ trx = &bts->trx[trx_no];
+ llist_for_each_entry(iter, &trx->dl_tbfs, list) {
+ tbf = (struct gprs_rlcmac_tbf *)iter->entry;
+ if (tbf->state_flags & flags)
+ tbf_print_vty_info(vty, tbf);
+ }
}
return CMD_SUCCESS;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index adfda959..afbb0b13 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -150,8 +150,8 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
memset(&m_ms_list, 0, sizeof(m_ms_list));
m_ms_list.entry = this;
- memset(&m_bts_list, 0, sizeof(m_bts_list));
- m_bts_list.entry = this;
+ memset(&m_trx_list, 0, sizeof(m_trx_list));
+ m_trx_list.entry = this;
m_rlc.init();
m_llc.init();
@@ -293,7 +293,7 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf)
tbf->stop_timers("freeing TBF");
/* TODO: Could/Should generate bssgp_tx_llc_discarded */
tbf_unlink_pdch(tbf);
- llist_del(tbf_bts_list(tbf));
+ llist_del(tbf_trx_list(tbf));
if (tbf->ms())
tbf->set_ms(NULL);
@@ -1092,11 +1092,11 @@ const char *gprs_rlcmac_tbf::name() const
void gprs_rlcmac_tbf::rotate_in_list()
{
- llist_del(tbf_bts_list((struct gprs_rlcmac_tbf *)this));
+ llist_del(tbf_trx_list((struct gprs_rlcmac_tbf *)this));
if (direction == GPRS_RLCMAC_UL_TBF)
- llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)this), &bts->ul_tbfs);
+ llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)this), &trx->ul_tbfs);
else
- llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)this), &bts->dl_tbfs);
+ llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)this), &trx->dl_tbfs);
}
uint8_t gprs_rlcmac_tbf::tsc() const
@@ -1166,9 +1166,9 @@ struct llist_head *tbf_ms_list(struct gprs_rlcmac_tbf *tbf)
return &tbf->m_ms_list.list;
}
-struct llist_head *tbf_bts_list(struct gprs_rlcmac_tbf *tbf)
+struct llist_head *tbf_trx_list(struct gprs_rlcmac_tbf *tbf)
{
- return &tbf->m_bts_list.list;
+ return &tbf->m_trx_list.list;
}
struct GprsMs *tbf_ms(const struct gprs_rlcmac_tbf *tbf)
diff --git a/src/tbf.h b/src/tbf.h
index 17f5b185..1bca82c0 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -183,7 +183,7 @@ enum gprs_rlcmac_tbf_state tbf_state(const struct gprs_rlcmac_tbf *tbf);
enum gprs_rlcmac_tbf_direction tbf_direction(const struct gprs_rlcmac_tbf *tbf);
void tbf_set_ms(struct gprs_rlcmac_tbf *tbf, struct GprsMs *ms);
struct llist_head *tbf_ms_list(struct gprs_rlcmac_tbf *tbf);
-struct llist_head *tbf_bts_list(struct gprs_rlcmac_tbf *tbf);
+struct llist_head *tbf_trx_list(struct gprs_rlcmac_tbf *tbf);
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);
@@ -327,7 +327,7 @@ struct gprs_rlcmac_tbf {
struct rate_ctr_group *m_ctrs;
enum gprs_rlcmac_tbf_state state;
struct llist_item m_ms_list;
- struct llist_item m_bts_list;
+ struct llist_item m_trx_list;
protected:
void merge_and_clear_ms(GprsMs *old_ms);
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 27dc4cf1..45856e8a 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -168,7 +168,7 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs
}
}
- llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)tbf), &bts->dl_tbfs);
+ llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)tbf), &tbf->trx->dl_tbfs);
bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_ALLOCATED);
osmo_clock_gettime(CLOCK_MONOTONIC, &tbf->m_bw.dl_bw_tv);
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 231ed063..44506843 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -134,7 +134,7 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs
return NULL;
}
- llist_add_tail(tbf_bts_list(tbf), &bts->ul_tbfs);
+ llist_add_tail(tbf_trx_list(tbf), &tbf->trx->ul_tbfs);
bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_ALLOCATED);
return tbf;
@@ -212,7 +212,7 @@ struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
}
ms_attach_tbf(ms, ul_tbf);
- llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)ul_tbf), &bts->ul_tbfs);
+ llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)ul_tbf), &trx->ul_tbfs);
bts_do_rate_ctr_inc(ul_tbf->bts, CTR_TBF_UL_ALLOCATED);
TBF_SET_ASS_ON(ul_tbf, GPRS_RLCMAC_FLAG_PACCH, false);
TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index fe803e32..e3e9614a 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -59,8 +59,8 @@ static void check_tfi_usage(struct gprs_rlcmac_bts *bts)
struct gprs_rlcmac_tbf *tfi_usage[8][8][2][32] = {{{{NULL}}}};
struct llist_head *tbf_lists[2] = {
- &bts->ul_tbfs,
- &bts->dl_tbfs
+ &bts->trx[0].ul_tbfs,
+ &bts->trx[0].dl_tbfs
};
struct llist_item *pos;
diff --git a/tests/ulc/PdchUlcTest.cpp b/tests/ulc/PdchUlcTest.cpp
index 84035d17..c980e332 100644
--- a/tests/ulc/PdchUlcTest.cpp
+++ b/tests/ulc/PdchUlcTest.cpp
@@ -160,6 +160,7 @@ static void test_reserve_multiple()
int _alloc_algorithm_dummy(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf,
bool single, int8_t use_tbf)
{
+ tbf->trx = &bts->trx[0];
return 0;
}
@@ -174,7 +175,6 @@ static void test_fn_wrap_around()
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct GprsMs *ms = ms_alloc(bts, 0x12345678);
struct gprs_rlcmac_tbf *tbf1 = tbf_alloc_dl_tbf(bts, ms, 0, true);
- tbf1->trx = &bts->trx[0];
struct gprs_rlcmac_pdch *pdch = &tbf1->trx->pdch[0];
int rc;
uint32_t fn, last_fn;