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
This commit is contained in:
Pau Espin 2021-05-13 18:39:36 +02:00
parent f62b0ec37d
commit 1a1557a60a
10 changed files with 47 additions and 40 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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))) {

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;