Get rid of bts singletons

There's no BTS single global object anymore, get rid of those APIs. Move
users to use "pcu->bts", which will evolve to a linked list in the
future.

Change-Id: I9cf762b0d3cb9e2cc3582727e07fa82c8e183ec5
This commit is contained in:
Pau Espin 2021-01-18 12:45:29 +01:00
parent 2182e627cd
commit a45aafd39c
7 changed files with 17 additions and 30 deletions

View File

@ -249,16 +249,6 @@ static void bts_init(struct gprs_rlcmac_bts *bts, struct gprs_pcu *pcu)
OSMO_ASSERT(bts->statg);
}
struct gprs_rlcmac_bts *bts_main_data()
{
return the_pcu->bts;
}
struct rate_ctr_group *bts_main_data_stats()
{
return bts_rate_counters(the_pcu->bts);
}
static void bts_cleanup(gprs_rlcmac_bts *bts)
{
/* this can cause counter updates and must not be left to the

View File

@ -318,9 +318,6 @@ static inline void bts_stat_item_add(struct gprs_rlcmac_bts *bts, unsigned int s
struct gprs_rlcmac_bts *bts_alloc(struct gprs_pcu *pcu);
struct gprs_rlcmac_bts *bts_main_data();
struct rate_ctr_group *bts_main_data_stats();
struct osmo_stat_item_group *bts_main_data_stat_items();
void bts_recalc_initial_cs(struct gprs_rlcmac_bts *bts);
void bts_recalc_initial_mcs(struct gprs_rlcmac_bts *bts);
void bts_recalc_max_cs(struct gprs_rlcmac_bts *bts);

View File

@ -808,7 +808,7 @@ static int gprs_bssgp_tx_fc_bvc(void)
LOGP(DBSSGP, LOGL_ERROR, "No bctx\n");
return -EIO;
}
bts = bts_main_data();
bts = the_pcu->bts;
max_cs_dl = max_coding_scheme_dl(bts);

View File

@ -62,7 +62,7 @@ static void pcu_sock_timeout(void *_priv)
static void pcu_tx_txt_retry(void *_priv)
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
if (bts->active)
return;
@ -90,7 +90,7 @@ int pcu_sock_send(struct msgb *msg)
static void pcu_sock_close(int lost)
{
struct osmo_fd *bfd = &pcu_sock_state.conn_bfd;
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
uint8_t trx, ts;
LOGP(DL1IF, LOGL_NOTICE, "PCU socket has %s connection\n",

View File

@ -201,7 +201,7 @@ void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn,
uint32_t fn, uint8_t block_nr)
{
#ifdef ENABLE_DIRECT_PHY
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr,
@ -286,13 +286,13 @@ extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx_no, uint8_t ts_no, uint8_t *dat
{
struct gprs_rlcmac_pdch *pdch;
pdch = &bts_main_data()->trx[trx_no].pdch[ts_no];
pdch = &the_pcu->bts->trx[trx_no].pdch[ts_no];
return pdch->rcv_block(data, len, fn, meas);
}
static int pcu_rx_data_ind_bcch(uint8_t *data, uint8_t len)
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
if (len == 0) {
bts->si13_is_set = false;
@ -384,13 +384,13 @@ static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf)
extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr)
{
return gprs_rlcmac_rcv_rts_block(bts_main_data(),
return gprs_rlcmac_rcv_rts_block(the_pcu->bts,
trx, ts, fn, block_nr);
}
extern "C" int pcu_rx_rts_req_ptcch(uint8_t trx, uint8_t ts,
uint32_t fn, uint8_t block_nr)
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_rlcmac_pdch *pdch;
/* Prevent buffer overflow */
@ -544,7 +544,7 @@ static int pcu_info_ind_ns(struct gprs_rlcmac_bts *bts,
static int pcu_rx_info_ind(const struct gsm_pcu_if_info_ind *info_ind)
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
struct gprs_bssgp_pcu *pcu;
int rc = 0;
unsigned int trx_nr, ts_nr;

View File

@ -753,7 +753,7 @@ DEFUN(show_bts_stats,
"show bts statistics",
SHOW_STR "BTS related functionality\nStatistics\n")
{
vty_out_rate_ctr_group(vty, "", bts_main_data_stats());
vty_out_rate_ctr_group(vty, "", bts_rate_counters(the_pcu->bts));
return CMD_SUCCESS;
}
@ -762,7 +762,7 @@ DEFUN(show_bts_pdch,
"show bts pdch",
SHOW_STR "BTS related functionality\nPDCH timeslots\n")
{
return pcu_vty_show_bts_pdch(vty, bts_main_data());
return pcu_vty_show_bts_pdch(vty, the_pcu->bts);
}
#define IDLE_TIME_STR "keep an idle DL TBF alive for the time given\n"
@ -1013,7 +1013,7 @@ DEFUN(show_bts_timer, show_bts_timer_cmd,
SHOW_STR "Show BTS controlled timers\n"
OSMO_TDEF_VTY_DOC_T)
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
const char *T_arg = argc > 0 ? argv[0] : NULL;
return osmo_tdef_vty_show_cmd(vty, bts->T_defs_bts, T_arg, NULL);
}
@ -1047,7 +1047,7 @@ DEFUN(show_tbf,
"TBFs allocated via CCCH\n"
"TBFs allocated via PACCH\n")
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
uint32_t flags = UINT32_MAX;
if (argv[0][0] == 'c')
@ -1063,7 +1063,7 @@ DEFUN(show_ms_all,
"show ms all",
SHOW_STR "information about MSs\n" "All TBFs\n")
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
return pcu_vty_show_ms_all(vty, bts);
}
@ -1072,7 +1072,7 @@ DEFUN(show_ms_tlli,
"show ms tlli TLLI",
SHOW_STR "information about MSs\n" "Select MS by TLLI\n" "TLLI as hex\n")
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
char *endp = NULL;
unsigned long long tlli = strtoll(argv[0], &endp, 16);
if ((endp != NULL && *endp != 0) || tlli > 0xffffffffULL) {
@ -1087,7 +1087,7 @@ DEFUN(show_ms_imsi,
"show ms imsi IMSI",
SHOW_STR "information about MSs\n" "Select MS by IMSI\n" "IMSI\n")
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
return pcu_vty_show_ms_by_imsi(vty, bts, argv[0]);
}

View File

@ -65,7 +65,7 @@ struct gprs_test all_tests[] = {
static void init_main_bts()
{
struct gprs_rlcmac_bts *bts = bts_main_data();
struct gprs_rlcmac_bts *bts = the_pcu->bts;
bts->initial_cs_dl = bts->initial_cs_ul = 1;
bts->cs_mask = 1 << 0; /* CS-1 always enabled by default */
bts->n3101 = 10;