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
diff --git a/src/bts.cpp b/src/bts.cpp
index 94cdcb3..dc550ef 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -263,9 +263,6 @@
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 @@
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 11b5113..52c89b9 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -59,6 +59,11 @@
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 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 0068eae..cd32653 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -41,19 +41,18 @@
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 @@
/* 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 @@
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 c2250d9..0b83a68 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -44,7 +44,7 @@
#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 @@
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 adfda95..afbb0b1 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -150,8 +150,8 @@
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 @@
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 @@
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 @@
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 17f5b18..1bca82c 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -183,7 +183,7 @@
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 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 27dc4cf..45856e8 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -168,7 +168,7 @@
}
}
- 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 231ed06..4450684 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -134,7 +134,7 @@
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 @@
}
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);