Change in osmo-pcu[master]: Get rid of bts singletons

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jan 18 11:56:15 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/22275 )


Change subject: Get rid of bts singletons
......................................................................

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
---
M src/bts.cpp
M src/bts.h
M src/gprs_bssgp_pcu.cpp
M src/osmobts_sock.cpp
M src/pcu_l1_if.cpp
M src/pcu_vty.c
M tests/emu/pcu_emu.cpp
7 files changed, 17 insertions(+), 30 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/75/22275/1

diff --git a/src/bts.cpp b/src/bts.cpp
index ac6e8c8..2ed81e6 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -249,16 +249,6 @@
 	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
diff --git a/src/bts.h b/src/bts.h
index 36c0ed7..86a7a49 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -317,9 +317,6 @@
 
 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);
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 92fa845..997cb1b 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -808,7 +808,7 @@
 		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);
 
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index 6addda6..d94c7e7 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -62,7 +62,7 @@
 
 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 @@
 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",
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 1a47b37..ce0f55e 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -201,7 +201,7 @@
 	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 @@
 {
 	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 @@
 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_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;
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index ed1a6a4..9beb4c1 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -753,7 +753,7 @@
       "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 @@
       "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 @@
       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 @@
       "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 @@
       "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 @@
       "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 @@
       "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]);
 }
 
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index ab2804b..d7b11ca 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -65,7 +65,7 @@
 
 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;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/22275
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I9cf762b0d3cb9e2cc3582727e07fa82c8e183ec5
Gerrit-Change-Number: 22275
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210118/81ba6cbe/attachment.htm>


More information about the gerrit-log mailing list