pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bsc/+/27858 )
Change subject: bts: Simplify bts->paging initialization
......................................................................
bts: Simplify bts->paging initialization
Related: SYS#5922
Change-Id: Id103d5f3d437065abcd32788caef339343b1e96a
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/paging.h
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/paging.c
6 files changed, 28 insertions(+), 49 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/58/27858/1
diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index cd0f8cb..95d9b05 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -17,6 +17,7 @@
#include "osmocom/bsc/bts_trx.h"
#include "osmocom/bsc/bts_sm.h"
#include "osmocom/bsc/abis_om2000.h"
+#include "osmocom/bsc/paging.h"
enum bts_counter_id {
BTS_CTR_CHREQ_TOTAL,
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 4a58c2b..b478ba0 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -962,26 +962,6 @@
#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
-/*
- * This keeps track of the paging status of one BTS. It
- * includes a number of pending requests, a back pointer
- * to the gsm_bts, a timer and some more state.
- */
-struct gsm_bts_paging_state {
- /* pending requests */
- struct llist_head pending_requests;
- struct gsm_bts *bts;
-
- struct osmo_timer_list work_timer;
- struct osmo_timer_list credit_timer;
-
- /* free chans needed */
- int free_chans_need;
-
- /* load */
- uint16_t available_slots;
-};
-
struct gsm_envabtse {
struct gsm_abis_mo mo;
};
diff --git a/include/osmocom/bsc/paging.h b/include/osmocom/bsc/paging.h
index 2d0f8da..c4381fa 100644
--- a/include/osmocom/bsc/paging.h
+++ b/include/osmocom/bsc/paging.h
@@ -89,6 +89,28 @@
enum bsc_paging_reason reason;
};
+/*
+ * This keeps track of the paging status of one BTS. It
+ * includes a number of pending requests, a back pointer
+ * to the gsm_bts, a timer and some more state.
+ */
+struct gsm_bts_paging_state {
+ /* pending requests */
+ struct llist_head pending_requests;
+ struct gsm_bts *bts;
+
+ struct osmo_timer_list work_timer;
+ struct osmo_timer_list credit_timer;
+
+ /* free chans needed */
+ int free_chans_need;
+
+ /* load */
+ uint16_t available_slots;
+};
+
+void paging_init(struct gsm_bts *bts);
+
/* schedule paging request */
int paging_request_bts(const struct bsc_paging_params *params, struct gsm_bts *bts);
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 5976721..92fa64a 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1043,9 +1043,6 @@
{
struct gsm_paging_request *pag;
- if (!bts->paging.bts)
- return;
-
llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
paging_dump_vty(vty, pag);
}
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index f4c90e0..16fe547 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -268,8 +268,7 @@
bts->rach_b_thresh = -1;
bts->rach_ldavg_slots = -1;
- bts->paging.free_chans_need = -1;
- INIT_LLIST_HEAD(&bts->paging.pending_requests);
+ paging_init(bts);
bts->features.data = &bts->_features_data[0];
bts->features.data_len = sizeof(bts->_features_data);
diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c
index 721ea31..d3b9f37 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -240,22 +240,14 @@
}
/*! initialize the bts paging state, if it hasn't been initialized yet */
-static void paging_init_if_needed(struct gsm_bts *bts)
+void paging_init(struct gsm_bts *bts)
{
- if (bts->paging.bts)
- return;
-
bts->paging.bts = bts;
-
- /* This should be initialized only once. There is currently no code that sets
bts->paging.bts
- * back to NULL, so let's just assert this one instead of graceful handling. */
- OSMO_ASSERT(llist_empty(&bts->paging.pending_requests));
-
- osmo_timer_setup(&bts->paging.work_timer, paging_worker,
- &bts->paging);
-
+ bts->paging.free_chans_need = -1;
/* Large number, until we get a proper message */
bts->paging.available_slots = 20;
+ INIT_LLIST_HEAD(&bts->paging.pending_requests);
+ osmo_timer_setup(&bts->paging.work_timer, paging_worker, st);
}
/*! do we have any pending paging requests for given subscriber? */
@@ -379,9 +371,6 @@
if (!trx_is_usable(bts->c0))
return 0;
- /* maybe it is the first time we use it */
- paging_init_if_needed(bts);
-
/* Trigger paging, pass any error to the caller */
rc = _paging_request(params, bts);
if (rc < 0)
@@ -405,8 +394,6 @@
*msc_p = NULL;
*reason_p = BSC_PAGING_NONE;
- paging_init_if_needed(bts);
-
llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests,
entry) {
if (req->bsub != bsub)
@@ -474,8 +461,6 @@
llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
struct gsm_paging_request *req, *req2;
- paging_init_if_needed(bts);
-
llist_for_each_entry_safe(req, req2, &bts->paging.pending_requests, entry) {
if (req->bsub != bsub)
continue;
@@ -492,7 +477,6 @@
/*! Update the BTS paging buffer slots on given BTS */
void paging_update_buffer_space(struct gsm_bts *bts, uint16_t free_slots)
{
- paging_init_if_needed(bts);
osmo_timer_del(&bts->paging.credit_timer);
bts->paging.available_slots = free_slots;
@@ -505,8 +489,6 @@
unsigned int requests = 0;
struct gsm_paging_request *req;
- paging_init_if_needed(bts);
-
llist_for_each_entry(req, &bts->paging.pending_requests, entry)
++requests;
@@ -519,8 +501,6 @@
struct gsm_paging_request *req, *req2;
int num_cancelled = 0;
- paging_init_if_needed(bts);
-
llist_for_each_entry_safe(req, req2, &bts->paging.pending_requests, entry) {
if (msc && req->msc != msc)
continue;
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc/+/27858
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id103d5f3d437065abcd32788caef339343b1e96a
Gerrit-Change-Number: 27858
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange